From 8cd74407ab4269736296d1cc9bbbf68940d343a7 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Fri, 4 Dec 2020 22:24:47 +0100 Subject: gb_proxy: Rename gbproxy_peer to gbproxy_bvc I cannot really read the code while it contains its historical weird naming. A "peer" used to be a strange amalgamation of NSE + BVC, while in reality we can have any number of BVC on top of each NSE. We recently started to split the peer into a gbproxy_nse_peer + gbproxy_peer. This takes it one step further and renames gbproxy_peer to gbproxy_bvc, as that's really what it is. Change-Id: Iae01067282a6401f6af4cab731202872d2cdb080 --- include/osmocom/sgsn/gb_proxy.h | 82 ++++---- src/gbproxy/gb_proxy.c | 406 ++++++++++++++++++++-------------------- src/gbproxy/gb_proxy_ctrl.c | 18 +- src/gbproxy/gb_proxy_patch.c | 88 ++++----- src/gbproxy/gb_proxy_peer.c | 190 ++++++++++--------- src/gbproxy/gb_proxy_tlli.c | 212 ++++++++++----------- src/gbproxy/gb_proxy_vty.c | 90 ++++----- tests/gbproxy/gbproxy_test.c | 102 +++++----- 8 files changed, 596 insertions(+), 592 deletions(-) diff --git a/include/osmocom/sgsn/gb_proxy.h b/include/osmocom/sgsn/gb_proxy.h index b3a9a6cf7..818ab9de5 100644 --- a/include/osmocom/sgsn/gb_proxy.h +++ b/include/osmocom/sgsn/gb_proxy.h @@ -37,7 +37,7 @@ enum gbproxy_global_ctr { GBPROX_GLOB_CTR_PATCH_PEER_ERR, }; -enum gbproxy_peer_ctr { +enum gbproxy_bvc_ctr { GBPROX_PEER_CTR_BLOCKED, GBPROX_PEER_CTR_UNBLOCKED, GBPROX_PEER_CTR_DROPPED, @@ -102,7 +102,7 @@ struct gbproxy_config { struct gprs_ns2_inst *nsi; /* Linked list of all Gb peers (except SGSN) */ - struct llist_head nse_peers; + struct llist_head nses; /* Counter */ struct rate_ctr_group *ctrg; @@ -118,7 +118,7 @@ struct gbproxy_config { unsigned int clean_stale_timer_freq; /* If !0, Max age to consider a struct gbproxy_link_info as stale */ int tlli_max_age; - /* If !0, Max len of gbproxy_peer->list (list of struct gbproxy_link_info) */ + /* If !0, Max len of gbproxy_bvc->list (list of struct gbproxy_link_info) */ int tlli_max_len; /* If !0, Max len of gbproxy_link_info->stored_msgs (list of msgb) */ uint32_t stored_msgs_max_len; @@ -147,17 +147,17 @@ struct gbproxy_patch_state { }; /* One BVC inside an NSE */ -struct gbproxy_peer { - /* linked to gbproxy_nse.bts_peers */ +struct gbproxy_bvc { + /* linked to gbproxy_nse.bvcs */ struct llist_head list; - /* The peer this BVC belongs to */ + /* The NSE this BVC belongs to */ struct gbproxy_nse *nse; - /* BVCI used for Point-to-Point to this peer */ + /* PTP BVCI of this BVC */ uint16_t bvci; - /* Routing Area that this peer is part of (raw 04.08 encoding) */ + /* Routing Area that this BVC is part of (raw 04.08 encoding) */ uint8_t ra[6]; /* true if this BVC is blocked */ @@ -173,19 +173,19 @@ struct gbproxy_peer { struct osmo_timer_list clean_stale_timer; }; -/* one peer at NS level that we interact with (BSS/PCU) */ +/* one NS Entity that we interact with (BSS/PCU) */ struct gbproxy_nse { - /* linked to gbproxy_config.nse_peers */ + /* linked to gbproxy_config.nses */ struct llist_head list; /* point back to the config */ struct gbproxy_config *cfg; - /* NSEI of the peer entity */ + /* NSEI of the NSE */ uint16_t nsei; /* List of all BVCs in this NSE */ - struct llist_head bts_peers; + struct llist_head bvcs; }; struct gbproxy_tlli_state { @@ -205,7 +205,7 @@ struct gbproxy_tlli_state { /* One TLLI (= UE, = Subscriber) served via this proxy */ struct gbproxy_link_info { - /* link to gbproxy_peer.patch_state.logical_links */ + /* link to gbproxy_bvc.patch_state.logical_links */ struct llist_head list; /* TLLI on the BSS/PCU side */ @@ -276,40 +276,40 @@ int gprs_ns2_prim_cb(struct osmo_prim_hdr *oph, void *ctx); void gbprox_reset(struct gbproxy_config *cfg); /* TLLI info handling */ -void gbproxy_delete_link_infos(struct gbproxy_peer *peer); +void gbproxy_delete_link_infos(struct gbproxy_bvc *bvc); struct gbproxy_link_info *gbproxy_update_link_state_ul( - struct gbproxy_peer *peer, time_t now, + struct gbproxy_bvc *bvc, time_t now, struct gprs_gb_parse_context *parse_ctx); struct gbproxy_link_info *gbproxy_update_link_state_dl( - struct gbproxy_peer *peer, time_t now, + struct gbproxy_bvc *bvc, time_t now, struct gprs_gb_parse_context *parse_ctx); int gbproxy_update_link_state_after( - struct gbproxy_peer *peer, struct gbproxy_link_info *link_info, + struct gbproxy_bvc *bvc, struct gbproxy_link_info *link_info, time_t now, struct gprs_gb_parse_context *parse_ctx); -int gbproxy_remove_stale_link_infos(struct gbproxy_peer *peer, time_t now); -void gbproxy_delete_link_info(struct gbproxy_peer *peer, +int gbproxy_remove_stale_link_infos(struct gbproxy_bvc *bvc, time_t now); +void gbproxy_delete_link_info(struct gbproxy_bvc *bvc, struct gbproxy_link_info *link_info); void gbproxy_link_info_discard_messages(struct gbproxy_link_info *link_info); -void gbproxy_attach_link_info(struct gbproxy_peer *peer, time_t now, +void gbproxy_attach_link_info(struct gbproxy_bvc *bvc, time_t now, struct gbproxy_link_info *link_info); void gbproxy_update_link_info(struct gbproxy_link_info *link_info, const uint8_t *imsi, size_t imsi_len); -void gbproxy_detach_link_info(struct gbproxy_peer *peer, +void gbproxy_detach_link_info(struct gbproxy_bvc *bvc, struct gbproxy_link_info *link_info); -struct gbproxy_link_info *gbproxy_link_info_alloc( struct gbproxy_peer *peer); +struct gbproxy_link_info *gbproxy_link_info_alloc( struct gbproxy_bvc *bvc); struct gbproxy_link_info *gbproxy_link_info_by_tlli( - struct gbproxy_peer *peer, uint32_t tlli); + struct gbproxy_bvc *bvc, uint32_t tlli); struct gbproxy_link_info *gbproxy_link_info_by_imsi( - struct gbproxy_peer *peer, const uint8_t *imsi, size_t imsi_len); + struct gbproxy_bvc *bvc, const uint8_t *imsi, size_t imsi_len); struct gbproxy_link_info *gbproxy_link_info_by_any_sgsn_tlli( - struct gbproxy_peer *peer, uint32_t tlli); + struct gbproxy_bvc *bvc, uint32_t tlli); struct gbproxy_link_info *gbproxy_link_info_by_sgsn_tlli( - struct gbproxy_peer *peer, + struct gbproxy_bvc *bvc, uint32_t tlli, uint32_t sgsn_nsei); struct gbproxy_link_info *gbproxy_link_info_by_ptmsi( - struct gbproxy_peer *peer, + struct gbproxy_bvc *bvc, uint32_t ptmsi); int gbproxy_imsi_matches( @@ -320,9 +320,9 @@ uint32_t gbproxy_map_tlli( uint32_t other_tlli, struct gbproxy_link_info *link_info, int to_bss); /* needed by gb_proxy_tlli.h */ -uint32_t gbproxy_make_bss_ptmsi(struct gbproxy_peer *peer, uint32_t sgsn_ptmsi); +uint32_t gbproxy_make_bss_ptmsi(struct gbproxy_bvc *bvc, uint32_t sgsn_ptmsi); uint32_t gbproxy_make_sgsn_tlli( - struct gbproxy_peer *peer, struct gbproxy_link_info *link_info, + struct gbproxy_bvc *bvc, struct gbproxy_link_info *link_info, uint32_t bss_tlli); void gbproxy_reset_link(struct gbproxy_link_info *link_info); int gbproxy_check_imsi( @@ -331,12 +331,12 @@ int gbproxy_check_imsi( /* Message patching */ void gbproxy_patch_bssgp( struct msgb *msg, uint8_t *bssgp, size_t bssgp_len, - struct gbproxy_peer *peer, struct gbproxy_link_info *link_info, + struct gbproxy_bvc *bvc, struct gbproxy_link_info *link_info, int *len_change, struct gprs_gb_parse_context *parse_ctx); int gbproxy_patch_llc( struct msgb *msg, uint8_t *llc, size_t llc_len, - struct gbproxy_peer *peer, struct gbproxy_link_info *link_info, + struct gbproxy_bvc *bvc, struct gbproxy_link_info *link_info, int *len_change, struct gprs_gb_parse_context *parse_ctx); int gbproxy_set_patch_filter( @@ -344,22 +344,22 @@ int gbproxy_set_patch_filter( void gbproxy_clear_patch_filter(struct gbproxy_match *match); /* Peer handling */ -struct gbproxy_peer *gbproxy_peer_by_bvci( +struct gbproxy_bvc *gbproxy_bvc_by_bvci( struct gbproxy_config *cfg, uint16_t bvci); -struct gbproxy_peer *gbproxy_peer_by_nsei( +struct gbproxy_bvc *gbproxy_bvc_by_nsei( struct gbproxy_config *cfg, uint16_t nsei); -struct gbproxy_peer *gbproxy_peer_by_rai( +struct gbproxy_bvc *gbproxy_bvc_by_rai( struct gbproxy_config *cfg, const uint8_t *ra); -struct gbproxy_peer *gbproxy_peer_by_lai( +struct gbproxy_bvc *gbproxy_bvc_by_lai( struct gbproxy_config *cfg, const uint8_t *la); -struct gbproxy_peer *gbproxy_peer_by_lac( +struct gbproxy_bvc *gbproxy_bvc_by_lac( struct gbproxy_config *cfg, const uint8_t *la); -struct gbproxy_peer *gbproxy_peer_by_bssgp_tlv( +struct gbproxy_bvc *gbproxy_bvc_by_bssgp_tlv( struct gbproxy_config *cfg, struct tlv_parsed *tp); -struct gbproxy_peer *gbproxy_peer_alloc(struct gbproxy_nse *nse, uint16_t bvci); -void gbproxy_peer_free(struct gbproxy_peer *peer); -void gbproxy_peer_move(struct gbproxy_peer *peer, struct gbproxy_nse *nse); -int gbproxy_cleanup_peers(struct gbproxy_config *cfg, uint16_t nsei, uint16_t bvci); +struct gbproxy_bvc *gbproxy_bvc_alloc(struct gbproxy_nse *nse, uint16_t bvci); +void gbproxy_bvc_free(struct gbproxy_bvc *bvc); +void gbproxy_bvc_move(struct gbproxy_bvc *bvc, struct gbproxy_nse *nse); +int gbproxy_cleanup_bvcs(struct gbproxy_config *cfg, uint16_t nsei, uint16_t bvci); /* NSE handling */ struct gbproxy_nse *gbproxy_nse_alloc(struct gbproxy_config *cfg, uint16_t nsei); diff --git a/src/gbproxy/gb_proxy.c b/src/gbproxy/gb_proxy.c index c1304667c..94944f9e2 100644 --- a/src/gbproxy/gb_proxy.c +++ b/src/gbproxy/gb_proxy.c @@ -77,21 +77,21 @@ static const struct rate_ctr_group_desc global_ctrg_desc = { .class_id = OSMO_STATS_CLASS_GLOBAL, }; -static int gbprox_relay2peer(struct msgb *old_msg, struct gbproxy_peer *peer, +static int gbprox_relay2peer(struct msgb *old_msg, struct gbproxy_bvc *bvc, uint16_t ns_bvci); static int gbprox_relay2sgsn(struct gbproxy_config *cfg, struct msgb *old_msg, uint16_t ns_bvci, uint16_t sgsn_nsei); static void gbproxy_reset_imsi_acquisition(struct gbproxy_link_info* link_info); -static int check_peer_nsei(struct gbproxy_peer *peer, uint16_t nsei) +static int check_bvc_nsei(struct gbproxy_bvc *bvc, uint16_t nsei) { - OSMO_ASSERT(peer); - OSMO_ASSERT(peer->nse); + OSMO_ASSERT(bvc); + OSMO_ASSERT(bvc->nse); - if (peer->nse->nsei != nsei) { - LOGPBVC(peer, LOGL_NOTICE, "Peer entry doesn't match current NSEI " + if (bvc->nse->nsei != nsei) { + LOGPBVC(bvc, LOGL_NOTICE, "Peer entry doesn't match current NSEI " "via NSE(%05u/BSS)\n", nsei); - rate_ctr_inc(&peer->ctrg->ctr[GBPROX_PEER_CTR_INV_NSEI]); + rate_ctr_inc(&bvc->ctrg->ctr[GBPROX_PEER_CTR_INV_NSEI]); return 0; } @@ -190,16 +190,16 @@ static void gprs_push_bssgp_dl_unitdata(struct msgb *msg, msgb_tlli(msg) = tlli; } -/* update peer according to the BSS message */ +/* update bvc according to the BSS message */ static void gbprox_update_current_raid(uint8_t *raid_enc, - struct gbproxy_peer *peer, + struct gbproxy_bvc *bvc, const char *log_text) { - struct gbproxy_patch_state *state = &peer->patch_state; + struct gbproxy_patch_state *state = &bvc->patch_state; const struct osmo_plmn_id old_plmn = state->local_plmn; struct gprs_ra_id raid; - OSMO_ASSERT(peer->nse); - struct gbproxy_config *cfg = peer->nse->cfg; + OSMO_ASSERT(bvc->nse); + struct gbproxy_config *cfg = bvc->nse->cfg; OSMO_ASSERT(cfg); if (!raid_enc) @@ -225,7 +225,7 @@ static void gbprox_update_current_raid(uint8_t *raid_enc, } if (osmo_plmn_cmp(&old_plmn, &state->local_plmn)) - LOGPBVC(peer, LOGL_NOTICE, + LOGPBVC(bvc, LOGL_NOTICE, "Patching RAID %sactivated, msg: %s, " "local: %s, core: %s\n", state->local_plmn.mcc || state->local_plmn.mnc ? @@ -235,12 +235,12 @@ static void gbprox_update_current_raid(uint8_t *raid_enc, osmo_plmn_name2(&cfg->core_plmn)); } -uint32_t gbproxy_make_bss_ptmsi(struct gbproxy_peer *peer, +uint32_t gbproxy_make_bss_ptmsi(struct gbproxy_bvc *bvc, uint32_t sgsn_ptmsi) { uint32_t bss_ptmsi; int max_retries = 23, rc = 0; - if (!peer->nse->cfg->patch_ptmsi) { + if (!bvc->nse->cfg->patch_ptmsi) { bss_ptmsi = sgsn_ptmsi; } else { do { @@ -252,24 +252,24 @@ uint32_t gbproxy_make_bss_ptmsi(struct gbproxy_peer *peer, bss_ptmsi = bss_ptmsi | GSM23003_TMSI_SGSN_MASK; - if (gbproxy_link_info_by_ptmsi(peer, bss_ptmsi)) + if (gbproxy_link_info_by_ptmsi(bvc, bss_ptmsi)) bss_ptmsi = GSM_RESERVED_TMSI; } while (bss_ptmsi == GSM_RESERVED_TMSI && max_retries--); } if (bss_ptmsi == GSM_RESERVED_TMSI) - LOGPBVC(peer, LOGL_ERROR, "Failed to allocate a BSS P-TMSI: %d (%s)\n", rc, strerror(-rc)); + LOGPBVC(bvc, LOGL_ERROR, "Failed to allocate a BSS P-TMSI: %d (%s)\n", rc, strerror(-rc)); return bss_ptmsi; } -uint32_t gbproxy_make_sgsn_tlli(struct gbproxy_peer *peer, +uint32_t gbproxy_make_sgsn_tlli(struct gbproxy_bvc *bvc, struct gbproxy_link_info *link_info, uint32_t bss_tlli) { uint32_t sgsn_tlli; int max_retries = 23, rc = 0; - if (!peer->nse->cfg->patch_ptmsi) { + if (!bvc->nse->cfg->patch_ptmsi) { sgsn_tlli = bss_tlli; } else if (link_info->sgsn_tlli.ptmsi != GSM_RESERVED_TMSI && gprs_tlli_type(bss_tlli) == TLLI_FOREIGN) { @@ -290,13 +290,13 @@ uint32_t gbproxy_make_sgsn_tlli(struct gbproxy_peer *peer, sgsn_tlli = (sgsn_tlli & 0x7fffffff) | 0x78000000; - if (gbproxy_link_info_by_any_sgsn_tlli(peer, sgsn_tlli)) + if (gbproxy_link_info_by_any_sgsn_tlli(bvc, sgsn_tlli)) sgsn_tlli = 0; } while (!sgsn_tlli && max_retries--); } if (!sgsn_tlli) - LOGPBVC(peer, LOGL_ERROR, "Failed to allocate an SGSN TLLI: %d (%s)\n", rc, strerror(-rc)); + LOGPBVC(bvc, LOGL_ERROR, "Failed to allocate an SGSN TLLI: %d (%s)\n", rc, strerror(-rc)); return sgsn_tlli; } @@ -330,15 +330,15 @@ static void gbproxy_reset_imsi_acquisition(struct gbproxy_link_info* link_info) /* Got identity response with IMSI, assuming the request had * been generated by the gbproxy */ -static int gbproxy_flush_stored_messages(struct gbproxy_peer *peer, +static int gbproxy_flush_stored_messages(struct gbproxy_bvc *bvc, time_t now, struct gbproxy_link_info* link_info) { int rc; struct msgb *stored_msg; - OSMO_ASSERT(peer); - OSMO_ASSERT(peer->nse); - struct gbproxy_config *cfg = peer->nse->cfg; + OSMO_ASSERT(bvc); + OSMO_ASSERT(bvc->nse); + struct gbproxy_config *cfg = bvc->nse->cfg; OSMO_ASSERT(cfg); /* Patch and flush stored messages towards the SGSN */ @@ -354,13 +354,13 @@ static int gbproxy_flush_stored_messages(struct gbproxy_peer *peer, &tmp_parse_ctx); gbproxy_patch_bssgp(stored_msg, msgb_bssgph(stored_msg), msgb_bssgp_len(stored_msg), - peer, link_info, &len_change, + bvc, link_info, &len_change, &tmp_parse_ctx); - rc = gbproxy_update_link_state_after(peer, link_info, now, + rc = gbproxy_update_link_state_after(bvc, link_info, now, &tmp_parse_ctx); if (rc == 1) { - LOGPBVC_CAT(peer, DLLC, LOGL_NOTICE, "link_info deleted while flushing stored messages\n"); + LOGPBVC_CAT(bvc, DLLC, LOGL_NOTICE, "link_info deleted while flushing stored messages\n"); msgb_free(stored_msg); return -1; } @@ -369,7 +369,7 @@ static int gbproxy_flush_stored_messages(struct gbproxy_peer *peer, msgb_bvci(stored_msg), link_info->sgsn_nsei); if (rc < 0) - LOGPBVC_CAT(peer, DLLC, LOGL_ERROR, + LOGPBVC_CAT(bvc, DLLC, LOGL_ERROR, "failed to send stored message " "(%s)\n", tmp_parse_ctx.llc_msg_name ? @@ -380,7 +380,7 @@ static int gbproxy_flush_stored_messages(struct gbproxy_peer *peer, return 0; } -static int gbproxy_gsm48_to_peer(struct gbproxy_peer *peer, +static int gbproxy_gsm48_to_bvc(struct gbproxy_bvc *bvc, struct gbproxy_link_info* link_info, uint16_t bvci, struct msgb *msg /* Takes msg ownership */) @@ -397,12 +397,12 @@ static int gbproxy_gsm48_to_peer(struct gbproxy_peer *peer, gprs_push_bssgp_dl_unitdata(msg, link_info->tlli.current); msg->l3h = msg->data; - rc = gbprox_relay2peer(msg, peer, bvci); + rc = gbprox_relay2peer(msg, bvc, bvci); msgb_free(msg); return rc; } -static void gbproxy_acquire_imsi(struct gbproxy_peer *peer, +static void gbproxy_acquire_imsi(struct gbproxy_bvc *bvc, struct gbproxy_link_info* link_info, uint16_t bvci) { @@ -411,10 +411,10 @@ static void gbproxy_acquire_imsi(struct gbproxy_peer *peer, /* Send IDENT REQ */ idreq_msg = gsm48_msgb_alloc_name("GSM 04.08 ACQ IMSI"); gprs_put_identity_req(idreq_msg, GSM_MI_TYPE_IMSI); - gbproxy_gsm48_to_peer(peer, link_info, bvci, idreq_msg); + gbproxy_gsm48_to_bvc(bvc, link_info, bvci, idreq_msg); } -static void gbproxy_tx_detach_acc(struct gbproxy_peer *peer, +static void gbproxy_tx_detach_acc(struct gbproxy_bvc *bvc, struct gbproxy_link_info* link_info, uint16_t bvci) { @@ -423,20 +423,20 @@ static void gbproxy_tx_detach_acc(struct gbproxy_peer *peer, /* Send DETACH ACC */ detacc_msg = gsm48_msgb_alloc_name("GSM 04.08 DET ACC"); gprs_put_mo_detach_acc(detacc_msg); - gbproxy_gsm48_to_peer(peer, link_info, bvci, detacc_msg); + gbproxy_gsm48_to_bvc(bvc, link_info, bvci, detacc_msg); } /* Return != 0 iff msg still needs to be processed */ -static int gbproxy_imsi_acquisition(struct gbproxy_peer *peer, +static int gbproxy_imsi_acquisition(struct gbproxy_bvc *bvc, struct msgb *msg, time_t now, struct gbproxy_link_info* link_info, struct gprs_gb_parse_context *parse_ctx) { struct msgb *stored_msg; - OSMO_ASSERT(peer); - OSMO_ASSERT(peer->nse); - struct gbproxy_config *cfg = peer->nse->cfg; + OSMO_ASSERT(bvc); + OSMO_ASSERT(bvc->nse); + struct gbproxy_config *cfg = bvc->nse->cfg; OSMO_ASSERT(cfg); if (!link_info) @@ -451,7 +451,7 @@ static int gbproxy_imsi_acquisition(struct gbproxy_peer *peer, case GSM48_MT_GMM_RA_UPD_REQ: case GSM48_MT_GMM_ATTACH_REQ: if (gbproxy_restart_imsi_acquisition(link_info)) { - LOGPBVC_CAT(peer, DLLC, LOGL_INFO, + LOGPBVC_CAT(bvc, DLLC, LOGL_INFO, " IMSI acquisition was in progress " "when receiving an %s.\n", parse_ctx->llc_msg_name); @@ -460,19 +460,19 @@ static int gbproxy_imsi_acquisition(struct gbproxy_peer *peer, case GSM48_MT_GMM_DETACH_REQ: /* Nothing has been sent to the SGSN yet */ if (link_info->imsi_acq_pending) { - LOGPBVC_CAT(peer, DLLC, LOGL_INFO, + LOGPBVC_CAT(bvc, DLLC, LOGL_INFO, "IMSI acquisition was in progress " "when receiving a DETACH_REQ.\n"); } if (!parse_ctx->invalidate_tlli) { - LOGPBVC_CAT(peer, DLLC, LOGL_INFO, + LOGPBVC_CAT(bvc, DLLC, LOGL_INFO, "IMSI not yet acquired, " "faking a DETACH_ACC.\n"); - gbproxy_tx_detach_acc(peer, link_info, msgb_bvci(msg)); + gbproxy_tx_detach_acc(bvc, link_info, msgb_bvci(msg)); parse_ctx->invalidate_tlli = 1; } gbproxy_reset_imsi_acquisition(link_info); - gbproxy_update_link_state_after(peer, link_info, now, + gbproxy_update_link_state_after(bvc, link_info, now, parse_ctx); return 0; } @@ -483,13 +483,13 @@ static int gbproxy_imsi_acquisition(struct gbproxy_peer *peer, gsm48_hdr_pdisc(parse_ctx->g48_hdr) == GSM48_PDISC_MM_GPRS && gsm48_hdr_msg_type(parse_ctx->g48_hdr) == GSM48_MT_GMM_ID_RESP; - LOGPBVC_CAT(peer, DLLC, LOGL_DEBUG, + LOGPBVC_CAT(bvc, DLLC, LOGL_DEBUG, "IMSI acquisition succeeded, " "flushing stored messages\n"); /* The IMSI is now available. If flushing the messages fails, * then link_info has been deleted and we should return * immediately. */ - if (gbproxy_flush_stored_messages(peer, now, link_info) < 0) + if (gbproxy_flush_stored_messages(bvc, now, link_info) < 0) return 0; gbproxy_reset_imsi_acquisition(link_info); @@ -511,7 +511,7 @@ static int gbproxy_imsi_acquisition(struct gbproxy_peer *peer, struct msgb *msgb_drop; msgb_drop = msgb_dequeue_count(&link_info->stored_msgs, &link_info->stored_msgs_len); - LOGPBVC_CAT(peer, DLLC, LOGL_INFO, + LOGPBVC_CAT(bvc, DLLC, LOGL_INFO, "Dropping stored msgb from list " "(!acq imsi, length %d, max_len exceeded)\n", link_info->stored_msgs_len); @@ -521,7 +521,7 @@ static int gbproxy_imsi_acquisition(struct gbproxy_peer *peer, } /* Enqueue unpatched messages */ - LOGPBVC_CAT(peer, DLLC, LOGL_INFO, + LOGPBVC_CAT(bvc, DLLC, LOGL_INFO, "IMSI acquisition in progress, " "storing message (%s)\n", parse_ctx->llc_msg_name ? parse_ctx->llc_msg_name : "BSSGP"); @@ -531,12 +531,12 @@ static int gbproxy_imsi_acquisition(struct gbproxy_peer *peer, &link_info->stored_msgs_len); if (!link_info->imsi_acq_pending) { - LOGPBVC_CAT(peer, DLLC, LOGL_INFO, + LOGPBVC_CAT(bvc, DLLC, LOGL_INFO, "IMSI is required but not available, " "initiating identification procedure (%s)\n", parse_ctx->llc_msg_name ? parse_ctx->llc_msg_name : "BSSGP"); - gbproxy_acquire_imsi(peer, link_info, msgb_bvci(msg)); + gbproxy_acquire_imsi(bvc, link_info, msgb_bvci(msg)); /* There is no explicit retransmission handling, the * implementation relies on the MS doing proper retransmissions @@ -548,37 +548,37 @@ static int gbproxy_imsi_acquisition(struct gbproxy_peer *peer, return 0; } -struct gbproxy_peer *gbproxy_find_peer(struct gbproxy_config *cfg, +struct gbproxy_bvc *gbproxy_find_bvc(struct gbproxy_config *cfg, struct msgb *msg, struct gprs_gb_parse_context *parse_ctx) { - struct gbproxy_peer *peer = NULL; + struct gbproxy_bvc *bvc = NULL; if (msgb_bvci(msg) >= 2) - peer = gbproxy_peer_by_bvci(cfg, msgb_bvci(msg)); + bvc = gbproxy_bvc_by_bvci(cfg, msgb_bvci(msg)); - if (!peer && !parse_ctx->to_bss) - peer = gbproxy_peer_by_nsei(cfg, msgb_nsei(msg)); + if (!bvc && !parse_ctx->to_bss) + bvc = gbproxy_bvc_by_nsei(cfg, msgb_nsei(msg)); - if (!peer) - peer = gbproxy_peer_by_bssgp_tlv(cfg, &parse_ctx->bssgp_tp); + if (!bvc) + bvc = gbproxy_bvc_by_bssgp_tlv(cfg, &parse_ctx->bssgp_tp); - if (!peer) { + if (!bvc) { LOGP(DLLC, LOGL_INFO, - "NSE(%05u/%s) patching: didn't find peer for message, " + "NSE(%05u/%s) patching: didn't find bvc for message, " "PDU %d\n", msgb_nsei(msg), parse_ctx->to_bss ? "BSS" : "SGSN", parse_ctx->pdu_type); /* Increment counter */ rate_ctr_inc(&cfg->ctrg->ctr[GBPROX_GLOB_CTR_PATCH_PEER_ERR]); } - return peer; + return bvc; } /* patch BSSGP message */ static int gbprox_process_bssgp_ul(struct gbproxy_config *cfg, struct msgb *msg, - struct gbproxy_peer *peer) + struct gbproxy_bvc *bvc) { struct gprs_gb_parse_context parse_ctx = {0}; int rc; @@ -610,49 +610,49 @@ static int gbprox_process_bssgp_ul(struct gbproxy_config *cfg, return 0; } - /* Get peer */ - if (!peer) - peer = gbproxy_find_peer(cfg, msg, &parse_ctx); + /* Get bvc */ + if (!bvc) + bvc = gbproxy_find_bvc(cfg, msg, &parse_ctx); - if (!peer) + if (!bvc) return 0; osmo_clock_gettime(CLOCK_MONOTONIC, &ts); now = ts.tv_sec; - gbprox_update_current_raid(parse_ctx.bssgp_raid_enc, peer, + gbprox_update_current_raid(parse_ctx.bssgp_raid_enc, bvc, parse_ctx.llc_msg_name); gprs_gb_log_parse_context(LOGL_DEBUG, &parse_ctx, "NS_UNITDATA"); - link_info = gbproxy_update_link_state_ul(peer, now, &parse_ctx); + link_info = gbproxy_update_link_state_ul(bvc, now, &parse_ctx); if (parse_ctx.g48_hdr) { switch (parse_ctx.g48_hdr->msg_type) { case GSM48_MT_GMM_ATTACH_REQ: - rate_ctr_inc(&peer->ctrg->ctr[GBPROX_PEER_CTR_ATTACH_REQS]); + rate_ctr_inc(&bvc->ctrg->ctr[GBPROX_PEER_CTR_ATTACH_REQS]); break; case GSM48_MT_GMM_DETACH_REQ: - rate_ctr_inc(&peer->ctrg->ctr[GBPROX_PEER_CTR_DETACH_REQS]); + rate_ctr_inc(&bvc->ctrg->ctr[GBPROX_PEER_CTR_DETACH_REQS]); break; case GSM48_MT_GMM_ATTACH_COMPL: - rate_ctr_inc(&peer->ctrg->ctr[GBPROX_PEER_CTR_ATTACH_COMPLS]); + rate_ctr_inc(&bvc->ctrg->ctr[GBPROX_PEER_CTR_ATTACH_COMPLS]); break; case GSM48_MT_GMM_RA_UPD_REQ: - rate_ctr_inc(&peer->ctrg->ctr[GBPROX_PEER_CTR_RA_UPD_REQS]); + rate_ctr_inc(&bvc->ctrg->ctr[GBPROX_PEER_CTR_RA_UPD_REQS]); break; case GSM48_MT_GMM_RA_UPD_COMPL: - rate_ctr_inc(&peer->ctrg->ctr[GBPROX_PEER_CTR_RA_UPD_COMPLS]); + rate_ctr_inc(&bvc->ctrg->ctr[GBPROX_PEER_CTR_RA_UPD_COMPLS]); break; case GSM48_MT_GMM_STATUS: - rate_ctr_inc(&peer->ctrg->ctr[GBPROX_PEER_CTR_GMM_STATUS_BSS]); + rate_ctr_inc(&bvc->ctrg->ctr[GBPROX_PEER_CTR_GMM_STATUS_BSS]); break; case GSM48_MT_GSM_ACT_PDP_REQ: - rate_ctr_inc(&peer->ctrg->ctr[GBPROX_PEER_CTR_PDP_ACT_REQS]); + rate_ctr_inc(&bvc->ctrg->ctr[GBPROX_PEER_CTR_PDP_ACT_REQS]); break; case GSM48_MT_GSM_DEACT_PDP_REQ: - rate_ctr_inc(&peer->ctrg->ctr[GBPROX_PEER_CTR_PDP_DEACT_REQS]); + rate_ctr_inc(&bvc->ctrg->ctr[GBPROX_PEER_CTR_PDP_DEACT_REQS]); break; default: @@ -673,16 +673,16 @@ static int gbprox_process_bssgp_ul(struct gbproxy_config *cfg, /* Handle IMSI acquisition */ if (cfg->acquire_imsi) { - rc = gbproxy_imsi_acquisition(peer, msg, now, link_info, + rc = gbproxy_imsi_acquisition(bvc, msg, now, link_info, &parse_ctx); if (rc <= 0) return rc; } gbproxy_patch_bssgp(msg, msgb_bssgph(msg), msgb_bssgp_len(msg), - peer, link_info, &len_change, &parse_ctx); + bvc, link_info, &len_change, &parse_ctx); - gbproxy_update_link_state_after(peer, link_info, now, &parse_ctx); + gbproxy_update_link_state_after(bvc, link_info, now, &parse_ctx); if (sgsn_nsei != cfg->nsip_sgsn_nsei) { /* Send message directly to the selected SGSN */ @@ -697,7 +697,7 @@ static int gbprox_process_bssgp_ul(struct gbproxy_config *cfg, /* patch BSSGP message to use core_plmn.mcc/mnc on the SGSN side */ static void gbprox_process_bssgp_dl(struct gbproxy_config *cfg, struct msgb *msg, - struct gbproxy_peer *peer) + struct gbproxy_bvc *bvc) { struct gprs_gb_parse_context parse_ctx = {0}; int rc; @@ -727,11 +727,11 @@ static void gbprox_process_bssgp_dl(struct gbproxy_config *cfg, return; } - /* Get peer */ - if (!peer) - peer = gbproxy_find_peer(cfg, msg, &parse_ctx); + /* Get bvc */ + if (!bvc) + bvc = gbproxy_find_bvc(cfg, msg, &parse_ctx); - if (!peer) + if (!bvc) return; osmo_clock_gettime(CLOCK_MONOTONIC, &ts); @@ -740,31 +740,31 @@ static void gbprox_process_bssgp_dl(struct gbproxy_config *cfg, if (parse_ctx.g48_hdr) { switch (parse_ctx.g48_hdr->msg_type) { case GSM48_MT_GMM_ATTACH_ACK: - rate_ctr_inc(&peer->ctrg->ctr[GBPROX_PEER_CTR_ATTACH_ACKS]); + rate_ctr_inc(&bvc->ctrg->ctr[GBPROX_PEER_CTR_ATTACH_ACKS]); break; case GSM48_MT_GMM_ATTACH_REJ: - rate_ctr_inc(&peer->ctrg->ctr[GBPROX_PEER_CTR_ATTACH_REJS]); + rate_ctr_inc(&bvc->ctrg->ctr[GBPROX_PEER_CTR_ATTACH_REJS]); break; case GSM48_MT_GMM_DETACH_ACK: - rate_ctr_inc(&peer->ctrg->ctr[GBPROX_PEER_CTR_DETACH_ACKS]); + rate_ctr_inc(&bvc->ctrg->ctr[GBPROX_PEER_CTR_DETACH_ACKS]); break; case GSM48_MT_GMM_RA_UPD_ACK: - rate_ctr_inc(&peer->ctrg->ctr[GBPROX_PEER_CTR_RA_UPD_ACKS]); + rate_ctr_inc(&bvc->ctrg->ctr[GBPROX_PEER_CTR_RA_UPD_ACKS]); break; case GSM48_MT_GMM_RA_UPD_REJ: - rate_ctr_inc(&peer->ctrg->ctr[GBPROX_PEER_CTR_RA_UPD_REJS]); + rate_ctr_inc(&bvc->ctrg->ctr[GBPROX_PEER_CTR_RA_UPD_REJS]); break; case GSM48_MT_GMM_STATUS: - rate_ctr_inc(&peer->ctrg->ctr[GBPROX_PEER_CTR_GMM_STATUS_SGSN]); + rate_ctr_inc(&bvc->ctrg->ctr[GBPROX_PEER_CTR_GMM_STATUS_SGSN]); break; case GSM48_MT_GSM_ACT_PDP_ACK: - rate_ctr_inc(&peer->ctrg->ctr[GBPROX_PEER_CTR_PDP_ACT_ACKS]); + rate_ctr_inc(&bvc->ctrg->ctr[GBPROX_PEER_CTR_PDP_ACT_ACKS]); break; case GSM48_MT_GSM_ACT_PDP_REJ: - rate_ctr_inc(&peer->ctrg->ctr[GBPROX_PEER_CTR_PDP_ACT_REJS]); + rate_ctr_inc(&bvc->ctrg->ctr[GBPROX_PEER_CTR_PDP_ACT_REJS]); break; case GSM48_MT_GSM_DEACT_PDP_ACK: - rate_ctr_inc(&peer->ctrg->ctr[GBPROX_PEER_CTR_PDP_DEACT_ACKS]); + rate_ctr_inc(&bvc->ctrg->ctr[GBPROX_PEER_CTR_PDP_DEACT_ACKS]); break; default: @@ -774,17 +774,17 @@ static void gbprox_process_bssgp_dl(struct gbproxy_config *cfg, gprs_gb_log_parse_context(LOGL_DEBUG, &parse_ctx, "NS_UNITDATA"); - link_info = gbproxy_update_link_state_dl(peer, now, &parse_ctx); + link_info = gbproxy_update_link_state_dl(bvc, now, &parse_ctx); gbproxy_patch_bssgp(msg, msgb_bssgph(msg), msgb_bssgp_len(msg), - peer, link_info, &len_change, &parse_ctx); + bvc, link_info, &len_change, &parse_ctx); - gbproxy_update_link_state_after(peer, link_info, now, &parse_ctx); + gbproxy_update_link_state_after(bvc, link_info, now, &parse_ctx); return; } -/* feed a message down the NS-VC associated with the specified peer */ +/* feed a message down the NS-VC associated with the specified bvc */ static int gbprox_relay2sgsn(struct gbproxy_config *cfg, struct msgb *old_msg, uint16_t ns_bvci, uint16_t sgsn_nsei) { @@ -847,32 +847,32 @@ static int gbprox_relay2nse(struct msgb *old_msg, struct gbproxy_nse *nse, rc = gprs_ns2_recv_prim(nsi, &nsp.oph); /* FIXME: We need a counter group for gbproxy_nse */ //if (rc < 0) - // rate_ctr_inc(&peer->ctrg->ctr[GBPROX_PEER_CTR_TX_ERR]); + // rate_ctr_inc(&bvc->ctrg->ctr[GBPROX_PEER_CTR_TX_ERR]); return rc; } -/* feed a message down the NS-VC associated with the specified peer */ -static int gbprox_relay2peer(struct msgb *old_msg, struct gbproxy_peer *peer, +/* feed a message down the NS-VC associated with the specified bvc */ +static int gbprox_relay2peer(struct msgb *old_msg, struct gbproxy_bvc *bvc, uint16_t ns_bvci) { int rc; - struct gbproxy_nse *nse = peer->nse; + struct gbproxy_nse *nse = bvc->nse; OSMO_ASSERT(nse); rc = gbprox_relay2nse(old_msg, nse, ns_bvci); if (rc < 0) - rate_ctr_inc(&peer->ctrg->ctr[GBPROX_PEER_CTR_TX_ERR]); + rate_ctr_inc(&bvc->ctrg->ctr[GBPROX_PEER_CTR_TX_ERR]); return rc; } -static int block_unblock_peer(struct gbproxy_config *cfg, uint16_t ptp_bvci, uint8_t pdu_type) +static int block_unblock_bvc(struct gbproxy_config *cfg, uint16_t ptp_bvci, uint8_t pdu_type) { - struct gbproxy_peer *peer; + struct gbproxy_bvc *bvc; - peer = gbproxy_peer_by_bvci(cfg, ptp_bvci); - if (!peer) { + bvc = gbproxy_bvc_by_bvci(cfg, ptp_bvci); + if (!bvc) { LOGP(DGPRS, LOGL_ERROR, "BVC(%05u/??) Cannot find BSS\n", ptp_bvci); rate_ctr_inc(&cfg->ctrg->ctr[GBPROX_GLOB_CTR_INV_BVCI]); @@ -881,12 +881,12 @@ static int block_unblock_peer(struct gbproxy_config *cfg, uint16_t ptp_bvci, uin switch (pdu_type) { case BSSGP_PDUT_BVC_BLOCK_ACK: - peer->blocked = true; - rate_ctr_inc(&peer->ctrg->ctr[GBPROX_PEER_CTR_BLOCKED]); + bvc->blocked = true; + rate_ctr_inc(&bvc->ctrg->ctr[GBPROX_PEER_CTR_BLOCKED]); break; case BSSGP_PDUT_BVC_UNBLOCK_ACK: - peer->blocked = false; - rate_ctr_inc(&peer->ctrg->ctr[GBPROX_PEER_CTR_UNBLOCKED]); + bvc->blocked = false; + rate_ctr_inc(&bvc->ctrg->ctr[GBPROX_PEER_CTR_UNBLOCKED]); break; default: break; @@ -894,22 +894,22 @@ static int block_unblock_peer(struct gbproxy_config *cfg, uint16_t ptp_bvci, uin return 0; } -/* Send a message to a peer identified by ptp_bvci but using ns_bvci +/* Send a message to a bvc identified by ptp_bvci but using ns_bvci * in the NS hdr */ static int gbprox_relay2bvci(struct gbproxy_config *cfg, struct msgb *msg, uint16_t ptp_bvci, uint16_t ns_bvci) { - struct gbproxy_peer *peer; + struct gbproxy_bvc *bvc; - peer = gbproxy_peer_by_bvci(cfg, ptp_bvci); - if (!peer) { + bvc = gbproxy_bvc_by_bvci(cfg, ptp_bvci); + if (!bvc) { LOGP(DGPRS, LOGL_ERROR, "BVC(%05u/??) Cannot find BSS\n", ptp_bvci); rate_ctr_inc(&cfg->ctrg->ctr[GBPROX_GLOB_CTR_INV_BVCI]); return -ENOENT; } - return gbprox_relay2peer(msg, peer, ns_bvci); + return gbprox_relay2peer(msg, bvc, ns_bvci); } int bssgp_prim_cb(struct osmo_prim_hdr *oph, void *ctx) @@ -922,14 +922,14 @@ static int gbprox_rx_ptp_from_bss(struct gbproxy_config *cfg, struct msgb *msg, uint16_t nsei, uint16_t ns_bvci) { - struct gbproxy_peer *peer; + struct gbproxy_bvc *bvc; struct bssgp_normal_hdr *bgph = (struct bssgp_normal_hdr *) msgb_bssgph(msg); uint8_t pdu_type = bgph->pdu_type; int rc; - peer = gbproxy_peer_by_bvci(cfg, ns_bvci); - if (!peer) { - LOGP(DGPRS, LOGL_NOTICE, "BVC(%05u/??) Didn't find peer " + bvc = gbproxy_bvc_by_bvci(cfg, ns_bvci); + if (!bvc) { + LOGP(DGPRS, LOGL_NOTICE, "BVC(%05u/??) Didn't find bvc " "for PTP message from NSE(%05u/BSS), " "discarding message\n", ns_bvci, nsei); @@ -938,9 +938,9 @@ static int gbprox_rx_ptp_from_bss(struct gbproxy_config *cfg, } /* TODO: Should we discard this message if the check fails */ - check_peer_nsei(peer, nsei); + check_bvc_nsei(bvc, nsei); - rc = gbprox_process_bssgp_ul(cfg, msg, peer); + rc = gbprox_process_bssgp_ul(cfg, msg, bvc); if (!rc) return 0; @@ -965,16 +965,16 @@ static int gbprox_rx_ptp_from_sgsn(struct gbproxy_config *cfg, struct msgb *msg, uint16_t nsei, uint16_t ns_bvci) { - struct gbproxy_peer *peer; + struct gbproxy_bvc *bvc; struct bssgp_normal_hdr *bgph = (struct bssgp_normal_hdr *) msgb_bssgph(msg); uint8_t pdu_type = bgph->pdu_type; - peer = gbproxy_peer_by_bvci(cfg, ns_bvci); + bvc = gbproxy_bvc_by_bvci(cfg, ns_bvci); /* Send status messages before patching */ - if (!peer) { - LOGP(DGPRS, LOGL_INFO, "BVC(%05u/??) Didn't find peer for " + if (!bvc) { + LOGP(DGPRS, LOGL_INFO, "BVC(%05u/??) Didn't find bvc for " "for message from NSE(%05u/SGSN)\n", ns_bvci, nsei); rate_ctr_inc(&cfg->ctrg-> @@ -983,10 +983,10 @@ static int gbprox_rx_ptp_from_sgsn(struct gbproxy_config *cfg, &ns_bvci, msg); } - if (peer->blocked) { - LOGPBVC(peer, LOGL_NOTICE, "Dropping PDU for " + if (bvc->blocked) { + LOGPBVC(bvc, LOGL_NOTICE, "Dropping PDU for " "blocked BVC via NSE(%05u/SGSN)\n", nsei); - rate_ctr_inc(&peer->ctrg->ctr[GBPROX_PEER_CTR_DROPPED]); + rate_ctr_inc(&bvc->ctrg->ctr[GBPROX_PEER_CTR_DROPPED]); return bssgp_tx_status(BSSGP_CAUSE_BVCI_BLOCKED, &ns_bvci, msg); } @@ -1004,9 +1004,9 @@ static int gbprox_rx_ptp_from_sgsn(struct gbproxy_config *cfg, } /* Optionally patch the message */ - gbprox_process_bssgp_dl(cfg, msg, peer); + gbprox_process_bssgp_dl(cfg, msg, bvc); - return gbprox_relay2peer(msg, peer, ns_bvci); + return gbprox_relay2peer(msg, bvc, ns_bvci); } /* process a BVC-RESET message from the BSS side */ @@ -1014,7 +1014,7 @@ static int gbprox_rx_bvc_reset_from_bss(struct gbproxy_config *cfg, struct msgb uint16_t nsei, struct tlv_parsed *tp, int *copy_to_sgsn2) { - struct gbproxy_peer *from_peer = NULL; + struct gbproxy_bvc *from_bvc = NULL; uint16_t bvci; if (!TLVP_PRES_LEN(tp, BSSGP_IE_BVCI, 2) || !TLVP_PRES_LEN(tp, BSSGP_IE_CAUSE, 1)) { @@ -1029,7 +1029,7 @@ static int gbprox_rx_bvc_reset_from_bss(struct gbproxy_config *cfg, struct msgb * don't want the SGSN to reset, as the signalling endpoint * is common for all point-to-point BVCs (and thus all BTS) */ - /* Ensure the NSE peer is there and clear all PtP BVCs */ + /* Ensure the NSE bvc is there and clear all PtP BVCs */ struct gbproxy_nse *nse = gbproxy_nse_by_nsei_or_new(cfg, nsei); if (!nse) { LOGP(DGPRS, LOGL_ERROR, "Could not create NSE(%05u)\n", nsei); @@ -1037,15 +1037,15 @@ static int gbprox_rx_bvc_reset_from_bss(struct gbproxy_config *cfg, struct msgb return 0; } - gbproxy_cleanup_peers(cfg, nsei, 0); + gbproxy_cleanup_bvcs(cfg, nsei, 0); /* FIXME: only do this if SGSN is alive! */ LOGPNSE(nse, LOGL_INFO, "Tx fake BVC RESET ACK of BVCI=0\n"); bssgp_tx_simple_bvci(BSSGP_PDUT_BVC_RESET_ACK, nsei, 0, 0); return 0; } else { - from_peer = gbproxy_peer_by_bvci(cfg, bvci); - if (!from_peer) { + from_bvc = gbproxy_bvc_by_bvci(cfg, bvci); + if (!from_bvc) { struct gbproxy_nse *nse = gbproxy_nse_by_nsei(cfg, nsei); if (!nse) { LOGP(DGPRS, LOGL_NOTICE, "NSE(%05u) Got PtP BVC reset before signalling reset for " @@ -1054,15 +1054,15 @@ static int gbprox_rx_bvc_reset_from_bss(struct gbproxy_config *cfg, struct msgb return 0; } /* if a PTP-BVC is reset, and we don't know that - * PTP-BVCI yet, we should allocate a new peer */ - from_peer = gbproxy_peer_alloc(nse, bvci); - OSMO_ASSERT(from_peer); - LOGPBVC(from_peer, LOGL_INFO, "Allocated new peer\n"); + * PTP-BVCI yet, we should allocate a new bvc */ + from_bvc = gbproxy_bvc_alloc(nse, bvci); + OSMO_ASSERT(from_bvc); + LOGPBVC(from_bvc, LOGL_INFO, "Allocated new bvc\n"); } /* Could have moved to a different NSE */ - if (!check_peer_nsei(from_peer, nsei)) { - LOGPBVC(from_peer, LOGL_NOTICE, "moving peer to NSE(%05u)\n", nsei); + if (!check_bvc_nsei(from_bvc, nsei)) { + LOGPBVC(from_bvc, LOGL_NOTICE, "moving bvc to NSE(%05u)\n", nsei); struct gbproxy_nse *nse_new = gbproxy_nse_by_nsei(cfg, nsei); if (!nse_new) { @@ -1072,8 +1072,8 @@ static int gbprox_rx_bvc_reset_from_bss(struct gbproxy_config *cfg, struct msgb return 0; } - /* Move peer to different NSE */ - gbproxy_peer_move(from_peer, nse_new); + /* Move bvc to different NSE */ + gbproxy_bvc_move(from_bvc, nse_new); } if (TLVP_PRES_LEN(tp, BSSGP_IE_CELL_ID, 8)) { @@ -1082,9 +1082,9 @@ static int gbprox_rx_bvc_reset_from_bss(struct gbproxy_config *cfg, struct msgb * PDU, this means we can extend our local * state information about this particular cell * */ - memcpy(from_peer->ra, TLVP_VAL(tp, BSSGP_IE_CELL_ID), sizeof(from_peer->ra)); - gsm48_parse_ra(&raid, from_peer->ra); - LOGPBVC(from_peer, LOGL_INFO, "Cell ID %s\n", osmo_rai_name(&raid)); + memcpy(from_bvc->ra, TLVP_VAL(tp, BSSGP_IE_CELL_ID), sizeof(from_bvc->ra)); + gsm48_parse_ra(&raid, from_bvc->ra); + LOGPBVC(from_bvc, LOGL_INFO, "Cell ID %s\n", osmo_rai_name(&raid)); } if (cfg->route_to_sgsn2) *copy_to_sgsn2 = 1; @@ -1102,7 +1102,7 @@ static int gbprox_rx_sig_from_bss(struct gbproxy_config *cfg, struct tlv_parsed tp; uint8_t pdu_type = bgph->pdu_type; int data_len = msgb_bssgp_len(msg) - sizeof(*bgph); - struct gbproxy_peer *from_peer = NULL; + struct gbproxy_bvc *from_bvc = NULL; struct gprs_ra_id raid; int copy_to_sgsn2 = 0; int rc; @@ -1128,19 +1128,19 @@ static int gbprox_rx_sig_from_bss(struct gbproxy_config *cfg, case BSSGP_PDUT_SUSPEND: case BSSGP_PDUT_RESUME: /* We implement RAI snooping during SUSPEND/RESUME, since it - * establishes a relationsip between BVCI/peer and the routeing + * establishes a relationsip between BVCI/bvc and the routeing * area identification. The snooped information is then used * for routing the {SUSPEND,RESUME}_[N]ACK back to the correct * BSSGP */ if (!TLVP_PRES_LEN(&tp, BSSGP_IE_ROUTEING_AREA, 6)) goto err_mand_ie; - from_peer = gbproxy_peer_by_nsei(cfg, nsei); - if (!from_peer) - goto err_no_peer; - memcpy(from_peer->ra, TLVP_VAL(&tp, BSSGP_IE_ROUTEING_AREA), - sizeof(from_peer->ra)); - gsm48_parse_ra(&raid, from_peer->ra); - LOGPBVC(from_peer, LOGL_INFO, "BSSGP SUSPEND/RESUME " + from_bvc = gbproxy_bvc_by_nsei(cfg, nsei); + if (!from_bvc) + goto err_no_bvc; + memcpy(from_bvc->ra, TLVP_VAL(&tp, BSSGP_IE_ROUTEING_AREA), + sizeof(from_bvc->ra)); + gsm48_parse_ra(&raid, from_bvc->ra); + LOGPBVC(from_bvc, LOGL_INFO, "BSSGP SUSPEND/RESUME " "RAI snooping: RAI %s\n", osmo_rai_name(&raid)); /* FIXME: This only supports one BSS per RA */ @@ -1155,7 +1155,7 @@ static int gbprox_rx_sig_from_bss(struct gbproxy_config *cfg, /* Normally, we can simply pass on all signalling messages from BSS to * SGSN */ - rc = gbprox_process_bssgp_ul(cfg, msg, from_peer); + rc = gbprox_process_bssgp_ul(cfg, msg, from_bvc); if (!rc) return 0; @@ -1163,8 +1163,8 @@ static int gbprox_rx_sig_from_bss(struct gbproxy_config *cfg, gbprox_relay2sgsn(cfg, msg, ns_bvci, cfg->nsip_sgsn2_nsei); return gbprox_relay2sgsn(cfg, msg, ns_bvci, cfg->nsip_sgsn_nsei); -err_no_peer: - LOGP(DGPRS, LOGL_ERROR, "NSE(%05u/BSS) cannot find peer based on NSEI\n", +err_no_bvc: + LOGP(DGPRS, LOGL_ERROR, "NSE(%05u/BSS) cannot find bvc based on NSEI\n", nsei); rate_ctr_inc(&cfg->ctrg->ctr[GBPROX_GLOB_CTR_INV_NSEI]); return bssgp_tx_status(BSSGP_CAUSE_INV_MAND_INF, NULL, msg); @@ -1180,7 +1180,7 @@ static int gbprox_rx_paging(struct gbproxy_config *cfg, struct msgb *msg, struct uint32_t nsei, uint16_t ns_bvci) { struct gbproxy_nse *nse; - struct gbproxy_peer *peer; + struct gbproxy_bvc *bvc; unsigned int n_nses = 0; int errctr = GBPROX_GLOB_CTR_PROTO_ERR_SGSN; @@ -1191,21 +1191,21 @@ static int gbprox_rx_paging(struct gbproxy_config *cfg, struct msgb *msg, struct if (TLVP_PRES_LEN(tp, BSSGP_IE_BVCI, 2)) { uint16_t bvci = ntohs(tlvp_val16_unal(tp, BSSGP_IE_BVCI)); errctr = GBPROX_GLOB_CTR_OTHER_ERR; - peer = gbproxy_peer_by_bvci(cfg, bvci); - if (!peer) { + bvc = gbproxy_bvc_by_bvci(cfg, bvci); + if (!bvc) { LOGP(DGPRS, LOGL_NOTICE, "NSE(%05u/SGSN) BSSGP PAGING: " "unable to route: BVCI=%05u unknown\n", nsei, bvci); rate_ctr_inc(&cfg->ctrg->ctr[errctr]); return -EINVAL; } - LOGPBVC(peer, LOGL_INFO, "routing by BVCI\n"); - return gbprox_relay2peer(msg, peer, ns_bvci); + LOGPBVC(bvc, LOGL_INFO, "routing by BVCI\n"); + return gbprox_relay2peer(msg, bvc, ns_bvci); } else if (TLVP_PRES_LEN(tp, BSSGP_IE_ROUTEING_AREA, 6)) { errctr = GBPROX_GLOB_CTR_INV_RAI; - /* iterate over all peers and dispatch the paging to each matching one */ - llist_for_each_entry(nse, &cfg->nse_peers, list) { - llist_for_each_entry(peer, &nse->bts_peers, list) { - if (!memcmp(peer->ra, TLVP_VAL(tp, BSSGP_IE_ROUTEING_AREA), 6)) { + /* iterate over all bvcs and dispatch the paging to each matching one */ + llist_for_each_entry(nse, &cfg->nses, list) { + llist_for_each_entry(bvc, &nse->bvcs, list) { + if (!memcmp(bvc->ra, TLVP_VAL(tp, BSSGP_IE_ROUTEING_AREA), 6)) { LOGPNSE(nse, LOGL_INFO, "routing to NSE (RAI match)\n"); gbprox_relay2nse(msg, nse, ns_bvci); n_nses++; @@ -1216,10 +1216,10 @@ static int gbprox_rx_paging(struct gbproxy_config *cfg, struct msgb *msg, struct } } else if (TLVP_PRES_LEN(tp, BSSGP_IE_LOCATION_AREA, 5)) { errctr = GBPROX_GLOB_CTR_INV_LAI; - /* iterate over all peers and dispatch the paging to each matching one */ - llist_for_each_entry(nse, &cfg->nse_peers, list) { - llist_for_each_entry(peer, &nse->bts_peers, list) { - if (!memcmp(peer->ra, TLVP_VAL(tp, BSSGP_IE_LOCATION_AREA), 5)) { + /* iterate over all bvcs and dispatch the paging to each matching one */ + llist_for_each_entry(nse, &cfg->nses, list) { + llist_for_each_entry(bvc, &nse->bvcs, list) { + if (!memcmp(bvc->ra, TLVP_VAL(tp, BSSGP_IE_LOCATION_AREA), 5)) { LOGPNSE(nse, LOGL_INFO, "routing to NSE (LAI match)\n"); gbprox_relay2nse(msg, nse, ns_bvci); n_nses++; @@ -1229,9 +1229,9 @@ static int gbprox_rx_paging(struct gbproxy_config *cfg, struct msgb *msg, struct } } } else if (TLVP_PRES_LEN(tp, BSSGP_IE_BSS_AREA_ID, 1)) { - /* iterate over all peers and dispatch the paging to each matching one */ - llist_for_each_entry(nse, &cfg->nse_peers, list) { - llist_for_each_entry(peer, &nse->bts_peers, list) { + /* iterate over all bvcs and dispatch the paging to each matching one */ + llist_for_each_entry(nse, &cfg->nses, list) { + llist_for_each_entry(bvc, &nse->bvcs, list) { LOGPNSE(nse, LOGL_INFO, "routing to NSE (broadcast)\n"); gbprox_relay2nse(msg, nse, ns_bvci); n_nses++; @@ -1261,7 +1261,7 @@ static int rx_reset_from_sgsn(struct gbproxy_config *cfg, uint32_t nsei, uint16_t ns_bvci) { struct gbproxy_nse *nse; - struct gbproxy_peer *peer; + struct gbproxy_bvc *bvc; uint16_t ptp_bvci; if (!TLVP_PRES_LEN(tp, BSSGP_IE_BVCI, 2)) { @@ -1274,9 +1274,9 @@ static int rx_reset_from_sgsn(struct gbproxy_config *cfg, if (ptp_bvci >= 2) { /* A reset for a PTP BVC was received, forward it to its - * respective peer */ - peer = gbproxy_peer_by_bvci(cfg, ptp_bvci); - if (!peer) { + * respective bvc */ + bvc = gbproxy_bvc_by_bvci(cfg, ptp_bvci); + if (!bvc) { LOGP(DGPRS, LOGL_ERROR, "NSE(%05u/SGSN) BVCI=%05u: Cannot find BSS\n", nsei, ptp_bvci); rate_ctr_inc(&cfg->ctrg-> @@ -1284,16 +1284,16 @@ static int rx_reset_from_sgsn(struct gbproxy_config *cfg, return bssgp_tx_status(BSSGP_CAUSE_UNKNOWN_BVCI, &ptp_bvci, orig_msg); } - return gbprox_relay2peer(msg, peer, ns_bvci); + return gbprox_relay2peer(msg, bvc, ns_bvci); } /* A reset for the Signalling entity has been received * from the SGSN. As the signalling BVCI is shared * among all the BSS's that we multiplex, it needs to * be relayed */ - llist_for_each_entry(nse, &cfg->nse_peers, list) { - llist_for_each_entry(peer, &nse->bts_peers, list) - gbprox_relay2peer(msg, peer, ns_bvci); + llist_for_each_entry(nse, &cfg->nses, list) { + llist_for_each_entry(bvc, &nse->bvcs, list) + gbprox_relay2peer(msg, bvc, ns_bvci); } return 0; @@ -1310,7 +1310,7 @@ static int gbprox_rx_sig_from_sgsn(struct gbproxy_config *cfg, uint8_t pdu_type = bgph->pdu_type; int data_len; struct gbproxy_nse *nse; - struct gbproxy_peer *peer; + struct gbproxy_bvc *bvc; uint16_t bvci; struct msgb *msg; int rc = 0; @@ -1397,10 +1397,10 @@ static int gbprox_rx_sig_from_sgsn(struct gbproxy_config *cfg, /* RAI IE is mandatory */ if (!TLVP_PRES_LEN(&tp, BSSGP_IE_ROUTEING_AREA, 6)) goto err_mand_ie; - peer = gbproxy_peer_by_rai(cfg, TLVP_VAL(&tp, BSSGP_IE_ROUTEING_AREA)); - if (!peer) - goto err_no_peer; - rc = gbprox_relay2peer(msg, peer, ns_bvci); + bvc = gbproxy_bvc_by_rai(cfg, TLVP_VAL(&tp, BSSGP_IE_ROUTEING_AREA)); + if (!bvc) + goto err_no_bvc; + rc = gbprox_relay2peer(msg, bvc, ns_bvci); break; case BSSGP_PDUT_BVC_BLOCK_ACK: case BSSGP_PDUT_BVC_UNBLOCK_ACK: @@ -1416,7 +1416,7 @@ static int gbprox_rx_sig_from_sgsn(struct gbproxy_config *cfg, ctr[GBPROX_GLOB_CTR_INV_BVCI]); } else { /* Mark BVC as (un)blocked */ - block_unblock_peer(cfg, bvci, pdu_type); + block_unblock_bvc(cfg, bvci, pdu_type); } rc = gbprox_relay2bvci(cfg, msg, bvci, ns_bvci); break; @@ -1424,8 +1424,8 @@ static int gbprox_rx_sig_from_sgsn(struct gbproxy_config *cfg, case BSSGP_PDUT_OVERLOAD: LOGP(DGPRS, LOGL_DEBUG, "NSE(%05u/SGSN) BSSGP %s: broadcasting\n", nsei, bssgp_pdu_str(pdu_type)); - /* broadcast to all BSS-side peers */ - llist_for_each_entry(nse, &cfg->nse_peers, list) { + /* broadcast to all BSS-side bvcs */ + llist_for_each_entry(nse, &cfg->nses, list) { gbprox_relay2nse(msg, nse, 0); } break; @@ -1448,8 +1448,8 @@ err_mand_ie: ctr[GBPROX_GLOB_CTR_PROTO_ERR_SGSN]); msgb_free(msg); return bssgp_tx_status(BSSGP_CAUSE_MISSING_MAND_IE, NULL, orig_msg); -err_no_peer: - LOGP(DGPRS, LOGL_ERROR, "NSE(%05u/SGSN) cannot find peer based on RAI\n", +err_no_bvc: + LOGP(DGPRS, LOGL_ERROR, "NSE(%05u/SGSN) cannot find bvc based on RAI\n", nsei); rate_ctr_inc(&cfg->ctrg-> ctr[GBPROX_GLOB_CTR_INV_RAI]); msgb_free(msg); @@ -1519,10 +1519,10 @@ int gbprox_rcvmsg(void *ctx, struct msgb *msg) void gprs_ns_prim_status_cb(struct gbproxy_config *cfg, struct osmo_gprs_ns2_prim *nsp) { - /* TODO: bss nsei available/unavailable bssgp_tx_simple_bvci(BSSGP_PDUT_BVC_BLOCK, nsvc->nsei, peer->bvci, 0); + /* TODO: bss nsei available/unavailable bssgp_tx_simple_bvci(BSSGP_PDUT_BVC_BLOCK, nsvc->nsei, bvc->bvci, 0); * TODO: sgsn nsei available/unavailable */ - struct gbproxy_peer *peer; + struct gbproxy_bvc *bvc; switch (nsp->u.status.cause) { case NS_AFF_CAUSE_SNS_FAILURE: @@ -1549,18 +1549,18 @@ void gprs_ns_prim_status_cb(struct gbproxy_config *cfg, struct osmo_gprs_ns2_pri } else { /* bss became unavailable * TODO: Block all BVC belonging to that NSE */ - peer = gbproxy_peer_by_nsei(cfg, nsp->nsei); - if (!peer) { + bvc = gbproxy_bvc_by_nsei(cfg, nsp->nsei); + if (!bvc) { /* TODO: use primitive name + status cause name */ - LOGP(DGPRS, LOGL_NOTICE, "Received ns2 primitive %d for unknown peer NSEI=%u\n", + LOGP(DGPRS, LOGL_NOTICE, "Received ns2 primitive %d for unknown bvc NSEI=%u\n", nsp->u.status.cause, nsp->nsei); break; } - if (!peer->blocked) + if (!bvc->blocked) break; bssgp_tx_simple_bvci(BSSGP_PDUT_BVC_BLOCK, cfg->nsip_sgsn_nsei, - peer->bvci, 0); + bvc->bvci, 0); } LOGP(DPCU, LOGL_NOTICE, "NS-NSE %d became unavailable\n", nsp->nsei); break; @@ -1620,10 +1620,10 @@ void gbprox_reset(struct gbproxy_config *cfg) { struct gbproxy_nse *nse, *ntmp; - llist_for_each_entry_safe(nse, ntmp, &cfg->nse_peers, list) { - struct gbproxy_peer *peer, *tmp; - llist_for_each_entry_safe(peer, tmp, &nse->bts_peers, list) - gbproxy_peer_free(peer); + llist_for_each_entry_safe(nse, ntmp, &cfg->nses, list) { + struct gbproxy_bvc *bvc, *tmp; + llist_for_each_entry_safe(bvc, tmp, &nse->bvcs, list) + gbproxy_bvc_free(bvc); gbproxy_nse_free(nse); } @@ -1636,7 +1636,7 @@ int gbproxy_init_config(struct gbproxy_config *cfg) { struct timespec tp; - INIT_LLIST_HEAD(&cfg->nse_peers); + INIT_LLIST_HEAD(&cfg->nses); cfg->ctrg = rate_ctr_group_alloc(tall_sgsn_ctx, &global_ctrg_desc, 0); if (!cfg->ctrg) { LOGP(DGPRS, LOGL_ERROR, "Cannot allocate global counter group!\n"); diff --git a/src/gbproxy/gb_proxy_ctrl.c b/src/gbproxy/gb_proxy_ctrl.c index 482bca013..097a29ec1 100644 --- a/src/gbproxy/gb_proxy_ctrl.c +++ b/src/gbproxy/gb_proxy_ctrl.c @@ -69,7 +69,7 @@ static int get_nsvc_state(struct ctrl_cmd *cmd, void *data) gprs_ns2_nse_foreach_nsvc(nse, &ctrl_nsvc_state_cb, cmd); /* NS-VCs for BSS peers */ - llist_for_each_entry(nse_peer, &cfg->nse_peers, list) { + llist_for_each_entry(nse_peer, &cfg->nses, list) { nse = gprs_ns2_nse_by_nsei(nsi, nse_peer->nsei); if (nse) gprs_ns2_nse_foreach_nsvc(nse, &ctrl_nsvc_state_cb, cmd); @@ -87,17 +87,17 @@ static int get_gbproxy_state(struct ctrl_cmd *cmd, void *data) cmd->reply = talloc_strdup(cmd, ""); - llist_for_each_entry(nse_peer, &cfg->nse_peers, list) { - struct gbproxy_peer *peer; - llist_for_each_entry(peer, &nse_peer->bts_peers, list) { + llist_for_each_entry(nse_peer, &cfg->nses, list) { + struct gbproxy_bvc *bvc; + llist_for_each_entry(bvc, &nse_peer->bvcs, list) { struct gprs_ra_id raid; - gsm48_parse_ra(&raid, peer->ra); + gsm48_parse_ra(&raid, bvc->ra); cmd->reply = talloc_asprintf_append(cmd->reply, "%u,%u,%u,%u,%u,%u,%s\n", - nse_peer->nsei, peer->bvci, + nse_peer->nsei, bvc->bvci, raid.mcc, raid.mnc, raid.lac, raid.rac, - peer->blocked ? "BLOCKED" : "UNBLOCKED"); + bvc->blocked ? "BLOCKED" : "UNBLOCKED"); } } @@ -112,8 +112,8 @@ static int get_num_peers(struct ctrl_cmd *cmd, void *data) struct gbproxy_nse *nse_peer; uint32_t count = 0; - llist_for_each_entry(nse_peer, &cfg->nse_peers, list) - count += llist_count(&nse_peer->bts_peers); + llist_for_each_entry(nse_peer, &cfg->nses, list) + count += llist_count(&nse_peer->bvcs); cmd->reply = talloc_strdup(cmd, ""); cmd->reply = talloc_asprintf_append(cmd->reply, "%u", count); diff --git a/src/gbproxy/gb_proxy_patch.c b/src/gbproxy/gb_proxy_patch.c index 59157221f..e78d31b2c 100644 --- a/src/gbproxy/gb_proxy_patch.c +++ b/src/gbproxy/gb_proxy_patch.c @@ -33,20 +33,20 @@ extern void *tall_sgsn_ctx; /* patch RA identifier in place */ -static void gbproxy_patch_raid(struct gsm48_ra_id *raid_enc, struct gbproxy_peer *peer, +static void gbproxy_patch_raid(struct gsm48_ra_id *raid_enc, struct gbproxy_bvc *bvc, int to_bss, const char *log_text) { - OSMO_ASSERT(peer); - struct gbproxy_patch_state *state = &peer->patch_state; + OSMO_ASSERT(bvc); + struct gbproxy_patch_state *state = &bvc->patch_state; struct osmo_plmn_id old_plmn; struct gprs_ra_id raid; - enum gbproxy_peer_ctr counter = + enum gbproxy_bvc_ctr counter = to_bss ? GBPROX_PEER_CTR_RAID_PATCHED_SGSN : GBPROX_PEER_CTR_RAID_PATCHED_BSS; - OSMO_ASSERT(peer->nse); - struct gbproxy_config *cfg = peer->nse->cfg; + OSMO_ASSERT(bvc->nse); + struct gbproxy_config *cfg = bvc->nse->cfg; OSMO_ASSERT(cfg); if (!state->local_plmn.mcc || !state->local_plmn.mnc) @@ -80,7 +80,7 @@ static void gbproxy_patch_raid(struct gsm48_ra_id *raid_enc, struct gbproxy_peer } } - LOGPBVC(peer, LOGL_DEBUG, + LOGPBVC(bvc, LOGL_DEBUG, "Patching %s to %s: " "%s-%d-%d -> %s\n", log_text, @@ -89,12 +89,12 @@ static void gbproxy_patch_raid(struct gsm48_ra_id *raid_enc, struct gbproxy_peer osmo_rai_name(&raid)); gsm48_encode_ra(raid_enc, &raid); - rate_ctr_inc(&peer->ctrg->ctr[counter]); + rate_ctr_inc(&bvc->ctrg->ctr[counter]); } static void gbproxy_patch_apn_ie(struct msgb *msg, uint8_t *apn_ie, size_t apn_ie_len, - struct gbproxy_peer *peer, + struct gbproxy_bvc *bvc, size_t *new_apn_ie_len, const char *log_text) { struct apn_ie_hdr { @@ -105,9 +105,9 @@ static void gbproxy_patch_apn_ie(struct msgb *msg, size_t apn_len = hdr->apn_len; uint8_t *apn = hdr->apn; - OSMO_ASSERT(peer); - OSMO_ASSERT(peer->nse); - struct gbproxy_config *cfg = peer->nse->cfg; + OSMO_ASSERT(bvc); + OSMO_ASSERT(bvc->nse); + struct gbproxy_config *cfg = bvc->nse->cfg; OSMO_ASSERT(cfg); OSMO_ASSERT(apn_ie_len == apn_len + sizeof(struct apn_ie_hdr)); @@ -116,7 +116,7 @@ static void gbproxy_patch_apn_ie(struct msgb *msg, if (cfg->core_apn_size == 0) { char str1[110]; /* Remove the IE */ - LOGPBVC(peer, LOGL_DEBUG, + LOGPBVC(bvc, LOGL_DEBUG, "Patching %s to SGSN: Removing APN '%s'\n", log_text, osmo_apn_to_str(str1, apn, apn_len)); @@ -130,7 +130,7 @@ static void gbproxy_patch_apn_ie(struct msgb *msg, OSMO_ASSERT(cfg->core_apn_size <= 100); - LOGPBVC(peer, LOGL_DEBUG, + LOGPBVC(bvc, LOGL_DEBUG, "Patching %s to SGSN: " "Replacing APN '%s' -> '%s'\n", log_text, @@ -144,21 +144,21 @@ static void gbproxy_patch_apn_ie(struct msgb *msg, hdr->apn_len = cfg->core_apn_size; } - rate_ctr_inc(&peer->ctrg->ctr[GBPROX_PEER_CTR_APN_PATCHED]); + rate_ctr_inc(&bvc->ctrg->ctr[GBPROX_PEER_CTR_APN_PATCHED]); } static int gbproxy_patch_tlli(uint8_t *tlli_enc, - struct gbproxy_peer *peer, + struct gbproxy_bvc *bvc, uint32_t new_tlli, int to_bss, const char *log_text) { uint32_t tlli_be; uint32_t tlli; - enum gbproxy_peer_ctr counter = + enum gbproxy_bvc_ctr counter = to_bss ? GBPROX_PEER_CTR_TLLI_PATCHED_SGSN : GBPROX_PEER_CTR_TLLI_PATCHED_BSS; - OSMO_ASSERT(peer); + OSMO_ASSERT(bvc); memcpy(&tlli_be, tlli_enc, sizeof(tlli_be)); tlli = ntohl(tlli_be); @@ -166,7 +166,7 @@ static int gbproxy_patch_tlli(uint8_t *tlli_enc, if (tlli == new_tlli) return 0; - LOGPBVC(peer, LOGL_DEBUG, + LOGPBVC(bvc, LOGL_DEBUG, "Patching %ss: " "Replacing %08x -> %08x\n", log_text, tlli, new_tlli); @@ -174,23 +174,23 @@ static int gbproxy_patch_tlli(uint8_t *tlli_enc, tlli_be = htonl(new_tlli); memcpy(tlli_enc, &tlli_be, sizeof(tlli_be)); - rate_ctr_inc(&peer->ctrg->ctr[counter]); + rate_ctr_inc(&bvc->ctrg->ctr[counter]); return 1; } static int gbproxy_patch_ptmsi(uint8_t *ptmsi_enc, - struct gbproxy_peer *peer, + struct gbproxy_bvc *bvc, uint32_t new_ptmsi, int to_bss, const char *log_text) { uint32_t ptmsi_be; uint32_t ptmsi; - enum gbproxy_peer_ctr counter = + enum gbproxy_bvc_ctr counter = to_bss ? GBPROX_PEER_CTR_PTMSI_PATCHED_SGSN : GBPROX_PEER_CTR_PTMSI_PATCHED_BSS; - OSMO_ASSERT(peer); + OSMO_ASSERT(bvc); memcpy(&ptmsi_be, ptmsi_enc, sizeof(ptmsi_be)); ptmsi = ntohl(ptmsi_be); @@ -198,7 +198,7 @@ static int gbproxy_patch_ptmsi(uint8_t *ptmsi_enc, if (ptmsi == new_ptmsi) return 0; - LOGPBVC(peer, LOGL_DEBUG, + LOGPBVC(bvc, LOGL_DEBUG, "Patching %ss: " "Replacing %08x -> %08x\n", log_text, ptmsi, new_ptmsi); @@ -206,22 +206,22 @@ static int gbproxy_patch_ptmsi(uint8_t *ptmsi_enc, ptmsi_be = htonl(new_ptmsi); memcpy(ptmsi_enc, &ptmsi_be, sizeof(ptmsi_be)); - rate_ctr_inc(&peer->ctrg->ctr[counter]); + rate_ctr_inc(&bvc->ctrg->ctr[counter]); return 1; } int gbproxy_patch_llc(struct msgb *msg, uint8_t *llc, size_t llc_len, - struct gbproxy_peer *peer, + struct gbproxy_bvc *bvc, struct gbproxy_link_info *link_info, int *len_change, struct gprs_gb_parse_context *parse_ctx) { struct gprs_llc_hdr_parsed *ghp = &parse_ctx->llc_hdr_parsed; int have_patched = 0; int fcs; - OSMO_ASSERT(peer); - OSMO_ASSERT(peer->nse); - struct gbproxy_config *cfg = peer->nse->cfg; + OSMO_ASSERT(bvc); + OSMO_ASSERT(bvc->nse); + struct gbproxy_config *cfg = bvc->nse->cfg; OSMO_ASSERT(cfg); if (parse_ctx->ptmsi_enc && link_info && @@ -233,7 +233,7 @@ int gbproxy_patch_llc(struct msgb *msg, uint8_t *llc, size_t llc_len, ptmsi = link_info->sgsn_tlli.ptmsi; if (ptmsi != GSM_RESERVED_TMSI) { - if (gbproxy_patch_ptmsi(parse_ctx->ptmsi_enc, peer, + if (gbproxy_patch_ptmsi(parse_ctx->ptmsi_enc, bvc, ptmsi, parse_ctx->to_bss, "P-TMSI")) have_patched = 1; } else { @@ -249,20 +249,20 @@ int gbproxy_patch_llc(struct msgb *msg, uint8_t *llc, size_t llc_len, ptmsi = link_info->sgsn_tlli.ptmsi; OSMO_ASSERT(ptmsi); - if (gbproxy_patch_ptmsi(parse_ctx->new_ptmsi_enc, peer, + if (gbproxy_patch_ptmsi(parse_ctx->new_ptmsi_enc, bvc, ptmsi, parse_ctx->to_bss, "new P-TMSI")) have_patched = 1; } if (parse_ctx->raid_enc) { - gbproxy_patch_raid((struct gsm48_ra_id *)parse_ctx->raid_enc, peer, parse_ctx->to_bss, + gbproxy_patch_raid((struct gsm48_ra_id *)parse_ctx->raid_enc, bvc, parse_ctx->to_bss, parse_ctx->llc_msg_name); have_patched = 1; } if (parse_ctx->old_raid_enc && !parse_ctx->old_raid_is_foreign) { /* TODO: Patch to invalid if P-TMSI unknown. */ - gbproxy_patch_raid((struct gsm48_ra_id *)parse_ctx->old_raid_enc, peer, parse_ctx->to_bss, + gbproxy_patch_raid((struct gsm48_ra_id *)parse_ctx->old_raid_enc, bvc, parse_ctx->to_bss, parse_ctx->llc_msg_name); have_patched = 1; } @@ -275,7 +275,7 @@ int gbproxy_patch_llc(struct msgb *msg, uint8_t *llc, size_t llc_len, size_t new_len; gbproxy_patch_apn_ie(msg, parse_ctx->apn_ie, parse_ctx->apn_ie_len, - peer, &new_len, parse_ctx->llc_msg_name); + bvc, &new_len, parse_ctx->llc_msg_name); *len_change += (int)new_len - (int)parse_ctx->apn_ie_len; have_patched = 1; @@ -287,7 +287,7 @@ int gbproxy_patch_llc(struct msgb *msg, uint8_t *llc, size_t llc_len, /* Fix FCS */ fcs = gprs_llc_fcs(llc, ghp->crc_length); - LOGPBVC_CAT(peer, DLLC, LOGL_DEBUG, "Updated LLC message, CRC: %06x -> %06x\n", + LOGPBVC_CAT(bvc, DLLC, LOGL_DEBUG, "Updated LLC message, CRC: %06x -> %06x\n", ghp->fcs, fcs); llc[llc_len - 3] = fcs & 0xff; @@ -300,18 +300,18 @@ int gbproxy_patch_llc(struct msgb *msg, uint8_t *llc, size_t llc_len, /* patch BSSGP message to use core_plmn.mcc/mnc on the SGSN side */ void gbproxy_patch_bssgp(struct msgb *msg, uint8_t *bssgp, size_t bssgp_len, - struct gbproxy_peer *peer, + struct gbproxy_bvc *bvc, struct gbproxy_link_info *link_info, int *len_change, struct gprs_gb_parse_context *parse_ctx) { const char *err_info = NULL; int err_ctr = -1; - OSMO_ASSERT(peer->nse); - struct gbproxy_config *cfg = peer->nse->cfg; + OSMO_ASSERT(bvc->nse); + struct gbproxy_config *cfg = bvc->nse->cfg; OSMO_ASSERT(cfg); if (parse_ctx->bssgp_raid_enc) - gbproxy_patch_raid((struct gsm48_ra_id *)parse_ctx->bssgp_raid_enc, peer, + gbproxy_patch_raid((struct gsm48_ra_id *)parse_ctx->bssgp_raid_enc, bvc, parse_ctx->to_bss, "BSSGP"); if (parse_ctx->need_decryption && @@ -342,7 +342,7 @@ void gbproxy_patch_bssgp(struct msgb *msg, uint8_t *bssgp, size_t bssgp_len, link_info, parse_ctx->to_bss); if (tlli) { - gbproxy_patch_tlli(parse_ctx->tlli_enc, peer, tlli, + gbproxy_patch_tlli(parse_ctx->tlli_enc, bvc, tlli, parse_ctx->to_bss, "TLLI"); parse_ctx->tlli = tlli; } else { @@ -362,7 +362,7 @@ void gbproxy_patch_bssgp(struct msgb *msg, uint8_t *bssgp, size_t bssgp_len, if (ptmsi != GSM_RESERVED_TMSI) gbproxy_patch_ptmsi( - parse_ctx->bssgp_ptmsi_enc, peer, + parse_ctx->bssgp_ptmsi_enc, bvc, ptmsi, parse_ctx->to_bss, "BSSGP P-TMSI"); } @@ -371,7 +371,7 @@ void gbproxy_patch_bssgp(struct msgb *msg, uint8_t *bssgp, size_t bssgp_len, size_t llc_len = parse_ctx->llc_len; int llc_len_change = 0; - gbproxy_patch_llc(msg, llc, llc_len, peer, link_info, + gbproxy_patch_llc(msg, llc, llc_len, bvc, link_info, &llc_len_change, parse_ctx); /* Note that the APN might have been resized here, but no * pointer int the parse_ctx will refer to an adress after the @@ -406,8 +406,8 @@ void gbproxy_patch_bssgp(struct msgb *msg, uint8_t *bssgp, size_t bssgp_len, patch_error: OSMO_ASSERT(err_ctr >= 0); - rate_ctr_inc(&peer->ctrg->ctr[err_ctr]); - LOGPBVC(peer, LOGL_ERROR, + rate_ctr_inc(&bvc->ctrg->ctr[err_ctr]); + LOGPBVC(bvc, LOGL_ERROR, "NSE(%05u/%s) failed to patch BSSGP message as requested: %s.\n", msgb_nsei(msg), parse_ctx->to_bss ? "SGSN" : "BSS", err_info); diff --git a/src/gbproxy/gb_proxy_peer.c b/src/gbproxy/gb_proxy_peer.c index 79ea8e332..a5b93eea5 100644 --- a/src/gbproxy/gb_proxy_peer.c +++ b/src/gbproxy/gb_proxy_peer.c @@ -35,7 +35,7 @@ extern void *tall_sgsn_ctx; -static const struct rate_ctr_desc peer_ctr_description[] = { +static const struct rate_ctr_desc bvc_ctr_description[] = { { "blocked", "BVC Block " }, { "unblocked", "BVC Unblock " }, { "dropped", "BVC blocked, dropped packet " }, @@ -71,98 +71,98 @@ static const struct rate_ctr_desc peer_ctr_description[] = { { "tlli-cache", "TLLI cache size " }, }; -osmo_static_assert(ARRAY_SIZE(peer_ctr_description) == GBPROX_PEER_CTR_LAST, everything_described); +osmo_static_assert(ARRAY_SIZE(bvc_ctr_description) == GBPROX_PEER_CTR_LAST, everything_described); -static const struct rate_ctr_group_desc peer_ctrg_desc = { +static const struct rate_ctr_group_desc bvc_ctrg_desc = { .group_name_prefix = "gbproxy:peer", .group_description = "GBProxy Peer Statistics", - .num_ctr = ARRAY_SIZE(peer_ctr_description), - .ctr_desc = peer_ctr_description, + .num_ctr = ARRAY_SIZE(bvc_ctr_description), + .ctr_desc = bvc_ctr_description, .class_id = OSMO_STATS_CLASS_PEER, }; -/* Find the gbproxy_peer by its BVCI. There can only be one match */ -struct gbproxy_peer *gbproxy_peer_by_bvci(struct gbproxy_config *cfg, uint16_t bvci) +/* Find the gbproxy_bvc by its BVCI. There can only be one match */ +struct gbproxy_bvc *gbproxy_bvc_by_bvci(struct gbproxy_config *cfg, uint16_t bvci) { struct gbproxy_nse *nse; - llist_for_each_entry(nse, &cfg->nse_peers, list) { - struct gbproxy_peer *peer; - llist_for_each_entry(peer, &nse->bts_peers, list) { - if (peer->bvci == bvci) - return peer; + llist_for_each_entry(nse, &cfg->nses, list) { + struct gbproxy_bvc *bvc; + llist_for_each_entry(bvc, &nse->bvcs, list) { + if (bvc->bvci == bvci) + return bvc; } } return NULL; } -/* Find the gbproxy_peer by its NSEI */ -/* FIXME: Only returns the first peer, but we could have multiple on this nsei */ -struct gbproxy_peer *gbproxy_peer_by_nsei(struct gbproxy_config *cfg, +/* Find the gbproxy_bvc by its NSEI */ +/* FIXME: Only returns the first bvc, but we could have multiple on this nsei */ +struct gbproxy_bvc *gbproxy_bvc_by_nsei(struct gbproxy_config *cfg, uint16_t nsei) { struct gbproxy_nse *nse; - llist_for_each_entry(nse, &cfg->nse_peers, list) { - if (nse->nsei == nsei && !llist_empty(&nse->bts_peers)) - return llist_first_entry(&nse->bts_peers, struct gbproxy_peer, list); + llist_for_each_entry(nse, &cfg->nses, list) { + if (nse->nsei == nsei && !llist_empty(&nse->bvcs)) + return llist_first_entry(&nse->bvcs, struct gbproxy_bvc, list); } return NULL; } -/* look-up a peer by its Routeing Area Identification (RAI) */ -/* FIXME: this doesn't make sense, as RA can span multiple peers! */ -struct gbproxy_peer *gbproxy_peer_by_rai(struct gbproxy_config *cfg, +/* look-up a bvc by its Routeing Area Identification (RAI) */ +/* FIXME: this doesn't make sense, as RA can span multiple bvcs! */ +struct gbproxy_bvc *gbproxy_bvc_by_rai(struct gbproxy_config *cfg, const uint8_t *ra) { struct gbproxy_nse *nse; - llist_for_each_entry(nse, &cfg->nse_peers, list) { - struct gbproxy_peer *peer; - llist_for_each_entry(peer, &nse->bts_peers, list) { - if (!memcmp(peer->ra, ra, 6)) - return peer; + llist_for_each_entry(nse, &cfg->nses, list) { + struct gbproxy_bvc *bvc; + llist_for_each_entry(bvc, &nse->bvcs, list) { + if (!memcmp(bvc->ra, ra, 6)) + return bvc; } } return NULL; } -/* look-up a peer by its Location Area Identification (LAI) */ -/* FIXME: this doesn't make sense, as LA can span multiple peers! */ -struct gbproxy_peer *gbproxy_peer_by_lai(struct gbproxy_config *cfg, +/* look-up a bvc by its Location Area Identification (LAI) */ +/* FIXME: this doesn't make sense, as LA can span multiple bvcs! */ +struct gbproxy_bvc *gbproxy_bvc_by_lai(struct gbproxy_config *cfg, const uint8_t *la) { struct gbproxy_nse *nse; - llist_for_each_entry(nse, &cfg->nse_peers, list) { - struct gbproxy_peer *peer; - llist_for_each_entry(peer, &nse->bts_peers, list) { - if (!memcmp(peer->ra, la, 5)) - return peer; + llist_for_each_entry(nse, &cfg->nses, list) { + struct gbproxy_bvc *bvc; + llist_for_each_entry(bvc, &nse->bvcs, list) { + if (!memcmp(bvc->ra, la, 5)) + return bvc; } } return NULL; } -/* look-up a peer by its Location Area Code (LAC) */ -/* FIXME: this doesn't make sense, as LAC can span multiple peers! */ -struct gbproxy_peer *gbproxy_peer_by_lac(struct gbproxy_config *cfg, +/* look-up a bvc by its Location Area Code (LAC) */ +/* FIXME: this doesn't make sense, as LAC can span multiple bvcs! */ +struct gbproxy_bvc *gbproxy_bvc_by_lac(struct gbproxy_config *cfg, const uint8_t *la) { struct gbproxy_nse *nse; - llist_for_each_entry(nse, &cfg->nse_peers, list) { - struct gbproxy_peer *peer; - llist_for_each_entry(peer, &nse->bts_peers, list) { - if (!memcmp(peer->ra + 3, la + 3, 2)) - return peer; + llist_for_each_entry(nse, &cfg->nses, list) { + struct gbproxy_bvc *bvc; + llist_for_each_entry(bvc, &nse->bvcs, list) { + if (!memcmp(bvc->ra + 3, la + 3, 2)) + return bvc; } } return NULL; } -struct gbproxy_peer *gbproxy_peer_by_bssgp_tlv(struct gbproxy_config *cfg, +struct gbproxy_bvc *gbproxy_bvc_by_bssgp_tlv(struct gbproxy_config *cfg, struct tlv_parsed *tp) { if (TLVP_PRES_LEN(tp, BSSGP_IE_BVCI, 2)) { @@ -170,22 +170,22 @@ struct gbproxy_peer *gbproxy_peer_by_bssgp_tlv(struct gbproxy_config *cfg, bvci = ntohs(tlvp_val16_unal(tp, BSSGP_IE_BVCI)); if (bvci >= 2) - return gbproxy_peer_by_bvci(cfg, bvci); + return gbproxy_bvc_by_bvci(cfg, bvci); } - /* FIXME: this doesn't make sense, as RA can span multiple peers! */ + /* FIXME: this doesn't make sense, as RA can span multiple bvcs! */ if (TLVP_PRES_LEN(tp, BSSGP_IE_ROUTEING_AREA, 6)) { uint8_t *rai = (uint8_t *)TLVP_VAL(tp, BSSGP_IE_ROUTEING_AREA); /* Only compare LAC part, since MCC/MNC are possibly patched. * Since the LAC of different BSS must be different when * MCC/MNC are patched, collisions shouldn't happen. */ - return gbproxy_peer_by_lac(cfg, rai); + return gbproxy_bvc_by_lac(cfg, rai); } - /* FIXME: this doesn't make sense, as LA can span multiple peers! */ + /* FIXME: this doesn't make sense, as LA can span multiple bvcs! */ if (TLVP_PRES_LEN(tp, BSSGP_IE_LOCATION_AREA, 5)) { uint8_t *lai = (uint8_t *)TLVP_VAL(tp, BSSGP_IE_LOCATION_AREA); - return gbproxy_peer_by_lac(cfg, lai); + return gbproxy_bvc_by_lac(cfg, lai); } return NULL; @@ -195,88 +195,92 @@ static void clean_stale_timer_cb(void *data) { time_t now; struct timespec ts = {0,}; - struct gbproxy_peer *peer = (struct gbproxy_peer *) data; - OSMO_ASSERT(peer); - OSMO_ASSERT(peer->nse); - struct gbproxy_config *cfg = peer->nse->cfg; + struct gbproxy_bvc *bvc = (struct gbproxy_bvc *) data; + OSMO_ASSERT(bvc); + OSMO_ASSERT(bvc->nse); + struct gbproxy_config *cfg = bvc->nse->cfg; OSMO_ASSERT(cfg); osmo_clock_gettime(CLOCK_MONOTONIC, &ts); now = ts.tv_sec; - gbproxy_remove_stale_link_infos(peer, now); + gbproxy_remove_stale_link_infos(bvc, now); if (cfg->clean_stale_timer_freq != 0) - osmo_timer_schedule(&peer->clean_stale_timer, + osmo_timer_schedule(&bvc->clean_stale_timer, cfg->clean_stale_timer_freq, 0); } -struct gbproxy_peer *gbproxy_peer_alloc(struct gbproxy_nse *nse, uint16_t bvci) +struct gbproxy_bvc *gbproxy_bvc_alloc(struct gbproxy_nse *nse, uint16_t bvci) { - struct gbproxy_peer *peer; + struct gbproxy_bvc *bvc; OSMO_ASSERT(nse); struct gbproxy_config *cfg = nse->cfg; OSMO_ASSERT(cfg); - peer = talloc_zero(tall_sgsn_ctx, struct gbproxy_peer); - if (!peer) + bvc = talloc_zero(tall_sgsn_ctx, struct gbproxy_bvc); + if (!bvc) return NULL; - peer->bvci = bvci; - peer->ctrg = rate_ctr_group_alloc(peer, &peer_ctrg_desc, bvci); - if (!peer->ctrg) { - talloc_free(peer); + bvc->bvci = bvci; + bvc->ctrg = rate_ctr_group_alloc(bvc, &bvc_ctrg_desc, bvci); + if (!bvc->ctrg) { + talloc_free(bvc); return NULL; } - peer->nse = nse; + bvc->nse = nse; - llist_add(&peer->list, &nse->bts_peers); + llist_add(&bvc->list, &nse->bvcs); - INIT_LLIST_HEAD(&peer->patch_state.logical_links); + INIT_LLIST_HEAD(&bvc->patch_state.logical_links); - osmo_timer_setup(&peer->clean_stale_timer, clean_stale_timer_cb, peer); + osmo_timer_setup(&bvc->clean_stale_timer, clean_stale_timer_cb, bvc); if (cfg->clean_stale_timer_freq != 0) - osmo_timer_schedule(&peer->clean_stale_timer, + osmo_timer_schedule(&bvc->clean_stale_timer, cfg->clean_stale_timer_freq, 0); - return peer; + return bvc; } -void gbproxy_peer_free(struct gbproxy_peer *peer) +void gbproxy_bvc_free(struct gbproxy_bvc *bvc) { - if (!peer) + if (!bvc) return; - llist_del(&peer->list); - osmo_timer_del(&peer->clean_stale_timer); - gbproxy_delete_link_infos(peer); + llist_del(&bvc->list); + osmo_timer_del(&bvc->clean_stale_timer); + gbproxy_delete_link_infos(bvc); - rate_ctr_group_free(peer->ctrg); - peer->ctrg = NULL; + rate_ctr_group_free(bvc->ctrg); + bvc->ctrg = NULL; - talloc_free(peer); + talloc_free(bvc); } -void gbproxy_peer_move(struct gbproxy_peer *peer, struct gbproxy_nse *nse) +void gbproxy_bvc_move(struct gbproxy_bvc *bvc, struct gbproxy_nse *nse) { - llist_del(&peer->list); - llist_add(&peer->list, &nse->bts_peers); - peer->nse = nse; + llist_del(&bvc->list); + llist_add(&bvc->list, &nse->bvcs); + bvc->nse = nse; } -int gbproxy_cleanup_peers(struct gbproxy_config *cfg, uint16_t nsei, uint16_t bvci) +/*! remove bvcs (BVCs) on NSE specified by NSEI. + * \param[in] cfg proxy in which we operate + * \param[in] nsei NS entity in which we should clean up + * \param[in] bvci if 0: remove all BVCs; if != 0: BVCI of the single BVC to clean up */ +int gbproxy_cleanup_bvcs(struct gbproxy_config *cfg, uint16_t nsei, uint16_t bvci) { int counter = 0; struct gbproxy_nse *nse, *ntmp; OSMO_ASSERT(cfg); - llist_for_each_entry_safe(nse, ntmp, &cfg->nse_peers, list) { - struct gbproxy_peer *peer, *tmp; + llist_for_each_entry_safe(nse, ntmp, &cfg->nses, list) { + struct gbproxy_bvc *bvc, *tmp; if (nse->nsei != nsei) continue; - llist_for_each_entry_safe(peer, tmp, &nse->bts_peers, list) { - if (bvci && peer->bvci != bvci) + llist_for_each_entry_safe(bvc, tmp, &nse->bvcs, list) { + if (bvci && bvc->bvci != bvci) continue; - gbproxy_peer_free(peer); + gbproxy_bvc_free(bvc); counter += 1; } } @@ -296,23 +300,23 @@ struct gbproxy_nse *gbproxy_nse_alloc(struct gbproxy_config *cfg, uint16_t nsei) nse->nsei = nsei; nse->cfg = cfg; - llist_add(&nse->list, &cfg->nse_peers); + llist_add(&nse->list, &cfg->nses); - INIT_LLIST_HEAD(&nse->bts_peers); + INIT_LLIST_HEAD(&nse->bvcs); return nse; } void gbproxy_nse_free(struct gbproxy_nse *nse) { - struct gbproxy_peer *peer, *tmp; + struct gbproxy_bvc *bvc, *tmp; if (!nse) return; llist_del(&nse->list); - llist_for_each_entry_safe(peer, tmp, &nse->bts_peers, list) - gbproxy_peer_free(peer); + llist_for_each_entry_safe(bvc, tmp, &nse->bvcs, list) + gbproxy_bvc_free(bvc); talloc_free(nse); } @@ -322,7 +326,7 @@ struct gbproxy_nse *gbproxy_nse_by_nsei(struct gbproxy_config *cfg, uint16_t nse struct gbproxy_nse *nse; OSMO_ASSERT(cfg); - llist_for_each_entry(nse, &cfg->nse_peers, list) { + llist_for_each_entry(nse, &cfg->nses, list) { if (nse->nsei == nsei) return nse; } @@ -340,4 +344,4 @@ struct gbproxy_nse *gbproxy_nse_by_nsei_or_new(struct gbproxy_config *cfg, uint1 nse = gbproxy_nse_alloc(cfg, nsei); return nse; -} \ No newline at end of file +} diff --git a/src/gbproxy/gb_proxy_tlli.c b/src/gbproxy/gb_proxy_tlli.c index b84d1ea4e..0ea3a9305 100644 --- a/src/gbproxy/gb_proxy_tlli.c +++ b/src/gbproxy/gb_proxy_tlli.c @@ -32,11 +32,11 @@ #include #include -struct gbproxy_link_info *gbproxy_link_info_by_tlli(struct gbproxy_peer *peer, +struct gbproxy_link_info *gbproxy_link_info_by_tlli(struct gbproxy_bvc *bvc, uint32_t tlli) { struct gbproxy_link_info *link_info; - struct gbproxy_patch_state *state = &peer->patch_state; + struct gbproxy_patch_state *state = &bvc->patch_state; if (!tlli) return NULL; @@ -50,11 +50,11 @@ struct gbproxy_link_info *gbproxy_link_info_by_tlli(struct gbproxy_peer *peer, } struct gbproxy_link_info *gbproxy_link_info_by_ptmsi( - struct gbproxy_peer *peer, + struct gbproxy_bvc *bvc, uint32_t ptmsi) { struct gbproxy_link_info *link_info; - struct gbproxy_patch_state *state = &peer->patch_state; + struct gbproxy_patch_state *state = &bvc->patch_state; if (ptmsi == GSM_RESERVED_TMSI) return NULL; @@ -67,11 +67,11 @@ struct gbproxy_link_info *gbproxy_link_info_by_ptmsi( } struct gbproxy_link_info *gbproxy_link_info_by_any_sgsn_tlli( - struct gbproxy_peer *peer, + struct gbproxy_bvc *bvc, uint32_t tlli) { struct gbproxy_link_info *link_info; - struct gbproxy_patch_state *state = &peer->patch_state; + struct gbproxy_patch_state *state = &bvc->patch_state; if (!tlli) return NULL; @@ -86,11 +86,11 @@ struct gbproxy_link_info *gbproxy_link_info_by_any_sgsn_tlli( } struct gbproxy_link_info *gbproxy_link_info_by_sgsn_tlli( - struct gbproxy_peer *peer, + struct gbproxy_bvc *bvc, uint32_t tlli, uint32_t sgsn_nsei) { struct gbproxy_link_info *link_info; - struct gbproxy_patch_state *state = &peer->patch_state; + struct gbproxy_patch_state *state = &bvc->patch_state; if (!tlli) return NULL; @@ -105,12 +105,12 @@ struct gbproxy_link_info *gbproxy_link_info_by_sgsn_tlli( } struct gbproxy_link_info *gbproxy_link_info_by_imsi( - struct gbproxy_peer *peer, + struct gbproxy_bvc *bvc, const uint8_t *imsi, size_t imsi_len) { struct gbproxy_link_info *link_info; - struct gbproxy_patch_state *state = &peer->patch_state; + struct gbproxy_patch_state *state = &bvc->patch_state; if (!gprs_is_mi_imsi(imsi, imsi_len)) return NULL; @@ -137,10 +137,10 @@ void gbproxy_link_info_discard_messages(struct gbproxy_link_info *link_info) } } -void gbproxy_delete_link_info(struct gbproxy_peer *peer, +void gbproxy_delete_link_info(struct gbproxy_bvc *bvc, struct gbproxy_link_info *link_info) { - struct gbproxy_patch_state *state = &peer->patch_state; + struct gbproxy_patch_state *state = &bvc->patch_state; gbproxy_link_info_discard_messages(link_info); @@ -148,44 +148,44 @@ void gbproxy_delete_link_info(struct gbproxy_peer *peer, talloc_free(link_info); state->logical_link_count -= 1; - peer->ctrg->ctr[GBPROX_PEER_CTR_TLLI_CACHE_SIZE].current = + bvc->ctrg->ctr[GBPROX_PEER_CTR_TLLI_CACHE_SIZE].current = state->logical_link_count; } -void gbproxy_delete_link_infos(struct gbproxy_peer *peer) +void gbproxy_delete_link_infos(struct gbproxy_bvc *bvc) { struct gbproxy_link_info *link_info, *nxt; - struct gbproxy_patch_state *state = &peer->patch_state; + struct gbproxy_patch_state *state = &bvc->patch_state; llist_for_each_entry_safe(link_info, nxt, &state->logical_links, list) - gbproxy_delete_link_info(peer, link_info); + gbproxy_delete_link_info(bvc, link_info); OSMO_ASSERT(state->logical_link_count == 0); OSMO_ASSERT(llist_empty(&state->logical_links)); } -void gbproxy_attach_link_info(struct gbproxy_peer *peer, time_t now, +void gbproxy_attach_link_info(struct gbproxy_bvc *bvc, time_t now, struct gbproxy_link_info *link_info) { - struct gbproxy_patch_state *state = &peer->patch_state; + struct gbproxy_patch_state *state = &bvc->patch_state; link_info->timestamp = now; llist_add(&link_info->list, &state->logical_links); state->logical_link_count += 1; - peer->ctrg->ctr[GBPROX_PEER_CTR_TLLI_CACHE_SIZE].current = + bvc->ctrg->ctr[GBPROX_PEER_CTR_TLLI_CACHE_SIZE].current = state->logical_link_count; } -int gbproxy_remove_stale_link_infos(struct gbproxy_peer *peer, time_t now) +int gbproxy_remove_stale_link_infos(struct gbproxy_bvc *bvc, time_t now) { - OSMO_ASSERT(peer); - struct gbproxy_patch_state *state = &peer->patch_state; + OSMO_ASSERT(bvc); + struct gbproxy_patch_state *state = &bvc->patch_state; int exceeded_max_len = 0; int deleted_count = 0; int check_for_age; - OSMO_ASSERT(peer->nse); - struct gbproxy_config *cfg = peer->nse->cfg; + OSMO_ASSERT(bvc->nse); + struct gbproxy_config *cfg = bvc->nse->cfg; OSMO_ASSERT(cfg); if (cfg->tlli_max_len > 0) @@ -200,12 +200,12 @@ int gbproxy_remove_stale_link_infos(struct gbproxy_peer *peer, time_t now) link_info = llist_entry(state->logical_links.prev, struct gbproxy_link_info, list); - LOGPBVC(peer, LOGL_INFO, + LOGPBVC(bvc, LOGL_INFO, "Removing TLLI %08x from list " "(stale, length %d, max_len exceeded)\n", link_info->tlli.current, state->logical_link_count); - gbproxy_delete_link_info(peer, link_info); + gbproxy_delete_link_info(bvc, link_info); deleted_count += 1; } @@ -222,23 +222,23 @@ int gbproxy_remove_stale_link_infos(struct gbproxy_peer *peer, time_t now) continue; } - LOGPBVC(peer, LOGL_INFO, + LOGPBVC(bvc, LOGL_INFO, "Removing TLLI %08x from list " "(stale, age %d, max_age exceeded)\n", link_info->tlli.current, (int)age); - gbproxy_delete_link_info(peer, link_info); + gbproxy_delete_link_info(bvc, link_info); deleted_count += 1; } return deleted_count; } -struct gbproxy_link_info *gbproxy_link_info_alloc( struct gbproxy_peer *peer) +struct gbproxy_link_info *gbproxy_link_info_alloc( struct gbproxy_bvc *bvc) { struct gbproxy_link_info *link_info; - link_info = talloc_zero(peer, struct gbproxy_link_info); + link_info = talloc_zero(bvc, struct gbproxy_link_info); link_info->tlli.ptmsi = GSM_RESERVED_TMSI; link_info->sgsn_tlli.ptmsi = GSM_RESERVED_TMSI; @@ -250,16 +250,16 @@ struct gbproxy_link_info *gbproxy_link_info_alloc( struct gbproxy_peer *peer) } void gbproxy_detach_link_info( - struct gbproxy_peer *peer, + struct gbproxy_bvc *bvc, struct gbproxy_link_info *link_info) { - struct gbproxy_patch_state *state = &peer->patch_state; + struct gbproxy_patch_state *state = &bvc->patch_state; llist_del(&link_info->list); OSMO_ASSERT(state->logical_link_count > 0); state->logical_link_count -= 1; - peer->ctrg->ctr[GBPROX_PEER_CTR_TLLI_CACHE_SIZE].current = + bvc->ctrg->ctr[GBPROX_PEER_CTR_TLLI_CACHE_SIZE].current = state->logical_link_count; } @@ -277,13 +277,13 @@ void gbproxy_update_link_info(struct gbproxy_link_info *link_info, } void gbproxy_reassign_tlli(struct gbproxy_tlli_state *tlli_state, - struct gbproxy_peer *peer, uint32_t new_tlli) + struct gbproxy_bvc *bvc, uint32_t new_tlli) { - OSMO_ASSERT(peer); + OSMO_ASSERT(bvc); if (new_tlli == tlli_state->current) return; - LOGPBVC(peer, LOGL_INFO, + LOGPBVC(bvc, LOGL_INFO, "The TLLI has been reassigned from %08x to %08x\n", tlli_state->current, new_tlli); @@ -345,26 +345,26 @@ static void gbproxy_validate_tlli(struct gbproxy_tlli_state *tlli_state, tlli_state->assigned = 0; } -static void gbproxy_touch_link_info(struct gbproxy_peer *peer, +static void gbproxy_touch_link_info(struct gbproxy_bvc *bvc, struct gbproxy_link_info *link_info, time_t now) { - gbproxy_detach_link_info(peer, link_info); - gbproxy_attach_link_info(peer, now, link_info); + gbproxy_detach_link_info(bvc, link_info); + gbproxy_attach_link_info(bvc, now, link_info); } -static int gbproxy_unregister_link_info(struct gbproxy_peer *peer, +static int gbproxy_unregister_link_info(struct gbproxy_bvc *bvc, struct gbproxy_link_info *link_info) { - OSMO_ASSERT(peer); + OSMO_ASSERT(bvc); if (!link_info) return 1; if (link_info->tlli.ptmsi == GSM_RESERVED_TMSI && !link_info->imsi_len) { - LOGPBVC(peer, LOGL_INFO, + LOGPBVC(bvc, LOGL_INFO, "Removing TLLI %08x from list (P-TMSI or IMSI are not set)\n", link_info->tlli.current); - gbproxy_delete_link_info(peer, link_info); + gbproxy_delete_link_info(bvc, link_info); return 1; } @@ -394,32 +394,32 @@ int gbproxy_imsi_matches(struct gbproxy_config *cfg, return link_info != NULL && link_info->is_matching[match_id]; } -static void gbproxy_assign_imsi(struct gbproxy_peer *peer, +static void gbproxy_assign_imsi(struct gbproxy_bvc *bvc, struct gbproxy_link_info *link_info, struct gprs_gb_parse_context *parse_ctx) { int imsi_matches; struct gbproxy_link_info *other_link_info; enum gbproxy_match_id match_id; - OSMO_ASSERT(peer); - OSMO_ASSERT(peer->nse); - struct gbproxy_config *cfg = peer->nse->cfg; + OSMO_ASSERT(bvc); + OSMO_ASSERT(bvc->nse); + struct gbproxy_config *cfg = bvc->nse->cfg; OSMO_ASSERT(cfg); /* Make sure that there is a second entry with the same IMSI */ other_link_info = gbproxy_link_info_by_imsi( - peer, parse_ctx->imsi, parse_ctx->imsi_len); + bvc, parse_ctx->imsi, parse_ctx->imsi_len); if (other_link_info && other_link_info != link_info) { struct osmo_mobile_identity mi; if (osmo_mobile_identity_decode(&mi, parse_ctx->imsi, parse_ctx->imsi_len, false) || mi.type != GSM_MI_TYPE_IMSI) { - LOGPBVC(peer, LOGL_ERROR, "Failed to decode Mobile Identity\n"); + LOGPBVC(bvc, LOGL_ERROR, "Failed to decode Mobile Identity\n"); } else { - LOGPBVC(peer, LOGL_INFO, + LOGPBVC(bvc, LOGL_INFO, "Removing TLLI %08x from list (IMSI %s re-used)\n", other_link_info->tlli.current, mi.imsi); - gbproxy_delete_link_info(peer, other_link_info); + gbproxy_delete_link_info(bvc, other_link_info); } } @@ -456,11 +456,11 @@ static int gbproxy_tlli_match(const struct gbproxy_tlli_state *a, } static void gbproxy_remove_matching_link_infos( - struct gbproxy_peer *peer, struct gbproxy_link_info *link_info) + struct gbproxy_bvc *bvc, struct gbproxy_link_info *link_info) { - OSMO_ASSERT(peer); + OSMO_ASSERT(bvc); struct gbproxy_link_info *info, *nxt; - struct gbproxy_patch_state *state = &peer->patch_state; + struct gbproxy_patch_state *state = &bvc->patch_state; /* Make sure that there is no second entry with the same P-TMSI or TLLI */ llist_for_each_entry_safe(info, nxt, &state->logical_links, list) { @@ -472,22 +472,22 @@ static void gbproxy_remove_matching_link_infos( !gbproxy_tlli_match(&link_info->sgsn_tlli, &info->sgsn_tlli))) continue; - LOGPBVC(peer, LOGL_INFO, + LOGPBVC(bvc, LOGL_INFO, "Removing TLLI %08x from list (P-TMSI/TLLI re-used)\n", info->tlli.current); - gbproxy_delete_link_info(peer, info); + gbproxy_delete_link_info(bvc, info); } } static struct gbproxy_link_info *gbproxy_get_link_info_ul( - struct gbproxy_peer *peer, + struct gbproxy_bvc *bvc, int *tlli_is_valid, struct gprs_gb_parse_context *parse_ctx) { struct gbproxy_link_info *link_info = NULL; if (parse_ctx->tlli_enc) { - link_info = gbproxy_link_info_by_tlli(peer, parse_ctx->tlli); + link_info = gbproxy_link_info_by_tlli(bvc, parse_ctx->tlli); if (link_info) { *tlli_is_valid = 1; @@ -499,13 +499,13 @@ static struct gbproxy_link_info *gbproxy_get_link_info_ul( if (!link_info && parse_ctx->imsi) { link_info = gbproxy_link_info_by_imsi( - peer, parse_ctx->imsi, parse_ctx->imsi_len); + bvc, parse_ctx->imsi, parse_ctx->imsi_len); } if (!link_info && parse_ctx->ptmsi_enc && !parse_ctx->old_raid_is_foreign) { uint32_t bss_ptmsi; gprs_parse_tmsi(parse_ctx->ptmsi_enc, &bss_ptmsi); - link_info = gbproxy_link_info_by_ptmsi(peer, bss_ptmsi); + link_info = gbproxy_link_info_by_ptmsi(bvc, bss_ptmsi); } if (!link_info) @@ -517,27 +517,27 @@ static struct gbproxy_link_info *gbproxy_get_link_info_ul( } struct gbproxy_link_info *gbproxy_update_link_state_ul( - struct gbproxy_peer *peer, + struct gbproxy_bvc *bvc, time_t now, struct gprs_gb_parse_context *parse_ctx) { struct gbproxy_link_info *link_info; int tlli_is_valid; - OSMO_ASSERT(peer); + OSMO_ASSERT(bvc); - link_info = gbproxy_get_link_info_ul(peer, &tlli_is_valid, parse_ctx); + link_info = gbproxy_get_link_info_ul(bvc, &tlli_is_valid, parse_ctx); if (parse_ctx->tlli_enc && parse_ctx->llc) { uint32_t sgsn_tlli; if (!link_info) { - LOGPBVC(peer, LOGL_INFO, "Adding TLLI %08x to list\n", + LOGPBVC(bvc, LOGL_INFO, "Adding TLLI %08x to list\n", parse_ctx->tlli); - link_info = gbproxy_link_info_alloc(peer); - gbproxy_attach_link_info(peer, now, link_info); + link_info = gbproxy_link_info_alloc(bvc); + gbproxy_attach_link_info(bvc, now, link_info); /* Setup TLLIs */ - sgsn_tlli = gbproxy_make_sgsn_tlli(peer, link_info, + sgsn_tlli = gbproxy_make_sgsn_tlli(bvc, link_info, parse_ctx->tlli); link_info->sgsn_tlli.current = sgsn_tlli; link_info->tlli.current = parse_ctx->tlli; @@ -546,34 +546,34 @@ struct gbproxy_link_info *gbproxy_update_link_state_ul( link_info->tlli.current = parse_ctx->tlli; link_info->tlli.assigned = 0; link_info->sgsn_tlli.current = - gbproxy_make_sgsn_tlli(peer, link_info, + gbproxy_make_sgsn_tlli(bvc, link_info, parse_ctx->tlli); link_info->sgsn_tlli.assigned = 0; - gbproxy_touch_link_info(peer, link_info, now); + gbproxy_touch_link_info(bvc, link_info, now); } else { sgsn_tlli = gbproxy_map_tlli(parse_ctx->tlli, link_info, 0); if (!sgsn_tlli) - sgsn_tlli = gbproxy_make_sgsn_tlli(peer, link_info, + sgsn_tlli = gbproxy_make_sgsn_tlli(bvc, link_info, parse_ctx->tlli); gbproxy_validate_tlli(&link_info->tlli, parse_ctx->tlli, 0); gbproxy_validate_tlli(&link_info->sgsn_tlli, sgsn_tlli, 0); - gbproxy_touch_link_info(peer, link_info, now); + gbproxy_touch_link_info(bvc, link_info, now); } } else if (link_info) { - gbproxy_touch_link_info(peer, link_info, now); + gbproxy_touch_link_info(bvc, link_info, now); } if (parse_ctx->imsi && link_info && link_info->imsi_len == 0) - gbproxy_assign_imsi(peer, link_info, parse_ctx); + gbproxy_assign_imsi(bvc, link_info, parse_ctx); return link_info; } static struct gbproxy_link_info *gbproxy_get_link_info_dl( - struct gbproxy_peer *peer, + struct gbproxy_bvc *bvc, struct gprs_gb_parse_context *parse_ctx) { struct gbproxy_link_info *link_info = NULL; @@ -581,14 +581,14 @@ static struct gbproxy_link_info *gbproxy_get_link_info_dl( /* Which key to use depends on its availability only, if that fails, do * not retry it with another key (e.g. IMSI). */ if (parse_ctx->tlli_enc) - link_info = gbproxy_link_info_by_sgsn_tlli(peer, parse_ctx->tlli, + link_info = gbproxy_link_info_by_sgsn_tlli(bvc, parse_ctx->tlli, parse_ctx->peer_nsei); /* TODO: Get link_info by (SGSN) P-TMSI if that is available (see * GSM 08.18, 7.2) instead of using the IMSI as key. */ else if (parse_ctx->imsi) link_info = gbproxy_link_info_by_imsi( - peer, parse_ctx->imsi, parse_ctx->imsi_len); + bvc, parse_ctx->imsi, parse_ctx->imsi_len); if (link_info) link_info->is_deregistered = false; @@ -597,17 +597,17 @@ static struct gbproxy_link_info *gbproxy_get_link_info_dl( } struct gbproxy_link_info *gbproxy_update_link_state_dl( - struct gbproxy_peer *peer, + struct gbproxy_bvc *bvc, time_t now, struct gprs_gb_parse_context *parse_ctx) { struct gbproxy_link_info *link_info = NULL; - OSMO_ASSERT(peer); - OSMO_ASSERT(peer->nse); - struct gbproxy_config *cfg = peer->nse->cfg; + OSMO_ASSERT(bvc); + OSMO_ASSERT(bvc->nse); + struct gbproxy_config *cfg = bvc->nse->cfg; OSMO_ASSERT(cfg); - link_info = gbproxy_get_link_info_dl(peer, parse_ctx); + link_info = gbproxy_get_link_info_dl(bvc, parse_ctx); if (parse_ctx->tlli_enc && parse_ctx->new_ptmsi_enc && link_info) { /* A new P-TMSI has been signalled in the message, @@ -620,9 +620,9 @@ struct gbproxy_link_info *gbproxy_update_link_state_dl( new_bss_ptmsi = link_info->tlli.ptmsi; if (new_bss_ptmsi == GSM_RESERVED_TMSI) - new_bss_ptmsi = gbproxy_make_bss_ptmsi(peer, new_sgsn_ptmsi); + new_bss_ptmsi = gbproxy_make_bss_ptmsi(bvc, new_sgsn_ptmsi); - LOGPBVC(peer, LOGL_INFO, + LOGPBVC(bvc, LOGL_INFO, "Got new PTMSI %08x from SGSN, using %08x for BSS\n", new_sgsn_ptmsi, new_bss_ptmsi); /* Setup PTMSIs */ @@ -636,25 +636,25 @@ struct gbproxy_link_info *gbproxy_update_link_state_dl( uint32_t new_ptmsi; gprs_parse_tmsi(parse_ctx->new_ptmsi_enc, &new_ptmsi); - LOGPBVC(peer, LOGL_INFO, + LOGPBVC(bvc, LOGL_INFO, "Adding TLLI %08x to list (SGSN, new P-TMSI is %08x)\n", parse_ctx->tlli, new_ptmsi); - link_info = gbproxy_link_info_alloc(peer); + link_info = gbproxy_link_info_alloc(bvc); link_info->sgsn_tlli.current = parse_ctx->tlli; link_info->tlli.current = parse_ctx->tlli; link_info->sgsn_tlli.ptmsi = new_ptmsi; link_info->tlli.ptmsi = new_ptmsi; - gbproxy_attach_link_info(peer, now, link_info); + gbproxy_attach_link_info(bvc, now, link_info); } else if (parse_ctx->tlli_enc && parse_ctx->llc && !link_info && !cfg->patch_ptmsi) { /* Unknown SGSN TLLI, create a new link_info */ uint32_t new_ptmsi; - link_info = gbproxy_link_info_alloc(peer); - LOGPBVC(peer, LOGL_INFO, "Adding TLLI %08x to list (SGSN)\n", + link_info = gbproxy_link_info_alloc(bvc); + LOGPBVC(bvc, LOGL_INFO, "Adding TLLI %08x to list (SGSN)\n", parse_ctx->tlli); - gbproxy_attach_link_info(peer, now, link_info); + gbproxy_attach_link_info(bvc, now, link_info); /* Setup TLLIs */ link_info->sgsn_tlli.current = parse_ctx->tlli; @@ -665,7 +665,7 @@ struct gbproxy_link_info *gbproxy_update_link_state_dl( /* A new P-TMSI has been signalled in the message */ gprs_parse_tmsi(parse_ctx->new_ptmsi_enc, &new_ptmsi); - LOGPBVC(peer, LOGL_INFO, + LOGPBVC(bvc, LOGL_INFO, "Assigning new P-TMSI %08x\n", new_ptmsi); /* Setup P-TMSIs */ link_info->sgsn_tlli.ptmsi = new_ptmsi; @@ -675,27 +675,27 @@ struct gbproxy_link_info *gbproxy_update_link_state_dl( link_info, 1); gbproxy_validate_tlli(&link_info->sgsn_tlli, parse_ctx->tlli, 1); gbproxy_validate_tlli(&link_info->tlli, bss_tlli, 1); - gbproxy_touch_link_info(peer, link_info, now); + gbproxy_touch_link_info(bvc, link_info, now); } else if (link_info) { - gbproxy_touch_link_info(peer, link_info, now); + gbproxy_touch_link_info(bvc, link_info, now); } if (parse_ctx->imsi && link_info && link_info->imsi_len == 0) - gbproxy_assign_imsi(peer, link_info, parse_ctx); + gbproxy_assign_imsi(bvc, link_info, parse_ctx); return link_info; } int gbproxy_update_link_state_after( - struct gbproxy_peer *peer, + struct gbproxy_bvc *bvc, struct gbproxy_link_info *link_info, time_t now, struct gprs_gb_parse_context *parse_ctx) { int rc = 0; - OSMO_ASSERT(peer); - OSMO_ASSERT(peer->nse); - struct gbproxy_config *cfg = peer->nse->cfg; + OSMO_ASSERT(bvc); + OSMO_ASSERT(bvc->nse); + struct gbproxy_config *cfg = bvc->nse->cfg; OSMO_ASSERT(cfg); if (parse_ctx->invalidate_tlli && link_info) { @@ -706,13 +706,13 @@ int gbproxy_update_link_state_after( (cfg->keep_link_infos == GBPROX_KEEP_IDENTIFIED && link_info->imsi_len > 0); if (keep_info) { - LOGPBVC(peer, LOGL_INFO, "Unregistering TLLI %08x\n", + LOGPBVC(bvc, LOGL_INFO, "Unregistering TLLI %08x\n", link_info->tlli.current); - rc = gbproxy_unregister_link_info(peer, link_info); + rc = gbproxy_unregister_link_info(bvc, link_info); } else { - LOGPBVC(peer, LOGL_INFO, "Removing TLLI %08x from list\n", + LOGPBVC(bvc, LOGL_INFO, "Removing TLLI %08x from list\n", link_info->tlli.current); - gbproxy_delete_link_info(peer, link_info); + gbproxy_delete_link_info(bvc, link_info); rc = 1; } } else if (parse_ctx->to_bss && parse_ctx->tlli_enc && @@ -727,18 +727,18 @@ int gbproxy_update_link_state_after( new_sgsn_tlli = gprs_tmsi2tlli(new_sgsn_ptmsi, TLLI_LOCAL); if (new_bss_ptmsi != GSM_RESERVED_TMSI) new_bss_tlli = gprs_tmsi2tlli(new_bss_ptmsi, TLLI_LOCAL); - LOGPBVC(peer, LOGL_INFO, + LOGPBVC(bvc, LOGL_INFO, "Assigning new TLLI %08x to SGSN, %08x to BSS\n", new_sgsn_tlli, new_bss_tlli); gbproxy_reassign_tlli(&link_info->sgsn_tlli, - peer, new_sgsn_tlli); + bvc, new_sgsn_tlli); gbproxy_reassign_tlli(&link_info->tlli, - peer, new_bss_tlli); - gbproxy_remove_matching_link_infos(peer, link_info); + bvc, new_bss_tlli); + gbproxy_remove_matching_link_infos(bvc, link_info); } - gbproxy_remove_stale_link_infos(peer, now); + gbproxy_remove_stale_link_infos(bvc, now); return rc; } diff --git a/src/gbproxy/gb_proxy_vty.c b/src/gbproxy/gb_proxy_vty.c index bf1c4e0da..3ef8ccc9a 100644 --- a/src/gbproxy/gb_proxy_vty.c +++ b/src/gbproxy/gb_proxy_vty.c @@ -68,14 +68,14 @@ static const struct value_string match_ids[] = { {0, NULL} }; -static void gbprox_vty_print_peer(struct vty *vty, struct gbproxy_peer *peer) +static void gbprox_vty_print_bvc(struct vty *vty, struct gbproxy_bvc *bvc) { struct gprs_ra_id raid; - gsm48_parse_ra(&raid, peer->ra); + gsm48_parse_ra(&raid, bvc->ra); vty_out(vty, "NSEI %5u, PTP-BVCI %5u, " - "RAI %s", peer->nse->nsei, peer->bvci, osmo_rai_name(&raid)); - if (peer->blocked) + "RAI %s", bvc->nse->nsei, bvc->bvci, osmo_rai_name(&raid)); + if (bvc->blocked) vty_out(vty, " [BVC-BLOCKED]"); vty_out(vty, "%s", VTY_NEWLINE); @@ -426,12 +426,12 @@ DEFUN(cfg_gbproxy_link_list_clean_stale_timer, /* Re-schedule running timers soon in case prev frequency was really big and new frequency is desired to be lower. After initial run, periodic - time is used. Use random() to avoid firing timers for all peers at + time is used. Use random() to avoid firing timers for all bvcs at the same time */ - llist_for_each_entry(nse, &g_cfg->nse_peers, list) { - struct gbproxy_peer *peer; - llist_for_each_entry(peer, &nse->bts_peers, list) - osmo_timer_schedule(&peer->clean_stale_timer, + llist_for_each_entry(nse, &g_cfg->nses, list) { + struct gbproxy_bvc *bvc; + llist_for_each_entry(bvc, &nse->bvcs, list) + osmo_timer_schedule(&bvc->clean_stale_timer, random() % 5, random() % 1000000); } @@ -447,10 +447,10 @@ DEFUN(cfg_gbproxy_link_list_no_clean_stale_timer, struct gbproxy_nse *nse; g_cfg->clean_stale_timer_freq = 0; - llist_for_each_entry(nse, &g_cfg->nse_peers, list) { - struct gbproxy_peer *peer; - llist_for_each_entry(peer, &nse->bts_peers, list) - osmo_timer_del(&peer->clean_stale_timer); + llist_for_each_entry(nse, &g_cfg->nses, list) { + struct gbproxy_bvc *bvc; + llist_for_each_entry(bvc, &nse->bvcs, list) + osmo_timer_del(&bvc->clean_stale_timer); } return CMD_SUCCESS; @@ -584,13 +584,13 @@ DEFUN(show_gbproxy, show_gbproxy_cmd, "show gbproxy [stats]", if (show_stats) vty_out_rate_ctr_group(vty, "", g_cfg->ctrg); - llist_for_each_entry(nse, &g_cfg->nse_peers, list) { - struct gbproxy_peer *peer; - llist_for_each_entry(peer, &nse->bts_peers, list) { - gbprox_vty_print_peer(vty, peer); + llist_for_each_entry(nse, &g_cfg->nses, list) { + struct gbproxy_bvc *bvc; + llist_for_each_entry(bvc, &nse->bvcs, list) { + gbprox_vty_print_bvc(vty, bvc); if (show_stats) - vty_out_rate_ctr_group(vty, " ", peer->ctrg); + vty_out_rate_ctr_group(vty, " ", bvc->ctrg); } } return CMD_SUCCESS; @@ -606,13 +606,13 @@ DEFUN(show_gbproxy_links, show_gbproxy_links_cmd, "show gbproxy links", osmo_clock_gettime(CLOCK_MONOTONIC, &ts); now = ts.tv_sec; - llist_for_each_entry(nse, &g_cfg->nse_peers, list) { - struct gbproxy_peer *peer; - llist_for_each_entry(peer, &nse->bts_peers, list) { + llist_for_each_entry(nse, &g_cfg->nses, list) { + struct gbproxy_bvc *bvc; + llist_for_each_entry(bvc, &nse->bvcs, list) { struct gbproxy_link_info *link_info; - struct gbproxy_patch_state *state = &peer->patch_state; + struct gbproxy_patch_state *state = &bvc->patch_state; - gbprox_vty_print_peer(vty, peer); + gbprox_vty_print_bvc(vty, bvc); llist_for_each_entry(link_info, &state->logical_links, list) { time_t age = now - link_info->timestamp; @@ -652,16 +652,16 @@ DEFUN(show_gbproxy_links, show_gbproxy_links_cmd, "show gbproxy links", DEFUN(delete_gb_bvci, delete_gb_bvci_cmd, "delete-gbproxy-peer <0-65534> bvci <2-65534>", - "Delete a GBProxy peer by NSEI and optionally BVCI\n" + "Delete a GBProxy bvc by NSEI and optionally BVCI\n" "NSEI number\n" - "Only delete peer with a matching BVCI\n" + "Only delete bvc with a matching BVCI\n" "BVCI number\n") { const uint16_t nsei = atoi(argv[0]); const uint16_t bvci = atoi(argv[1]); int counter; - counter = gbproxy_cleanup_peers(g_cfg, nsei, bvci); + counter = gbproxy_cleanup_bvcs(g_cfg, nsei, bvci); if (counter == 0) { vty_out(vty, "BVC not found%s", VTY_NEWLINE); @@ -673,7 +673,7 @@ DEFUN(delete_gb_bvci, delete_gb_bvci_cmd, DEFUN(delete_gb_nsei, delete_gb_nsei_cmd, "delete-gbproxy-peer <0-65534> (only-bvc|only-nsvc|all) [dry-run]", - "Delete a GBProxy peer by NSEI and optionally BVCI\n" + "Delete a GBProxy bvc by NSEI and optionally BVCI\n" "NSEI number\n" "Only delete BSSGP connections (BVC)\n" "Only delete dynamic NS connections (NS-VC)\n" @@ -698,18 +698,18 @@ DEFUN(delete_gb_nsei, delete_gb_nsei_cmd, if (delete_bvc) { if (!dry_run) { struct gbproxy_nse *nse = gbproxy_nse_by_nsei(g_cfg, nsei); - counter = gbproxy_cleanup_peers(g_cfg, nsei, 0); + counter = gbproxy_cleanup_bvcs(g_cfg, nsei, 0); gbproxy_nse_free(nse); } else { struct gbproxy_nse *nse; - struct gbproxy_peer *peer; + struct gbproxy_bvc *bvc; counter = 0; - llist_for_each_entry(nse, &g_cfg->nse_peers, list) { + llist_for_each_entry(nse, &g_cfg->nses, list) { if (nse->nsei != nsei) continue; - llist_for_each_entry(peer, &nse->bts_peers, list) { + llist_for_each_entry(bvc, &nse->bvcs, list) { vty_out(vty, "BVC: "); - gbprox_vty_print_peer(vty, peer); + gbprox_vty_print_bvc(vty, bvc); counter += 1; } } @@ -754,7 +754,7 @@ DEFUN(delete_gb_link_by_id, delete_gb_link_by_id_cmd, enum {MATCH_TLLI = 't', MATCH_IMSI = 'i', MATCH_SGSN = 's'} match; uint32_t ident = 0; const char *imsi = NULL; - struct gbproxy_peer *peer = 0; + struct gbproxy_bvc *bvc = 0; struct gbproxy_link_info *link_info, *nxt; struct gbproxy_patch_state *state; int found = 0; @@ -767,14 +767,14 @@ DEFUN(delete_gb_link_by_id, delete_gb_link_by_id_cmd, case MATCH_SGSN: ident = strtoll(argv[2], NULL, 0); break; }; - peer = gbproxy_peer_by_nsei(g_cfg, nsei); - if (!peer) { - vty_out(vty, "Didn't find peer with NSEI %d%s", + bvc = gbproxy_bvc_by_nsei(g_cfg, nsei); + if (!bvc) { + vty_out(vty, "Didn't find bvc with NSEI %d%s", nsei, VTY_NEWLINE); return CMD_WARNING; } - state = &peer->patch_state; + state = &bvc->patch_state; llist_for_each_entry_safe(link_info, nxt, &state->logical_links, list) { struct osmo_mobile_identity mi; @@ -801,7 +801,7 @@ DEFUN(delete_gb_link_by_id, delete_gb_link_by_id_cmd, vty_out(vty, "Deleting link with TLLI %08x%s", link_info->tlli.current, VTY_NEWLINE); - gbproxy_delete_link_info(peer, link_info); + gbproxy_delete_link_info(bvc, link_info); found += 1; } @@ -821,7 +821,7 @@ DEFUN(delete_gb_link, delete_gb_link_cmd, { const uint16_t nsei = atoi(argv[0]); enum {MATCH_STALE = 's', MATCH_DEREGISTERED = 'd'} match; - struct gbproxy_peer *peer = 0; + struct gbproxy_bvc *bvc = 0; struct gbproxy_link_info *link_info, *nxt; struct gbproxy_patch_state *state; time_t now; @@ -831,20 +831,20 @@ DEFUN(delete_gb_link, delete_gb_link_cmd, match = argv[1][0]; - peer = gbproxy_peer_by_nsei(g_cfg, nsei); - if (!peer) { - vty_out(vty, "Didn't find peer with NSEI %d%s", + bvc = gbproxy_bvc_by_nsei(g_cfg, nsei); + if (!bvc) { + vty_out(vty, "Didn't find bvc with NSEI %d%s", nsei, VTY_NEWLINE); return CMD_WARNING; } - state = &peer->patch_state; + state = &bvc->patch_state; osmo_clock_gettime(CLOCK_MONOTONIC, &ts); now = ts.tv_sec; if (match == MATCH_STALE) { - found = gbproxy_remove_stale_link_infos(peer, now); + found = gbproxy_remove_stale_link_infos(bvc, now); if (found) vty_out(vty, "Deleted %d stale logical link%s%s", found, found == 1 ? "" : "s", VTY_NEWLINE); @@ -854,7 +854,7 @@ DEFUN(delete_gb_link, delete_gb_link_cmd, if (!link_info->is_deregistered) continue; - gbproxy_delete_link_info(peer, link_info); + gbproxy_delete_link_info(bvc, link_info); found += 1; } } diff --git a/tests/gbproxy/gbproxy_test.c b/tests/gbproxy/gbproxy_test.c index fec5914d8..873319ba5 100644 --- a/tests/gbproxy/gbproxy_test.c +++ b/tests/gbproxy/gbproxy_test.c @@ -129,9 +129,9 @@ static int dump_peers(FILE *stream, int indent, time_t now, return rc; - llist_for_each_entry(nse, &cfg->nse_peers, list) { - struct gbproxy_peer *peer; - llist_for_each_entry(peer, &nse->bts_peers, list) { + llist_for_each_entry(nse, &cfg->nses, list) { + struct gbproxy_bvc *peer; + llist_for_each_entry(peer, &nse->bvcs, list) { struct gbproxy_link_info *link_info; struct gbproxy_patch_state *state = &peer->patch_state; gsm48_parse_ra(&raid, peer->ra); @@ -1285,20 +1285,20 @@ static void test_gbproxy() send_ns_unitdata(nsi, NULL, SGSN_NSEI, 0x10ff, (uint8_t *)"", 0); /* Find peer */ - OSMO_ASSERT(gbproxy_peer_by_bvci(&gbcfg, 0xeeee) == NULL); - OSMO_ASSERT(gbproxy_peer_by_bvci(&gbcfg, 0x1000) == NULL); - OSMO_ASSERT(gbproxy_peer_by_bvci(&gbcfg, 0x1012) != NULL); - OSMO_ASSERT(gbproxy_peer_by_nsei(&gbcfg, 0xeeee) == NULL); - OSMO_ASSERT(gbproxy_peer_by_nsei(&gbcfg, 0x1012) == NULL); - OSMO_ASSERT(gbproxy_peer_by_nsei(&gbcfg, 0x1000) != NULL); + OSMO_ASSERT(gbproxy_bvc_by_bvci(&gbcfg, 0xeeee) == NULL); + OSMO_ASSERT(gbproxy_bvc_by_bvci(&gbcfg, 0x1000) == NULL); + OSMO_ASSERT(gbproxy_bvc_by_bvci(&gbcfg, 0x1012) != NULL); + OSMO_ASSERT(gbproxy_bvc_by_nsei(&gbcfg, 0xeeee) == NULL); + OSMO_ASSERT(gbproxy_bvc_by_nsei(&gbcfg, 0x1012) == NULL); + OSMO_ASSERT(gbproxy_bvc_by_nsei(&gbcfg, 0x1000) != NULL); /* Cleanup */ - OSMO_ASSERT(gbproxy_cleanup_peers(&gbcfg, 0, 0) == 0); - OSMO_ASSERT(gbproxy_cleanup_peers(&gbcfg, 0x1000, 0xeeee) == 0); - OSMO_ASSERT(gbproxy_cleanup_peers(&gbcfg, 0, 0x1002) == 0); - OSMO_ASSERT(gbproxy_cleanup_peers(&gbcfg, 0x1000, 0x1012) == 1); - OSMO_ASSERT(gbproxy_cleanup_peers(&gbcfg, 0x1000, 0x1012) == 0); + OSMO_ASSERT(gbproxy_cleanup_bvcs(&gbcfg, 0, 0) == 0); + OSMO_ASSERT(gbproxy_cleanup_bvcs(&gbcfg, 0x1000, 0xeeee) == 0); + OSMO_ASSERT(gbproxy_cleanup_bvcs(&gbcfg, 0, 0x1002) == 0); + OSMO_ASSERT(gbproxy_cleanup_bvcs(&gbcfg, 0x1000, 0x1012) == 1); + OSMO_ASSERT(gbproxy_cleanup_bvcs(&gbcfg, 0x1000, 0x1012) == 0); dump_peers(stdout, 0, 0, &gbcfg); @@ -1411,7 +1411,7 @@ static void test_gbproxy_ra_patching() const uint8_t imsi[] = {0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0xf8}; const char *patch_re = "^9898|^121314"; struct gbproxy_link_info *link_info; - struct gbproxy_peer *peer; + struct gbproxy_bvc *peer; LLIST_HEAD(rcv_list); struct expect_result *expect_res; @@ -1450,7 +1450,7 @@ static void test_gbproxy_ra_patching() setup_bssgp(nsi, bss_nsei[0], 0x1002); dump_peers(stdout, 0, 0, &gbcfg); - peer = gbproxy_peer_by_nsei(&gbcfg, 0x1000); + peer = gbproxy_bvc_by_nsei(&gbcfg, 0x1000); OSMO_ASSERT(peer != NULL); OSMO_ASSERT(expect_bssgp_msg(SGSN_NSEI, 0, BSSGP_PDUT_BVC_RESET)); @@ -1509,17 +1509,17 @@ static void test_gbproxy_ra_patching() OSMO_ASSERT(2 == peer->ctrg->ctr[GBPROX_PEER_CTR_RAID_PATCHED_SGSN].current); - OSMO_ASSERT(gbproxy_peer_by_rai(&gbcfg, convert_ra(&rai_bss)) != NULL); - OSMO_ASSERT(gbproxy_peer_by_rai(&gbcfg, convert_ra(&rai_sgsn)) == NULL); - OSMO_ASSERT(gbproxy_peer_by_rai(&gbcfg, convert_ra(&rai_unknown)) == NULL); + OSMO_ASSERT(gbproxy_bvc_by_rai(&gbcfg, convert_ra(&rai_bss)) != NULL); + OSMO_ASSERT(gbproxy_bvc_by_rai(&gbcfg, convert_ra(&rai_sgsn)) == NULL); + OSMO_ASSERT(gbproxy_bvc_by_rai(&gbcfg, convert_ra(&rai_unknown)) == NULL); - OSMO_ASSERT(gbproxy_peer_by_lai(&gbcfg, convert_ra(&rai_bss)) != NULL); - OSMO_ASSERT(gbproxy_peer_by_lai(&gbcfg, convert_ra(&rai_sgsn)) == NULL); - OSMO_ASSERT(gbproxy_peer_by_lai(&gbcfg, convert_ra(&rai_unknown)) == NULL); + OSMO_ASSERT(gbproxy_bvc_by_lai(&gbcfg, convert_ra(&rai_bss)) != NULL); + OSMO_ASSERT(gbproxy_bvc_by_lai(&gbcfg, convert_ra(&rai_sgsn)) == NULL); + OSMO_ASSERT(gbproxy_bvc_by_lai(&gbcfg, convert_ra(&rai_unknown)) == NULL); - OSMO_ASSERT(gbproxy_peer_by_lac(&gbcfg, convert_ra(&rai_bss)) != NULL); - OSMO_ASSERT(gbproxy_peer_by_lac(&gbcfg, convert_ra(&rai_sgsn)) != NULL); - OSMO_ASSERT(gbproxy_peer_by_lac(&gbcfg, convert_ra(&rai_unknown)) == NULL); + OSMO_ASSERT(gbproxy_bvc_by_lac(&gbcfg, convert_ra(&rai_bss)) != NULL); + OSMO_ASSERT(gbproxy_bvc_by_lac(&gbcfg, convert_ra(&rai_sgsn)) != NULL); + OSMO_ASSERT(gbproxy_bvc_by_lac(&gbcfg, convert_ra(&rai_unknown)) == NULL); link_info = gbproxy_link_info_by_sgsn_tlli(peer, local_tlli, SGSN_NSEI); OSMO_ASSERT(link_info); @@ -1750,7 +1750,7 @@ static void test_gbproxy_ptmsi_assignment() const uint8_t imsi2[] = {0x11, 0x12, 0x99, 0x99, 0x99, 0x16, 0x17, 0xf8}; struct gbproxy_link_info *link_info, *link_info2; - struct gbproxy_peer *peer; + struct gbproxy_bvc *peer; unsigned bss_nu = 0; unsigned sgsn_nu = 0; @@ -1777,7 +1777,7 @@ static void test_gbproxy_ptmsi_assignment() setup_ns(nsi, bss_nsei[0]); setup_bssgp(nsi, bss_nsei[0], 0x1002); - peer = gbproxy_peer_by_nsei(&gbcfg, 0x1000); + peer = gbproxy_bvc_by_nsei(&gbcfg, 0x1000); OSMO_ASSERT(peer != NULL); send_bssgp_reset_ack(nsi, SGSN_NSEI, 0x1002); @@ -1977,7 +1977,7 @@ static void test_gbproxy_ptmsi_patching() const uint8_t imsi[] = {0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0xf8}; struct gbproxy_link_info *link_info; - struct gbproxy_peer *peer; + struct gbproxy_bvc *peer; unsigned bss_nu = 0; unsigned sgsn_nu = 0; int old_ctr; @@ -2010,7 +2010,7 @@ static void test_gbproxy_ptmsi_patching() setup_ns(nsi, bss_nsei[0]); setup_bssgp(nsi, bss_nsei[0], 0x1002); - peer = gbproxy_peer_by_nsei(&gbcfg, 0x1000); + peer = gbproxy_bvc_by_nsei(&gbcfg, 0x1000); OSMO_ASSERT(peer != NULL); send_bssgp_reset_ack(nsi, SGSN_NSEI, 0x1002); @@ -2300,7 +2300,7 @@ static void test_gbproxy_ptmsi_patching_bad_cases() const uint8_t imsi[] = {0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0xf8}; struct gbproxy_link_info *link_info; - struct gbproxy_peer *peer; + struct gbproxy_bvc *peer; unsigned bss_nu = 0; unsigned sgsn_nu = 0; uint16_t bss_nsei[] = { 0x1000 }; @@ -2327,7 +2327,7 @@ static void test_gbproxy_ptmsi_patching_bad_cases() setup_ns(nsi, bss_nsei[0]); setup_bssgp(nsi, bss_nsei[0], 0x1002); - peer = gbproxy_peer_by_nsei(&gbcfg, 0x1000); + peer = gbproxy_bvc_by_nsei(&gbcfg, 0x1000); OSMO_ASSERT(peer != NULL); send_bssgp_reset_ack(nsi, SGSN_NSEI, 0x1002); @@ -2483,7 +2483,7 @@ static void test_gbproxy_imsi_acquisition() const uint8_t imsi[] = {0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0xf8}; struct gbproxy_link_info *link_info; - struct gbproxy_peer *peer; + struct gbproxy_bvc *peer; unsigned bss_nu = 0; unsigned sgsn_nu = 0; uint16_t bss_nsei[] = { 0x1000 }; @@ -2510,7 +2510,7 @@ static void test_gbproxy_imsi_acquisition() setup_ns(nsi, bss_nsei[0]); setup_bssgp(nsi, bss_nsei[0], 0x1002); - peer = gbproxy_peer_by_nsei(&gbcfg, 0x1000); + peer = gbproxy_bvc_by_nsei(&gbcfg, 0x1000); OSMO_ASSERT(peer != NULL); send_bssgp_reset_ack(nsi, SGSN_NSEI, 0x1002); @@ -2803,7 +2803,7 @@ static void test_gbproxy_secondary_sgsn() const uint8_t imsi3[] = {0x11, 0x12, 0x99, 0x99, 0x99, 0x26, 0x27, 0xf8}; struct gbproxy_link_info *link_info; struct gbproxy_link_info *other_info; - struct gbproxy_peer *peer; + struct gbproxy_bvc *peer; unsigned bss_nu = 0; unsigned sgsn_nu = 0; @@ -2852,7 +2852,7 @@ static void test_gbproxy_secondary_sgsn() send_bssgp_reset_ack(nsi, SGSN_NSEI, 0x1002); send_bssgp_reset_ack(nsi, SGSN2_NSEI, 0x1002); - peer = gbproxy_peer_by_nsei(&gbcfg, 0x1000); + peer = gbproxy_bvc_by_nsei(&gbcfg, 0x1000); OSMO_ASSERT(peer != NULL); dump_global(stdout, 0); @@ -3279,7 +3279,7 @@ static void test_gbproxy_keep_info() const uint8_t imsi[] = {0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0xf8}; struct gbproxy_link_info *link_info, *link_info2; - struct gbproxy_peer *peer; + struct gbproxy_bvc *peer; unsigned bss_nu = 0; unsigned sgsn_nu = 0; uint16_t bss_nsei[] = { 0x1000 }; @@ -3311,7 +3311,7 @@ static void test_gbproxy_keep_info() setup_ns(nsi, bss_nsei[0]); setup_bssgp(nsi, bss_nsei[0], 0x1002); - peer = gbproxy_peer_by_nsei(&gbcfg, 0x1000); + peer = gbproxy_bvc_by_nsei(&gbcfg, 0x1000); OSMO_ASSERT(peer != NULL); send_bssgp_reset_ack(nsi, SGSN_NSEI, 0x1002); @@ -4208,7 +4208,7 @@ static void test_gbproxy_keep_info() } struct gbproxy_link_info *register_tlli( - struct gbproxy_peer *peer, uint32_t tlli, + struct gbproxy_bvc *peer, uint32_t tlli, const uint8_t *imsi, size_t imsi_len, time_t now) { struct gbproxy_link_info *link_info; @@ -4264,7 +4264,7 @@ static void test_gbproxy_tlli_expire(void) { struct gbproxy_config cfg = {0}; struct gbproxy_nse *nse; - struct gbproxy_peer *peer; + struct gbproxy_bvc *peer; const char *err_msg = NULL; const uint8_t imsi1[] = { GSM_MI_TYPE_IMSI, 0x23, 0x24, 0x25, 0xf6 }; const uint8_t imsi2[] = { GSM_MI_TYPE_IMSI, 0x26, 0x27, 0x28, 0xf9 }; @@ -4294,7 +4294,7 @@ static void test_gbproxy_tlli_expire(void) cfg.tlli_max_len = 0; cfg.tlli_max_age = 0; - peer = gbproxy_peer_alloc(nse, 20); + peer = gbproxy_bvc_alloc(nse, 20); OSMO_ASSERT(peer->patch_state.logical_link_count == 0); printf(" Add TLLI 1, IMSI 1\n"); @@ -4323,7 +4323,7 @@ static void test_gbproxy_tlli_expire(void) printf("\n"); - gbproxy_peer_free(peer); + gbproxy_bvc_free(peer); } { @@ -4333,7 +4333,7 @@ static void test_gbproxy_tlli_expire(void) cfg.tlli_max_len = 0; cfg.tlli_max_age = 0; - peer = gbproxy_peer_alloc(nse, 20); + peer = gbproxy_bvc_alloc(nse, 20); OSMO_ASSERT(peer->patch_state.logical_link_count == 0); printf(" Add TLLI 1, IMSI 1\n"); @@ -4362,7 +4362,7 @@ static void test_gbproxy_tlli_expire(void) printf("\n"); - gbproxy_peer_free(peer); + gbproxy_bvc_free(peer); } { @@ -4373,7 +4373,7 @@ static void test_gbproxy_tlli_expire(void) cfg.tlli_max_len = 1; cfg.tlli_max_age = 0; - peer = gbproxy_peer_alloc(nse, 20); + peer = gbproxy_bvc_alloc(nse, 20); OSMO_ASSERT(peer->patch_state.logical_link_count == 0); printf(" Add TLLI 1, IMSI 1\n"); @@ -4400,7 +4400,7 @@ static void test_gbproxy_tlli_expire(void) printf("\n"); - gbproxy_peer_free(peer); + gbproxy_bvc_free(peer); } { @@ -4411,7 +4411,7 @@ static void test_gbproxy_tlli_expire(void) cfg.tlli_max_len = 0; cfg.tlli_max_age = 1; - peer = gbproxy_peer_alloc(nse, 20); + peer = gbproxy_bvc_alloc(nse, 20); OSMO_ASSERT(peer->patch_state.logical_link_count == 0); printf(" Add TLLI 1, IMSI 1 (should expire after timeout)\n"); @@ -4438,7 +4438,7 @@ static void test_gbproxy_tlli_expire(void) printf("\n"); - gbproxy_peer_free(peer); + gbproxy_bvc_free(peer); } { @@ -4449,7 +4449,7 @@ static void test_gbproxy_tlli_expire(void) cfg.tlli_max_len = 0; cfg.tlli_max_age = 1; - peer = gbproxy_peer_alloc(nse, 20); + peer = gbproxy_bvc_alloc(nse, 20); OSMO_ASSERT(peer->patch_state.logical_link_count == 0); printf(" Add TLLI 1, IMSI 1 (should expire)\n"); @@ -4486,7 +4486,7 @@ static void test_gbproxy_tlli_expire(void) printf("\n"); - gbproxy_peer_free(peer); + gbproxy_bvc_free(peer); } gbproxy_clear_patch_filter(&cfg.matches[GBPROX_MATCH_PATCHING]); gbprox_reset(&cfg); @@ -4583,7 +4583,7 @@ static void test_gbproxy_stored_messages() const uint32_t foreign_tlli1 = 0x8000dead; - struct gbproxy_peer *peer; + struct gbproxy_bvc *peer; unsigned bss_nu = 0; unsigned sgsn_nu = 0; uint16_t bss_nsei[] = { 0x1000 }; @@ -4611,7 +4611,7 @@ static void test_gbproxy_stored_messages() setup_ns(nsi, bss_nsei[0]); setup_bssgp(nsi, bss_nsei[0], 0x1002); - peer = gbproxy_peer_by_nsei(&gbcfg, 0x1000); + peer = gbproxy_bvc_by_nsei(&gbcfg, 0x1000); OSMO_ASSERT(peer != NULL); send_bssgp_reset_ack(nsi, SGSN_NSEI, 0x1002); -- cgit v1.2.3