lists.osmocom.org
Sign In Sign Up
Manage this list Sign In Sign Up

Keyboard Shortcuts

Thread View

  • j: Next unread message
  • k: Previous unread message
  • j a: Jump to all threads
  • j l: Jump to MailingList overview

gerrit-log

Thread Start a new thread
Download
Threads by month
  • ----- 2026 -----
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2025 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2024 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2023 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2022 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
gerrit-log@lists.osmocom.org

June 2022

  • 3 participants
  • 1374 discussions
Change in osmo-hnodeb[master]: audio: Introduce SAPI v1 with unordered RFCI support
by pespin 09 Jun '22

09 Jun '22
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-hnodeb/+/28251 ) Change subject: audio: Introduce SAPI v1 with unordered RFCI support ...................................................................... audio: Introduce SAPI v1 with unordered RFCI support This commit introduces support for the new llsk_audio SAPI v1. This new version is almost the same as v0, with the exception that primitive <REQUEST,HNB_AUDIO_PRIM_CONN_ESTABLISH> wins an extra field appended at the end: """ uint8_t rfci[HNB_MAX_RFCIS]; /* values range 6 bits */ """ This allows lowerlayers to provide an unordered array of RFCIs, which was seen may happen under some conditions. For instance: """ rfci[HNB_MAX_RFCIS] = { 2, 3, 1}; [0] RFCI 2 [1] RFCI 3 [2] RFCI 1 """ OsmoHNodeB still supports v0 if the lowerlayer asks for it, and will continue having the exact behavior as before in this case (using position in the array as RFCI). Hence, no compatibility breakage occurs in this patch. New clients, on the other hand, can provide the extra information by announcing V1 support during version negotiation at startup. Related: SYS#5516 Change-Id: I860d18b80c1041bf63a1570d435e0568c0f6b01b --- M include/osmocom/hnodeb/hnb_prim.h M include/osmocom/hnodeb/llsk.h M src/osmo-hnodeb/llsk.c M src/osmo-hnodeb/llsk_audio.c M src/osmo-hnodeb/rtp.c 5 files changed, 64 insertions(+), 29 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hnodeb refs/changes/51/28251/1 diff --git a/include/osmocom/hnodeb/hnb_prim.h b/include/osmocom/hnodeb/hnb_prim.h index ba3223d..be5cba2 100644 --- a/include/osmocom/hnodeb/hnb_prim.h +++ b/include/osmocom/hnodeb/hnb_prim.h @@ -188,7 +188,7 @@ /* HNB_AUDIO_PRIM_CONN_ESTABLISH, UL */ #define HNB_MAX_RFCIS 64 #define HNB_MAX_SUBFLOWS 7 -struct hnb_audio_conn_establish_req_param { +struct hnb_audio_conn_establish_req_param_v0 { uint32_t context_id; uint16_t remote_rtp_port; uint8_t spare1; @@ -204,6 +204,16 @@ uint8_t IPTIs_present; /* 1=present; 0=not present */ uint8_t IPTIs[HNB_MAX_RFCIS]; /* values range 0-15, 4 bits */ } __attribute__ ((packed)); +struct hnb_audio_conn_establish_req_param_v1 { + struct hnb_audio_conn_establish_req_param_v0 v0; + uint8_t rfci[HNB_MAX_RFCIS]; /* values range 6 bits */ +} __attribute__ ((packed)); +struct hnb_audio_conn_establish_req_param { + union { + struct hnb_audio_conn_establish_req_param_v0 v0; + struct hnb_audio_conn_establish_req_param_v1 v1; + } __attribute__ ((packed)); +} __attribute__ ((packed)); /* HNB_AUDIO_PRIM_CONN_ESTABLISH, DL */ struct hnb_audio_conn_establish_cnf_param { diff --git a/include/osmocom/hnodeb/llsk.h b/include/osmocom/hnodeb/llsk.h index d9e1a69..bde531a 100644 --- a/include/osmocom/hnodeb/llsk.h +++ b/include/osmocom/hnodeb/llsk.h @@ -51,8 +51,9 @@ struct hnb_iuh_prim *hnb_iuh_makeprim_unitdata_ind(const uint8_t *data, uint32_t data_len); #define LLSK_SAPI_AUDIO_VERSION_MIN 0 -#define LLSK_SAPI_AUDIO_VERSION_MAX 0 +#define LLSK_SAPI_AUDIO_VERSION_MAX 1 extern const struct value_string hnb_audio_prim_type_names[]; +int llsk_audio_sapi_version_confirmed(uint16_t sapi_version); int llsk_rx_audio(struct hnb *hnb, struct osmo_prim_hdr *oph); int llsk_audio_tx_conn_data_ind(struct rtp_conn *conn, uint8_t frame_nr, uint8_t fqc, uint8_t rfci, const uint8_t *payload, uint32_t len); diff --git a/src/osmo-hnodeb/llsk.c b/src/osmo-hnodeb/llsk.c index b56cae7..f2d778f 100644 --- a/src/osmo-hnodeb/llsk.c +++ b/src/osmo-hnodeb/llsk.c @@ -167,6 +167,8 @@ return -1; if (rem_version > LLSK_SAPI_AUDIO_VERSION_MAX) return LLSK_SAPI_AUDIO_VERSION_MAX; + if (llsk_audio_sapi_version_confirmed(hnb->llsk.sapi_version_audio) < 0) + return -1; hnb->llsk.sapi_version_audio = rem_version; break; default: diff --git a/src/osmo-hnodeb/llsk_audio.c b/src/osmo-hnodeb/llsk_audio.c index a9fe858..a545ee7 100644 --- a/src/osmo-hnodeb/llsk_audio.c +++ b/src/osmo-hnodeb/llsk_audio.c @@ -68,6 +68,24 @@ { 0, NULL } }; +int llsk_audio_sapi_version_confirmed(uint16_t sapi_version) +{ + /* Update primitive size expectancies based on SAPI version: */ + switch (sapi_version) { + case 0: + llsk_audio_prim_size_tbl[PRIM_OP_REQUEST][HNB_AUDIO_PRIM_CONN_ESTABLISH] = + sizeof(struct hnb_audio_conn_establish_req_param_v0); + break; + case 1: + llsk_audio_prim_size_tbl[PRIM_OP_REQUEST][HNB_AUDIO_PRIM_CONN_ESTABLISH] = + sizeof(struct hnb_audio_conn_establish_req_param_v1); + break; + default: + return -1; + } + return 0; +} + static struct hnb_audio_prim *hnb_audio_prim_alloc(enum hnb_audio_prim_type ptype, enum osmo_prim_operation op, size_t extra_len) { struct osmo_prim_hdr *oph; @@ -159,34 +177,35 @@ union u_addr loc_uaddr = {0}; uint16_t loc_port = 0; struct rtp_conn *conn = NULL; + struct hnb_audio_conn_establish_req_param_v0 *v0 = &ce_req->v0; - rc = ll_addr2osa(ce_req->remote_rtp_address_type, &ce_req->remote_rtp_addr, ce_req->remote_rtp_port, &rem_osa); + rc = ll_addr2osa(v0->remote_rtp_address_type, &v0->remote_rtp_addr, v0->remote_rtp_port, &rem_osa); if (rc < 0) { LOGP(DLLSK, LOGL_ERROR, "Rx AUDIO-CONN_ESTABLISH.req: ctx=%u with unexpected address type %u\n", - ce_req->context_id, ce_req->remote_rtp_address_type); - return _send_conn_establish_cnf_failed(hnb, ce_req->context_id, 1); + v0->context_id, v0->remote_rtp_address_type); + return _send_conn_establish_cnf_failed(hnb, v0->context_id, 1); } osmo_sockaddr_to_str_buf(rem_addrstr, sizeof(rem_addrstr), &rem_osa); LOGP(DLLSK, LOGL_INFO, "Rx AUDIO-CONN_ESTABLISH.req ctx=%u rem_addr=%s\n", - ce_req->context_id, rem_addrstr); + v0->context_id, rem_addrstr); - if ((af = ll_addr_type2af(ce_req->remote_rtp_address_type)) < 0) { + if ((af = ll_addr_type2af(v0->remote_rtp_address_type)) < 0) { LOGP(DLLSK, LOGL_ERROR, "Rx AUDIO-CONN_ESTABLISH.req: ctx=%u with unexpected address type %u\n", - ce_req->context_id, ce_req->remote_rtp_address_type); - return _send_conn_establish_cnf_failed(hnb, ce_req->context_id, 1); + v0->context_id, v0->remote_rtp_address_type); + return _send_conn_establish_cnf_failed(hnb, v0->context_id, 1); } - ue = hnb_find_ue_by_id(hnb, ce_req->context_id); + ue = hnb_find_ue_by_id(hnb, v0->context_id); if (!ue) { LOGP(DLLSK, LOGL_ERROR, "Rx AUDIO-CONN_ESTABLISH.req: UE not found! ctx=%u rem_addr=%s\n", - ce_req->context_id, rem_addrstr); - return _send_conn_establish_cnf_failed(hnb, ce_req->context_id, 2); + v0->context_id, rem_addrstr); + return _send_conn_establish_cnf_failed(hnb, v0->context_id, 2); } if (!ue->conn_cs.active) { LOGUE(ue, DLLSK, LOGL_ERROR, "Rx AUDIO-CONN_ESTABLISH.req: CS chan not active! rem_addr=%s\n", rem_addrstr); - return _send_conn_establish_cnf_failed(hnb, ce_req->context_id, 3); + return _send_conn_establish_cnf_failed(hnb, v0->context_id, 3); } /* Create the socket: */ @@ -194,22 +213,22 @@ if ((rc = rtp_conn_setup(conn, &rem_osa, ce_req)) < 0) { LOGUE(ue, DLLSK, LOGL_ERROR, "Rx AUDIO-CONN_ESTABLISH.req: Failed to set up audio socket rem_addr=%s\n", rem_addrstr); - return _send_conn_establish_cnf_failed(hnb, ce_req->context_id, 4); + return _send_conn_establish_cnf_failed(hnb, v0->context_id, 4); } /* Convert resulting local address back to LLSK format: */ - if (osa2_ll_addr(&conn->loc_addr, &loc_uaddr, &loc_port) != ce_req->remote_rtp_address_type) { + if (osa2_ll_addr(&conn->loc_addr, &loc_uaddr, &loc_port) != v0->remote_rtp_address_type) { LOGUE(ue, DLLSK, LOGL_ERROR, "Rx AUDIO-CONN_ESTABLISH.req: Failed to provide proper local address rem_addr=%s\n", rem_addrstr); - rc = _send_conn_establish_cnf_failed(hnb, ce_req->context_id, 4); + rc = _send_conn_establish_cnf_failed(hnb, v0->context_id, 4); goto release_sock; } /* Submit successful confirmation */ LOGUE(ue, DLLSK, LOGL_INFO, "Tx AUDIO-CONN_ESTABLISH.cnf: error_code=0 rem_addr=%s loc_addr=%s\n", 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); + audio_prim = hnb_audio_makeprim_conn_establish_cnf(v0->context_id, conn->id, 0, loc_port, + v0->remote_rtp_address_type, &loc_uaddr); 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/rtp.c b/src/osmo-hnodeb/rtp.c index c0d96a9..422e043 100644 --- a/src/osmo-hnodeb/rtp.c +++ b/src/osmo-hnodeb/rtp.c @@ -31,30 +31,33 @@ #define HNB_IUUP_MSGB_SIZE 4096 -static struct osmo_iuup_rnl_prim *llsk_audio_ce_to_iuup_rnl_cfg(void *ctx, const struct hnb_audio_conn_establish_req_param *ce_req) +static struct osmo_iuup_rnl_prim *llsk_audio_ce_to_iuup_rnl_cfg(struct rtp_conn *conn, const struct hnb_audio_conn_establish_req_param *ce_req) { struct osmo_iuup_rnl_prim *irp; struct osmo_iuup_rnl_config *cfg; unsigned int i; + const struct hnb_audio_conn_establish_req_param_v0 *v0 = &ce_req->v0; + const struct hnb *hnb = conn->ue->hnb; - irp = osmo_iuup_rnl_prim_alloc(ctx, OSMO_IUUP_RNL_CONFIG, PRIM_OP_REQUEST, HNB_IUUP_MSGB_SIZE); + irp = osmo_iuup_rnl_prim_alloc(conn, OSMO_IUUP_RNL_CONFIG, PRIM_OP_REQUEST, HNB_IUUP_MSGB_SIZE); cfg = &irp->u.config; - cfg->transparent = !!ce_req->transparent; + cfg->transparent = !!v0->transparent; cfg->active = true; - cfg->data_pdu_type = ce_req->data_pdu_type; - cfg->supported_versions_mask = ce_req->supported_versions_mask; - cfg->num_rfci = ce_req->num_rfci; - cfg->num_subflows = ce_req->num_subflows; - cfg->IPTIs_present = ce_req->IPTIs_present; + cfg->data_pdu_type = v0->data_pdu_type; + cfg->supported_versions_mask = v0->supported_versions_mask; + cfg->num_rfci = v0->num_rfci; + cfg->num_subflows = v0->num_subflows; + cfg->IPTIs_present = v0->IPTIs_present; OSMO_ASSERT(cfg->num_rfci <= ARRAY_SIZE(cfg->rfci)); OSMO_ASSERT(cfg->num_subflows <= ARRAY_SIZE(cfg->rfci[0].subflow_sizes)); for (i = 0; i < cfg->num_rfci; i++) { cfg->rfci[i].used = true; - cfg->rfci[i].id = i; /* Assume RFC ID from position, llsk_audio doesn't provide info */ + /* llsk_audio v0 doesn't provide info, assume RFC ID from position: */ + cfg->rfci[i].id = (hnb->llsk.sapi_version_audio > 0) ? ce_req->v1.rfci[i] : i; if (cfg->IPTIs_present) - cfg->rfci[i].IPTI = ce_req->IPTIs[i]; + cfg->rfci[i].IPTI = v0->IPTIs[i]; if (cfg->num_subflows > 0) - memcpy(&cfg->rfci[i].subflow_sizes[0], &ce_req->subflow_sizes[i][0], cfg->num_subflows*sizeof(uint16_t)); + memcpy(&cfg->rfci[i].subflow_sizes[0], &v0->subflow_sizes[i][0], cfg->num_subflows*sizeof(uint16_t)); } cfg->t_init = (struct osmo_iuup_rnl_config_timer){ .t_ms = IUUP_TIMER_INIT_T_DEFAULT, .n_max = IUUP_TIMER_INIT_N_DEFAULT }; -- To view, visit https://gerrit.osmocom.org/c/osmo-hnodeb/+/28251 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-hnodeb Gerrit-Branch: master Gerrit-Change-Id: I860d18b80c1041bf63a1570d435e0568c0f6b01b Gerrit-Change-Number: 28251 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: newchange
1 0
0 0
Change in osmo-hnodeb[master]: llsk: Validate received SAPI versions at startup
by pespin 09 Jun '22

