diff --git a/include/osmocom/hnodeb/hnodeb.h b/include/osmocom/hnodeb/hnodeb.h index 924e1ac..5503020 100644 --- a/include/osmocom/hnodeb/hnodeb.h +++ b/include/osmocom/hnodeb/hnodeb.h @@ -88,10 +88,12 @@ struct hnb { } iuh; /* Lower Layer UD socket */ - struct osmo_prim_srv_link *llsk_link; - struct osmo_prim_srv *llsk; - uint8_t llsk_valid_sapi_mask; - struct osmo_timer_list llsk_defer_configure_ind_timer; + struct { + struct osmo_prim_srv_link *link; + struct osmo_prim_srv *srv; + uint8_t valid_sapi_mask; + struct osmo_timer_list defer_configure_ind_timer; + } llsk; struct { unsigned int jitter_buf_ms; diff --git a/src/osmo-hnodeb/gtp.c b/src/osmo-hnodeb/gtp.c index ef12cf6..58b28fe 100644 --- a/src/osmo-hnodeb/gtp.c +++ b/src/osmo-hnodeb/gtp.c @@ -189,7 +189,7 @@ static int hnb_gtp_rx_gtp(struct hnb *hnb, struct msgb *msg, const struct osmo_s LOGUE(ue, DGTP, LOGL_DEBUG, "Tx GTP-CONN_DATA.ind len=%u\n", msgb_l3len(msg)); gtp_prim = hnb_gtp_makeprim_conn_data_ind(conn->id, msgb_l3(msg), msgb_l3len(msg)); - if ((rc = osmo_prim_srv_send(hnb->llsk, gtp_prim->hdr.msg)) < 0) { + if ((rc = osmo_prim_srv_send(hnb->llsk.srv, gtp_prim->hdr.msg)) < 0) { LOGUE(ue, DGTP, LOGL_ERROR, "Failed Tx GTP-CONN_DATA.ind len=%u\n", msgb_l3len(msg)); } diff --git a/src/osmo-hnodeb/hnb.c b/src/osmo-hnodeb/hnb.c index 18f39b4..1d03826 100644 --- a/src/osmo-hnodeb/hnb.c +++ b/src/osmo-hnodeb/hnb.c @@ -88,9 +88,9 @@ void hnb_free(struct hnb *hnb) } hnb_iuh_free(hnb); - osmo_timer_del(&hnb->llsk_defer_configure_ind_timer); - osmo_prim_srv_link_free(hnb->llsk_link); - hnb->llsk_link = NULL; + osmo_timer_del(&hnb->llsk.defer_configure_ind_timer); + osmo_prim_srv_link_free(hnb->llsk.link); + hnb->llsk.link = NULL; hnb_gtp_unbind(hnb); diff --git a/src/osmo-hnodeb/llsk.c b/src/osmo-hnodeb/llsk.c index 76d4c4a..89e8364 100644 --- a/src/osmo-hnodeb/llsk.c +++ b/src/osmo-hnodeb/llsk.c @@ -86,13 +86,13 @@ static int llsk_opened_cb(struct osmo_prim_srv *srv) { struct hnb *hnb = (struct hnb *)osmo_prim_srv_get_priv(srv); - if (hnb->llsk) { + if (hnb->llsk.srv) { LOGP(DLLSK, LOGL_ERROR, "New connection opened while one is already active, dropping it\n"); osmo_prim_srv_close(srv); return 0; } LOGP(DLLSK, LOGL_NOTICE, "LLSK conn is UP\n"); - hnb->llsk = srv; + hnb->llsk.srv = srv; return 0; } @@ -100,37 +100,37 @@ static int llsk_closed_cb(struct osmo_prim_srv *srv) { struct hnb *hnb = (struct hnb *)osmo_prim_srv_get_priv(srv); - if (!hnb->llsk) { + if (!hnb->llsk.srv) { LOGP(DLLSK, LOGL_ERROR, "closed_cb received but we have no active llsk conn!\n"); return 0; } /* If a later conn different than active one is dropped (because we closed it): */ - if (hnb->llsk != srv) + if (hnb->llsk.srv != srv) return 0; LOGP(DLLSK, LOGL_NOTICE, "LLSK conn is DOWN\n"); - hnb->llsk = NULL; - hnb->llsk_valid_sapi_mask = 0x0; - osmo_timer_del(&hnb->llsk_defer_configure_ind_timer); + hnb->llsk.srv = NULL; + hnb->llsk.valid_sapi_mask = 0x0; + osmo_timer_del(&hnb->llsk.defer_configure_ind_timer); hnb_shutdown(hnb, "LLSK conn dropped", false); return 0; } bool hnb_llsk_connected(const struct hnb *hnb) { - return !!hnb->llsk; + return !!hnb->llsk.srv; } bool hnb_llsk_can_be_configured(struct hnb *hnb) { if (!hnb->registered) return false; - if (!hnb->llsk) + if (!hnb->llsk.srv) return false; - if (hnb->llsk_valid_sapi_mask & (1 << HNB_PRIM_SAPI_IUH) && - hnb->llsk_valid_sapi_mask & (1 << HNB_PRIM_SAPI_AUDIO) && - hnb->llsk_valid_sapi_mask & (1 << HNB_PRIM_SAPI_GTP)) + if (hnb->llsk.valid_sapi_mask & (1 << HNB_PRIM_SAPI_IUH) && + hnb->llsk.valid_sapi_mask & (1 << HNB_PRIM_SAPI_AUDIO) && + hnb->llsk.valid_sapi_mask & (1 << HNB_PRIM_SAPI_GTP)) return true; return false; } @@ -144,13 +144,13 @@ static void llsk_defer_configure_ind_timer_cb(void *data) static int llsk_rx_sapi_version_cb(struct osmo_prim_srv *prim_srv, uint32_t sapi, uint16_t rem_version) { struct hnb *hnb = (struct hnb *)osmo_prim_srv_get_priv(prim_srv); - if (sapi > sizeof(hnb->llsk_valid_sapi_mask)*8 - 1) + if (sapi > sizeof(hnb->llsk.valid_sapi_mask)*8 - 1) return -1; - hnb->llsk_valid_sapi_mask |= (1 << sapi); + hnb->llsk.valid_sapi_mask |= (1 << sapi); /* Defer CONFIGURE.req after we have confirmed the versions */ if (hnb_llsk_can_be_configured(hnb)) - osmo_timer_schedule(&hnb->llsk_defer_configure_ind_timer, 0, 0); + osmo_timer_schedule(&hnb->llsk.defer_configure_ind_timer, 0, 0); return rem_version; } @@ -177,14 +177,14 @@ static int llsk_rx_cb(struct osmo_prim_srv *srv, struct osmo_prim_hdr *oph) int hnb_llsk_alloc(struct hnb *hnb) { - hnb->llsk_link = osmo_prim_srv_link_alloc(hnb); - osmo_prim_srv_link_set_priv(hnb->llsk_link, hnb); - osmo_prim_srv_link_set_log_category(hnb->llsk_link, DLLSK); - osmo_prim_srv_link_set_addr(hnb->llsk_link, HNB_PRIM_UD_SOCK_DEFAULT); - osmo_prim_srv_link_set_opened_conn_cb(hnb->llsk_link, llsk_opened_cb); - osmo_prim_srv_link_set_closed_conn_cb(hnb->llsk_link, llsk_closed_cb); - osmo_prim_srv_link_set_rx_sapi_version_cb(hnb->llsk_link, llsk_rx_sapi_version_cb); - osmo_prim_srv_link_set_rx_cb(hnb->llsk_link, llsk_rx_cb); - osmo_timer_setup(&hnb->llsk_defer_configure_ind_timer, llsk_defer_configure_ind_timer_cb, hnb); + hnb->llsk.link = osmo_prim_srv_link_alloc(hnb); + osmo_prim_srv_link_set_priv(hnb->llsk.link, hnb); + osmo_prim_srv_link_set_log_category(hnb->llsk.link, DLLSK); + osmo_prim_srv_link_set_addr(hnb->llsk.link, HNB_PRIM_UD_SOCK_DEFAULT); + osmo_prim_srv_link_set_opened_conn_cb(hnb->llsk.link, llsk_opened_cb); + osmo_prim_srv_link_set_closed_conn_cb(hnb->llsk.link, llsk_closed_cb); + osmo_prim_srv_link_set_rx_sapi_version_cb(hnb->llsk.link, llsk_rx_sapi_version_cb); + osmo_prim_srv_link_set_rx_cb(hnb->llsk.link, llsk_rx_cb); + osmo_timer_setup(&hnb->llsk.defer_configure_ind_timer, llsk_defer_configure_ind_timer_cb, hnb); return 0; } diff --git a/src/osmo-hnodeb/llsk_audio.c b/src/osmo-hnodeb/llsk_audio.c index da54d28..a9fe858 100644 --- a/src/osmo-hnodeb/llsk_audio.c +++ b/src/osmo-hnodeb/llsk_audio.c @@ -129,7 +129,7 @@ int llsk_audio_tx_conn_data_ind(struct rtp_conn *conn, uint8_t frame_nr, uint8_t LOGUE(conn->ue, DLLSK, LOGL_DEBUG, "Tx AUDIO-CONN_DATA.ind conn_id=%u fn=%u fqc=%u rfci=%u data_len=%u\n", conn->id, frame_nr, fqc, rfci, len); audio_prim = hnb_audio_makeprim_conn_data_ind(conn->id, frame_nr, fqc, rfci, payload, len); - if ((rc = osmo_prim_srv_send(conn->ue->hnb->llsk, audio_prim->hdr.msg)) < 0) + if ((rc = osmo_prim_srv_send(conn->ue->hnb->llsk.srv, audio_prim->hdr.msg)) < 0) LOGUE(conn->ue, DLLSK, LOGL_ERROR, "Failed sending AUDIO-CONN_DATA.ind\n"); return rc; } @@ -141,7 +141,7 @@ static int _send_conn_establish_cnf_failed(struct hnb *hnb, uint32_t context_id, LOGP(DLLSK, LOGL_ERROR, "Tx AUDIO-CONN_ESTABLISH.cnf: ctx=%u error_code=%u\n", context_id, error_code); audio_prim = hnb_audio_makeprim_conn_establish_cnf(context_id, 0, error_code, 0, HNB_PRIM_ADDR_TYPE_UNSPEC, NULL); - if ((rc = osmo_prim_srv_send(hnb->llsk, audio_prim->hdr.msg)) < 0) { + if ((rc = osmo_prim_srv_send(hnb->llsk.srv, audio_prim->hdr.msg)) < 0) { LOGP(DLLSK, LOGL_ERROR, "Failed sending AUDIO-CONN_ESTABLISH.cnf context_id=%u error_code=%u\n", context_id, error_code); } @@ -210,7 +210,7 @@ static int llsk_rx_audio_conn_establish_req(struct hnb *hnb, struct hnb_audio_co rem_addrstr, osmo_sockaddr_to_str(&conn->loc_addr)); audio_prim = hnb_audio_makeprim_conn_establish_cnf(ce_req->context_id, conn->id, 0, loc_port, ce_req->remote_rtp_address_type, &loc_uaddr); - if ((rc = osmo_prim_srv_send(hnb->llsk, audio_prim->hdr.msg)) < 0) { + if ((rc = osmo_prim_srv_send(hnb->llsk.srv, audio_prim->hdr.msg)) < 0) { LOGUE(ue, DLLSK, LOGL_ERROR, "Failed sending AUDIO-CONN_ESTABLISH.cnf error_code=0\n"); goto release_sock; } diff --git a/src/osmo-hnodeb/llsk_gtp.c b/src/osmo-hnodeb/llsk_gtp.c index 775df50..9882ecf 100644 --- a/src/osmo-hnodeb/llsk_gtp.c +++ b/src/osmo-hnodeb/llsk_gtp.c @@ -120,7 +120,7 @@ static int _send_conn_establish_cnf_failed(struct hnb *hnb, uint32_t context_id, LOGP(DLLSK, LOGL_ERROR, "Tx GTP-CONN_ESTABLISH.cnf: ctx=%u error_code=%u\n", context_id, error_code); gtp_prim = hnb_gtp_makeprim_conn_establish_cnf(context_id, 0, error_code, 0, HNB_PRIM_ADDR_TYPE_UNSPEC, NULL); - if ((rc = osmo_prim_srv_send(hnb->llsk, gtp_prim->hdr.msg)) < 0) { + if ((rc = osmo_prim_srv_send(hnb->llsk.srv, gtp_prim->hdr.msg)) < 0) { LOGP(DLLSK, LOGL_ERROR, "Failed sending GTP-CONN_ESTABLISH.cnf context_id=%u error_code=%u\n", context_id, error_code); } @@ -191,7 +191,7 @@ static int llsk_rx_gtp_conn_establish_req(struct hnb *hnb, struct hnb_gtp_conn_e rem_addrstr, ce_req->remote_tei, osmo_sockaddr_to_str(&conn->loc_addr), conn->loc_tei); gtp_prim = hnb_gtp_makeprim_conn_establish_cnf(ce_req->context_id, conn->id, 0, conn->loc_tei, ce_req->remote_gtpu_address_type, &loc_uaddr); - if ((rc = osmo_prim_srv_send(hnb->llsk, gtp_prim->hdr.msg)) < 0) { + if ((rc = osmo_prim_srv_send(hnb->llsk.srv, gtp_prim->hdr.msg)) < 0) { LOGUE(ue, DLLSK, LOGL_ERROR, "Failed sending GTP-CONN_ESTABLISH.cnf error_code=0\n"); goto release_sock; } diff --git a/src/osmo-hnodeb/llsk_iuh.c b/src/osmo-hnodeb/llsk_iuh.c index 00c399a..3cb9077 100644 --- a/src/osmo-hnodeb/llsk_iuh.c +++ b/src/osmo-hnodeb/llsk_iuh.c @@ -117,7 +117,7 @@ int llsk_iuh_tx_configure_ind(struct hnb *hnb) iuh_prim = hnb_iuh_makeprim_configure_ind(hnb->plmn.mcc, hnb->plmn.mnc, hnb->cell_identity, hnb->lac, hnb->rac, hnb->sac, hnb->rnc_id); - if ((rc = osmo_prim_srv_send(hnb->llsk, iuh_prim->hdr.msg)) < 0) + if ((rc = osmo_prim_srv_send(hnb->llsk.srv, iuh_prim->hdr.msg)) < 0) LOGP(DLLSK, LOGL_ERROR, "Failed sending IUH-CONFIGURE.ind\n"); return rc; } diff --git a/src/osmo-hnodeb/main.c b/src/osmo-hnodeb/main.c index 5d35c18..304ad1c 100644 --- a/src/osmo-hnodeb/main.c +++ b/src/osmo-hnodeb/main.c @@ -275,7 +275,7 @@ int main(int argc, char **argv) } /* Start listening on lower layer unix domain socket: */ - rc = osmo_prim_srv_link_open(g_hnb->llsk_link); + rc = osmo_prim_srv_link_open(g_hnb->llsk.link); if (rc < 0) { perror("Error opening lower layer socket"); exit(1); diff --git a/src/osmo-hnodeb/rua.c b/src/osmo-hnodeb/rua.c index 5b225de..e109ae0 100644 --- a/src/osmo-hnodeb/rua.c +++ b/src/osmo-hnodeb/rua.c @@ -77,7 +77,7 @@ static void hnb_rua_dt_handle(struct hnb *hnb, ANY_t *in) LOGP(DLLSK, LOGL_INFO, "Tx IUH-CONN_ESTABLISH.cnf context_id=%u is_ps=%u\n", context_id, is_ps); iuh_prim = hnb_iuh_makeprim_conn_establish_cnf(context_id, is_ps, 0); - if ((rc = osmo_prim_srv_send(hnb->llsk, iuh_prim->hdr.msg)) < 0) { + if ((rc = osmo_prim_srv_send(hnb->llsk.srv, iuh_prim->hdr.msg)) < 0) { LOGP(DRUA, LOGL_ERROR, "Failed sending IUH-CONN_ESTABLISH.cnf context_id=%u is_ps=%u\n", context_id, is_ps); goto free_ret; @@ -87,7 +87,7 @@ static void hnb_rua_dt_handle(struct hnb *hnb, ANY_t *in) LOGP(DLLSK, LOGL_DEBUG, "Tx IUH-CONN_DATA.ind context_id=%u is_ps=%u ranap_len=%zu\n", context_id, is_ps, ranap_buf_len); iuh_prim = hnb_iuh_makeprim_conn_data_ind(context_id, is_ps, ranap_buf, ranap_buf_len); - if ((rc = osmo_prim_srv_send(hnb->llsk, iuh_prim->hdr.msg)) < 0) { + if ((rc = osmo_prim_srv_send(hnb->llsk.srv, iuh_prim->hdr.msg)) < 0) { LOGP(DRUA, LOGL_ERROR, "Failed sending IUH-CONN_DATA.ind context_id=%u is_ps=%u ranap_len=%zu\n", context_id, is_ps, ranap_buf_len); goto free_ret; @@ -118,7 +118,7 @@ static void hnb_rua_cl_handle(struct hnb *hnb, ANY_t *in) LOGP(DLLSK, LOGL_DEBUG, "Tx IUH-UNITDATA.ind ranap_len=%zu\n", ranap_buf_len); iuh_prim = hnb_iuh_makeprim_unitdata_ind(ranap_buf, ranap_buf_len); - if ((rc = osmo_prim_srv_send(hnb->llsk, iuh_prim->hdr.msg)) < 0) { + if ((rc = osmo_prim_srv_send(hnb->llsk.srv, iuh_prim->hdr.msg)) < 0) { LOGP(DRUA, LOGL_ERROR, "Failed sending IUH-CONN_DATA.ind ranap_len=%zu\n", ranap_buf_len); goto free_ret; diff --git a/src/osmo-hnodeb/vty.c b/src/osmo-hnodeb/vty.c index e84e330..f06e4cc 100644 --- a/src/osmo-hnodeb/vty.c +++ b/src/osmo-hnodeb/vty.c @@ -279,7 +279,7 @@ DEFUN(cfg_hnodeb_llsk_path, cfg_hnodeb_llsk_path_cmd, "Configure the Lower Layer Unix Domain Socket path\n" "UNIX socket path\n") { - osmo_prim_srv_link_set_addr(g_hnb->llsk_link, argv[0]); + osmo_prim_srv_link_set_addr(g_hnb->llsk.link, argv[0]); /* FIXME: re-open the interface? */ return CMD_SUCCESS; @@ -332,7 +332,7 @@ static int config_write_hnodeb(struct vty *vty) vty_out(vty, " remote-ip %s%s", g_hnb->iuh.remote_addr, VTY_NEWLINE); vty_out(vty, " remote-port %u%s", g_hnb->iuh.remote_port, VTY_NEWLINE); vty_out(vty, " ll-socket%s", VTY_NEWLINE); - vty_out(vty, " path %s%s", osmo_prim_srv_link_get_addr(g_hnb->llsk_link), VTY_NEWLINE); + vty_out(vty, " path %s%s", osmo_prim_srv_link_get_addr(g_hnb->llsk.link), VTY_NEWLINE); vty_out(vty, " gtp%s", VTY_NEWLINE); vty_out(vty, " local-ip %s%s", g_hnb->gtp.cfg_local_addr, VTY_NEWLINE); return CMD_SUCCESS;