neels has submitted this change. ( https://gerrit.osmocom.org/c/osmo-hnbgw/+/32618 )
Change subject: simplify: one g_hnbgw as global state and root ctx ......................................................................
simplify: one g_hnbgw as global state and root ctx
So far we jump through hoops everywhere to pass around osmo-hnbgw's global singleton state to all code paths. Some files choose to spawn a static "global" pointer. And we also have the talloc root tall_hnb_ctx.
Simplify: - Have a single global g_hnbgw pointer. Drop all function args and backpointers to the global state. - Use that global g_hnbgw as talloc root context, instead of passing a separate tall_hnb_ctx around.
(Cosmetic preparation for separate osmo_hnbgw_main.c file)
Change-Id: I3d54a5bb30c16a990c6def2a0ed207f60a95ef5d --- M include/osmocom/hnbgw/context_map.h M include/osmocom/hnbgw/hnbgw.h M include/osmocom/hnbgw/hnbgw_cn.h M include/osmocom/hnbgw/hnbgw_pfcp.h M include/osmocom/hnbgw/ps_rab_fsm.h M src/osmo-hnbgw/context_map.c M src/osmo-hnbgw/context_map_rua.c M src/osmo-hnbgw/context_map_sccp.c M src/osmo-hnbgw/hnbgw.c M src/osmo-hnbgw/hnbgw_cn.c M src/osmo-hnbgw/hnbgw_hnbap.c M src/osmo-hnbgw/hnbgw_pfcp.c M src/osmo-hnbgw/hnbgw_rua.c M src/osmo-hnbgw/hnbgw_vty.c M src/osmo-hnbgw/mgw_fsm.c M src/osmo-hnbgw/ps_rab_ass_fsm.c M src/osmo-hnbgw/ps_rab_fsm.c 17 files changed, 234 insertions(+), 255 deletions(-)
Approvals: Jenkins Builder: Verified neels: Looks good to me, but someone else must approve fixeria: Looks good to me, approved
diff --git a/include/osmocom/hnbgw/context_map.h b/include/osmocom/hnbgw/context_map.h index b64358a..2b60958 100644 --- a/include/osmocom/hnbgw/context_map.h +++ b/include/osmocom/hnbgw/context_map.h @@ -77,9 +77,6 @@ * must not be used. */ struct llist_head hnb_list;
- /* Backpointer to global hnb_gw. */ - struct hnb_gw *gw; - /* Pointer to HNB for this map, to transceive RUA. If the HNB has disconnected without releasing the RUA * context, this is NULL. */ struct hnb_context *hnb_ctx; diff --git a/include/osmocom/hnbgw/hnbgw.h b/include/osmocom/hnbgw/hnbgw.h index 1d46cda..954a356 100644 --- a/include/osmocom/hnbgw/hnbgw.h +++ b/include/osmocom/hnbgw/hnbgw.h @@ -58,8 +58,6 @@ uint32_t cid; /*!< Cell ID */ };
-struct hnb_gw; - enum hnbgw_cnlink_state { /* we have just been initialized or were disconnected */ CNLINK_S_NULL, @@ -76,7 +74,6 @@ struct hnbgw_cnlink { struct llist_head list; enum hnbgw_cnlink_state state; - struct hnb_gw *gw; /* timer for re-transmitting the RANAP Reset */ struct osmo_timer_list T_RafC; /* reference to the SCCP User SAP by which we communicate */ @@ -92,8 +89,6 @@ struct hnb_context { /*! Entry in HNB-global list of HNB */ struct llist_head list; - /*! HNB-GW we are part of */ - struct hnb_gw *gw; /*! SCTP socket + write queue for Iuh to this specific HNB */ struct osmo_stream_srv *conn; /*! copied from HNB-Identity-Info IE */ @@ -124,7 +119,7 @@ struct hnb_context *hnb; };
-struct hnb_gw { +struct hnbgw { struct { const char *iuh_local_ip; /*! SCTP port for Iuh listening */ @@ -173,24 +168,25 @@ } pfcp; };
+extern struct hnbgw *g_hnbgw; extern void *talloc_asn1_ctx;
-struct hnb_context *hnb_context_by_id(struct hnb_gw *gw, uint32_t cid); -struct hnb_context *hnb_context_by_identity_info(struct hnb_gw *gw, const char *identity_info); +struct hnb_context *hnb_context_by_id(uint32_t cid); +struct hnb_context *hnb_context_by_identity_info(const char *identity_info); const char *hnb_context_name(struct hnb_context *ctx);
-struct ue_context *ue_context_by_id(struct hnb_gw *gw, uint32_t id); -struct ue_context *ue_context_by_imsi(struct hnb_gw *gw, const char *imsi); -struct ue_context *ue_context_by_tmsi(struct hnb_gw *gw, uint32_t tmsi); +struct ue_context *ue_context_by_id(uint32_t id); +struct ue_context *ue_context_by_imsi(const char *imsi); +struct ue_context *ue_context_by_tmsi(uint32_t tmsi); struct ue_context *ue_context_alloc(struct hnb_context *hnb, const char *imsi, uint32_t tmsi); void ue_context_free(struct ue_context *ue);
-struct hnb_context *hnb_context_alloc(struct hnb_gw *gw, struct osmo_stream_srv_link *link, int new_fd); +struct hnb_context *hnb_context_alloc(struct osmo_stream_srv_link *link, int new_fd); void hnb_context_release(struct hnb_context *ctx); void hnb_context_release_ue_state(struct hnb_context *ctx);
-void hnbgw_vty_init(struct hnb_gw *gw, void *tall_ctx); +void hnbgw_vty_init(void); int hnbgw_vty_go_parent(struct vty *vty);
/* Return true when the user configured GTP mapping to be enabled, by configuring a PFCP link to a UPF. @@ -198,9 +194,9 @@ * 1:1. * GTP mapping means that there are two GTP tunnels, one towards HNB and one towards CN, and we forward payloads between * the two tunnels, mapping the TEIDs and GTP addresses. */ -static inline bool hnb_gw_is_gtp_mapping_enabled(const struct hnb_gw *gw) +static inline bool hnb_gw_is_gtp_mapping_enabled(void) { - return gw->config.pfcp.remote_addr != NULL; + return g_hnbgw->config.pfcp.remote_addr != NULL; }
struct msgb *hnbgw_ranap_msg_alloc(const char *name); diff --git a/include/osmocom/hnbgw/hnbgw_cn.h b/include/osmocom/hnbgw/hnbgw_cn.h index 0df2716..5711c5e 100644 --- a/include/osmocom/hnbgw/hnbgw_cn.h +++ b/include/osmocom/hnbgw/hnbgw_cn.h @@ -2,6 +2,6 @@
#include <osmocom/hnbgw/hnbgw.h>
-int hnbgw_cnlink_init(struct hnb_gw *gw, const char *stp_host, uint16_t stp_port, const char *local_ip); +int hnbgw_cnlink_init(const char *stp_host, uint16_t stp_port, const char *local_ip);
-const struct osmo_sccp_addr *hnbgw_cn_get_remote_addr(struct hnb_gw *gw, bool is_ps); +const struct osmo_sccp_addr *hnbgw_cn_get_remote_addr(bool is_ps); diff --git a/include/osmocom/hnbgw/hnbgw_pfcp.h b/include/osmocom/hnbgw/hnbgw_pfcp.h index f3f5bb4..585d3f7 100644 --- a/include/osmocom/hnbgw/hnbgw_pfcp.h +++ b/include/osmocom/hnbgw/hnbgw_pfcp.h @@ -1,5 +1,3 @@ #pragma once
-struct hnb_gw; - -int hnbgw_pfcp_init(struct hnb_gw *hnb_gw); +int hnbgw_pfcp_init(void); diff --git a/include/osmocom/hnbgw/ps_rab_fsm.h b/include/osmocom/hnbgw/ps_rab_fsm.h index e52c2ca..e8dddbe 100644 --- a/include/osmocom/hnbgw/ps_rab_fsm.h +++ b/include/osmocom/hnbgw/ps_rab_fsm.h @@ -49,9 +49,6 @@ /* Instance of ps_rab_fsm. */ struct osmo_fsm_inst *fi;
- /* backpointer */ - struct hnb_gw *hnb_gw; - /* List entry and backpointer. * If map == NULL, do not call llist_del(&entry): the hnbgw_context_map may deallocate before the PFCP release * is complete, in which case it sets map = NULL. */ @@ -98,5 +95,5 @@ int ps_rab_rx_access_remote_f_teid(struct hnbgw_context_map *map, uint8_t rab_id, const struct ps_rab_rx_args *args);
-struct ps_rab *ps_rab_find_by_seid(struct hnb_gw *hnb_gw, uint64_t seid, bool is_cp_seid); +struct ps_rab *ps_rab_find_by_seid(uint64_t seid, bool is_cp_seid); void ps_rab_pfcp_set_msg_ctx(struct ps_rab *rab, struct osmo_pfcp_msg *m); diff --git a/src/osmo-hnbgw/context_map.c b/src/osmo-hnbgw/context_map.c index 31f635d..c9507be 100644 --- a/src/osmo-hnbgw/context_map.c +++ b/src/osmo-hnbgw/context_map.c @@ -128,7 +128,6 @@
/* allocate a new map entry. */ map = talloc_zero(hnb, struct hnbgw_context_map); - map->gw = hnb->gw; map->cn_link = cn_if_new; map->hnb_ctx = hnb; map->rua_ctx_id = rua_ctx_id; @@ -208,7 +207,7 @@ * We could also always allocate hnbgw_context_map under hnb_gw, but it is nice to see which hnb_context owns * which hnbgw_context_map in a talloc report. */ - talloc_steal(map->gw, map); + talloc_steal(g_hnbgw, map);
/* Tell RUA that the HNB is gone. SCCP release will follow via FSM events. */ map_rua_dispatch(map, MAP_RUA_EV_HNB_LINK_LOST, NULL); diff --git a/src/osmo-hnbgw/context_map_rua.c b/src/osmo-hnbgw/context_map_rua.c index 12a428b..f5537f3 100644 --- a/src/osmo-hnbgw/context_map_rua.c +++ b/src/osmo-hnbgw/context_map_rua.c @@ -154,7 +154,7 @@ } } #if ENABLE_PFCP - } else if (hnb_gw_is_gtp_mapping_enabled(map->gw)) { + } else if (hnb_gw_is_gtp_mapping_enabled()) { /* map->is_ps == true and PFCP is enabled in osmo-hnbgw.cfg */ ranap_message *message = talloc_zero(OTC_SELECT, ranap_message); rc = ranap_cn_rx_co_decode2(message, msgb_l2(ranap_msg), msgb_l2len(ranap_msg)); diff --git a/src/osmo-hnbgw/context_map_sccp.c b/src/osmo-hnbgw/context_map_sccp.c index 65939f3..47297e7 100644 --- a/src/osmo-hnbgw/context_map_sccp.c +++ b/src/osmo-hnbgw/context_map_sccp.c @@ -130,8 +130,8 @@
prim = (struct osmo_scu_prim *)msgb_push(ranap_msg, sizeof(*prim)); osmo_prim_init(&prim->oph, SCCP_SAP_USER, OSMO_SCU_PRIM_N_CONNECT, PRIM_OP_REQUEST, ranap_msg); - prim->u.connect.called_addr = *hnbgw_cn_get_remote_addr(map->gw, map->is_ps); - prim->u.connect.calling_addr = map->gw->sccp.local_addr; + prim->u.connect.called_addr = *hnbgw_cn_get_remote_addr(map->is_ps); + prim->u.connect.calling_addr = g_hnbgw->sccp.local_addr; prim->u.connect.sccp_class = 2; prim->u.connect.conn_id = map->scu_conn_id;
@@ -224,10 +224,10 @@ case RANAP_ProcedureCode_id_RAB_Assignment: /* If a UPF is configured, handle the RAB Assignment via ps_rab_ass_fsm, and replace the * GTP F-TEIDs in the RAB Assignment message before passing it on to RUA. */ - if (hnb_gw_is_gtp_mapping_enabled(map->gw)) { + if (hnb_gw_is_gtp_mapping_enabled()) { LOGP(DMAIN, LOGL_DEBUG, "RAB Assignment: setting up GTP tunnel mapping via UPF %s\n", - osmo_sockaddr_to_str_c(OTC_SELECT, &map->gw->pfcp.cp_peer->remote_addr)); + osmo_sockaddr_to_str_c(OTC_SELECT, &g_hnbgw->pfcp.cp_peer->remote_addr)); return hnbgw_gtpmap_rx_rab_ass_req(map, ranap_msg, message); } /* If no UPF is configured, directly forward the message as-is (no GTP mapping). */ diff --git a/src/osmo-hnbgw/hnbgw.c b/src/osmo-hnbgw/hnbgw.c index 8c6a293..bad7064 100644 --- a/src/osmo-hnbgw/hnbgw.c +++ b/src/osmo-hnbgw/hnbgw.c @@ -81,39 +81,36 @@ "This is free software: you are free to change and redistribute it.\r\n" "There is NO WARRANTY, to the extent permitted by law.\r\n";
-static void *tall_hnb_ctx; +struct hnbgw *g_hnbgw = NULL;
-static struct hnb_gw *g_hnb_gw; - -static struct hnb_gw *hnb_gw_create(void *ctx) +static void g_hnbgw_alloc(void *ctx) { - struct hnb_gw *gw = talloc_zero(ctx, struct hnb_gw); + OSMO_ASSERT(!g_hnbgw); + g_hnbgw = talloc_zero(ctx, struct hnbgw);
/* strdup so we can easily talloc_free in the VTY code */ - gw->config.iuh_local_ip = talloc_strdup(gw, HNBGW_LOCAL_IP_DEFAULT); - gw->config.iuh_local_port = IUH_DEFAULT_SCTP_PORT; - gw->config.log_prefix_hnb_id = true; + g_hnbgw->config.iuh_local_ip = talloc_strdup(g_hnbgw, HNBGW_LOCAL_IP_DEFAULT); + g_hnbgw->config.iuh_local_port = IUH_DEFAULT_SCTP_PORT; + g_hnbgw->config.log_prefix_hnb_id = true;
- gw->next_ue_ctx_id = 23; - INIT_LLIST_HEAD(&gw->hnb_list); - INIT_LLIST_HEAD(&gw->ue_list); + g_hnbgw->next_ue_ctx_id = 23; + INIT_LLIST_HEAD(&g_hnbgw->hnb_list); + INIT_LLIST_HEAD(&g_hnbgw->ue_list);
- gw->mgw_pool = mgcp_client_pool_alloc(gw); - gw->config.mgcp_client = talloc_zero(tall_hnb_ctx, struct mgcp_client_conf); - mgcp_client_conf_init(gw->config.mgcp_client); + g_hnbgw->mgw_pool = mgcp_client_pool_alloc(g_hnbgw); + g_hnbgw->config.mgcp_client = talloc_zero(g_hnbgw, struct mgcp_client_conf); + mgcp_client_conf_init(g_hnbgw->config.mgcp_client);
#if ENABLE_PFCP - gw->config.pfcp.remote_port = OSMO_PFCP_PORT; + g_hnbgw->config.pfcp.remote_port = OSMO_PFCP_PORT; #endif - - return gw; }
-struct hnb_context *hnb_context_by_id(struct hnb_gw *gw, uint32_t cid) +struct hnb_context *hnb_context_by_id(uint32_t cid) { struct hnb_context *hnb;
- llist_for_each_entry(hnb, &gw->hnb_list, list) { + llist_for_each_entry(hnb, &g_hnbgw->hnb_list, list) { if (hnb->id.cid == cid) return hnb; } @@ -121,11 +118,11 @@ return NULL; }
-struct hnb_context *hnb_context_by_identity_info(struct hnb_gw *gw, const char *identity_info) +struct hnb_context *hnb_context_by_identity_info(const char *identity_info) { struct hnb_context *hnb;
- llist_for_each_entry(hnb, &gw->hnb_list, list) { + llist_for_each_entry(hnb, &g_hnbgw->hnb_list, list) { if (strcmp(identity_info, hnb->identity_info) == 0) return hnb; } @@ -133,11 +130,11 @@ return NULL; }
-struct ue_context *ue_context_by_id(struct hnb_gw *gw, uint32_t id) +struct ue_context *ue_context_by_id(uint32_t id) { struct ue_context *ue;
- llist_for_each_entry(ue, &gw->ue_list, list) { + llist_for_each_entry(ue, &g_hnbgw->ue_list, list) { if (ue->context_id == id) return ue; } @@ -145,45 +142,45 @@
}
-struct ue_context *ue_context_by_imsi(struct hnb_gw *gw, const char *imsi) +struct ue_context *ue_context_by_imsi(const char *imsi) { struct ue_context *ue;
- llist_for_each_entry(ue, &gw->ue_list, list) { + llist_for_each_entry(ue, &g_hnbgw->ue_list, list) { if (!strcmp(ue->imsi, imsi)) return ue; } return NULL; }
-struct ue_context *ue_context_by_tmsi(struct hnb_gw *gw, uint32_t tmsi) +struct ue_context *ue_context_by_tmsi(uint32_t tmsi) { struct ue_context *ue;
- llist_for_each_entry(ue, &gw->ue_list, list) { + llist_for_each_entry(ue, &g_hnbgw->ue_list, list) { if (ue->tmsi == tmsi) return ue; } return NULL; }
-void ue_context_free_by_hnb(struct hnb_gw *gw, const struct hnb_context *hnb) +void ue_context_free_by_hnb(const struct hnb_context *hnb) { struct ue_context *ue, *tmp;
- llist_for_each_entry_safe(ue, tmp, &gw->ue_list, list) { + llist_for_each_entry_safe(ue, tmp, &g_hnbgw->ue_list, list) { if (ue->hnb == hnb) ue_context_free(ue); } }
-static uint32_t get_next_ue_ctx_id(struct hnb_gw *gw) +static uint32_t get_next_ue_ctx_id(void) { uint32_t id;
do { - id = gw->next_ue_ctx_id++; - } while (ue_context_by_id(gw, id)); + id = g_hnbgw->next_ue_ctx_id++; + } while (ue_context_by_id(id));
return id; } @@ -193,7 +190,7 @@ { struct ue_context *ue;
- ue = talloc_zero(tall_hnb_ctx, struct ue_context); + ue = talloc_zero(g_hnbgw, struct ue_context); if (!ue) return NULL;
@@ -203,8 +200,8 @@ else ue->imsi[0] = '\0'; ue->tmsi = tmsi; - ue->context_id = get_next_ue_ctx_id(hnb->gw); - llist_add_tail(&ue->list, &hnb->gw->ue_list); + ue->context_id = get_next_ue_ctx_id(); + llist_add_tail(&ue->list, &g_hnbgw->ue_list);
LOGP(DHNBAP, LOGL_INFO, "created UE context: id 0x%x, imsi %s, tmsi 0x%x\n", ue->context_id, imsi? imsi : "-", tmsi); @@ -337,24 +334,23 @@ return 0; }
-struct hnb_context *hnb_context_alloc(struct hnb_gw *gw, struct osmo_stream_srv_link *link, int new_fd) +struct hnb_context *hnb_context_alloc(struct osmo_stream_srv_link *link, int new_fd) { struct hnb_context *ctx;
- ctx = talloc_zero(tall_hnb_ctx, struct hnb_context); + ctx = talloc_zero(g_hnbgw, struct hnb_context); if (!ctx) return NULL; INIT_LLIST_HEAD(&ctx->map_list);
- ctx->gw = gw; - ctx->conn = osmo_stream_srv_create(tall_hnb_ctx, link, new_fd, hnb_read_cb, hnb_closed_cb, ctx); + ctx->conn = osmo_stream_srv_create(g_hnbgw, link, new_fd, hnb_read_cb, hnb_closed_cb, ctx); if (!ctx->conn) { LOGP(DMAIN, LOGL_INFO, "error while creating connection\n"); talloc_free(ctx); return NULL; }
- llist_add_tail(&ctx->list, &gw->hnb_list); + llist_add_tail(&ctx->list, &g_hnbgw->hnb_list); return ctx; }
@@ -371,7 +367,7 @@ if (!ctx) return "NULL";
- if (ctx->gw->config.log_prefix_hnb_id) + if (g_hnbgw->config.log_prefix_hnb_id) return ctx->identity_info; else return umts_cell_id_name(&ctx->id); @@ -386,7 +382,7 @@ context_map_hnb_released(map); /* hnbgw_context_map will remove itself from lists when it is ready. */ } - ue_context_free_by_hnb(ctx->gw, ctx); + ue_context_free_by_hnb(ctx); }
void hnb_context_release(struct hnb_context *ctx) @@ -422,13 +418,12 @@ /*! call-back when the listen FD has something to read */ static int accept_cb(struct osmo_stream_srv_link *srv, int fd) { - struct hnb_gw *gw = osmo_stream_srv_link_get_data(srv); struct hnb_context *ctx;
LOGP(DMAIN, LOGL_INFO, "New HNB SCTP connection %s\n", osmo_sock_get_name2(fd));
- ctx = hnb_context_alloc(gw, srv, fd); + ctx = hnb_context_alloc(srv, fd); if (!ctx) return -ENOMEM;
@@ -627,8 +622,7 @@ CTRL_CMD_DEFINE_RO(hnbs, "num-hnb"); static int get_hnbs(struct ctrl_cmd *cmd, void *data) { - struct hnb_gw *gw = data; - cmd->reply = talloc_asprintf(cmd, "%u", llist_count(&gw->hnb_list)); + cmd->reply = talloc_asprintf(cmd, "%u", llist_count(&g_hnbgw->hnb_list));
return CTRL_CMD_REPLY; } @@ -659,7 +653,7 @@ if (!ctrl_parse_get_num(vline, *i, &num)) return -ERANGE;
- hnb = hnb_context_by_id(data, num); + hnb = hnb_context_by_id(num); if (!hnb) return -ENODEV;
@@ -681,8 +675,8 @@ /* Initialize MGW pool. This initalizes and connects all MGCP clients that are currently configured in * the pool. Adding additional MGCP clients to the pool is possible but the user has to configure and * (re)connect them manually from the VTY. */ - if (!mgcp_client_pool_empty(g_hnb_gw->mgw_pool)) { - pool_members_initalized = mgcp_client_pool_connect(g_hnb_gw->mgw_pool); + if (!mgcp_client_pool_empty(g_hnbgw->mgw_pool)) { + pool_members_initalized = mgcp_client_pool_connect(g_hnbgw->mgw_pool); if (!pool_members_initalized) { LOGP(DMGW, LOGL_ERROR, "MGW pool failed to initialize any pool members\n"); return -EINVAL; @@ -696,18 +690,18 @@ /* Initialize and connect a single MGCP client. This MGCP client will appear as the one and only pool * member if there is no MGW pool configured. */ LOGP(DMGW, LOGL_NOTICE, "No MGW pool configured, using MGW configuration in VTY node 'mgcp'\n"); - mgcp_client_single = mgcp_client_init(tall_hnb_ctx, g_hnb_gw->config.mgcp_client); + mgcp_client_single = mgcp_client_init(g_hnbgw, g_hnbgw->config.mgcp_client); if (!mgcp_client_single) { LOGP(DMGW, LOGL_ERROR, "MGW (single) client initalization failed\n"); return -EINVAL; } if (mgcp_client_connect(mgcp_client_single)) { LOGP(DMGW, LOGL_ERROR, "MGW (single) connect failed at (%s:%u)\n", - g_hnb_gw->config.mgcp_client->remote_addr, - g_hnb_gw->config.mgcp_client->remote_port); + g_hnbgw->config.mgcp_client->remote_addr, + g_hnbgw->config.mgcp_client->remote_port); return -EINVAL; } - mgcp_client_pool_register_single(g_hnb_gw->mgw_pool, mgcp_client_single); + mgcp_client_pool_register_single(g_hnbgw->mgw_pool, mgcp_client_single);
return 0; } @@ -719,14 +713,14 @@
talloc_enable_null_tracking();
- tall_hnb_ctx = talloc_named_const(NULL, 0, "hnb_context"); - talloc_asn1_ctx = talloc_named_const(tall_hnb_ctx, 1, "asn1_context"); - msgb_talloc_ctx_init(tall_hnb_ctx, 0); + /* g_hnbgw serves as the root talloc ctx, so allocate with NULL parent */ + g_hnbgw_alloc(NULL); + g_hnbgw->config.rnc_id = 23;
- g_hnb_gw = hnb_gw_create(tall_hnb_ctx); - g_hnb_gw->config.rnc_id = 23; + talloc_asn1_ctx = talloc_named_const(g_hnbgw, 1, "asn1_context"); + msgb_talloc_ctx_init(g_hnbgw, 0);
- rc = osmo_init_logging2(tall_hnb_ctx, &hnbgw_log_info); + rc = osmo_init_logging2(g_hnbgw, &hnbgw_log_info); if (rc < 0) exit(1);
@@ -738,14 +732,14 @@ exit(1); }
- vty_info.tall_ctx = tall_hnb_ctx; + vty_info.tall_ctx = g_hnbgw; vty_info.copyright = osmo_hnbgw_copyright; vty_init(&vty_info);
- osmo_ss7_vty_init_asp(tall_hnb_ctx); + osmo_ss7_vty_init_asp(g_hnbgw); osmo_sccp_vty_init(); - hnbgw_vty_init(g_hnb_gw, tall_hnb_ctx); - ctrl_vty_init(tall_hnb_ctx); + hnbgw_vty_init(); + ctrl_vty_init(g_hnbgw); logging_vty_add_cmds(); osmo_talloc_vty_add_cmds();
@@ -774,15 +768,15 @@ log_set_log_level(osmo_stderr_target, hnbgw_cmdline_config.log_level);
- rc = telnet_init_default(tall_hnb_ctx, g_hnb_gw, OSMO_VTY_PORT_HNBGW); + rc = telnet_init_default(g_hnbgw, g_hnbgw, OSMO_VTY_PORT_HNBGW); if (rc < 0) { perror("Error binding VTY port"); exit(1); }
- g_hnb_gw->ctrl = ctrl_interface_setup2(g_hnb_gw, OSMO_CTRL_PORT_HNBGW, hnb_ctrl_node_lookup, + g_hnbgw->ctrl = ctrl_interface_setup2(g_hnbgw, OSMO_CTRL_PORT_HNBGW, hnb_ctrl_node_lookup, _LAST_CTRL_NODE_HNB); - if (!g_hnb_gw->ctrl) { + if (!g_hnbgw->ctrl) { LOGP(DMAIN, LOGL_ERROR, "Failed to create CTRL interface on %s:%u\n", ctrl_vty_get_bind_addr(), OSMO_CTRL_PORT_HNBGW); exit(1); @@ -796,35 +790,35 @@
ranap_set_log_area(DRANAP);
- rc = hnbgw_cnlink_init(g_hnb_gw, "localhost", M3UA_PORT, "localhost"); + rc = hnbgw_cnlink_init("localhost", M3UA_PORT, "localhost"); if (rc < 0) { LOGP(DMAIN, LOGL_ERROR, "Failed to initialize SCCP link to CN\n"); exit(1); }
- LOGP(DHNBAP, LOGL_NOTICE, "Using RNC-Id %u\n", g_hnb_gw->config.rnc_id); + LOGP(DHNBAP, LOGL_NOTICE, "Using RNC-Id %u\n", g_hnbgw->config.rnc_id);
- OSMO_ASSERT(g_hnb_gw->config.iuh_local_ip); + OSMO_ASSERT(g_hnbgw->config.iuh_local_ip); LOGP(DMAIN, LOGL_NOTICE, "Listening for Iuh at %s %d\n", - g_hnb_gw->config.iuh_local_ip, - g_hnb_gw->config.iuh_local_port); - srv = osmo_stream_srv_link_create(tall_hnb_ctx); + g_hnbgw->config.iuh_local_ip, + g_hnbgw->config.iuh_local_port); + srv = osmo_stream_srv_link_create(g_hnbgw); if (!srv) { perror("cannot create server"); exit(1); } - osmo_stream_srv_link_set_data(srv, g_hnb_gw); + osmo_stream_srv_link_set_data(srv, g_hnbgw); osmo_stream_srv_link_set_proto(srv, IPPROTO_SCTP); osmo_stream_srv_link_set_nodelay(srv, true); - osmo_stream_srv_link_set_addr(srv, g_hnb_gw->config.iuh_local_ip); - osmo_stream_srv_link_set_port(srv, g_hnb_gw->config.iuh_local_port); + osmo_stream_srv_link_set_addr(srv, g_hnbgw->config.iuh_local_ip); + osmo_stream_srv_link_set_port(srv, g_hnbgw->config.iuh_local_port); osmo_stream_srv_link_set_accept_cb(srv, accept_cb);
if (osmo_stream_srv_link_open(srv) < 0) { perror("Cannot open server"); exit(1); } - g_hnb_gw->iuh = srv; + g_hnbgw->iuh = srv;
/* Initialize and connect MGCP client. */ if (hnbgw_mgw_setup() != 0) @@ -832,7 +826,7 @@
#if ENABLE_PFCP /* If UPF is configured, set up PFCP socket and send Association Setup Request to UPF */ - hnbgw_pfcp_init(g_hnb_gw); + hnbgw_pfcp_init(); #endif
if (hnbgw_cmdline_config.daemonize) { diff --git a/src/osmo-hnbgw/hnbgw_cn.c b/src/osmo-hnbgw/hnbgw_cn.c index fdc5cde..a256b24 100644 --- a/src/osmo-hnbgw/hnbgw_cn.c +++ b/src/osmo-hnbgw/hnbgw_cn.c @@ -43,7 +43,7 @@
void hnbgw_cnlink_change_state(struct hnbgw_cnlink *cnlink, enum hnbgw_cnlink_state state);
-static int transmit_rst(struct hnb_gw *gw, RANAP_CN_DomainIndicator_t domain, +static int transmit_rst(RANAP_CN_DomainIndicator_t domain, struct osmo_sccp_addr *remote_addr) { struct msgb *msg; @@ -54,41 +54,39 @@
LOGP(DRANAP, LOGL_NOTICE, "Tx RESET to %s %s\n", domain == RANAP_CN_DomainIndicator_cs_domain ? "IuCS" : "IuPS", - osmo_sccp_inst_addr_name(gw->sccp.cnlink->sccp, remote_addr)); + osmo_sccp_inst_addr_name(g_hnbgw->sccp.cnlink->sccp, remote_addr));
msg = ranap_new_msg_reset(domain, &cause);
- return osmo_sccp_tx_unitdata_msg(gw->sccp.cnlink->sccp_user, - &gw->sccp.local_addr, + return osmo_sccp_tx_unitdata_msg(g_hnbgw->sccp.cnlink->sccp_user, + &g_hnbgw->sccp.local_addr, remote_addr, msg); }
-static int transmit_reset_ack(struct hnb_gw *gw, RANAP_CN_DomainIndicator_t domain, +static int transmit_reset_ack(RANAP_CN_DomainIndicator_t domain, const struct osmo_sccp_addr *remote_addr) { struct msgb *msg;
LOGP(DRANAP, LOGL_NOTICE, "Tx RESET ACK to %s %s\n", domain == RANAP_CN_DomainIndicator_cs_domain ? "IuCS" : "IuPS", - osmo_sccp_inst_addr_name(gw->sccp.cnlink->sccp, remote_addr)); + osmo_sccp_inst_addr_name(g_hnbgw->sccp.cnlink->sccp, remote_addr));
msg = ranap_new_msg_reset_ack(domain, NULL);
- return osmo_sccp_tx_unitdata_msg(gw->sccp.cnlink->sccp_user, - &gw->sccp.local_addr, + return osmo_sccp_tx_unitdata_msg(g_hnbgw->sccp.cnlink->sccp_user, + &g_hnbgw->sccp.local_addr, remote_addr, msg); }
/* Timer callback once T_RafC expires */ -static void cnlink_trafc_cb(void *data) +static void cnlink_trafc_cb(void *unused) { - struct hnb_gw *gw = data; - - transmit_rst(gw, RANAP_CN_DomainIndicator_cs_domain, &gw->sccp.iucs_remote_addr); - transmit_rst(gw, RANAP_CN_DomainIndicator_ps_domain, &gw->sccp.iups_remote_addr); - hnbgw_cnlink_change_state(gw->sccp.cnlink, CNLINK_S_EST_RST_TX_WAIT_ACK); + transmit_rst(RANAP_CN_DomainIndicator_cs_domain, &g_hnbgw->sccp.iucs_remote_addr); + transmit_rst(RANAP_CN_DomainIndicator_ps_domain, &g_hnbgw->sccp.iups_remote_addr); + hnbgw_cnlink_change_state(g_hnbgw->sccp.cnlink, CNLINK_S_EST_RST_TX_WAIT_ACK); /* The spec states that we should abandon after a configurable * number of times. We decide to simply continue trying */ } @@ -101,7 +99,7 @@ case CNLINK_S_EST_PEND: break; case CNLINK_S_EST_CONF: - cnlink_trafc_cb(cnlink->gw); + cnlink_trafc_cb(NULL); break; case CNLINK_S_EST_RST_TX_WAIT_ACK: osmo_timer_schedule(&cnlink->T_RafC, 5, 0); @@ -134,7 +132,7 @@
/* FIXME: actually reset connections, if any */
- if (transmit_reset_ack(cnlink->gw, domain, &unitdata->calling_addr)) + if (transmit_reset_ack(domain, &unitdata->calling_addr)) LOGP(DRANAP, LOGL_ERROR, "Error: cannot send RESET ACK to %s %s\n", domain == RANAP_CN_DomainIndicator_cs_domain ? "IuCS" : "IuPS", osmo_sccp_inst_addr_name(cnlink->sccp, &unitdata->calling_addr)); @@ -160,7 +158,6 @@ RANAP_InitiatingMessage_t *imsg, const uint8_t *data, unsigned int len) { - struct hnb_gw *gw = cnlink->gw; struct hnb_context *hnb; RANAP_PagingIEs_t ies; int rc; @@ -171,7 +168,7 @@
/* FIXME: determine which HNBs to send this Paging command, * rather than broadcasting to all HNBs */ - llist_for_each_entry(hnb, &gw->hnb_list, list) { + llist_for_each_entry(hnb, &g_hnbgw->hnb_list, list) { rc = rua_tx_udt(hnb, data, len); }
@@ -288,16 +285,15 @@ && (a->ssn == b->ssn)); }
-static int classify_cn_remote_addr(const struct hnb_gw *gw, - const struct osmo_sccp_addr *cn_remote_addr, +static int classify_cn_remote_addr(const struct osmo_sccp_addr *cn_remote_addr, bool *is_ps) { - if (pc_and_ssn_match(cn_remote_addr, &gw->sccp.iucs_remote_addr)) { + if (pc_and_ssn_match(cn_remote_addr, &g_hnbgw->sccp.iucs_remote_addr)) { if (is_ps) *is_ps = false; return 0; } - if (pc_and_ssn_match(cn_remote_addr, &gw->sccp.iups_remote_addr)) { + if (pc_and_ssn_match(cn_remote_addr, &g_hnbgw->sccp.iups_remote_addr)) { if (is_ps) *is_ps = true; return 0; @@ -317,7 +313,7 @@ return -1; }
- if (classify_cn_remote_addr(cnlink->gw, ¶m->calling_addr, NULL) < 0) + if (classify_cn_remote_addr(¶m->calling_addr, NULL) < 0) return -1;
return handle_cn_ranap(cnlink, param, msgb_l2(oph->msg), msgb_l2len(oph->msg)); @@ -327,7 +323,7 @@ const struct osmo_scu_connect_param *param, struct osmo_prim_hdr *oph) { - struct osmo_ss7_instance *ss7 = osmo_sccp_get_ss7(cnlink->gw->sccp.client); + struct osmo_ss7_instance *ss7 = osmo_sccp_get_ss7(g_hnbgw->sccp.client); struct hnbgw_context_map *map;
LOGP(DMAIN, LOGL_DEBUG, "handle_cn_conn_conf() conn_id=%d, addrs: called=%s calling=%s responding=%s\n", @@ -485,27 +481,27 @@ return 0; }
-int hnbgw_cnlink_init(struct hnb_gw *gw, const char *stp_host, uint16_t stp_port, const char *local_ip) +int hnbgw_cnlink_init(const char *stp_host, uint16_t stp_port, const char *local_ip) { struct hnbgw_cnlink *cnlink; struct osmo_ss7_instance *ss7; uint32_t local_pc;
- OSMO_ASSERT(!gw->sccp.client); - OSMO_ASSERT(!gw->sccp.cnlink); + OSMO_ASSERT(!g_hnbgw->sccp.client); + OSMO_ASSERT(!g_hnbgw->sccp.cnlink);
ss7 = NULL; - if (resolve_addr_name(&gw->sccp.iucs_remote_addr, &ss7, - gw->config.iucs_remote_addr_name, "IuCS", (23 << 3) + 1)) + if (resolve_addr_name(&g_hnbgw->sccp.iucs_remote_addr, &ss7, + g_hnbgw->config.iucs_remote_addr_name, "IuCS", (23 << 3) + 1)) return -1; - if (resolve_addr_name(&gw->sccp.iups_remote_addr, &ss7, - gw->config.iups_remote_addr_name, "IuPS", (23 << 3) + 4)) + if (resolve_addr_name(&g_hnbgw->sccp.iups_remote_addr, &ss7, + g_hnbgw->config.iups_remote_addr_name, "IuPS", (23 << 3) + 4)) return -1;
if (!ss7) { LOGP(DRANAP, LOGL_NOTICE, "No cs7 instance configured for IuCS nor IuPS," " creating default instance\n"); - ss7 = osmo_ss7_instance_find_or_create(gw, 0); + ss7 = osmo_ss7_instance_find_or_create(g_hnbgw, 0); if (!ss7) return -1; ss7->cfg.primary_pc = (23 << 3) + 5; @@ -518,45 +514,43 @@ } local_pc = ss7->cfg.primary_pc;
- osmo_sccp_make_addr_pc_ssn(&gw->sccp.local_addr, local_pc, OSMO_SCCP_SSN_RANAP); - LOGP(DRANAP, LOGL_NOTICE, "Local SCCP addr: %s\n", osmo_sccp_addr_name(ss7, &gw->sccp.local_addr)); + osmo_sccp_make_addr_pc_ssn(&g_hnbgw->sccp.local_addr, local_pc, OSMO_SCCP_SSN_RANAP); + LOGP(DRANAP, LOGL_NOTICE, "Local SCCP addr: %s\n", osmo_sccp_addr_name(ss7, &g_hnbgw->sccp.local_addr));
- gw->sccp.client = osmo_sccp_simple_client_on_ss7_id(gw, ss7->cfg.id, "OsmoHNBGW", - local_pc, OSMO_SS7_ASP_PROT_M3UA, - 0, local_ip, stp_port, stp_host); - if (!gw->sccp.client) { + g_hnbgw->sccp.client = osmo_sccp_simple_client_on_ss7_id(g_hnbgw, ss7->cfg.id, "OsmoHNBGW", + local_pc, OSMO_SS7_ASP_PROT_M3UA, + 0, local_ip, stp_port, stp_host); + if (!g_hnbgw->sccp.client) { LOGP(DMAIN, LOGL_ERROR, "Failed to init SCCP Client\n"); return -1; }
- cnlink = talloc_zero(gw, struct hnbgw_cnlink); - cnlink->gw = gw; + cnlink = talloc_zero(g_hnbgw, struct hnbgw_cnlink); INIT_LLIST_HEAD(&cnlink->map_list); cnlink->T_RafC.cb = cnlink_trafc_cb; - cnlink->T_RafC.data = gw; cnlink->next_conn_id = 1000;
- cnlink->sccp_user = osmo_sccp_user_bind_pc(gw->sccp.client, "OsmoHNBGW", sccp_sap_up, - OSMO_SCCP_SSN_RANAP, gw->sccp.local_addr.pc); + cnlink->sccp_user = osmo_sccp_user_bind_pc(g_hnbgw->sccp.client, "OsmoHNBGW", sccp_sap_up, + OSMO_SCCP_SSN_RANAP, g_hnbgw->sccp.local_addr.pc); if (!cnlink->sccp_user) { LOGP(DMAIN, LOGL_ERROR, "Failed to init SCCP User\n"); return -1; }
LOGP(DRANAP, LOGL_NOTICE, "Remote SCCP addr: IuCS: %s\n", - osmo_sccp_addr_name(ss7, &gw->sccp.iucs_remote_addr)); + osmo_sccp_addr_name(ss7, &g_hnbgw->sccp.iucs_remote_addr)); LOGP(DRANAP, LOGL_NOTICE, "Remote SCCP addr: IuPS: %s\n", - osmo_sccp_addr_name(ss7, &gw->sccp.iups_remote_addr)); + osmo_sccp_addr_name(ss7, &g_hnbgw->sccp.iups_remote_addr));
/* In sccp_sap_up() we expect the cnlink in the user's priv. */ osmo_sccp_user_set_priv(cnlink->sccp_user, cnlink);
- gw->sccp.cnlink = cnlink; + g_hnbgw->sccp.cnlink = cnlink;
return 0; }
-const struct osmo_sccp_addr *hnbgw_cn_get_remote_addr(struct hnb_gw *gw, bool is_ps) +const struct osmo_sccp_addr *hnbgw_cn_get_remote_addr(bool is_ps) { - return is_ps ? &gw->sccp.iups_remote_addr : &gw->sccp.iucs_remote_addr; + return is_ps ? &g_hnbgw->sccp.iups_remote_addr : &g_hnbgw->sccp.iucs_remote_addr; } diff --git a/src/osmo-hnbgw/hnbgw_hnbap.c b/src/osmo-hnbgw/hnbgw_hnbap.c index 395cca7..85adccd 100644 --- a/src/osmo-hnbgw/hnbgw_hnbap.c +++ b/src/osmo-hnbgw/hnbgw_hnbap.c @@ -99,7 +99,7 @@
/* Single required response IE: RNC-ID */ HNBAP_HNBRegisterAcceptIEs_t accept = { - .rnc_id = ctx->gw->config.rnc_id + .rnc_id = g_hnbgw->config.rnc_id };
/* encode the Information Elements */ @@ -330,7 +330,7 @@ tmsi = ntohl(tmsi); LOGHNB(hnb, DHNBAP, LOGL_DEBUG, "HNBAP register with TMSI %x\n", tmsi);
- ue = ue_context_by_tmsi(hnb->gw, tmsi); + ue = ue_context_by_tmsi(tmsi); if (!ue) ue = ue_allocated = ue_context_alloc(hnb, NULL, tmsi);
@@ -431,7 +431,7 @@ ctx->id.mcc = plmn.mcc; ctx->id.mnc = plmn.mnc;
- llist_for_each_entry_safe(hnb, tmp, &ctx->gw->hnb_list, list) { + llist_for_each_entry_safe(hnb, tmp, &g_hnbgw->hnb_list, list) { if (hnb->hnb_registered && ctx != hnb && memcmp(&ctx->id, &hnb->id, sizeof(ctx->id)) == 0) { /* If it's coming from the same remote IP addr+port, then it must be our internal * fault (bug), and we release the old context to keep going... */ @@ -513,7 +513,7 @@ break; case HNBAP_UE_Identity_PR_tMSILAI: case HNBAP_UE_Identity_PR_pTMSIRAI: - if (ctx->gw->config.hnbap_allow_tmsi) + if (g_hnbgw->config.hnbap_allow_tmsi) rc = hnbgw_tx_ue_register_acc_tmsi(ctx, &ies.uE_Identity); else rc = hnbgw_tx_ue_register_rej_tmsi(ctx, &ies.uE_Identity); @@ -529,7 +529,7 @@ LOGHNB(ctx, DHNBAP, LOGL_DEBUG, "UE-REGISTER-REQ ID_type=%d imsi=%s cause=%ld\n", ies.uE_Identity.present, imsi, ies.registration_Cause);
- ue = ue_context_by_imsi(ctx->gw, imsi); + ue = ue_context_by_imsi(imsi); if (!ue) ue = ue_allocated = ue_context_alloc(ctx, imsi, 0);
@@ -561,7 +561,7 @@
LOGHNB(ctx, DHNBAP, LOGL_DEBUG, "UE-DE-REGISTER context=%u cause=%s\n", ctxid, hnbap_cause_str(&ies.cause));
- ue = ue_context_by_id(ctx->gw, ctxid); + ue = ue_context_by_id(ctxid); if (ue) ue_context_free(ue);
diff --git a/src/osmo-hnbgw/hnbgw_pfcp.c b/src/osmo-hnbgw/hnbgw_pfcp.c index 6973a1b..c7b2b08 100644 --- a/src/osmo-hnbgw/hnbgw_pfcp.c +++ b/src/osmo-hnbgw/hnbgw_pfcp.c @@ -29,10 +29,8 @@
static void pfcp_set_msg_ctx(struct osmo_pfcp_endpoint *ep, struct osmo_pfcp_msg *m, struct osmo_pfcp_msg *req) { - struct hnb_gw *hnb_gw = osmo_pfcp_endpoint_get_priv(ep); - if (!m->ctx.peer_fi) - osmo_pfcp_cp_peer_set_msg_ctx(hnb_gw->pfcp.cp_peer, m); + osmo_pfcp_cp_peer_set_msg_ctx(g_hnbgw->pfcp.cp_peer, m);
/* If this is a response to an earlier request, just take the msg context from the request message. * In osmo-hnbgw, a session_fi always points at a ps_rab FSM. */ @@ -43,7 +41,7 @@ * ps_rab_new_pfcp_msg_tx() already sets the msg ctx, and for rx, we only expect to receive PFCP Responses, * which are handled above. The only time this will happen is when the UPF shuts down and sends a Deletion. */ if (!m->ctx.session_fi && m->h.seid_present && m->h.seid != 0) { - struct ps_rab *rab = ps_rab_find_by_seid(hnb_gw, m->h.seid, m->rx); + struct ps_rab *rab = ps_rab_find_by_seid(m->h.seid, m->rx); if (rab) ps_rab_pfcp_set_msg_ctx(rab, m); } @@ -64,7 +62,7 @@ } }
-int hnbgw_pfcp_init(struct hnb_gw *hnb_gw) +int hnbgw_pfcp_init(void) { struct osmo_pfcp_endpoint_cfg cfg; struct osmo_pfcp_endpoint *ep; @@ -72,13 +70,13 @@ struct osmo_sockaddr_str upf_addr_str; struct osmo_sockaddr upf_addr;
- if (!hnb_gw_is_gtp_mapping_enabled(hnb_gw)) { + if (!hnb_gw_is_gtp_mapping_enabled()) { LOGP(DLPFCP, LOGL_NOTICE, "No UPF configured, NOT setting up PFCP, NOT mapping GTP via UPF\n"); return 0; } - LOGP(DLPFCP, LOGL_DEBUG, "%p cfg: pfcp remote-addr %s\n", hnb_gw, hnb_gw->config.pfcp.remote_addr); + LOGP(DLPFCP, LOGL_DEBUG, "%p cfg: pfcp remote-addr %s\n", g_hnbgw, g_hnbgw->config.pfcp.remote_addr);
- if (!hnb_gw->config.pfcp.local_addr) { + if (!g_hnbgw->config.pfcp.local_addr) { LOGP(DLPFCP, LOGL_ERROR, "Configuration error: missing local PFCP address, required for Node Id\n"); return -1; } @@ -86,44 +84,43 @@ cfg = (struct osmo_pfcp_endpoint_cfg){ .set_msg_ctx_cb = pfcp_set_msg_ctx, .rx_msg_cb = pfcp_rx_msg, - .priv = hnb_gw, };
/* Set up PFCP endpoint's local node id from local IP address. Parse address string into local_addr_str... */ - if (osmo_sockaddr_str_from_str(&local_addr_str, hnb_gw->config.pfcp.local_addr, hnb_gw->config.pfcp.local_port)) { + if (osmo_sockaddr_str_from_str(&local_addr_str, g_hnbgw->config.pfcp.local_addr, g_hnbgw->config.pfcp.local_port)) { LOGP(DLPFCP, LOGL_ERROR, "Error in PFCP local IP: %s\n", - osmo_quote_str_c(OTC_SELECT, hnb_gw->config.pfcp.local_addr, -1)); + osmo_quote_str_c(OTC_SELECT, g_hnbgw->config.pfcp.local_addr, -1)); return -1; } /* ...and convert to osmo_sockaddr, write to ep->cfg */ if (osmo_sockaddr_str_to_sockaddr(&local_addr_str, &cfg.local_addr.u.sas)) { LOGP(DLPFCP, LOGL_ERROR, "Error in PFCP local IP: %s\n", - osmo_quote_str_c(OTC_SELECT, hnb_gw->config.pfcp.local_addr, -1)); + osmo_quote_str_c(OTC_SELECT, g_hnbgw->config.pfcp.local_addr, -1)); return -1; } /* also store the local addr as local Node ID */ if (osmo_pfcp_ie_node_id_from_osmo_sockaddr(&cfg.local_node_id, &cfg.local_addr)) { LOGP(DLPFCP, LOGL_ERROR, "Error in PFCP local IP: %s\n", - osmo_quote_str_c(OTC_SELECT, hnb_gw->config.pfcp.local_addr, -1)); + osmo_quote_str_c(OTC_SELECT, g_hnbgw->config.pfcp.local_addr, -1)); return -1; }
- hnb_gw->pfcp.ep = ep = osmo_pfcp_endpoint_create(hnb_gw, &cfg); + g_hnbgw->pfcp.ep = ep = osmo_pfcp_endpoint_create(g_hnbgw, &cfg); if (!ep) { LOGP(DLPFCP, LOGL_ERROR, "Failed to allocate PFCP endpoint\n"); return -1; }
/* Set up remote PFCP address to reach UPF at. First parse the string into upf_addr_str. */ - if (osmo_sockaddr_str_from_str(&upf_addr_str, hnb_gw->config.pfcp.remote_addr, hnb_gw->config.pfcp.remote_port)) { + if (osmo_sockaddr_str_from_str(&upf_addr_str, g_hnbgw->config.pfcp.remote_addr, g_hnbgw->config.pfcp.remote_port)) { LOGP(DLPFCP, LOGL_ERROR, "Error in PFCP remote IP: %s\n", - osmo_quote_str_c(OTC_SELECT, hnb_gw->config.pfcp.remote_addr, -1)); + osmo_quote_str_c(OTC_SELECT, g_hnbgw->config.pfcp.remote_addr, -1)); return -1; } /* then convert upf_addr_str to osmo_sockaddr */ if (osmo_sockaddr_str_to_sockaddr(&upf_addr_str, &upf_addr.u.sas)) { LOGP(DLPFCP, LOGL_ERROR, "Error in PFCP remote IP: %s\n", - osmo_quote_str_c(OTC_SELECT, hnb_gw->config.pfcp.remote_addr, -1)); + osmo_quote_str_c(OTC_SELECT, g_hnbgw->config.pfcp.remote_addr, -1)); return -1; }
@@ -134,12 +131,12 @@ }
/* Associate with UPF */ - hnb_gw->pfcp.cp_peer = osmo_pfcp_cp_peer_alloc(hnb_gw, ep, &upf_addr); - if (!hnb_gw->pfcp.cp_peer) { + g_hnbgw->pfcp.cp_peer = osmo_pfcp_cp_peer_alloc(g_hnbgw, ep, &upf_addr); + if (!g_hnbgw->pfcp.cp_peer) { LOGP(DLPFCP, LOGL_ERROR, "Cannot allocate PFCP CP Peer FSM\n"); return -1; } - if (osmo_pfcp_cp_peer_associate(hnb_gw->pfcp.cp_peer)) { + if (osmo_pfcp_cp_peer_associate(g_hnbgw->pfcp.cp_peer)) { LOGP(DLPFCP, LOGL_ERROR, "Cannot start PFCP CP Peer FSM\n"); return -1; } diff --git a/src/osmo-hnbgw/hnbgw_rua.c b/src/osmo-hnbgw/hnbgw_rua.c index a8dc458..2e03e01 100644 --- a/src/osmo-hnbgw/hnbgw_rua.c +++ b/src/osmo-hnbgw/hnbgw_rua.c @@ -200,7 +200,7 @@ { struct msgb *ranap_msg = NULL; struct hnbgw_context_map *map = NULL; - struct hnbgw_cnlink *cn = hnb->gw->sccp.cnlink; + struct hnbgw_cnlink *cn = g_hnbgw->sccp.cnlink; bool is_ps;
switch (cN_DomainIndicator) { diff --git a/src/osmo-hnbgw/hnbgw_vty.c b/src/osmo-hnbgw/hnbgw_vty.c index 70c2d13..216d8cc 100644 --- a/src/osmo-hnbgw/hnbgw_vty.c +++ b/src/osmo-hnbgw/hnbgw_vty.c @@ -37,9 +37,6 @@
#include <osmocom/mgcp_client/mgcp_client.h>
-static void *tall_hnb_ctx = NULL; -static struct hnb_gw *g_hnb_gw = NULL; - static struct cmd_node hnbgw_node = { HNBGW_NODE, "%s(config-hnbgw)# ", @@ -138,29 +135,29 @@ SHOW_STR "Display information on core network link\n") { struct osmo_ss7_route *rt; - struct osmo_ss7_instance *ss7 = osmo_sccp_get_ss7(g_hnb_gw->sccp.client); + struct osmo_ss7_instance *ss7 = osmo_sccp_get_ss7(g_hnbgw->sccp.client); #define GUARD(STR) \ STR ? STR : "", \ STR ? ":" : ""
vty_out(vty, "IuCS: %s <->", - osmo_sccp_user_name(g_hnb_gw->sccp.cnlink->sccp_user)); + osmo_sccp_user_name(g_hnbgw->sccp.cnlink->sccp_user)); vty_out(vty, " %s%s%s%s", - GUARD(g_hnb_gw->config.iucs_remote_addr_name), - osmo_sccp_inst_addr_name(g_hnb_gw->sccp.client, &g_hnb_gw->sccp.iucs_remote_addr), + GUARD(g_hnbgw->config.iucs_remote_addr_name), + osmo_sccp_inst_addr_name(g_hnbgw->sccp.client, &g_hnbgw->sccp.iucs_remote_addr), VTY_NEWLINE);
- rt = osmo_ss7_route_lookup(ss7, g_hnb_gw->sccp.iucs_remote_addr.pc); + rt = osmo_ss7_route_lookup(ss7, g_hnbgw->sccp.iucs_remote_addr.pc); vty_out(vty, " SS7 route: %s%s", osmo_ss7_route_name(rt, true), VTY_NEWLINE);
vty_out(vty, "IuPS: %s <->", - osmo_sccp_user_name(g_hnb_gw->sccp.cnlink->sccp_user)); + osmo_sccp_user_name(g_hnbgw->sccp.cnlink->sccp_user)); vty_out(vty, " %s%s%s%s", - GUARD(g_hnb_gw->config.iups_remote_addr_name), - osmo_sccp_inst_addr_name(g_hnb_gw->sccp.client, &g_hnb_gw->sccp.iups_remote_addr), + GUARD(g_hnbgw->config.iups_remote_addr_name), + osmo_sccp_inst_addr_name(g_hnbgw->sccp.client, &g_hnbgw->sccp.iups_remote_addr), VTY_NEWLINE);
- rt = osmo_ss7_route_lookup(ss7, g_hnb_gw->sccp.iups_remote_addr.pc); + rt = osmo_ss7_route_lookup(ss7, g_hnbgw->sccp.iups_remote_addr.pc); vty_out(vty, " SS7 route: %s%s", osmo_ss7_route_name(rt, true), VTY_NEWLINE);
#undef GUARD @@ -229,12 +226,12 @@ struct hnb_context *hnb; unsigned int count = 0;
- if (llist_empty(&g_hnb_gw->hnb_list)) { + if (llist_empty(&g_hnbgw->hnb_list)) { vty_out(vty, "No HNB connected%s", VTY_NEWLINE); return CMD_SUCCESS; }
- llist_for_each_entry(hnb, &g_hnb_gw->hnb_list, list) { + llist_for_each_entry(hnb, &g_hnbgw->hnb_list, list) { vty_dump_hnb_info(vty, hnb); count++; } @@ -250,12 +247,12 @@ struct hnb_context *hnb; const char *identity_info = argv[0];
- if (llist_empty(&g_hnb_gw->hnb_list)) { + if (llist_empty(&g_hnbgw->hnb_list)) { vty_out(vty, "No HNB connected%s", VTY_NEWLINE); return CMD_SUCCESS; }
- hnb = hnb_context_by_identity_info(g_hnb_gw, identity_info); + hnb = hnb_context_by_identity_info(identity_info); if (hnb == NULL) { vty_out(vty, "No HNB found with identity '%s'%s", identity_info, VTY_NEWLINE); return CMD_SUCCESS; @@ -270,7 +267,7 @@ { struct ue_context *ue;
- llist_for_each_entry(ue, &g_hnb_gw->ue_list, list) { + llist_for_each_entry(ue, &g_hnbgw->ue_list, list) { vty_dump_ue_info(vty, ue); }
@@ -279,8 +276,7 @@
DEFUN(show_talloc, show_talloc_cmd, "show talloc", SHOW_STR "Display talloc info") { - talloc_report_full(tall_hnb_ctx, stderr); - talloc_report_full(talloc_asn1_ctx, stderr); + talloc_report_full(g_hnbgw, stderr);
return CMD_SUCCESS; } @@ -292,7 +288,7 @@ " RANAP InitialUE Messages' GlobalRNC-ID IE. Takes effect as soon as the hNodeB re-registers.\n" "RNC Id value\n") { - g_hnb_gw->config.rnc_id = atoi(argv[0]); + g_hnbgw->config.rnc_id = atoi(argv[0]); return CMD_SUCCESS; }
@@ -300,8 +296,8 @@ "Accept Iuh connections on local interface\n" "Local interface IP address (default: " HNBGW_LOCAL_IP_DEFAULT ")") { - talloc_free((void*)g_hnb_gw->config.iuh_local_ip); - g_hnb_gw->config.iuh_local_ip = talloc_strdup(tall_hnb_ctx, argv[0]); + talloc_free((void *)g_hnbgw->config.iuh_local_ip); + g_hnbgw->config.iuh_local_ip = talloc_strdup(g_hnbgw, argv[0]); return CMD_SUCCESS; }
@@ -309,7 +305,7 @@ "Accept Iuh connections on local port\n" "Local interface port (default: 29169)") { - g_hnb_gw->config.iuh_local_port = atoi(argv[0]); + g_hnbgw->config.iuh_local_port = atoi(argv[0]); return CMD_SUCCESS; }
@@ -319,7 +315,7 @@ "Only accept IMSI identity, reject TMSI or PTMSI\n" "Accept IMSI, TMSI or PTMSI as UE identity\n") { - g_hnb_gw->config.hnbap_allow_tmsi = (*argv[0] == '1'); + g_hnbgw->config.hnbap_allow_tmsi = (*argv[0] == '1'); return CMD_SUCCESS; }
@@ -330,9 +326,9 @@ "Use the UMTS Cell ID as log message prefix\n") { if (!strcmp(argv[0], "hnb-id")) - g_hnb_gw->config.log_prefix_hnb_id = true; + g_hnbgw->config.log_prefix_hnb_id = true; else - g_hnb_gw->config.log_prefix_hnb_id = false; + g_hnbgw->config.log_prefix_hnb_id = false; return CMD_SUCCESS; }
@@ -356,7 +352,7 @@ "SCCP address to send IuCS to (MSC)\n" "SCCP address book entry name (see 'cs7-instance')\n") { - g_hnb_gw->config.iucs_remote_addr_name = talloc_strdup(g_hnb_gw, argv[0]); + g_hnbgw->config.iucs_remote_addr_name = talloc_strdup(g_hnbgw, argv[0]); return CMD_SUCCESS; }
@@ -366,7 +362,7 @@ "SCCP address to send IuPS to (SGSN)\n" "SCCP address book entry name (see 'cs7-instance')\n") { - g_hnb_gw->config.iups_remote_addr_name = talloc_strdup(g_hnb_gw, argv[0]); + g_hnbgw->config.iups_remote_addr_name = talloc_strdup(g_hnbgw, argv[0]); return CMD_SUCCESS; }
@@ -390,8 +386,8 @@ "Remote UPF's listen IP address; where to send PFCP requests\n" "IP address\n") { - osmo_talloc_replace_string(g_hnb_gw, &g_hnb_gw->config.pfcp.remote_addr, argv[0]); - LOGP(DLPFCP, LOGL_NOTICE, "%p cfg: pfcp remote-addr %s\n", g_hnb_gw, g_hnb_gw->config.pfcp.remote_addr); + osmo_talloc_replace_string(g_hnbgw, &g_hnbgw->config.pfcp.remote_addr, argv[0]); + LOGP(DLPFCP, LOGL_NOTICE, "%p cfg: pfcp remote-addr %s\n", g_hnbgw, g_hnbgw->config.pfcp.remote_addr); return CMD_SUCCESS; }
@@ -400,7 +396,7 @@ "Local address for PFCP\n" "IP address\n") { - osmo_talloc_replace_string(g_hnb_gw, &g_hnb_gw->config.pfcp.local_addr, argv[0]); + osmo_talloc_replace_string(g_hnbgw, &g_hnbgw->config.pfcp.local_addr, argv[0]); return CMD_SUCCESS; }
@@ -409,7 +405,7 @@ "Local port for PFCP\n" "IP port\n") { - g_hnb_gw->config.pfcp.local_port = atoi(argv[0]); + g_hnbgw->config.pfcp.local_port = atoi(argv[0]); return CMD_SUCCESS; }
@@ -418,7 +414,7 @@ static int config_write_hnbgw(struct vty *vty) { vty_out(vty, "hnbgw%s", VTY_NEWLINE); - vty_out(vty, " log-prefix %s%s", g_hnb_gw->config.log_prefix_hnb_id ? "hnb-id" : "umts-cell-id", + vty_out(vty, " log-prefix %s%s", g_hnbgw->config.log_prefix_hnb_id ? "hnb-id" : "umts-cell-id", VTY_NEWLINE); osmo_tdef_vty_groups_write(vty, " "); return CMD_SUCCESS; @@ -431,15 +427,15 @@
vty_out(vty, " iuh%s", VTY_NEWLINE);
- addr = g_hnb_gw->config.iuh_local_ip; + addr = g_hnbgw->config.iuh_local_ip; if (addr && (strcmp(addr, HNBGW_LOCAL_IP_DEFAULT) != 0)) vty_out(vty, " local-ip %s%s", addr, VTY_NEWLINE);
- port = g_hnb_gw->config.iuh_local_port; + port = g_hnbgw->config.iuh_local_port; if (port && port != IUH_DEFAULT_SCTP_PORT) vty_out(vty, " local-port %u%s", port, VTY_NEWLINE);
- if (g_hnb_gw->config.hnbap_allow_tmsi) + if (g_hnbgw->config.hnbap_allow_tmsi) vty_out(vty, " hnbap-allow-tmsi 1%s", VTY_NEWLINE);
return CMD_SUCCESS; @@ -447,11 +443,11 @@
static int config_write_hnbgw_iucs(struct vty *vty) { - if (!g_hnb_gw->config.iucs_remote_addr_name) + if (!g_hnbgw->config.iucs_remote_addr_name) return CMD_SUCCESS;
vty_out(vty, " iucs%s", VTY_NEWLINE); - vty_out(vty, " remote-addr %s%s", g_hnb_gw->config.iucs_remote_addr_name, + vty_out(vty, " remote-addr %s%s", g_hnbgw->config.iucs_remote_addr_name, VTY_NEWLINE);
return CMD_SUCCESS; @@ -459,11 +455,11 @@
static int config_write_hnbgw_iups(struct vty *vty) { - if (!g_hnb_gw->config.iups_remote_addr_name) + if (!g_hnbgw->config.iups_remote_addr_name) return CMD_SUCCESS;
vty_out(vty, " iups%s", VTY_NEWLINE); - vty_out(vty, " remote-addr %s%s", g_hnb_gw->config.iups_remote_addr_name, + vty_out(vty, " remote-addr %s%s", g_hnbgw->config.iups_remote_addr_name, VTY_NEWLINE);
return CMD_SUCCESS; @@ -473,20 +469,17 @@ static int config_write_hnbgw_pfcp(struct vty *vty) { vty_out(vty, " pfcp%s", VTY_NEWLINE); - if (g_hnb_gw->config.pfcp.local_addr) - vty_out(vty, " local-addr %s%s", g_hnb_gw->config.pfcp.local_addr, VTY_NEWLINE); - if (g_hnb_gw->config.pfcp.remote_addr) - vty_out(vty, " remote-addr %s%s", g_hnb_gw->config.pfcp.remote_addr, VTY_NEWLINE); + if (g_hnbgw->config.pfcp.local_addr) + vty_out(vty, " local-addr %s%s", g_hnbgw->config.pfcp.local_addr, VTY_NEWLINE); + if (g_hnbgw->config.pfcp.remote_addr) + vty_out(vty, " remote-addr %s%s", g_hnbgw->config.pfcp.remote_addr, VTY_NEWLINE);
return CMD_SUCCESS; } #endif
-void hnbgw_vty_init(struct hnb_gw *gw, void *tall_ctx) +void hnbgw_vty_init(void) { - g_hnb_gw = gw; - tall_hnb_ctx = tall_ctx; - install_element(CONFIG_NODE, &cfg_hnbgw_cmd); install_node(&hnbgw_node, config_write_hnbgw);
@@ -520,9 +513,9 @@ install_element(HNBGW_NODE, &cfg_hnbgw_mgcp_cmd); /* Deprecated: Old MGCP config without pooling support in MSC node: */ install_node(&mgcp_node, NULL); - mgcp_client_vty_init(tall_hnb_ctx, MGCP_NODE, g_hnb_gw->config.mgcp_client); + mgcp_client_vty_init(g_hnbgw, MGCP_NODE, g_hnbgw->config.mgcp_client);
- mgcp_client_pool_vty_init(HNBGW_NODE, MGW_NODE, " ", g_hnb_gw->mgw_pool); + mgcp_client_pool_vty_init(HNBGW_NODE, MGW_NODE, " ", g_hnbgw->mgw_pool);
#if ENABLE_PFCP install_node(&pfcp_node, config_write_hnbgw_pfcp); diff --git a/src/osmo-hnbgw/mgw_fsm.c b/src/osmo-hnbgw/mgw_fsm.c index e07ea3b..f6f1089 100644 --- a/src/osmo-hnbgw/mgw_fsm.c +++ b/src/osmo-hnbgw/mgw_fsm.c @@ -167,7 +167,7 @@ mgw_info.codecs[0] = CODEC_IUFP; mgw_info.codecs_len = 1;
- mgw_fsm_priv->mgcpc = mgcp_client_pool_get(map->gw->mgw_pool); + mgw_fsm_priv->mgcpc = mgcp_client_pool_get(g_hnbgw->mgw_pool); if (!mgw_fsm_priv->mgcpc) { LOGPFSML(fi, LOGL_ERROR, "cannot ensure MGW endpoint -- no MGW configured, check configuration!\n"); diff --git a/src/osmo-hnbgw/ps_rab_ass_fsm.c b/src/osmo-hnbgw/ps_rab_ass_fsm.c index 3e4c54a..aa1fe74 100644 --- a/src/osmo-hnbgw/ps_rab_ass_fsm.c +++ b/src/osmo-hnbgw/ps_rab_ass_fsm.c @@ -220,7 +220,6 @@ RANAP_RAB_AssignmentRequestIEs_t *ies = &message->msg.raB_AssignmentRequestIEs; int i;
- struct hnb_gw *hnb_gw = map->gw; struct ps_rab_ass *rab_ass; struct osmo_fsm_inst *fi;
@@ -230,7 +229,7 @@ rab_ass->ranap_rab_ass_req_message = message; /* Now rab_ass owns message and will clean it up */
- if (!osmo_pfcp_cp_peer_is_associated(hnb_gw->pfcp.cp_peer)) { + if (!osmo_pfcp_cp_peer_is_associated(g_hnbgw->pfcp.cp_peer)) { LOG_MAP(map, DLPFCP, LOGL_ERROR, "PFCP is not associated, cannot set up GTP mapping\n"); goto no_rab; } @@ -413,7 +412,6 @@ struct ps_rab_ass *rab_ass; struct osmo_fsm_inst *fi; RANAP_RAB_AssignmentResponseIEs_t *ies; - struct hnb_gw *hnb_gw = map->gw;
/* Make sure we indeed deal with a setup-or-modify list */ ies = &message->msg.raB_AssignmentResponseIEs; @@ -431,7 +429,7 @@ rab_ass->ranap_rab_ass_resp_msgb = ranap_msg; /* Now rab_ass owns message and will clean it up */
- if (!osmo_pfcp_cp_peer_is_associated(hnb_gw->pfcp.cp_peer)) { + if (!osmo_pfcp_cp_peer_is_associated(g_hnbgw->pfcp.cp_peer)) { LOG_PS_RAB_ASS(rab_ass, LOGL_ERROR, "PFCP is not associated, cannot set up GTP mapping\n"); ps_rab_ass_failure(rab_ass); return -1; diff --git a/src/osmo-hnbgw/ps_rab_fsm.c b/src/osmo-hnbgw/ps_rab_fsm.c index f4a1f12..bcf097d 100644 --- a/src/osmo-hnbgw/ps_rab_fsm.c +++ b/src/osmo-hnbgw/ps_rab_fsm.c @@ -87,7 +87,7 @@
/* Allocate with the global hnb_gw, so that we can gracefully handle PFCP release even if a hnb_ctx gets * deallocated. */ - fi = osmo_fsm_inst_alloc(&ps_rab_fsm, map->gw, NULL, LOGL_DEBUG, NULL); + fi = osmo_fsm_inst_alloc(&ps_rab_fsm, g_hnbgw, NULL, LOGL_DEBUG, NULL); OSMO_ASSERT(fi); osmo_fsm_inst_update_id_f_sanitize(fi, '-', "%s-RUA-%u-RAB-%u", hnb_context_name(map->hnb_ctx), map->rua_ctx_id, rab_id); @@ -96,7 +96,6 @@ OSMO_ASSERT(rab); *rab = (struct ps_rab){ .fi = fi, - .hnb_gw = map->gw, .map = map, .rab_id = rab_id, .use_count = { @@ -115,10 +114,10 @@ /* Iterate all ps_rab instances of all context maps and return the one matching the given SEID. * If is_cp_seid == true, match seid with rab->cp_seid (e.g. for received PFCP messages). * Otherwise match seid with rab->up_f_seid.seid (e.g. for sent PFCP messages). */ -struct ps_rab *ps_rab_find_by_seid(struct hnb_gw *hnb_gw, uint64_t seid, bool is_cp_seid) +struct ps_rab *ps_rab_find_by_seid(uint64_t seid, bool is_cp_seid) { struct hnb_context *hnb; - llist_for_each_entry(hnb, &hnb_gw->hnb_list, list) { + llist_for_each_entry(hnb, &g_hnbgw->hnb_list, list) { struct hnbgw_context_map *map; llist_for_each_entry(map, &hnb->map_list, hnb_list) { struct ps_rab *rab; @@ -144,8 +143,7 @@
static struct osmo_pfcp_msg *ps_rab_new_pfcp_msg_req(struct ps_rab *rab, enum osmo_pfcp_message_type msg_type) { - struct hnb_gw *hnb_gw = rab->hnb_gw; - struct osmo_pfcp_msg *m = osmo_pfcp_cp_peer_new_req(hnb_gw->pfcp.cp_peer, msg_type); + struct osmo_pfcp_msg *m = osmo_pfcp_cp_peer_new_req(g_hnbgw->pfcp.cp_peer, msg_type);
m->h.seid_present = true; m->h.seid = rab->up_f_seid.seid; @@ -300,7 +298,6 @@ static void ps_rab_fsm_wait_pfcp_est_resp_onenter(struct osmo_fsm_inst *fi, uint32_t prev_state) { struct ps_rab *rab = fi->priv; - struct hnb_gw *hnb_gw = rab->hnb_gw; struct osmo_pfcp_msg *m; struct osmo_pfcp_ie_f_seid cp_f_seid; struct osmo_pfcp_msg_session_est_req *ser; @@ -313,11 +310,11 @@ m->h.seid = 0;
/* Make a new CP-SEID, our local reference for the PFCP session. */ - rab->cp_seid = osmo_pfcp_next_seid(&hnb_gw->pfcp.cp_peer->next_seid_state); + rab->cp_seid = osmo_pfcp_next_seid(&g_hnbgw->pfcp.cp_peer->next_seid_state); cp_f_seid = (struct osmo_pfcp_ie_f_seid){ .seid = rab->cp_seid, }; - osmo_pfcp_ip_addrs_set(&cp_f_seid.ip_addr, &osmo_pfcp_endpoint_get_cfg(hnb_gw->pfcp.ep)->local_addr); + osmo_pfcp_ip_addrs_set(&cp_f_seid.ip_addr, &osmo_pfcp_endpoint_get_cfg(g_hnbgw->pfcp.ep)->local_addr);
m->ies.session_est_req = (struct osmo_pfcp_msg_session_est_req){ .node_id = m->ies.session_est_req.node_id, @@ -336,7 +333,7 @@
/* Send PFCP Session Establishment Request to UPF, wait for response. */ m->ctx.resp_cb = on_pfcp_est_resp; - if (osmo_pfcp_endpoint_tx(hnb_gw->pfcp.ep, m)) { + if (osmo_pfcp_endpoint_tx(g_hnbgw->pfcp.ep, m)) { LOG_PS_RAB(rab, LOGL_ERROR, "Failed to send PFCP message\n"); ps_rab_failure(rab); } @@ -524,7 +521,6 @@ /* We have been given the Access side's remote F-TEID, now in rab->access.remote, and we need to tell the UPF * about it. */ struct ps_rab *rab = fi->priv; - struct hnb_gw *hnb_gw = rab->hnb_gw; struct osmo_pfcp_msg *m;
if (!(rab->up_f_seid.ip_addr.v4_present /* || rab->up_f_seid.ip_addr.v6_present */)) { @@ -542,7 +538,7 @@ }
m->ctx.resp_cb = on_pfcp_mod_resp; - if (osmo_pfcp_endpoint_tx(hnb_gw->pfcp.ep, m)) { + if (osmo_pfcp_endpoint_tx(g_hnbgw->pfcp.ep, m)) { LOG_PS_RAB(rab, LOGL_ERROR, "Failed to send PFCP message\n"); ps_rab_failure(rab); } @@ -611,7 +607,6 @@ /* If a PFCP session has been established, send a Session Deletion Request and wait for the response. * If no session is established, just terminate. */ struct ps_rab *rab = fi->priv; - struct hnb_gw *hnb_gw = rab->hnb_gw; struct osmo_pfcp_msg *m;
if (!(rab->up_f_seid.ip_addr.v4_present /* || rab->up_f_seid.ip_addr.v6_present */)) { @@ -622,7 +617,7 @@
m = ps_rab_new_pfcp_msg_req(rab, OSMO_PFCP_MSGT_SESSION_DEL_REQ); m->ctx.resp_cb = on_pfcp_del_resp; - if (osmo_pfcp_endpoint_tx(hnb_gw->pfcp.ep, m)) { + if (osmo_pfcp_endpoint_tx(g_hnbgw->pfcp.ep, m)) { LOG_PS_RAB(rab, LOGL_ERROR, "Failed to send PFCP message\n"); ps_rab_failure(rab); }