09 Jun '22
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-hnodeb/+/28250 ) Change subject: llsk: Validate received SAPI versions at startup ...................................................................... llsk: Validate received SAPI versions at startup Change-Id: I172abfee3bfadb383aa6bce6fe76306291c7cd7f --- M include/osmocom/hnodeb/hnodeb.h M include/osmocom/hnodeb/llsk.h M src/osmo-hnodeb/llsk.c 3 files changed, 36 insertions(+), 3 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hnodeb refs/changes/50/28250/1 diff --git a/include/osmocom/hnodeb/hnodeb.h b/include/osmocom/hnodeb/hnodeb.h index 5503020..986c638 100644 --- a/include/osmocom/hnodeb/hnodeb.h +++ b/include/osmocom/hnodeb/hnodeb.h @@ -92,6 +92,9 @@ struct osmo_prim_srv_link *link; struct osmo_prim_srv *srv; uint8_t valid_sapi_mask; + uint16_t sapi_version_iuh; + uint16_t sapi_version_gtp; + uint16_t sapi_version_audio; struct osmo_timer_list defer_configure_ind_timer; } llsk; diff --git a/include/osmocom/hnodeb/llsk.h b/include/osmocom/hnodeb/llsk.h index 78eb065..d9e1a69 100644 --- a/include/osmocom/hnodeb/llsk.h +++ b/include/osmocom/hnodeb/llsk.h @@ -37,8 +37,8 @@ int ll_addr2osa(enum u_addr_type t, const union u_addr *uaddr, uint16_t port, struct osmo_sockaddr *osa); enum u_addr_type osa2_ll_addr(const struct osmo_sockaddr *osa, union u_addr *uaddr, uint16_t *port); - - +#define LLSK_SAPI_IUH_VERSION_MIN 0 +#define LLSK_SAPI_IUH_VERSION_MAX 0 extern const struct value_string hnb_iuh_prim_type_names[]; int llsk_rx_iuh(struct hnb *hnb, struct osmo_prim_hdr *oph); int llsk_iuh_tx_configure_ind(struct hnb *hnb); @@ -50,12 +50,15 @@ uint32_t data_len); struct hnb_iuh_prim *hnb_iuh_makeprim_unitdata_ind(const uint8_t *data, uint32_t data_len); - +#define LLSK_SAPI_AUDIO_VERSION_MIN 0 +#define LLSK_SAPI_AUDIO_VERSION_MAX 0 extern const struct value_string hnb_audio_prim_type_names[]; int llsk_rx_audio(struct hnb *hnb, struct osmo_prim_hdr *oph); int llsk_audio_tx_conn_data_ind(struct rtp_conn *conn, uint8_t frame_nr, uint8_t fqc, uint8_t rfci, const uint8_t *payload, uint32_t len); +#define LLSK_SAPI_GTP_VERSION_MIN 0 +#define LLSK_SAPI_GTP_VERSION_MAX 0 extern const struct value_string hnb_gtp_prim_type_names[]; int llsk_rx_gtp(struct hnb *hnb, struct osmo_prim_hdr *oph); struct hnb_gtp_prim *hnb_gtp_makeprim_conn_data_ind(uint32_t gtp_conn_id, const uint8_t *data, uint32_t data_len); diff --git a/src/osmo-hnodeb/llsk.c b/src/osmo-hnodeb/llsk.c index 89e8364..b56cae7 100644 --- a/src/osmo-hnodeb/llsk.c +++ b/src/osmo-hnodeb/llsk.c @@ -146,6 +146,33 @@ struct hnb *hnb = (struct hnb *)osmo_prim_srv_get_priv(prim_srv); if (sapi > sizeof(hnb->llsk.valid_sapi_mask)*8 - 1) return -1; + + switch (sapi) { + case HNB_PRIM_SAPI_IUH: + if (rem_version < LLSK_SAPI_IUH_VERSION_MIN) + return -1; + if (rem_version > LLSK_SAPI_IUH_VERSION_MAX) + return LLSK_SAPI_IUH_VERSION_MAX; + hnb->llsk.sapi_version_iuh = rem_version; + break; + case HNB_PRIM_SAPI_GTP: + if (rem_version < LLSK_SAPI_GTP_VERSION_MIN) + return -1; + if (rem_version > LLSK_SAPI_GTP_VERSION_MAX) + return LLSK_SAPI_GTP_VERSION_MAX; + hnb->llsk.sapi_version_gtp = rem_version; + break; + case HNB_PRIM_SAPI_AUDIO: + if (rem_version < LLSK_SAPI_AUDIO_VERSION_MIN) + return -1; + if (rem_version > LLSK_SAPI_AUDIO_VERSION_MAX) + return LLSK_SAPI_AUDIO_VERSION_MAX; + hnb->llsk.sapi_version_audio = rem_version; + break; + default: + return -1; + } + hnb->llsk.valid_sapi_mask |= (1 << sapi); /* Defer CONFIGURE.req after we have confirmed the versions */ -- To view, visit https://gerrit.osmocom.org/c/osmo-hnodeb/+/28250 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-hnodeb Gerrit-Branch: master Gerrit-Change-Id: I172abfee3bfadb383aa6bce6fe76306291c7cd7f Gerrit-Change-Number: 28250 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: newchange
1 0
0 0
Change in osmo-bsc-nat[master]: subscr_conn_fsm: refactor timeouts
by fixeria 09 Jun '22

09 Jun '22
Attention is currently required from: osmith, pespin. fixeria has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-bsc-nat/+/28249 ) Change subject: subscr_conn_fsm: refactor timeouts ...................................................................... Patch Set 2: (1 comment) File src/osmo-bsc-nat/bsc_nat.c: https://gerrit.osmocom.org/c/osmo-bsc-nat/+/28249/comment/2eef689a_f8f1a72e PS2, Line 31: struct osmo_tdef g_bsc_nat_tdefs[] = { > static static const -- To view, visit https://gerrit.osmocom.org/c/osmo-bsc-nat/+/28249 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-bsc-nat Gerrit-Branch: master Gerrit-Change-Id: Ib34e6ccc34901ebc37d2dbe347d9644cb70921ca Gerrit-Change-Number: 28249 Gerrit-PatchSet: 2 Gerrit-Owner: osmith <osmith(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-CC: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-CC: pespin <pespin(a)sysmocom.de> Gerrit-Attention: osmith <osmith(a)sysmocom.de> Gerrit-Attention: pespin <pespin(a)sysmocom.de> Gerrit-Comment-Date: Thu, 09 Jun 2022 09:51:23 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: No Comment-In-Reply-To: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: comment
1 0
0 0
Change in osmo-bsc-nat[master]: subscr_conn_fsm: handle dialing invalid number
by osmith 09 Jun '22

09 Jun '22
osmith has submitted this change. ( https://gerrit.osmocom.org/c/osmo-bsc-nat/+/28240 ) Change subject: subscr_conn_fsm: handle dialing invalid number ...................................................................... subscr_conn_fsm: handle dialing invalid number Reset the FSM to idle when receiving a clear command from the MSC during ST_WAITING_FOR_ASSIGNMENT_COMPLETE. Related: SYS#5560 Change-Id: Ic0589be21f0ee4dbbbe0ffa6b0acdbe152909700 --- M src/osmo-bsc-nat/subscr_conn_fsm.c 1 file changed, 9 insertions(+), 0 deletions(-) Approvals: Jenkins Builder: Verified fixeria: Looks good to me, approved pespin: Looks good to me, but someone else must approve diff --git a/src/osmo-bsc-nat/subscr_conn_fsm.c b/src/osmo-bsc-nat/subscr_conn_fsm.c index f4b9fb6..848204d 100644 --- a/src/osmo-bsc-nat/subscr_conn_fsm.c +++ b/src/osmo-bsc-nat/subscr_conn_fsm.c @@ -267,6 +267,14 @@ * reset the FSM to idle here (clears the mgw endpoint). */ osmo_fsm_inst_state_chg(fi, SUBSCR_CONN_FSM_ST_IDLE, 0, 0); break; + case SUBSCR_CONN_FSM_EV_BSSMAP_CLEAR_COMMAND: + /* Dialing an invalid number results in receiving a clear + * command from the MSC in ST_WAITING_FOR_ASSIGNMENT_COMPLETE. + * The original message gets forwarded from CN to RAN by + * bssmap_cn_handle_clear_cmd() already, so just reset the FSM + * to idle here (clears the mgw endpoint). */ + osmo_fsm_inst_state_chg(fi, SUBSCR_CONN_FSM_ST_IDLE, 0, 0); + break; default: OSMO_ASSERT(false); } @@ -395,6 +403,7 @@ .in_event_mask = 0 | X(SUBSCR_CONN_FSM_EV_BSSMAP_ASSIGNMENT_COMPLETE) | X(SUBSCR_CONN_FSM_EV_BSSMAP_ASSIGNMENT_FAILURE) + | X(SUBSCR_CONN_FSM_EV_BSSMAP_CLEAR_COMMAND) , .out_state_mask = 0 | X(SUBSCR_CONN_FSM_ST_IDLE) -- To view, visit https://gerrit.osmocom.org/c/osmo-bsc-nat/+/28240 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-bsc-nat Gerrit-Branch: master Gerrit-Change-Id: Ic0589be21f0ee4dbbbe0ffa6b0acdbe152909700 Gerrit-Change-Number: 28240 Gerrit-PatchSet: 2 Gerrit-Owner: osmith <osmith(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: neels <nhofmeyr(a)sysmocom.de> Gerrit-Reviewer: osmith <osmith(a)sysmocom.de> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: merged
1 0
0 0
Change in osmo-bsc-nat[master]: subscr_conn_fsm: handle dialing invalid number
by fixeria 09 Jun '22

09 Jun '22
Attention is currently required from: osmith, neels. fixeria has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-bsc-nat/+/28240 ) Change subject: subscr_conn_fsm: handle dialing invalid number ...................................................................... Patch Set 2: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/c/osmo-bsc-nat/+/28240 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-bsc-nat Gerrit-Branch: master Gerrit-Change-Id: Ic0589be21f0ee4dbbbe0ffa6b0acdbe152909700 Gerrit-Change-Number: 28240 Gerrit-PatchSet: 2 Gerrit-Owner: osmith <osmith(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: neels <nhofmeyr(a)sysmocom.de> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-Attention: osmith <osmith(a)sysmocom.de> Gerrit-Attention: neels <nhofmeyr(a)sysmocom.de> Gerrit-Comment-Date: Thu, 09 Jun 2022 09:49:26 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
1 0
0 0
Change in osmo-bsc-nat[master]: subscr_conn_fsm: refactor timeouts
by pespin 09 Jun '22

09 Jun '22
Attention is currently required from: osmith. pespin has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-bsc-nat/+/28249 ) Change subject: subscr_conn_fsm: refactor timeouts ...................................................................... Patch Set 2: (2 comments) File src/osmo-bsc-nat/bsc_nat.c: https://gerrit.osmocom.org/c/osmo-bsc-nat/+/28249/comment/4049e968_bbb6be89 PS2, Line 31: struct osmo_tdef g_bsc_nat_tdefs[] = { static https://gerrit.osmocom.org/c/osmo-bsc-nat/+/28249/comment/59de5da7_1493153e PS2, Line 37: struct osmo_tdef_group g_bsc_nat_tdef_group[] = { where is this used? -- To view, visit https://gerrit.osmocom.org/c/osmo-bsc-nat/+/28249 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-bsc-nat Gerrit-Branch: master Gerrit-Change-Id: Ib34e6ccc34901ebc37d2dbe347d9644cb70921ca Gerrit-Change-Number: 28249 Gerrit-PatchSet: 2 Gerrit-Owner: osmith <osmith(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-CC: pespin <pespin(a)sysmocom.de> Gerrit-Attention: osmith <osmith(a)sysmocom.de> Gerrit-Comment-Date: Thu, 09 Jun 2022 09:43:47 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: No Gerrit-MessageType: comment
1 0
0 0
Change in osmo-bsc-nat[master]: subscr_conn_fsm: refactor timeouts
by osmith 09 Jun '22

09 Jun '22
Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/c/osmo-bsc-nat/+/28249 to look at the new patch set (#2). Change subject: subscr_conn_fsm: refactor timeouts ...................................................................... subscr_conn_fsm: refactor timeouts Use osmo_tdef_state_timeout instead of passing timers every time. Rename g_mgw_tdefs to g_bsc_nat_tdefs and add the new TDEF_ASS_COMPL there, so the TDEF_MGCP can be used in subscr_conn_fsm and by mgcp client without duplicating it. Related: SYS#5560 Change-Id: Ib34e6ccc34901ebc37d2dbe347d9644cb70921ca --- M include/osmocom/bsc_nat/bsc_nat.h M src/osmo-bsc-nat/bsc_nat.c M src/osmo-bsc-nat/subscr_conn_fsm.c 3 files changed, 41 insertions(+), 25 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-bsc-nat refs/changes/49/28249/2 -- To view, visit https://gerrit.osmocom.org/c/osmo-bsc-nat/+/28249 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-bsc-nat Gerrit-Branch: master Gerrit-Change-Id: Ib34e6ccc34901ebc37d2dbe347d9644cb70921ca Gerrit-Change-Number: 28249 Gerrit-PatchSet: 2 Gerrit-Owner: osmith <osmith(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-MessageType: newpatchset
1 0
0 0
Change in osmo-bsc-nat[master]: Add subscr_conn_fsm
by osmith 09 Jun '22

09 Jun '22
osmith has submitted this change. ( https://gerrit.osmocom.org/c/osmo-bsc-nat/+/27712 ) Change subject: Add subscr_conn_fsm ...................................................................... Add subscr_conn_fsm Insert the BSCNAT's MGW into phone calls by replacing the AoIP transport layer address IE inside BSSMAP Assignment Request and Assignment Confirm. Accomplish this with a new subscr_conn_fsm that parses and stores the original ass_req / ass_conf messages, communicates with the BSCNAT MGW, and then creates new ass_req / ass_conf messages based on the original ones but with new RTP information. With this patch it is possible to do a successful voice call with the following network: MS1 --- BTS1 --- BSC1 --. | | BSCNAT ----------- MSC | | | | | '-- MGW-BSC1 --|-- MGW-BSCNAT --- MGW-MSC | | MS2 --- BTS2 --- BSC2 --' | | | | '-- MGW-BSC2 ------' Related: SYS#5560 Related: https://osmocom.org/projects/osmo-bscnat/wiki/Ladder_diagrams_for_key_proce… Change-Id: I7e491aada6f5db0eb35ef2039869c6ba07f9ca3b --- M include/osmocom/bsc_nat/Makefile.am M include/osmocom/bsc_nat/bsc_nat.h M include/osmocom/bsc_nat/bssap.h M include/osmocom/bsc_nat/subscr_conn.h A include/osmocom/bsc_nat/subscr_conn_fsm.h M src/osmo-bsc-nat/Makefile.am M src/osmo-bsc-nat/bssap_conn.c M src/osmo-bsc-nat/subscr_conn.c A src/osmo-bsc-nat/subscr_conn_fsm.c 9 files changed, 776 insertions(+), 0 deletions(-) Approvals: Jenkins Builder: Verified osmith: Looks good to me, approved diff --git a/include/osmocom/bsc_nat/Makefile.am b/include/osmocom/bsc_nat/Makefile.am index 81dacad..ebf3b0b 100644 --- a/include/osmocom/bsc_nat/Makefile.am +++ b/include/osmocom/bsc_nat/Makefile.am @@ -6,5 +6,6 @@ logging.h \ msc.h \ subscr_conn.h \ + subscr_conn_fsm.h \ vty.h \ $(NULL) diff --git a/include/osmocom/bsc_nat/bsc_nat.h b/include/osmocom/bsc_nat/bsc_nat.h index 032386a..fd2c3fb 100644 --- a/include/osmocom/bsc_nat/bsc_nat.h +++ b/include/osmocom/bsc_nat/bsc_nat.h @@ -44,6 +44,7 @@ struct { struct mgcp_client_pool *pool; struct osmo_tdef *tdefs; + uint32_t call_id_next; } mgw; struct { diff --git a/include/osmocom/bsc_nat/bssap.h b/include/osmocom/bsc_nat/bssap.h index 3fecc7d..5b7e753 100644 --- a/include/osmocom/bsc_nat/bssap.h +++ b/include/osmocom/bsc_nat/bssap.h @@ -20,6 +20,8 @@ #pragma once #include <osmocom/core/msgb.h> +#include <osmocom/core/sockaddr_str.h> +#include <osmocom/gsm/protocol/gsm_08_08.h> #include <osmocom/bsc_nat/bsc_nat.h> /* connection-less */ @@ -32,3 +34,11 @@ struct subscr_conn; int bssap_handle_dt(enum bsc_nat_net net, struct subscr_conn *subscr_conn, struct msgb *msgb, unsigned int length); + +#define bssmap_tx_assignment_failure_cn(subscr_conn, cause) \ + bssmap_tx_assignment_failure(BSC_NAT_NET_CN, subscr_conn, cause) +#define bssmap_tx_assignment_failure_ran(subscr_conn, cause) \ + bssmap_tx_assignment_failure(BSC_NAT_NET_RAN, subscr_conn, cause) +int bssmap_tx_assignment_failure(enum bsc_nat_net net, struct subscr_conn *subscr_conn, enum gsm0808_cause cause); + +int bssmap_replace_ie_aoip_transp_addr(struct msgb **msg, struct sockaddr_storage *ss); diff --git a/include/osmocom/bsc_nat/subscr_conn.h b/include/osmocom/bsc_nat/subscr_conn.h index 02a0019..f740aea 100644 --- a/include/osmocom/bsc_nat/subscr_conn.h +++ b/include/osmocom/bsc_nat/subscr_conn.h @@ -20,26 +20,45 @@ #pragma once #include <osmocom/bsc_nat/bsc_nat.h> +#include <osmocom/bsc_nat/bssap.h> /* connection for one subscriber */ struct subscr_conn { struct llist_head list; + struct osmo_fsm_inst *fi; + struct osmo_mgcpc_ep *ep; + uint32_t mgw_call_id; struct { uint32_t id; + struct osmo_mgcpc_ep_ci *ci; struct msc *msc; } cn; struct { uint32_t id; + struct osmo_mgcpc_ep_ci *ci; struct bsc *bsc; } ran; + + /* Copy of BSSMAP Assignment Request/Complete while being processed by + * subscr_conn_fsm. */ + struct { + struct msgb *msg; + struct osmo_sockaddr_str aoip_transp_addr; + } ass; }; int subscr_conn_get_next_id_ran(); +int subscr_conn_get_next_id_mgw(); struct subscr_conn *subscr_conn_alloc(struct msc *msc, struct bsc *bsc, uint32_t id_cn, uint32_t id_ran); struct subscr_conn *subscr_conn_get_by_id(uint32_t id, enum bsc_nat_net net); +int subscr_conn_rx_ass_req(struct subscr_conn *subscr_conn, const struct osmo_sockaddr_str *aoip_transp_addr, + struct msgb *msg); +int subscr_conn_rx_ass_compl(struct subscr_conn *subscr_conn, const struct osmo_sockaddr_str *aoip_transp_addr, + struct msgb *msg); + void subscr_conn_free(struct subscr_conn *subscr_conn); diff --git a/include/osmocom/bsc_nat/subscr_conn_fsm.h b/include/osmocom/bsc_nat/subscr_conn_fsm.h new file mode 100644 index 0000000..205fcb6 --- /dev/null +++ b/include/osmocom/bsc_nat/subscr_conn_fsm.h @@ -0,0 +1,30 @@ +/* (C) 2022 by sysmocom - s.f.m.c. GmbH <info(a)sysmocom.de> + * Author: Oliver Smith <osmith(a)sysmocom.de> + * All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/lienses/>. + * + */ + +#pragma once + +enum subscr_conn_fsm_events { + SUBSCR_CONN_FSM_EV_BSSMAP_ASSIGNMENT_REQUEST, + SUBSCR_CONN_FSM_EV_BSSMAP_ASSIGNMENT_COMPLETE, + SUBSCR_CONN_FSM_EV_BSSMAP_ASSIGNMENT_FAILURE, + SUBSCR_CONN_FSM_EV_BSSMAP_CLEAR_COMMAND, + SUBSCR_CONN_FSM_EV_MGCP_EP_OK, + SUBSCR_CONN_FSM_EV_MGCP_EP_FAIL, + SUBSCR_CONN_FSM_EV_MGCP_EP_TERM, +}; diff --git a/src/osmo-bsc-nat/Makefile.am b/src/osmo-bsc-nat/Makefile.am index e3f7305..f632a7d 100644 --- a/src/osmo-bsc-nat/Makefile.am +++ b/src/osmo-bsc-nat/Makefile.am @@ -36,6 +36,7 @@ msc.c \ msc_fsm.c \ subscr_conn.c \ + subscr_conn_fsm.c \ vty.c \ $(NULL) diff --git a/src/osmo-bsc-nat/bssap_conn.c b/src/osmo-bsc-nat/bssap_conn.c index 10b3a01..ec2a897 100644 --- a/src/osmo-bsc-nat/bssap_conn.c +++ b/src/osmo-bsc-nat/bssap_conn.c @@ -23,6 +23,75 @@ #include <osmocom/sigtran/sccp_helpers.h> #include <osmocom/bsc_nat/logging.h> #include <osmocom/bsc_nat/subscr_conn.h> +#include <osmocom/bsc_nat/subscr_conn_fsm.h> + +int bssmap_replace_ie_aoip_transp_addr(struct msgb **msg, struct sockaddr_storage *ss) +{ + struct msgb *msg_new; + struct msgb *msg_old = *msg; + const struct tlv_definition *def = gsm0808_att_tlvdef(); + int ofs = 1; /* first byte is bssmap message type */ + int rc; + + msg_new = msgb_alloc_headroom(BSSMAP_MSG_SIZE, BSSMAP_MSG_HEADROOM, talloc_get_name(msg_old)); + OSMO_ASSERT(msg_new); + msgb_v_put(msg_new, msg_old->l3h[0]); /* bssmap message type */ + + while (ofs < msgb_l3len(msg_old)) { + int rv; + uint8_t tag; + const uint8_t *val; + uint16_t len; + + rv = tlv_parse_one(&tag, &len, &val, def, &msg_old->l3h[ofs], msgb_l3len(msg_old) - ofs); + if (rv < 0) { + LOGP(DMAIN, LOGL_ERROR, "Failed to parse bssmap msg\n"); + msgb_free(msg_new); + return rv; + } + + if (tag == GSM0808_IE_AOIP_TRASP_ADDR) + rc = gsm0808_enc_aoip_trasp_addr(msg_new, ss); + else + rc = tlv_encode_one(msg_new, def->def[tag].type, tag, len, val); + + if (rc < 0) { + LOGP(DMAIN, LOGL_ERROR, "Failed to encode tag %d into copy of bssmap msg\n", tag); + msgb_free(msg_new); + return rc; + } + + ofs += rv; + } + + msg_new->l3h = msgb_tv_push(msg_new, BSSAP_MSG_BSS_MANAGEMENT, msgb_length(msg_new)); + msgb_free(msg_old); + *msg = msg_new; + return 0; +} + +int bssmap_tx_assignment_failure(enum bsc_nat_net net, struct subscr_conn *subscr_conn, enum gsm0808_cause cause) +{ + struct bsc_nat_sccp_inst *sccp_inst; + uint32_t id; + struct msgb *msg; + + LOGP(DMAIN, LOGL_ERROR, "Tx BSSMAP assignment failure %s to %s via %s\n", + gsm0808_cause_name(cause), + net == BSC_NAT_NET_CN ? "CN" : "RAN", + talloc_get_name(subscr_conn)); + + if (net == BSC_NAT_NET_CN) { + sccp_inst = g_bsc_nat->cn.sccp_inst; + id = subscr_conn->cn.id; + } else { + sccp_inst = g_bsc_nat->ran.sccp_inst; + id = subscr_conn->ran.id; + } + + msg = gsm0808_create_ass_fail(cause, NULL, NULL); + return osmo_sccp_tx_data_msg(sccp_inst->scu, id, msg); +} static int bssap_fwd_to_cn(struct subscr_conn *subscr_conn, struct msgb *msg, unsigned int length) { @@ -42,11 +111,131 @@ return osmo_sccp_tx_data(g_bsc_nat->ran.sccp_inst->scu, subscr_conn->ran.id, msg->data, msgb_length(msg)); } +static int bssmap_cn_handle_ass_req(struct subscr_conn *subscr_conn, struct msgb *msg, unsigned int length) +{ + struct gsm0808_channel_type ct; + struct tlv_parsed tp; + struct sockaddr_storage ss; + struct tlv_p_entry *e; + struct osmo_sockaddr_str aoip_transp_addr; + + tlv_parse(&tp, gsm0808_att_tlvdef(), msg->l3h + 1, length - 1, 0, 0); + + /* Get channel type */ + if (!(e = TLVP_GET(&tp, GSM0808_IE_CHANNEL_TYPE))) { + LOGP(DMAIN, LOGL_ERROR, "Missing IE: channel type\n"); + bssmap_tx_assignment_failure_cn(subscr_conn, GSM0808_CAUSE_INFORMATION_ELEMENT_OR_FIELD_MISSING); + return -1; + } + if (gsm0808_dec_channel_type(&ct, e->val, e->len) <= 0) { + LOGP(DMAIN, LOGL_ERROR, "Invalid IE: channel type\n"); + bssmap_tx_assignment_failure_cn(subscr_conn, GSM0808_CAUSE_INCORRECT_VALUE); + return -1; + } + + /* Not speech: fwd directly */ + if ((ct.ch_indctr & 0x0f) != GSM0808_CHAN_SPEECH) { + LOGP(DMAIN, LOGL_DEBUG, "Channel type is not speech, forwarding without modification\n"); + if (bssap_fwd_to_ran(subscr_conn, msg, length) < 0) { + bssmap_tx_assignment_failure_cn(subscr_conn, GSM0808_CAUSE_PROTOCOL_ERROR_BETWEEN_BSS_AND_MSC); + return -1; + } + return 0; + } + + /* Get AoIP transport layer address */ + if (!(e = TLVP_GET(&tp, GSM0808_IE_AOIP_TRASP_ADDR))) { + LOGP(DMAIN, LOGL_ERROR, "Missing IE: AoIP transport layer address\n"); + bssmap_tx_assignment_failure_cn(subscr_conn, GSM0808_CAUSE_INFORMATION_ELEMENT_OR_FIELD_MISSING); + return -1; + } + if (gsm0808_dec_aoip_trasp_addr(&ss, e->val, e->len) <= 0 + || osmo_sockaddr_str_from_sockaddr(&aoip_transp_addr, &ss) < 0) { + LOGP(DMAIN, LOGL_ERROR, "Invalid IE: AoIP transport layer address\n"); + bssmap_tx_assignment_failure_cn(subscr_conn, GSM0808_CAUSE_INCORRECT_VALUE); + return -1; + } + + /* Don't forward the message directly. Instead, let the subscr_conn FSM + * allocate new MGCP connections in the BSCNAT's MGW and then send a + * similar assignment request, but with the RTP address replaced. */ + if (subscr_conn_rx_ass_req(subscr_conn, &aoip_transp_addr, msg) < 0) { + bssmap_tx_assignment_failure_cn(subscr_conn, GSM0808_CAUSE_PROTOCOL_ERROR_BETWEEN_BSS_AND_MSC); + return -1; + } + + return 0; +} + +static void bssmap_ran_error_ass_compl(struct subscr_conn *subscr_conn, enum gsm0808_cause cause_ran) +{ + bssmap_tx_assignment_failure_cn(subscr_conn, GSM0808_CAUSE_PROTOCOL_ERROR_BETWEEN_BSS_AND_MSC); + bssmap_tx_assignment_failure_ran(subscr_conn, cause_ran); + + /* For the FSM, treat this the same as if the BSC had responded with + * assignment failure. */ + osmo_fsm_inst_dispatch(subscr_conn->fi, SUBSCR_CONN_FSM_EV_BSSMAP_ASSIGNMENT_FAILURE, NULL); +} + +static int bssmap_ran_handle_ass_compl(struct subscr_conn *subscr_conn, struct msgb *msg, unsigned int length) +{ + struct tlv_parsed tp; + struct sockaddr_storage ss; + struct tlv_p_entry *e; + struct osmo_sockaddr_str aoip_transp_addr; + + tlv_parse(&tp, gsm0808_att_tlvdef(), msg->l3h + 1, length - 1, 0, 0); + + /* Get AoIP transport layer address */ + if (!(e = TLVP_GET(&tp, GSM0808_IE_AOIP_TRASP_ADDR))) { + LOGP(DMAIN, LOGL_ERROR, "Missing IE: AoIP transport layer address\n"); + bssmap_ran_error_ass_compl(subscr_conn, GSM0808_CAUSE_INFORMATION_ELEMENT_OR_FIELD_MISSING); + return -1; + } + if (gsm0808_dec_aoip_trasp_addr(&ss, e->val, e->len) <= 0 + || osmo_sockaddr_str_from_sockaddr(&aoip_transp_addr, &ss) < 0) { + LOGP(DMAIN, LOGL_ERROR, "Invalid IE: AoIP transport layer address\n"); + bssmap_ran_error_ass_compl(subscr_conn, GSM0808_CAUSE_INCORRECT_VALUE); + return -1; + } + + /* Don't forward the message directly. Instead, let the subscr_conn FSM + * use the RTP info to MDCX the BSC-side connection in the BSCNAT's MGW + * and then send a similar assignment complete to the MSC, but with the + * RTP address replaced. */ + if (subscr_conn_rx_ass_compl(subscr_conn, &aoip_transp_addr, msg) < 0) { + bssmap_ran_error_ass_compl(subscr_conn, GSM0808_CAUSE_PROTOCOL_ERROR_BETWEEN_BSS_AND_MSC); + return -1; + } + + return 0; +} + +static int bssmap_ran_handle_assignment_failure(struct subscr_conn *subscr_conn, struct msgb *msg, unsigned int length) +{ + osmo_fsm_inst_dispatch(subscr_conn->fi, SUBSCR_CONN_FSM_EV_BSSMAP_ASSIGNMENT_FAILURE, NULL); + bssap_fwd_to_ran(subscr_conn, msg, length); + return 0; +} + +static int bssmap_cn_handle_clear_cmd(struct subscr_conn *subscr_conn, struct msgb *msg, unsigned int length) +{ + osmo_fsm_inst_dispatch(subscr_conn->fi, SUBSCR_CONN_FSM_EV_BSSMAP_CLEAR_COMMAND, NULL); + bssap_fwd_to_ran(subscr_conn, msg, length); + return 0; +} + static int bssmap_cn_rcvmsg_dt(struct subscr_conn *subscr_conn, struct msgb *msg, unsigned int length) { int ret = 0; switch (msg->l3h[0]) { + case BSS_MAP_MSG_ASSIGNMENT_RQST: + ret = bssmap_cn_handle_ass_req(subscr_conn, msg, length); + break; + case BSS_MAP_MSG_CLEAR_CMD: + ret = bssmap_cn_handle_clear_cmd(subscr_conn, msg, length); + break; default: ret = bssap_fwd_to_ran(subscr_conn, msg, length); break; @@ -60,6 +249,12 @@ int ret = 0; switch (msg->l3h[0]) { + case BSS_MAP_MSG_ASSIGNMENT_COMPLETE: + ret = bssmap_ran_handle_ass_compl(subscr_conn, msg, length); + break; + case BSS_MAP_MSG_ASSIGNMENT_FAILURE: + ret = bssmap_ran_handle_assignment_failure(subscr_conn, msg, length); + break; default: ret = bssap_fwd_to_cn(subscr_conn, msg, length); break; diff --git a/src/osmo-bsc-nat/subscr_conn.c b/src/osmo-bsc-nat/subscr_conn.c index a94287c..ed35899 100644 --- a/src/osmo-bsc-nat/subscr_conn.c +++ b/src/osmo-bsc-nat/subscr_conn.c @@ -26,6 +26,8 @@ #include <osmocom/bsc_nat/subscr_conn.h> #include <osmocom/bsc_nat/logging.h> +extern struct osmo_fsm subscr_conn_fsm; + int subscr_conn_get_next_id_ran() { uint32_t *id = &g_bsc_nat->ran.subscr_conn_id_next; @@ -49,6 +51,29 @@ return -1; } +int subscr_conn_get_next_id_mgw() +{ + uint32_t *id = &g_bsc_nat->mgw.call_id_next; + + for (int i = 0; i < 0xFFFFFF; i++) { + struct subscr_conn *subscr_conn; + bool already_used = false; + + *id = (*id + 1) & 0xffffff; + + llist_for_each_entry(subscr_conn, &g_bsc_nat->subscr_conns, list) { + if (*id == subscr_conn->mgw_call_id) { + already_used = true; + break; + } + } + + if (!already_used) + return *id; + } + return -1; +} + struct subscr_conn *subscr_conn_alloc(struct msc *msc, struct bsc *bsc, uint32_t id_cn, uint32_t id_ran) { struct subscr_conn *subscr_conn = talloc_zero(g_bsc_nat, struct subscr_conn); @@ -60,6 +85,9 @@ LOGP(DMAIN, LOGL_DEBUG, "Add %s\n", talloc_get_name(subscr_conn)); + subscr_conn->fi = osmo_fsm_inst_alloc(&subscr_conn_fsm, subscr_conn, subscr_conn, LOGL_INFO, NULL); + OSMO_ASSERT(subscr_conn->fi); + subscr_conn->cn.id = id_cn; subscr_conn->cn.msc = msc; subscr_conn->ran.id = id_ran; @@ -88,5 +116,6 @@ { LOGP(DMAIN, LOGL_DEBUG, "Del %s\n", talloc_get_name(subscr_conn)); llist_del(&subscr_conn->list); + osmo_fsm_inst_free(subscr_conn->fi); talloc_free(subscr_conn); } diff --git a/src/osmo-bsc-nat/subscr_conn_fsm.c b/src/osmo-bsc-nat/subscr_conn_fsm.c new file mode 100644 index 0000000..f4b9fb6 --- /dev/null +++ b/src/osmo-bsc-nat/subscr_conn_fsm.c @@ -0,0 +1,490 @@ +/* (C) 2022 by sysmocom - s.f.m.c. GmbH <info(a)sysmocom.de> + * Author: Oliver Smith <osmith(a)sysmocom.de> + * All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/lienses/>. + * + */ + +#include "config.h" +#include <inttypes.h> +#include <osmocom/core/fsm.h> +#include <osmocom/gsm/gsm0808.h> +#include <osmocom/mgcp_client/mgcp_client_endpoint_fsm.h> +#include <osmocom/mgcp_client/mgcp_client_fsm.h> +#include <osmocom/sigtran/sccp_helpers.h> +#include <osmocom/bsc_nat/bsc_nat.h> +#include <osmocom/bsc_nat/bssap.h> +#include <osmocom/bsc_nat/logging.h> +#include <osmocom/bsc_nat/subscr_conn.h> +#include <osmocom/bsc_nat/subscr_conn_fsm.h> + +#define X(s) (1 << (s)) +#define TIMEOUT_MGW 10 +#define TIMEOUT_BSC 20 + +enum subscr_conn_fsm_states { + SUBSCR_CONN_FSM_ST_IDLE, + SUBSCR_CONN_FSM_ST_PROCESSING_ASSIGNMENT_REQUEST_CRCX_CN, + SUBSCR_CONN_FSM_ST_PROCESSING_ASSIGNMENT_REQUEST_MDCX_CN, + SUBSCR_CONN_FSM_ST_PROCESSING_ASSIGNMENT_REQUEST_CRCX_RAN, + SUBSCR_CONN_FSM_ST_WAITING_FOR_ASSIGNMENT_COMPLETE, + SUBSCR_CONN_FSM_ST_PROCESSING_ASSIGNMENT_COMPLETE_MDCX_RAN, + SUBSCR_CONN_FSM_ST_WAITING_FOR_CLEAR_COMMAND, +}; + +static int tx_ass_req_to_ran(struct subscr_conn *subscr_conn) +{ + const struct mgcp_conn_peer *rtp_info; + struct sockaddr_storage ss; + struct osmo_sockaddr_str aoip_transp_addr; + int rc; + + /* Fill sockaddr_storage from rtp_info */ + rtp_info = osmo_mgcpc_ep_ci_get_rtp_info(subscr_conn->ran.ci); + if (!rtp_info) { + LOGPFSML(subscr_conn->fi, LOGL_ERROR, "Failed to get RTP info from MGW, aborting assignment request\n"); + return -1; + } + if (osmo_sockaddr_str_from_str(&aoip_transp_addr, rtp_info->addr, rtp_info->port) < 0 + || osmo_sockaddr_str_to_sockaddr((const struct osmo_sockaddr_str *)&aoip_transp_addr, &ss) < 0) { + LOGPFSML(subscr_conn->fi, LOGL_ERROR, "RTP info from MGW is invalid, aborting assignment request\n"); + return -1; + } + + if (bssmap_replace_ie_aoip_transp_addr(&subscr_conn->ass.msg, &ss) < 0) { + LOGPFSML(subscr_conn->fi, LOGL_ERROR, "Failed to replace AoIP transport layer address, aborting" + " assignment request\n"); + return -1; + } + + rc = osmo_sccp_tx_data_msg(g_bsc_nat->ran.sccp_inst->scu, subscr_conn->ran.id, subscr_conn->ass.msg); + subscr_conn->ass.msg = NULL; + return rc; +} + +static int tx_ass_compl_to_cn(struct subscr_conn *subscr_conn) +{ + const struct mgcp_conn_peer *rtp_info; + struct sockaddr_storage ss; + struct osmo_sockaddr_str aoip_transp_addr; + int rc; + + /* Fill sockaddr_storage from rtp_info */ + rtp_info = osmo_mgcpc_ep_ci_get_rtp_info(subscr_conn->cn.ci); + if (!rtp_info) { + LOGPFSML(subscr_conn->fi, LOGL_ERROR, "Failed to get RTP info from MGW, aborting assignment complete\n"); + return -1; + } + if (osmo_sockaddr_str_from_str(&aoip_transp_addr, rtp_info->addr, rtp_info->port) < 0 + || osmo_sockaddr_str_to_sockaddr((const struct osmo_sockaddr_str *)&aoip_transp_addr, &ss) < 0) { + LOGPFSML(subscr_conn->fi, LOGL_ERROR, "RTP info from MGW is invalid, aborting assignment complete\n"); + return -1; + } + + if (bssmap_replace_ie_aoip_transp_addr(&subscr_conn->ass.msg, &ss) < 0) { + LOGPFSML(subscr_conn->fi, LOGL_ERROR, "Failed to replace AoIP transport layer address, aborting" + " assignment complete\n"); + return -1; + } + + rc = osmo_sccp_tx_data_msg(g_bsc_nat->cn.sccp_inst->scu, subscr_conn->cn.id, subscr_conn->ass.msg); + subscr_conn->ass.msg = NULL; + return rc; +} + + +static void st_idle_on_enter(struct osmo_fsm_inst *fi, uint32_t prev_state) +{ + struct subscr_conn *subscr_conn = (struct subscr_conn *)fi->priv; + if (!subscr_conn->ep) + return; + + osmo_mgcpc_ep_clear(subscr_conn->ep); + + subscr_conn->ep = NULL; + subscr_conn->ran.ci = NULL; + subscr_conn->cn.ci = NULL; +} + +static void st_idle(struct osmo_fsm_inst *fi, uint32_t event, void *data) +{ + switch (event) { + case SUBSCR_CONN_FSM_EV_BSSMAP_ASSIGNMENT_REQUEST: + osmo_fsm_inst_state_chg(fi, SUBSCR_CONN_FSM_ST_PROCESSING_ASSIGNMENT_REQUEST_CRCX_CN, TIMEOUT_MGW, 0); + break; + case SUBSCR_CONN_FSM_EV_MGCP_EP_TERM: + /* This event is expected, as we terminate the MGCP EP in + * st_idle_on_enter(). Nothing to do here. */ + break; + case SUBSCR_CONN_FSM_EV_BSSMAP_CLEAR_COMMAND: + /* Clear commands sent to this FSM in idle state are not + * relevant, so ignore them here. bssmap_cn_handle_clear_cmd() + * forwards them from CN to RAN. */ + break; + default: + OSMO_ASSERT(false); + } +} + +static void st_processing_ass_req_crcx_cn_on_enter(struct osmo_fsm_inst *fi, uint32_t prev_stat) +{ + struct mgcp_client *mgcp_client; + struct mgcp_conn_peer crcx_info = {}; + struct subscr_conn *subscr_conn = (struct subscr_conn *)fi->priv; + int call_id = subscr_conn_get_next_id_mgw(); + + if (call_id < 0) { + LOGPFSML(fi, LOGL_ERROR, "Failed to get next_id_mgw, aborting assignment request processing\n"); + bssmap_tx_assignment_failure_cn(subscr_conn, GSM0808_CAUSE_PROTOCOL_ERROR_BETWEEN_BSS_AND_MSC); + osmo_fsm_inst_state_chg(fi, SUBSCR_CONN_FSM_ST_IDLE, 0, 0); + } + + /* MGCP EP */ + mgcp_client = mgcp_client_pool_get(g_bsc_nat->mgw.pool); + OSMO_ASSERT(mgcp_client); + subscr_conn->ep = osmo_mgcpc_ep_alloc(subscr_conn->fi, SUBSCR_CONN_FSM_EV_MGCP_EP_TERM, mgcp_client, + g_bsc_nat->mgw.tdefs, "SUBSCR-CONN-EP", + mgcp_client_rtpbridge_wildcard(mgcp_client)); + + /* MGCP CRCX CN */ + LOGPFSML(fi, LOGL_DEBUG, "Set MGW call_id=%d for %s\n", call_id, talloc_get_name(subscr_conn)); + crcx_info.call_id = subscr_conn->mgw_call_id = call_id; + subscr_conn->cn.ci = osmo_mgcpc_ep_ci_add(subscr_conn->ep, "CI-%"PRIu32"-CN", crcx_info.call_id); + osmo_mgcpc_ep_ci_request(subscr_conn->cn.ci, MGCP_VERB_CRCX, &crcx_info, subscr_conn->fi, + SUBSCR_CONN_FSM_EV_MGCP_EP_OK, SUBSCR_CONN_FSM_EV_MGCP_EP_FAIL, NULL); +} + +static void st_processing_ass_req_crcx_cn(struct osmo_fsm_inst *fi, uint32_t event, void *data) +{ + struct subscr_conn *subscr_conn = (struct subscr_conn *)fi->priv; + + switch (event) { + case SUBSCR_CONN_FSM_EV_MGCP_EP_OK: + LOGPFSML(fi, LOGL_DEBUG, "Rx MGCP OK\n"); + osmo_fsm_inst_state_chg(fi, SUBSCR_CONN_FSM_ST_PROCESSING_ASSIGNMENT_REQUEST_MDCX_CN, TIMEOUT_MGW, 0); + break; + case SUBSCR_CONN_FSM_EV_MGCP_EP_FAIL: + LOGPFSML(fi, LOGL_ERROR, "MGCP failure, aborting assignment request processing\n"); + bssmap_tx_assignment_failure_cn(subscr_conn, GSM0808_CAUSE_PROTOCOL_ERROR_BETWEEN_BSS_AND_MSC); + osmo_fsm_inst_state_chg(fi, SUBSCR_CONN_FSM_ST_IDLE, 0, 0); + break; + default: + OSMO_ASSERT(false); + } +} + +static void st_processing_ass_req_mdcx_cn_on_enter(struct osmo_fsm_inst *fi, uint32_t prev_stat) +{ + struct mgcp_conn_peer mdcx_info = {}; + struct subscr_conn *subscr_conn = (struct subscr_conn *)fi->priv; + struct osmo_sockaddr_str *addr = &subscr_conn->ass.aoip_transp_addr; + + /* Set RTP addr + port */ + osmo_static_assert(sizeof(mdcx_info.addr) == sizeof(addr->ip), sizeof_addr); + memcpy(mdcx_info.addr, addr->ip, sizeof(mdcx_info.addr)); + mdcx_info.port = addr->port; + + /* MGCP MDCX CN */ + osmo_mgcpc_ep_ci_request(subscr_conn->cn.ci, MGCP_VERB_MDCX, &mdcx_info, subscr_conn->fi, + SUBSCR_CONN_FSM_EV_MGCP_EP_OK, SUBSCR_CONN_FSM_EV_MGCP_EP_FAIL, NULL); +} + +static void st_processing_ass_req_mdcx_cn(struct osmo_fsm_inst *fi, uint32_t event, void *data) +{ + struct subscr_conn *subscr_conn = (struct subscr_conn *)fi->priv; + + switch (event) { + case SUBSCR_CONN_FSM_EV_MGCP_EP_OK: + LOGPFSML(fi, LOGL_DEBUG, "Rx MGCP OK\n"); + osmo_fsm_inst_state_chg(fi, SUBSCR_CONN_FSM_ST_PROCESSING_ASSIGNMENT_REQUEST_CRCX_RAN, TIMEOUT_MGW, 0); + break; + case SUBSCR_CONN_FSM_EV_MGCP_EP_FAIL: + LOGPFSML(fi, LOGL_ERROR, "MGCP failure, aborting assignment request processing\n"); + bssmap_tx_assignment_failure_cn(subscr_conn, GSM0808_CAUSE_PROTOCOL_ERROR_BETWEEN_BSS_AND_MSC); + osmo_fsm_inst_state_chg(fi, SUBSCR_CONN_FSM_ST_IDLE, 0, 0); + break; + default: + OSMO_ASSERT(false); + } +} + +static void st_processing_ass_req_crcx_ran_on_enter(struct osmo_fsm_inst *fi, uint32_t prev_stat) +{ + struct subscr_conn *subscr_conn = (struct subscr_conn *)fi->priv; + struct mgcp_conn_peer crcx_info = {}; + crcx_info.call_id = subscr_conn->mgw_call_id; + + subscr_conn->ran.ci = osmo_mgcpc_ep_ci_add(subscr_conn->ep, "CI-%"PRIu32"-RAN", crcx_info.call_id); + osmo_mgcpc_ep_ci_request(subscr_conn->ran.ci, MGCP_VERB_CRCX, &crcx_info, subscr_conn->fi, + SUBSCR_CONN_FSM_EV_MGCP_EP_OK, SUBSCR_CONN_FSM_EV_MGCP_EP_FAIL, NULL); +} + +static void st_processing_ass_req_crcx_ran(struct osmo_fsm_inst *fi, uint32_t event, void *data) +{ + struct subscr_conn *subscr_conn = (struct subscr_conn *)fi->priv; + + switch (event) { + case SUBSCR_CONN_FSM_EV_MGCP_EP_OK: + LOGPFSML(fi, LOGL_DEBUG, "Rx MGCP OK\n"); + if (tx_ass_req_to_ran(subscr_conn) < 0) { + bssmap_tx_assignment_failure_cn(subscr_conn, GSM0808_CAUSE_PROTOCOL_ERROR_BETWEEN_BSS_AND_MSC); + osmo_fsm_inst_state_chg(fi, SUBSCR_CONN_FSM_ST_IDLE, 0, 0); + return; + } + osmo_fsm_inst_state_chg(fi, SUBSCR_CONN_FSM_ST_WAITING_FOR_ASSIGNMENT_COMPLETE, TIMEOUT_BSC, 0); + break; + case SUBSCR_CONN_FSM_EV_MGCP_EP_FAIL: + LOGPFSML(fi, LOGL_ERROR, "MGCP failure, aborting assignment request processing\n"); + bssmap_tx_assignment_failure_cn(subscr_conn, GSM0808_CAUSE_PROTOCOL_ERROR_BETWEEN_BSS_AND_MSC); + osmo_fsm_inst_state_chg(fi, SUBSCR_CONN_FSM_ST_IDLE, 0, 0); + break; + default: + OSMO_ASSERT(false); + } +} + +static void st_waiting_for_ass_compl(struct osmo_fsm_inst *fi, uint32_t event, void *data) +{ + switch (event) { + case SUBSCR_CONN_FSM_EV_BSSMAP_ASSIGNMENT_COMPLETE: + osmo_fsm_inst_state_chg(fi, SUBSCR_CONN_FSM_ST_PROCESSING_ASSIGNMENT_COMPLETE_MDCX_RAN, TIMEOUT_MGW, 0); + break; + case SUBSCR_CONN_FSM_EV_BSSMAP_ASSIGNMENT_FAILURE: + /* The original bssmap message gets forwarded from RAN to CN by + * bssmap_ran_handle_assignment_failure() already, so just + * reset the FSM to idle here (clears the mgw endpoint). */ + osmo_fsm_inst_state_chg(fi, SUBSCR_CONN_FSM_ST_IDLE, 0, 0); + break; + default: + OSMO_ASSERT(false); + } +} + +static void st_processing_ass_compl_mdcx_ran_on_enter(struct osmo_fsm_inst *fi, uint32_t prev_stat) +{ + struct mgcp_conn_peer mdcx_info = {}; + struct subscr_conn *subscr_conn = (struct subscr_conn *)fi->priv; + struct osmo_sockaddr_str *aoip_transp_addr = &subscr_conn->ass.aoip_transp_addr; + + /* Set RTP addr + port */ + osmo_static_assert(sizeof(mdcx_info.addr) == sizeof(aoip_transp_addr->ip), sizeof_addr); + memcpy(mdcx_info.addr, aoip_transp_addr->ip, sizeof(mdcx_info.addr)); + mdcx_info.port = aoip_transp_addr->port; + + /* MGCP MDCX RAN */ + osmo_mgcpc_ep_ci_request(subscr_conn->ran.ci, MGCP_VERB_MDCX, &mdcx_info, subscr_conn->fi, + SUBSCR_CONN_FSM_EV_MGCP_EP_OK, SUBSCR_CONN_FSM_EV_MGCP_EP_FAIL, NULL); +} + +static void st_processing_ass_compl_mdcx_ran(struct osmo_fsm_inst *fi, uint32_t event, void *data) +{ + struct subscr_conn *subscr_conn = (struct subscr_conn *)fi->priv; + + switch (event) { + case SUBSCR_CONN_FSM_EV_MGCP_EP_OK: + LOGPFSML(fi, LOGL_DEBUG, "Rx MGCP EP OK\n"); + if (tx_ass_compl_to_cn(subscr_conn) < 0) { + bssmap_tx_assignment_failure_cn(subscr_conn, GSM0808_CAUSE_PROTOCOL_ERROR_BETWEEN_BSS_AND_MSC); + bssmap_tx_assignment_failure_ran(subscr_conn, GSM0808_CAUSE_PROTOCOL_ERROR_BETWEEN_BSS_AND_MSC); + osmo_fsm_inst_state_chg(fi, SUBSCR_CONN_FSM_ST_IDLE, 0, 0); + return; + } + /* No timeout for ST_WAITING_FOR_CLEAR_COMMAND, as the FSM will + * stay in this state until the call is done. */ + osmo_fsm_inst_state_chg(fi, SUBSCR_CONN_FSM_ST_WAITING_FOR_CLEAR_COMMAND, 0, 0); + break; + case SUBSCR_CONN_FSM_EV_MGCP_EP_FAIL: + LOGPFSML(fi, LOGL_ERROR, "MGCP failure, aborting assignment complete processing\n"); + bssmap_tx_assignment_failure_cn(subscr_conn, GSM0808_CAUSE_PROTOCOL_ERROR_BETWEEN_BSS_AND_MSC); + bssmap_tx_assignment_failure_ran(subscr_conn, GSM0808_CAUSE_PROTOCOL_ERROR_BETWEEN_BSS_AND_MSC); + osmo_fsm_inst_state_chg(fi, SUBSCR_CONN_FSM_ST_IDLE, 0, 0); + break; + default: + OSMO_ASSERT(false); + } +} + +static void st_waiting_for_clear_command(struct osmo_fsm_inst *fi, uint32_t event, void *data) +{ + switch (event) { + case SUBSCR_CONN_FSM_EV_BSSMAP_CLEAR_COMMAND: + /* The original bssmap message gets forwarded from CN to RAN by + * bssmap_cn_handle_clear_cmd() already, so just reset the FSM + * to idle here (clears the mgw endpoint). */ + osmo_fsm_inst_state_chg(fi, SUBSCR_CONN_FSM_ST_IDLE, 0, 0); + break; + default: + OSMO_ASSERT(false); + } +} + +int subscr_conn_fsm_timer_cb(struct osmo_fsm_inst *fi) +{ + LOGPFSML(fi, LOGL_ERROR, "Timeout reached, reset FSM to idle\n"); + osmo_fsm_inst_state_chg(fi, SUBSCR_CONN_FSM_ST_IDLE, 0, 0); + return 0; +} + +static struct osmo_fsm_state subscr_conn_fsm_states[] = { + [SUBSCR_CONN_FSM_ST_IDLE] = { + .name = "IDLE", + .in_event_mask = 0 + | X(SUBSCR_CONN_FSM_EV_BSSMAP_ASSIGNMENT_REQUEST) + | X(SUBSCR_CONN_FSM_EV_BSSMAP_CLEAR_COMMAND) + | X(SUBSCR_CONN_FSM_EV_MGCP_EP_TERM) + , + .out_state_mask = 0 + | X(SUBSCR_CONN_FSM_ST_PROCESSING_ASSIGNMENT_REQUEST_CRCX_CN) + , + .action = st_idle, + .onenter = st_idle_on_enter, + }, + [SUBSCR_CONN_FSM_ST_PROCESSING_ASSIGNMENT_REQUEST_CRCX_CN] = { + .name = "PROCESSING_ASSIGNMENT_REQUEST_CRCX_CN", + .in_event_mask = 0 + | X(SUBSCR_CONN_FSM_EV_MGCP_EP_OK) + | X(SUBSCR_CONN_FSM_EV_MGCP_EP_FAIL) + , + .out_state_mask = 0 + | X(SUBSCR_CONN_FSM_ST_IDLE) + | X(SUBSCR_CONN_FSM_ST_PROCESSING_ASSIGNMENT_REQUEST_MDCX_CN) + , + .action = st_processing_ass_req_crcx_cn, + .onenter = st_processing_ass_req_crcx_cn_on_enter, + }, + [SUBSCR_CONN_FSM_ST_PROCESSING_ASSIGNMENT_REQUEST_MDCX_CN] = { + .name = "PROCESSING_ASSIGNMENT_REQUEST_MDCX_CN", + .in_event_mask = 0 + | X(SUBSCR_CONN_FSM_EV_MGCP_EP_OK) + | X(SUBSCR_CONN_FSM_EV_MGCP_EP_FAIL) + , + .out_state_mask = 0 + | X(SUBSCR_CONN_FSM_ST_IDLE) + | X(SUBSCR_CONN_FSM_ST_PROCESSING_ASSIGNMENT_REQUEST_CRCX_RAN) + , + .action = st_processing_ass_req_mdcx_cn, + .onenter = st_processing_ass_req_mdcx_cn_on_enter, + }, + [SUBSCR_CONN_FSM_ST_PROCESSING_ASSIGNMENT_REQUEST_CRCX_RAN] = { + .name = "PROCESSING_ASSIGNMENT_REQUEST_CRCX_RAN", + .in_event_mask = 0 + | X(SUBSCR_CONN_FSM_EV_MGCP_EP_OK) + | X(SUBSCR_CONN_FSM_EV_MGCP_EP_FAIL) + , + .out_state_mask = 0 + | X(SUBSCR_CONN_FSM_ST_IDLE) + | X(SUBSCR_CONN_FSM_ST_WAITING_FOR_ASSIGNMENT_COMPLETE) + , + .action = st_processing_ass_req_crcx_ran, + .onenter = st_processing_ass_req_crcx_ran_on_enter, + }, + [SUBSCR_CONN_FSM_ST_WAITING_FOR_ASSIGNMENT_COMPLETE] = { + .name = "WAITING_FOR_ASSIGNMENT_COMPLETE", + .in_event_mask = 0 + | X(SUBSCR_CONN_FSM_EV_BSSMAP_ASSIGNMENT_COMPLETE) + | X(SUBSCR_CONN_FSM_EV_BSSMAP_ASSIGNMENT_FAILURE) + , + .out_state_mask = 0 + | X(SUBSCR_CONN_FSM_ST_IDLE) + | X(SUBSCR_CONN_FSM_ST_PROCESSING_ASSIGNMENT_COMPLETE_MDCX_RAN) + , + .action = st_waiting_for_ass_compl, + }, + [SUBSCR_CONN_FSM_ST_PROCESSING_ASSIGNMENT_COMPLETE_MDCX_RAN] = { + .name = "PROCESSING_ASSIGNMENT_COMPLETE", + .in_event_mask = 0 + | X(SUBSCR_CONN_FSM_EV_MGCP_EP_OK) + | X(SUBSCR_CONN_FSM_EV_MGCP_EP_FAIL) + , + .out_state_mask = 0 + | X(SUBSCR_CONN_FSM_ST_IDLE) + | X(SUBSCR_CONN_FSM_ST_WAITING_FOR_CLEAR_COMMAND) + , + .action = st_processing_ass_compl_mdcx_ran, + .onenter = st_processing_ass_compl_mdcx_ran_on_enter, + }, + [SUBSCR_CONN_FSM_ST_WAITING_FOR_CLEAR_COMMAND] = { + .name = "WAITING_FOR_CLEAR_COMMAND", + .in_event_mask = 0 + | X(SUBSCR_CONN_FSM_EV_BSSMAP_CLEAR_COMMAND) + , + .out_state_mask = 0 + | X(SUBSCR_CONN_FSM_ST_IDLE) + , + .action = st_waiting_for_clear_command, + }, +}; + +const struct value_string subscr_conn_fsm_event_names[] = { + OSMO_VALUE_STRING(SUBSCR_CONN_FSM_EV_BSSMAP_ASSIGNMENT_REQUEST), + OSMO_VALUE_STRING(SUBSCR_CONN_FSM_EV_BSSMAP_ASSIGNMENT_COMPLETE), + OSMO_VALUE_STRING(SUBSCR_CONN_FSM_EV_BSSMAP_ASSIGNMENT_FAILURE), + OSMO_VALUE_STRING(SUBSCR_CONN_FSM_EV_BSSMAP_CLEAR_COMMAND), + OSMO_VALUE_STRING(SUBSCR_CONN_FSM_EV_MGCP_EP_OK), + OSMO_VALUE_STRING(SUBSCR_CONN_FSM_EV_MGCP_EP_FAIL), + OSMO_VALUE_STRING(SUBSCR_CONN_FSM_EV_MGCP_EP_TERM), + { 0, NULL } +}; + +struct osmo_fsm subscr_conn_fsm = { + .name = "SUBSCR_CONN", + .states = subscr_conn_fsm_states, + .num_states = ARRAY_SIZE(subscr_conn_fsm_states), + .log_subsys = DMAIN, + .event_names = subscr_conn_fsm_event_names, + .timer_cb = subscr_conn_fsm_timer_cb, +}; + +static void ass_update(struct subscr_conn *subscr_conn, const struct osmo_sockaddr_str *aoip_transp_addr, + struct msgb *msg) +{ + struct msgb *copy = msgb_copy_c(subscr_conn, msg, talloc_get_name(msg)); + OSMO_ASSERT(copy); + + if (subscr_conn->ass.msg) + msgb_free(subscr_conn->ass.msg); + + subscr_conn->ass.msg = copy; + subscr_conn->ass.aoip_transp_addr = *aoip_transp_addr; +} + +int subscr_conn_rx_ass_req(struct subscr_conn *subscr_conn, const struct osmo_sockaddr_str *aoip_transp_addr, + struct msgb *msg) +{ + if (subscr_conn->fi->state != SUBSCR_CONN_FSM_ST_IDLE) { + LOGPFSML(subscr_conn->fi, LOGL_ERROR, "Unexpected Rx BSSMAP assignment request\n"); + return -1; + } + + ass_update(subscr_conn, aoip_transp_addr, msg); + return osmo_fsm_inst_dispatch(subscr_conn->fi, SUBSCR_CONN_FSM_EV_BSSMAP_ASSIGNMENT_REQUEST, NULL); +} + +int subscr_conn_rx_ass_compl(struct subscr_conn *subscr_conn, const struct osmo_sockaddr_str *aoip_transp_addr, + struct msgb *msg) +{ + if (subscr_conn->fi->state != SUBSCR_CONN_FSM_ST_WAITING_FOR_ASSIGNMENT_COMPLETE) { + LOGPFSML(subscr_conn->fi, LOGL_ERROR, "Unexpected Rx BSSMAP assignment complete\n"); + return -1; + } + + ass_update(subscr_conn, aoip_transp_addr, msg); + return osmo_fsm_inst_dispatch(subscr_conn->fi, SUBSCR_CONN_FSM_EV_BSSMAP_ASSIGNMENT_COMPLETE, NULL); +} + +static __attribute__((constructor)) void subscr_conn_fsm_init(void) +{ + OSMO_ASSERT(osmo_fsm_register(&subscr_conn_fsm) == 0); +} -- To view, visit https://gerrit.osmocom.org/c/osmo-bsc-nat/+/27712 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-bsc-nat Gerrit-Branch: master Gerrit-Change-Id: I7e491aada6f5db0eb35ef2039869c6ba07f9ca3b Gerrit-Change-Number: 27712 Gerrit-PatchSet: 7 Gerrit-Owner: osmith <osmith(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: neels <nhofmeyr(a)sysmocom.de> Gerrit-Reviewer: osmith <osmith(a)sysmocom.de> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: merged
1 0
0 0
Change in osmo-bsc-nat[master]: Add subscr_conn_fsm
by osmith 09 Jun '22

09 Jun '22
Attention is currently required from: neels, laforge, pespin, fixeria. osmith has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-bsc-nat/+/27712 ) Change subject: Add subscr_conn_fsm ...................................................................... Patch Set 7: Code-Review+2 (6 comments) Patchset: PS7: re-applying +2 after minor changes File include/osmocom/bsc_nat/subscr_conn_fsm.h: https://gerrit.osmocom.org/c/osmo-bsc-nat/+/27712/comment/3c1f6b7d_e591ce54 PS6, Line 31: > (doesn't the linter complain about trailing blank lines?) nope File src/osmo-bsc-nat/bssap_conn.c: https://gerrit.osmocom.org/c/osmo-bsc-nat/+/27712/comment/50f57106_08e5de5d PS4, Line 47: uint8_t tag = tag_order[i]; > Pau is correct that it would indeed be possible to copy the part leading up to the changed IE and th […] Done File src/osmo-bsc-nat/bssap_conn.c: https://gerrit.osmocom.org/c/osmo-bsc-nat/+/27712/comment/4b9e740f_bbe3a730 PS6, Line 49: goto error; bug: rc would be uninitialized here, fixed in patchset 7 https://gerrit.osmocom.org/c/osmo-bsc-nat/+/27712/comment/576c8e95_4ac7c524 PS6, Line 228: > (1 blank line) Done File src/osmo-bsc-nat/subscr_conn_fsm.c: https://gerrit.osmocom.org/c/osmo-bsc-nat/+/27712/comment/ebfed292_af5fcd6d PS6, Line 262: osmo_fsm_inst_state_chg(fi, SUBSCR_CONN_FSM_ST_PROCESSING_ASSIGNMENT_COMPLETE_MDCX_RAN, TIMEOUT_MGW, 0); > Did you think about using osmo_tdef_state_timeout instead of passing timers every time? It's easier […] Thanks! Done in new patch: https://gerrit.osmocom.org/c/osmo-bsc-nat/+/28249/1 -- To view, visit https://gerrit.osmocom.org/c/osmo-bsc-nat/+/27712 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-bsc-nat Gerrit-Branch: master Gerrit-Change-Id: I7e491aada6f5db0eb35ef2039869c6ba07f9ca3b Gerrit-Change-Number: 27712 Gerrit-PatchSet: 7 Gerrit-Owner: osmith <osmith(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: neels <nhofmeyr(a)sysmocom.de> Gerrit-Reviewer: osmith <osmith(a)sysmocom.de> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-Attention: neels <nhofmeyr(a)sysmocom.de> Gerrit-Attention: laforge <laforge(a)osmocom.org> Gerrit-Attention: pespin <pespin(a)sysmocom.de> Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Comment-Date: Thu, 09 Jun 2022 09:30:53 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: Yes Comment-In-Reply-To: osmith <osmith(a)sysmocom.de> Comment-In-Reply-To: neels <nhofmeyr(a)sysmocom.de> Comment-In-Reply-To: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: comment
1 0
0 0
Change in osmo-bsc-nat[master]: Add subscr_conn_fsm
by osmith 09 Jun '22

09 Jun '22
Attention is currently required from: osmith, laforge, pespin, fixeria. Hello Jenkins Builder, neels, laforge, pespin, fixeria, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/c/osmo-bsc-nat/+/27712 to look at the new patch set (#7). Change subject: Add subscr_conn_fsm ...................................................................... Add subscr_conn_fsm Insert the BSCNAT's MGW into phone calls by replacing the AoIP transport layer address IE inside BSSMAP Assignment Request and Assignment Confirm. Accomplish this with a new subscr_conn_fsm that parses and stores the original ass_req / ass_conf messages, communicates with the BSCNAT MGW, and then creates new ass_req / ass_conf messages based on the original ones but with new RTP information. With this patch it is possible to do a successful voice call with the following network: MS1 --- BTS1 --- BSC1 --. | | BSCNAT ----------- MSC | | | | | '-- MGW-BSC1 --|-- MGW-BSCNAT --- MGW-MSC | | MS2 --- BTS2 --- BSC2 --' | | | | '-- MGW-BSC2 ------' Related: SYS#5560 Related: https://osmocom.org/projects/osmo-bscnat/wiki/Ladder_diagrams_for_key_proce… Change-Id: I7e491aada6f5db0eb35ef2039869c6ba07f9ca3b --- M include/osmocom/bsc_nat/Makefile.am M include/osmocom/bsc_nat/bsc_nat.h M include/osmocom/bsc_nat/bssap.h M include/osmocom/bsc_nat/subscr_conn.h A include/osmocom/bsc_nat/subscr_conn_fsm.h M src/osmo-bsc-nat/Makefile.am M src/osmo-bsc-nat/bssap_conn.c M src/osmo-bsc-nat/subscr_conn.c A src/osmo-bsc-nat/subscr_conn_fsm.c 9 files changed, 776 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-bsc-nat refs/changes/12/27712/7 -- To view, visit https://gerrit.osmocom.org/c/osmo-bsc-nat/+/27712 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-bsc-nat Gerrit-Branch: master Gerrit-Change-Id: I7e491aada6f5db0eb35ef2039869c6ba07f9ca3b Gerrit-Change-Number: 27712 Gerrit-PatchSet: 7 Gerrit-Owner: osmith <osmith(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: neels <nhofmeyr(a)sysmocom.de> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-Attention: osmith <osmith(a)sysmocom.de> Gerrit-Attention: laforge <laforge(a)osmocom.org> Gerrit-Attention: pespin <pespin(a)sysmocom.de> Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-MessageType: newpatchset
1 0
0 0
  • ← Newer
  • 1
  • ...
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • ...
  • 138
  • Older →

HyperKitty Powered by HyperKitty version 1.3.12.