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 -----
  • 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

March 2025

  • 1 participants
  • 1378 discussions
[M] Change in libosmo-sigtran[master]: ASP loadsharing: Pass ownership of Tx xua_msg down the stack [1/2]
by pespin 06 Mar '25

06 Mar '25
pespin has submitted this change. ( https://gerrit.osmocom.org/c/libosmo-sigtran/+/39396?usp=email ) ( 10 is the latest approved patch-set. No files were changed between the latest approved patch-set and the submitted one. )Change subject: ASP loadsharing: Pass ownership of Tx xua_msg down the stack [1/2] ...................................................................... ASP loadsharing: Pass ownership of Tx xua_msg down the stack [1/2] This is a first step towards getting MTP OPC & SLS fields down the stack so that they can be used to implement loadsharing at ASP level. So far, we always encode the xua_msg (which holds the OPC and SLS info into xua_msg->mtp) into a msgb before passing it to as->fi through event XUA_AS_E_TRANSFER_REQ, which in turn calls xua_as_transmit_msg(as, msg). This patch is part 1 of 2 patches, which only modifies mostly the Tx path, but still requires modifications on Rx path (done in patch 2/2) to properly handle the forwarding path from Rx to Tx without double freeing. It is submitted in 2 parts to ease code reviewing. Future patches will modify that code to pass a xua_msg and only encode it into a msgb deeper into the stack after an ASP has been selected and msg needs to be transmitted. All previous calls to sua_tx_xua_asp() actually had a memory leak before this change, hence why no xua_msg_free() is removed from callers in this patch. Since now ownership is taken by sua_tx_xua_asp() which always frees the xua msg, the memleak is fixed. Related: SYS#7112 Change-Id: I49e718e624da08510a9c3d28bdb360c59f9a65d3 --- M src/ipa.c M src/m3ua.c M src/osmo_ss7_hmrt.c M src/sua.c 4 files changed, 48 insertions(+), 19 deletions(-) Approvals: laforge: Looks good to me, but someone else must approve Jenkins Builder: Verified osmith: Looks good to me, but someone else must approve pespin: Looks good to me, approved diff --git a/src/ipa.c b/src/ipa.c index 4e0180c..47ddc0d 100644 --- a/src/ipa.c +++ b/src/ipa.c @@ -94,13 +94,17 @@ /*! \brief Send a given xUA message via a given IPA "Application Server" * \param[in] as Application Server through which to send \a xua * \param[in] xua xUA message to be sent - * \return 0 on success; negative on error */ + * \return 0 on success; negative on error + * + * This function takes ownership of xua msg passed to it. + */ int ipa_tx_xua_as(struct osmo_ss7_as *as, struct xua_msg *xua) { struct msgb *msg; OSMO_ASSERT(as->cfg.proto == OSMO_SS7_ASP_PROT_IPA); msg = ipa_to_msg(xua); + xua_msg_free(xua); if (!msg) { LOGPAS(as, DLSS7, LOGL_ERROR, "Error encoding IPA Msg\n"); return -1; diff --git a/src/m3ua.c b/src/m3ua.c index 2f180c3..cdbfc48 100644 --- a/src/m3ua.c +++ b/src/m3ua.c @@ -506,23 +506,31 @@ return msg; } -/* transmit given xua_msg via given ASP */ +/* transmit given xua_msg via given ASP + * This function takes ownership of xua msg passed to it. + */ static int m3ua_tx_xua_asp(struct osmo_ss7_asp *asp, struct xua_msg *xua) { - struct msgb *msg = m3ua_to_msg(xua); + struct msgb *msg; OSMO_ASSERT(asp->cfg.proto == OSMO_SS7_ASP_PROT_M3UA); + msg = m3ua_to_msg(xua); + xua_msg_free(xua); if (!msg) return -1; + /* msg becomes owned by osmo_ss7_asp_send here: */ return osmo_ss7_asp_send(asp, msg); } /*! \brief Send a given xUA message via a given M3UA Application Server * \param[in] as Application Server through which to send \ref xua * \param[in] xua xUA message to be sent - * \return 0 on success; negative on error */ + * \return 0 on success; negative on error + * + * This function takes ownership of xua msg passed to it. + */ int m3ua_tx_xua_as(struct osmo_ss7_as *as, struct xua_msg *xua) { struct msgb *msg; @@ -535,6 +543,7 @@ xua_msg_add_u32(xua, M3UA_IEI_ROUTE_CTX, as->cfg.routing_key.context); msg = m3ua_to_msg(xua); + xua_msg_free(xua); if (!msg) { LOGPAS(as, DLM3UA, LOGL_ERROR, "Error encoding M3UA Msg\n"); return -1; @@ -794,10 +803,8 @@ err = m3ua_gen_error_msg(rc, msg); out: - if (err) { + if (err) m3ua_tx_xua_asp(asp, err); - xua_msg_free(err); - } xua_msg_free(xua); @@ -900,7 +907,6 @@ xua = m3ua_encode_duna(rctx, num_rctx, aff_pc, num_aff_pc, info_string); m3ua_tx_xua_asp(asp, xua); - xua_msg_free(xua); } /*! Transmit SSNM SCON message indicating congestion @@ -934,7 +940,6 @@ xua_msg_add_data(xua, M3UA_IEI_INFO_STRING, strlen(info_string)+1, (const uint8_t *) info_string); m3ua_tx_xua_asp(asp, xua); - xua_msg_free(xua); } /*! Transmit SSNM DUPU message indicating user unavailability. @@ -950,7 +955,6 @@ { struct xua_msg *xua = m3ua_encode_dupu(rctx, num_rctx, dpc, user, cause, info_str); m3ua_tx_xua_asp(asp, xua); - xua_msg_free(xua); } /* received SNM message on ASP side */ diff --git a/src/osmo_ss7_hmrt.c b/src/osmo_ss7_hmrt.c index 675b231..654692a 100644 --- a/src/osmo_ss7_hmrt.c +++ b/src/osmo_ss7_hmrt.c @@ -86,24 +86,35 @@ return m3ua_xfer_from_data(&data_hdr, msgb_l2(msg), msgb_l2len(msg)); } -/* delivery given XUA message to given SS7 user */ +/* delivery given XUA message to given SS7 user + * Ownership of xua_msg passed is transferred to this function. + */ static int deliver_to_mtp_user(const struct osmo_ss7_user *osu, struct xua_msg *xua) { struct osmo_mtp_prim *prim; + int rc; /* Create MTP-TRANSFER.ind and feed to user */ prim = m3ua_to_xfer_ind(xua); - if (!prim) - return -1; + if (!prim) { + rc = -1; + goto ret_free; + } prim->u.transfer = xua->mtp; - return osu->prim_cb(&prim->oph, (void *) osu->priv); + rc = osu->prim_cb(&prim->oph, (void *) osu->priv); + +ret_free: + xua_msg_free(xua); + return rc; } /* HMDC -> HMDT: Message for distribution; Figure 25/Q.704 */ /* This means it is a message we received from remote/L2, and it is to - * be routed to a local user part */ + * be routed to a local user part. + * Ownership of xua_msg passed is transferred to this function. + */ static int hmdt_message_for_distribution(struct osmo_ss7_instance *inst, struct xua_msg *xua) { struct m3ua_data_hdr *mdh; @@ -120,6 +131,7 @@ default: LOGP(DLSS7, LOGL_ERROR, "Unknown M3UA XFER Message " "Type %u\n", xua->hdr.msg_type); + xua_msg_free(xua); return -1; } break; @@ -131,6 +143,7 @@ /* Discard Message */ LOGP(DLSS7, LOGL_ERROR, "Unknown M3UA Message Class %u\n", xua->hdr.msg_class); + xua_msg_free(xua); return -1; } @@ -142,13 +155,16 @@ LOGP(DLSS7, LOGL_NOTICE, "No MTP-User for SI %u\n", service_ind); /* Discard Message */ /* FIXME: User Part Unavailable HMDT -> HMRT */ + xua_msg_free(xua); return -1; } } /* HMDC->HMRT Msg For Routing; Figure 26/Q.704 */ /* local message was receive d from L4, SRM, SLM, STM or SLTC, or - * remote message received from L2 and HMDC determined msg for routing */ + * remote message received from L2 and HMDC determined msg for routing + * Ownership of xua_msg passed is transferred to this function. + */ static int hmrt_message_for_routing(struct osmo_ss7_instance *inst, struct xua_msg *xua) { @@ -215,12 +231,14 @@ /* Message Received for inaccesible SP HMRT ->RTPC */ /* Discard Message */ } + xua_msg_free(xua); return -1; } /* HMDC: Received Message L2 -> L3; Figure 24/Q.704 */ /* This means a message was received from L2 and we have to decide if it - * is for the local stack (HMDT) or for routng (HMRT) */ + * is for the local stack (HMDT) or for routng (HMRT) + * Ownership of xua_msg passed is transferred to this function. */ int m3ua_hmdc_rx_from_l2(struct osmo_ss7_instance *inst, struct xua_msg *xua) { uint32_t dpc = xua->mtp.dpc; @@ -257,7 +275,6 @@ * IPv4). So we call m3ua_hmdc_rx_from_l2() just like * the MTP-TRANSFER had been received from L2. */ rc = m3ua_hmdc_rx_from_l2(inst, xua); - xua_msg_free(xua); break; default: LOGP(DLSS7, LOGL_ERROR, "Ignoring unknown primitive %u:%u\n", diff --git a/src/sua.c b/src/sua.c index 6d023cb..4d90f9b 100644 --- a/src/sua.c +++ b/src/sua.c @@ -291,13 +291,16 @@ static int sua_tx_xua_asp(struct osmo_ss7_asp *asp, struct xua_msg *xua) { - struct msgb *msg = sua_to_msg(xua); + struct msgb *msg; OSMO_ASSERT(asp->cfg.proto == OSMO_SS7_ASP_PROT_SUA); + msg = sua_to_msg(xua); + xua_msg_free(xua); if (!msg) return -1; + /* msg becomes owned by osmo_ss7_asp_send here: */ return osmo_ss7_asp_send(asp, msg); } @@ -317,6 +320,7 @@ xua_msg_add_u32(xua, SUA_IEI_ROUTE_CTX, as->cfg.routing_key.context); msg = sua_to_msg(xua); + xua_msg_free(xua); if (!msg) { LOGPAS(as, DLSUA, LOGL_ERROR, "Error encoding SUA Msg\n"); return -1; -- To view, visit https://gerrit.osmocom.org/c/libosmo-sigtran/+/39396?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: merged Gerrit-Project: libosmo-sigtran Gerrit-Branch: master Gerrit-Change-Id: I49e718e624da08510a9c3d28bdb360c59f9a65d3 Gerrit-Change-Number: 39396 Gerrit-PatchSet: 11 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: daniel <dwillmann(a)sysmocom.de> Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: osmith <osmith(a)sysmocom.de> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
1 0
0 0
[M] Change in libosmo-sigtran[master]: AS loadsharing: Implement AS loadshare, skip unavailable AS/lset when...
by pespin 06 Mar '25

06 Mar '25
Attention is currently required from: laforge. pespin has posted comments on this change by pespin. ( https://gerrit.osmocom.org/c/libosmo-sigtran/+/39391?usp=email ) Change subject: AS loadsharing: Implement AS loadshare, skip unavailable AS/lset when choosing ...................................................................... Patch Set 11: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/c/libosmo-sigtran/+/39391?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: comment Gerrit-Project: libosmo-sigtran Gerrit-Branch: master Gerrit-Change-Id: I928fb1ef5db6922f1386a188e3fbf9e70780f25d Gerrit-Change-Number: 39391 Gerrit-PatchSet: 11 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: osmith <osmith(a)sysmocom.de> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-CC: laforge <laforge(a)osmocom.org> Gerrit-Attention: laforge <laforge(a)osmocom.org> Gerrit-Comment-Date: Thu, 06 Mar 2025 20:12:08 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes
1 0
0 0
[L] Change in libosmo-sigtran[master]: AS loadsharing: Initial routing implementation based on extended-SLS
by pespin 06 Mar '25

06 Mar '25
Attention is currently required from: laforge. pespin has posted comments on this change by pespin. ( https://gerrit.osmocom.org/c/libosmo-sigtran/+/39377?usp=email ) Change subject: AS loadsharing: Initial routing implementation based on extended-SLS ...................................................................... Patch Set 12: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/c/libosmo-sigtran/+/39377?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: comment Gerrit-Project: libosmo-sigtran Gerrit-Branch: master Gerrit-Change-Id: I0fb4ca4959096f748a23082efa0481300de56436 Gerrit-Change-Number: 39377 Gerrit-PatchSet: 12 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: osmith <osmith(a)sysmocom.de> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-Attention: laforge <laforge(a)osmocom.org> Gerrit-Comment-Date: Thu, 06 Mar 2025 20:11:59 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes
1 0
0 0
[L] Change in osmo-mgw[master]: mgw: Split MGCP LocalConnectionOptions parsing from updating endpoint
by pespin 06 Mar '25

06 Mar '25
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-mgw/+/39723?usp=email ) Change subject: mgw: Split MGCP LocalConnectionOptions parsing from updating endpoint ...................................................................... mgw: Split MGCP LocalConnectionOptions parsing from updating endpoint Split current code into 2 steps, so first read-only parsing can be done, then when all parsing and checks have been done, finally can be applied o the object. Change-Id: If75731fb92329dca6d092ffc7ff17cb354d28c0d --- M include/osmocom/mgcp/mgcp_endp.h M include/osmocom/mgcp/mgcp_protocol.h M src/libosmo-mgcp/mgcp_endp.c M src/libosmo-mgcp/mgcp_msg.c M src/libosmo-mgcp/mgcp_protocol.c 5 files changed, 259 insertions(+), 244 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/23/39723/1 diff --git a/include/osmocom/mgcp/mgcp_endp.h b/include/osmocom/mgcp/mgcp_endp.h index fbe0850..8a2c8a2 100644 --- a/include/osmocom/mgcp/mgcp_endp.h +++ b/include/osmocom/mgcp/mgcp_endp.h @@ -149,6 +149,7 @@ const struct mgcp_trunk *trunk); struct mgcp_endpoint *mgcp_endp_find_specific(const char *epname, const struct mgcp_trunk *trunk); +void mgcp_endp_update_lco(struct mgcp_endpoint *endp, const struct mgcp_lco *lco); void mgcp_endp_release(struct mgcp_endpoint *endp); struct mgcp_conn *mgcp_endp_get_conn(struct mgcp_endpoint *endp, const char *id); diff --git a/include/osmocom/mgcp/mgcp_protocol.h b/include/osmocom/mgcp/mgcp_protocol.h index 2ef4c3e..9f79334 100644 --- a/include/osmocom/mgcp/mgcp_protocol.h +++ b/include/osmocom/mgcp/mgcp_protocol.h @@ -42,12 +42,26 @@ mgcp_codecset_reset(&sdp->cset); } +/* Local connection options */ +struct mgcp_lco { + bool present; + char *codec; /* talloc-allocated to some parent */ + int pkt_period_min; /* time in ms */ + int pkt_period_max; /* time in ms */ +}; +static inline void mgcp_lco_init(struct mgcp_lco *lco) +{ + *lco = (struct mgcp_lco){}; +} +char *get_lco_identifier(const char *options); +int check_local_cx_options(void *ctx, const char *options); #define MGCP_PARSE_HDR_PARS_OSMUX_CID_UNSET (-2) #define MGCP_PARSE_HDR_PARS_OSMUX_CID_WILDCARD (-1) struct mgcp_parse_hdr_pars { - const char *local_options; + const char *lco_string; + struct mgcp_lco lco; const char *callid; const char *connid; enum mgcp_connection_mode mode; @@ -59,15 +73,14 @@ static inline void mgcp_parse_hdr_pars_init(struct mgcp_parse_hdr_pars *hpars) { - *hpars = (struct mgcp_parse_hdr_pars){ - .local_options = NULL, - .callid = NULL, - .connid = NULL, - .mode = MGCP_CONN_NONE, - .remote_osmux_cid = MGCP_PARSE_HDR_PARS_OSMUX_CID_UNSET, - .have_sdp = false, - .x_osmo_ign = 0, - }; + hpars->lco_string = NULL; + mgcp_lco_init(&hpars->lco); + hpars->callid = NULL; + hpars->connid = NULL; + hpars->mode = MGCP_CONN_NONE; + hpars->remote_osmux_cid = MGCP_PARSE_HDR_PARS_OSMUX_CID_UNSET; + hpars->have_sdp = false; + hpars->x_osmo_ign = 0; } /* Internal structure while parsing a request */ @@ -111,18 +124,8 @@ int mgcp_cause; }; -/* Local connection options */ -struct mgcp_lco { - char *string; - char *codec; - int pkt_period_min; /* time in ms */ - int pkt_period_max; /* time in ms */ -}; - char *mgcp_debug_get_last_endpoint_name(void); -char *get_lco_identifier(const char *options); -int check_local_cx_options(void *ctx, const char *options); struct mgcp_rtp_end; struct mgcp_endpoint; diff --git a/src/libosmo-mgcp/mgcp_endp.c b/src/libosmo-mgcp/mgcp_endp.c index 1d2287c..a4ab860 100644 --- a/src/libosmo-mgcp/mgcp_endp.c +++ b/src/libosmo-mgcp/mgcp_endp.c @@ -764,6 +764,22 @@ return NULL; } +/* Helps assigning a new lco structure, since "codec" is talloc allocated. */ +void mgcp_endp_update_lco(struct mgcp_endpoint *endp, const struct mgcp_lco *lco) +{ + /* First free old talloc allocated codec string: */ + talloc_free(endp->local_options.codec); + endp->local_options.codec = NULL; + + if (lco) { + endp->local_options = *lco; + if (lco->codec) + endp->local_options.codec = talloc_strdup(endp, lco->codec); + } else { + endp->local_options = (struct mgcp_lco){0}; + } +} + /*! release endpoint, all open connections are closed. * \param[in] endp endpoint to release */ void mgcp_endp_release(struct mgcp_endpoint *endp) @@ -785,10 +801,7 @@ /* Reset endpoint parameters and states */ talloc_free(endp->callid); endp->callid = NULL; - talloc_free(endp->local_options.string); - endp->local_options.string = NULL; - talloc_free(endp->local_options.codec); - endp->local_options.codec = NULL; + mgcp_endp_update_lco(endp, NULL); if (endp->trunk->trunk_type == MGCP_TRUNK_E1) { uint8_t ts = e1_ts_nr_from_epname(endp->name); diff --git a/src/libosmo-mgcp/mgcp_msg.c b/src/libosmo-mgcp/mgcp_msg.c index af4f9d0..afeadd5 100644 --- a/src/libosmo-mgcp/mgcp_msg.c +++ b/src/libosmo-mgcp/mgcp_msg.c @@ -101,6 +101,197 @@ return MGCP_CONN_NONE; } +/*! Helper function for check_local_cx_options() to get a pointer of the next + * lco option identifier + * \param[in] lco string + * \returns pointer to the beginning of the LCO identifier, NULL on failure */ +char *get_lco_identifier(const char *options) +{ + char *ptr; + unsigned int count = 0; + + /* Jump to the end of the lco identifier */ + ptr = strstr(options, ":"); + if (!ptr) + return NULL; + + /* Walk backwards until the pointer points to the beginning of the + * lco identifier. We know that we stand at the beginning when we + * are either at the beginning of the memory or see a space or + * comma. (this is tolerant, it will accept a:10, b:11 as well as + * a:10,b:11) */ + while (1) { + /* Endless loop protection */ + if (count > 10000) + return NULL; + else if (ptr < options || *ptr == ' ' || *ptr == ',') { + ptr++; + break; + } + ptr--; + count++; + } + + /* Check if we got any result */ + if (*ptr == ':') + return NULL; + + return ptr; +} + +/*! Check the LCO option. This function checks for multiple appearance of LCO +* options, which is illegal +* \param[in] ctx talloc context +* \param[in] lco string +* \returns 0 on success, -1 on failure */ +int check_local_cx_options(void *ctx, const char *options) +{ + int i; + char *options_copy; + char *lco_identifier; + char *lco_identifier_end; + char *next_lco_identifier; + + char **lco_seen; + unsigned int lco_seen_n = 0; + + if (!options) + return -1; + + lco_seen = + (char **)talloc_zero_size(ctx, strlen(options) * sizeof(char *)); + options_copy = talloc_strdup(ctx, options); + lco_identifier = options_copy; + + do { + /* Move the lco_identifier pointer to the beginning of the + * current lco option identifier */ + lco_identifier = get_lco_identifier(lco_identifier); + if (!lco_identifier) + goto error; + + /* Look ahead to the next LCO option early, since we + * will parse destructively */ + next_lco_identifier = strstr(lco_identifier + 1, ","); + + /* Pinch off the end of the lco field identifier name + * and see if we still got something, also check if + * there is some value after the colon. */ + lco_identifier_end = strstr(lco_identifier, ":"); + if (!lco_identifier_end) + goto error; + if (*(lco_identifier_end + 1) == ' ' + || *(lco_identifier_end + 1) == ',' + || *(lco_identifier_end + 1) == '\0') + goto error; + *lco_identifier_end = '\0'; + if (strlen(lco_identifier) == 0) + goto error; + + /* Check if we have already seen the current field identifier + * before. If yes, we must bail, an LCO must only appear once + * in the LCO string */ + for (i = 0; i < lco_seen_n; i++) { + if (strcasecmp(lco_seen[i], lco_identifier) == 0) + goto error; + } + lco_seen[lco_seen_n] = lco_identifier; + lco_seen_n++; + + /* The first identifier must always be found at the beginnning + * of the LCO string */ + if (lco_seen[0] != options_copy) + goto error; + + /* Go to the next lco option */ + lco_identifier = next_lco_identifier; + } while (lco_identifier); + + talloc_free(lco_seen); + talloc_free(options_copy); + return 0; +error: + talloc_free(lco_seen); + talloc_free(options_copy); + return -1; +} + +/* Set the LCO from a string (see RFC 3435). +* The string is stored in the 'string' field. A NULL string is handled exactly +* like an empty string, the 'string' field is never NULL after this function +* has been called. */ +static int mgcp_parse_lco(void *ctx, struct mgcp_lco *lco, const char *options) +{ + const char *lco_id; + char codec[17]; + char nt[17]; + int len; + + if (!options) + return 0; + if (strlen(options) == 0) + return 0; + + lco->present = true; + + /* Make sure the encoding of the LCO is consistent before we proceed */ + if (check_local_cx_options(ctx, options) != 0) { + LOGP(DLMGCP, LOGL_ERROR, + "local CX options: Internal inconsistency in Local Connection Options!\n"); + return -524; + } + + lco_id = options; + while ((lco_id = get_lco_identifier(lco_id))) { + switch (tolower(lco_id[0])) { + case 'p': + if (sscanf(lco_id + 1, ":%d-%d", + &lco->pkt_period_min, &lco->pkt_period_max) == 1) + lco->pkt_period_max = lco->pkt_period_min; + break; + case 'a': + /* FIXME: LCO also supports the negotiation of more than one codec. + * (e.g. a:PCMU;G726-32) But this implementation only supports a single + * codec only. Ignoring all but the first codec. */ + if (sscanf(lco_id + 1, ":%16[^,;]", codec) == 1) { + talloc_free(lco->codec); + /* MGCP header is case insensive, and we'll need + codec in uppercase when using it later: */ + len = strlen(codec); + lco->codec = talloc_size(ctx, len + 1); + osmo_str_toupper_buf(lco->codec, len + 1, codec); + } + break; + case 'n': + if (lco_id[1] == 't' && sscanf(lco_id + 2, ":%16[^,]", nt) == 1) + break; + /* else: fall through to print notice log */ + default: + LOGP(DLMGCP, LOGL_NOTICE, + "LCO: unhandled option: '%c'/%d in \"%s\"\n", + *lco_id, *lco_id, options); + break; + } + + lco_id = strchr(lco_id, ','); + if (!lco_id) + break; + } + + LOGP(DLMGCP, LOGL_DEBUG, + "local CX options: lco->pkt_period_max: %d, lco->codec: %s\n", + lco->pkt_period_max, lco->codec); + + /* Check if the packetization fits the 20ms raster */ + if (lco->pkt_period_min % 20 && lco->pkt_period_max % 20) { + LOGP(DLMGCP, LOGL_ERROR, + "local CX options: packetization interval is not a multiple of 20ms!\n"); + return -535; + } + + return 0; +} + /*! Analyze and parse the the hader of an MGCP messeage string. * \param[out] pdata caller provided memory to store the parsing results. * \param[in] data mgcp message string. @@ -177,6 +368,7 @@ { struct mgcp_parse_hdr_pars *hp = &pdata->hpars; char *line; + int rc; mgcp_parse_hdr_pars_init(hp); @@ -188,7 +380,24 @@ switch (toupper(line[0])) { case 'L': - hp->local_options = (const char *)line + 3; + hp->lco_string = (const char *)line + 3; + rc = mgcp_parse_lco(pdata, &hp->lco, hp->lco_string); + if (rc < 0) { + LOG_MGCP_PDATA(pdata, LOGL_NOTICE, "Invalid LocalConnectionOptions line: '%s'", line); + switch (pdata->rq->verb) { + case MGCP_VERB_CRCX: + rate_ctr_inc(rate_ctr_group_get_ctr(pdata->rq->trunk->ratectr.mgcp_crcx_ctr_group, + MGCP_CRCX_FAIL_INVALID_CONN_OPTIONS)); + break; + case MGCP_VERB_MDCX: + rate_ctr_inc(rate_ctr_group_get_ctr(pdata->rq->trunk->ratectr.mgcp_mdcx_ctr_group, + MGCP_MDCX_FAIL_INVALID_CONN_OPTIONS)); + break; + default: + break; + } + return rc; + } break; case 'C': hp->callid = (const char *)line + 3; diff --git a/src/libosmo-mgcp/mgcp_protocol.c b/src/libosmo-mgcp/mgcp_protocol.c index 06da91a..49a4e83 100644 --- a/src/libosmo-mgcp/mgcp_protocol.c +++ b/src/libosmo-mgcp/mgcp_protocol.c @@ -455,199 +455,6 @@ return create_ok_response(rq->trunk, rq->endp, 200, "AUEP", rq->pdata->trans); } -/*! Helper function for check_local_cx_options() to get a pointer of the next - * lco option identifier - * \param[in] lco string - * \returns pointer to the beginning of the LCO identifier, NULL on failure */ -char *get_lco_identifier(const char *options) -{ - char *ptr; - unsigned int count = 0; - - /* Jump to the end of the lco identifier */ - ptr = strstr(options, ":"); - if (!ptr) - return NULL; - - /* Walk backwards until the pointer points to the beginning of the - * lco identifier. We know that we stand at the beginning when we - * are either at the beginning of the memory or see a space or - * comma. (this is tolerant, it will accept a:10, b:11 as well as - * a:10,b:11) */ - while (1) { - /* Endless loop protection */ - if (count > 10000) - return NULL; - else if (ptr < options || *ptr == ' ' || *ptr == ',') { - ptr++; - break; - } - ptr--; - count++; - } - - /* Check if we got any result */ - if (*ptr == ':') - return NULL; - - return ptr; -} - -/*! Check the LCO option. This function checks for multiple appearence of LCO - * options, which is illegal - * \param[in] ctx talloc context - * \param[in] lco string - * \returns 0 on success, -1 on failure */ -int check_local_cx_options(void *ctx, const char *options) -{ - int i; - char *options_copy; - char *lco_identifier; - char *lco_identifier_end; - char *next_lco_identifier; - - char **lco_seen; - unsigned int lco_seen_n = 0; - - if (!options) - return -1; - - lco_seen = - (char **)talloc_zero_size(ctx, strlen(options) * sizeof(char *)); - options_copy = talloc_strdup(ctx, options); - lco_identifier = options_copy; - - do { - /* Move the lco_identifier pointer to the beginning of the - * current lco option identifier */ - lco_identifier = get_lco_identifier(lco_identifier); - if (!lco_identifier) - goto error; - - /* Look ahead to the next LCO option early, since we - * will parse destructively */ - next_lco_identifier = strstr(lco_identifier + 1, ","); - - /* Pinch off the end of the lco field identifier name - * and see if we still got something, also check if - * there is some value after the colon. */ - lco_identifier_end = strstr(lco_identifier, ":"); - if (!lco_identifier_end) - goto error; - if (*(lco_identifier_end + 1) == ' ' - || *(lco_identifier_end + 1) == ',' - || *(lco_identifier_end + 1) == '\0') - goto error; - *lco_identifier_end = '\0'; - if (strlen(lco_identifier) == 0) - goto error; - - /* Check if we have already seen the current field identifier - * before. If yes, we must bail, an LCO must only appear once - * in the LCO string */ - for (i = 0; i < lco_seen_n; i++) { - if (strcasecmp(lco_seen[i], lco_identifier) == 0) - goto error; - } - lco_seen[lco_seen_n] = lco_identifier; - lco_seen_n++; - - /* The first identifier must always be found at the beginnning - * of the LCO string */ - if (lco_seen[0] != options_copy) - goto error; - - /* Go to the next lco option */ - lco_identifier = next_lco_identifier; - } while (lco_identifier); - - talloc_free(lco_seen); - talloc_free(options_copy); - return 0; -error: - talloc_free(lco_seen); - talloc_free(options_copy); - return -1; -} - -/* Set the LCO from a string (see RFC 3435). - * The string is stored in the 'string' field. A NULL string is handled exactly - * like an empty string, the 'string' field is never NULL after this function - * has been called. */ -static int set_local_cx_options(void *ctx, struct mgcp_lco *lco, - const char *options) -{ - char *lco_id; - char codec[17]; - char nt[17]; - int len; - - if (!options) - return 0; - if (strlen(options) == 0) - return 0; - - /* Make sure the encoding of the LCO is consistant before we proceed */ - if (check_local_cx_options(ctx, options) != 0) { - LOGP(DLMGCP, LOGL_ERROR, - "local CX options: Internal inconsistency in Local Connection Options!\n"); - return 524; - } - - talloc_free(lco->string); - lco->string = talloc_strdup(ctx, options); - - lco_id = lco->string; - while ((lco_id = get_lco_identifier(lco_id))) { - switch (tolower(lco_id[0])) { - case 'p': - if (sscanf(lco_id + 1, ":%d-%d", - &lco->pkt_period_min, &lco->pkt_period_max) == 1) - lco->pkt_period_max = lco->pkt_period_min; - break; - case 'a': - /* FIXME: LCO also supports the negotiation of more than one codec. - * (e.g. a:PCMU;G726-32) But this implementation only supports a single - * codec only. Ignoring all but the first codec. */ - if (sscanf(lco_id + 1, ":%16[^,;]", codec) == 1) { - talloc_free(lco->codec); - /* MGCP header is case insensive, and we'll need - codec in uppercase when using it later: */ - len = strlen(codec); - lco->codec = talloc_size(ctx, len + 1); - osmo_str_toupper_buf(lco->codec, len + 1, codec); - } - break; - case 'n': - if (lco_id[1] == 't' && sscanf(lco_id + 2, ":%16[^,]", nt) == 1) - break; - /* else: fall throught to print notice log */ - default: - LOGP(DLMGCP, LOGL_NOTICE, - "LCO: unhandled option: '%c'/%d in \"%s\"\n", - *lco_id, *lco_id, lco->string); - break; - } - - lco_id = strchr(lco_id, ','); - if (!lco_id) - break; - } - - LOGP(DLMGCP, LOGL_DEBUG, - "local CX options: lco->pkt_period_max: %i, lco->codec: %s\n", - lco->pkt_period_max, lco->codec); - - /* Check if the packetization fits the 20ms raster */ - if (lco->pkt_period_min % 20 && lco->pkt_period_max % 20) { - LOGP(DLMGCP, LOGL_ERROR, - "local CX options: packetization interval is not a multiple of 20ms!\n"); - return 535; - } - - return 0; -} - uint32_t mgcp_rtp_packet_duration(const struct mgcp_endpoint *endp, const struct mgcp_rtp_end *rtp) { @@ -907,6 +714,10 @@ /* Update endp->x_osmo_ign: */ endp->x_osmo_ign |= hpars->x_osmo_ign; + /* Set local connection options, if present */ + if (hpars->lco.present) + mgcp_endp_update_lco(endp, &hpars->lco); + if (!endp->callid) { /* Claim endpoint resources. This will also set the callid, * creating additional connections will only be possible if @@ -953,19 +764,6 @@ } /* else: -1 (wildcard) */ } - /* Set local connection options, if present */ - if (hpars->local_options) { - rc = set_local_cx_options(trunk->endpoints, - &endp->local_options, hpars->local_options); - if (rc != 0) { - LOGPCONN(conn, DLMGCP, LOGL_ERROR, - "CRCX: invalid local connection options!\n"); - error_code = rc; - rate_ctr_inc(rate_ctr_group_get_ctr(rate_ctrs, MGCP_CRCX_FAIL_INVALID_CONN_OPTIONS)); - goto error2; - } - } - /* Handle codec information and decide for a suitable codec */ rc = handle_codec_info(conn_rtp, rq); mgcp_codecset_summary(&conn_rtp->end.cset, mgcp_conn_dump(conn)); @@ -1120,6 +918,10 @@ return create_err_response(endp, endp, 400, "MDCX", pdata->trans); } + /* Set local connection options, if present */ + if (hpars->lco.present) + mgcp_endp_update_lco(endp, &hpars->lco); + mgcp_conn_watchdog_kick(conn); if (hpars->mode == MGCP_CONN_NONE) { @@ -1130,19 +932,6 @@ return create_err_response(endp, endp, 517, "MDCX", pdata->trans); } - /* Set local connection options, if present */ - if (hpars->local_options) { - rc = set_local_cx_options(trunk->endpoints, - &endp->local_options, hpars->local_options); - if (rc != 0) { - LOGPCONN(conn, DLMGCP, LOGL_ERROR, - "MDCX: invalid local connection options!\n"); - error_code = rc; - rate_ctr_inc(rate_ctr_group_get_ctr(rate_ctrs, MGCP_MDCX_FAIL_INVALID_CONN_OPTIONS)); - goto error3; - } - } - conn_rtp = mgcp_conn_get_conn_rtp(conn); OSMO_ASSERT(conn_rtp); -- To view, visit https://gerrit.osmocom.org/c/osmo-mgw/+/39723?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: osmo-mgw Gerrit-Branch: master Gerrit-Change-Id: If75731fb92329dca6d092ffc7ff17cb354d28c0d Gerrit-Change-Number: 39723 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de>
1 0
0 0
[M] Change in osmo-mgw[master]: mgw: Move struct mgcp_request_data definition to header file
by pespin 06 Mar '25

06 Mar '25
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-mgw/+/39718?usp=email ) Change subject: mgw: Move struct mgcp_request_data definition to header file ...................................................................... mgw: Move struct mgcp_request_data definition to header file All the related handling structs are placed in the header file, let's move them there. This will also allow accessing the rq object information in other files. Change-Id: I1b2831874c1aaad054ad19bf87646062ba9d4da4 --- M include/osmocom/mgcp/mgcp_protocol.h M src/libosmo-mgcp/mgcp_protocol.c 2 files changed, 25 insertions(+), 25 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/18/39718/1 diff --git a/include/osmocom/mgcp/mgcp_protocol.h b/include/osmocom/mgcp/mgcp_protocol.h index 4fed248..dda0fb3 100644 --- a/include/osmocom/mgcp/mgcp_protocol.h +++ b/include/osmocom/mgcp/mgcp_protocol.h @@ -82,6 +82,31 @@ struct mgcp_parse_sdp sdp; }; +/* Request data passed to the request handler */ +struct mgcp_request_data { + enum mgcp_verb verb; + /* Verb string (e.g. "MDCX") */ + char name[4+1]; + + /* parsing results from the MGCP header (trans id, endpoint name ...) */ + struct mgcp_parse_data *pdata; + + /* pointer to endpoint resource (may be NULL for wildcarded requests) */ + struct mgcp_endpoint *endp; + + /* pointer to trunk resource */ + struct mgcp_trunk *trunk; + + /* set to true when the request has been classified as wildcarded */ + bool wildcarded; + + /* Set to true when the request is targeted at the "null" endpoint */ + bool null_endp; + + /* contains cause code in case of problems during endp/trunk resolution */ + int mgcp_cause; +}; + /* Local connection options */ struct mgcp_lco { char *string; diff --git a/src/libosmo-mgcp/mgcp_protocol.c b/src/libosmo-mgcp/mgcp_protocol.c index 36d9ebf..74ed14e 100644 --- a/src/libosmo-mgcp/mgcp_protocol.c +++ b/src/libosmo-mgcp/mgcp_protocol.c @@ -89,31 +89,6 @@ LOGPTRUNK(trunk, cat, level, fmt, ## args); \ } while (0) -/* Request data passed to the request handler */ -struct mgcp_request_data { - enum mgcp_verb verb; - /* Verb string (e.g. "MDCX") */ - char name[4+1]; - - /* parsing results from the MGCP header (trans id, endpoint name ...) */ - struct mgcp_parse_data *pdata; - - /* pointer to endpoint resource (may be NULL for wildcarded requests) */ - struct mgcp_endpoint *endp; - - /* pointer to trunk resource */ - struct mgcp_trunk *trunk; - - /* set to true when the request has been classified as wildcarded */ - bool wildcarded; - - /* Set to true when the request is targeted at the "null" endpoint */ - bool null_endp; - - /* contains cause code in case of problems during endp/trunk resolution */ - int mgcp_cause; -}; - static struct msgb *handle_audit_endpoint(struct mgcp_request_data *data); static struct msgb *handle_create_con(struct mgcp_request_data *data); static struct msgb *handle_delete_con(struct mgcp_request_data *data); -- To view, visit https://gerrit.osmocom.org/c/osmo-mgw/+/39718?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: osmo-mgw Gerrit-Branch: master Gerrit-Change-Id: I1b2831874c1aaad054ad19bf87646062ba9d4da4 Gerrit-Change-Number: 39718 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de>
1 0
0 0
[M] Change in osmo-mgw[master]: mgw: Store Command as enum in struct mgcp_request_data
by pespin 06 Mar '25

06 Mar '25
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-mgw/+/39717?usp=email ) Change subject: mgw: Store Command as enum in struct mgcp_request_data ...................................................................... mgw: Store Command as enum in struct mgcp_request_data This simplifies code further, and will simpify more code since we'll have some easy way to check for the command we are in during a request. Change-Id: I2d4b5ddb93376b59413b34c9668c41157ab05497 --- M include/osmocom/mgcp/mgcp.h M include/osmocom/mgcp/mgcp_protocol.h M src/libosmo-mgcp/mgcp_protocol.c 3 files changed, 67 insertions(+), 76 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/17/39717/1 diff --git a/include/osmocom/mgcp/mgcp.h b/include/osmocom/mgcp/mgcp.h index 4dff4d0..41eee42 100644 --- a/include/osmocom/mgcp/mgcp.h +++ b/include/osmocom/mgcp/mgcp.h @@ -50,11 +50,6 @@ struct mgcp_config; struct mgcp_trunk; struct mgcp_rtp_end; - -#define MGCP_ENDP_CRCX 1 -#define MGCP_ENDP_DLCX 2 -#define MGCP_ENDP_MDCX 3 - /* * what to do with the msg? * - continue as usual? diff --git a/include/osmocom/mgcp/mgcp_protocol.h b/include/osmocom/mgcp/mgcp_protocol.h index 427fe5f..4fed248 100644 --- a/include/osmocom/mgcp/mgcp_protocol.h +++ b/include/osmocom/mgcp/mgcp_protocol.h @@ -8,6 +8,18 @@ #include <osmocom/mgcp/mgcp_common.h> #include <osmocom/mgcp/mgcp_codec.h> +enum mgcp_verb { + MGCP_VERB_CRCX, + MGCP_VERB_MDCX, + MGCP_VERB_DLCX, + MGCP_VERB_AUEP, + MGCP_VERB_RQNT, + MGCP_VERB_RSIP, +}; +extern const struct value_string mgcp_verb_names[]; +static inline const char *mgcp_verb_name(enum mgcp_verb val) +{ return get_value_string(mgcp_verb_names, val); } + #define MGCP_PARSE_SDP_PTIME_UNSET (-1) #define MGCP_PARSE_SDP_MAXPTIME_UNSET (-1) diff --git a/src/libosmo-mgcp/mgcp_protocol.c b/src/libosmo-mgcp/mgcp_protocol.c index 35d0811..36d9ebf 100644 --- a/src/libosmo-mgcp/mgcp_protocol.c +++ b/src/libosmo-mgcp/mgcp_protocol.c @@ -59,6 +59,16 @@ return debug_last_endpoint_name; } +const struct value_string mgcp_verb_names[] = { + { MGCP_VERB_CRCX, "CRCX" }, + { MGCP_VERB_MDCX, "MDCX" }, + { MGCP_VERB_DLCX, "DLCX" }, + { MGCP_VERB_AUEP, "AUEP" }, + { MGCP_VERB_RSIP, "RSIP" }, + { MGCP_VERB_RQNT, "RQNT" }, + {} +}; + const struct value_string mgcp_connection_mode_strs[] = { { MGCP_CONN_NONE, "none" }, { MGCP_CONN_RECV_SEND, "sendrecv" }, @@ -81,7 +91,8 @@ /* Request data passed to the request handler */ struct mgcp_request_data { - /* request name (e.g. "MDCX") */ + enum mgcp_verb verb; + /* Verb string (e.g. "MDCX") */ char name[4+1]; /* parsing results from the MGCP header (trans id, endpoint name ...) */ @@ -103,55 +114,12 @@ int mgcp_cause; }; -/* Request handler specification, here we specify an array with function - * pointers to the various MGCP requests implemented below */ -struct mgcp_request { - /* request name (e.g. "MDCX") */ - char *name; - - /* function pointer to the request handler */ - struct msgb *(*handle_request)(struct mgcp_request_data *data); - - /* a human readable name that describes the request */ - char *debug_name; -}; - static struct msgb *handle_audit_endpoint(struct mgcp_request_data *data); static struct msgb *handle_create_con(struct mgcp_request_data *data); static struct msgb *handle_delete_con(struct mgcp_request_data *data); static struct msgb *handle_modify_con(struct mgcp_request_data *data); static struct msgb *handle_rsip(struct mgcp_request_data *data); static struct msgb *handle_noti_req(struct mgcp_request_data *data); -static const struct mgcp_request mgcp_requests[] = { - { .name = "AUEP", .handle_request = handle_audit_endpoint, .debug_name = "AuditEndpoint" }, - { - .name = "CRCX", - .handle_request = handle_create_con, - .debug_name = "CreateConnection", - }, - { - .name = "DLCX", - .handle_request = handle_delete_con, - .debug_name = "DeleteConnection", - }, - { - .name = "MDCX", - .handle_request = handle_modify_con, - .debug_name = "ModifiyConnection", - }, - { - .name = "RQNT", - .handle_request = handle_noti_req, - .debug_name = "NotificationRequest", - }, - - /* SPEC extension */ - { - .name = "RSIP", - .handle_request = handle_rsip, - .debug_name = "ReSetInProgress", - }, -}; /* Initalize transcoder */ static int setup_rtp_processing(struct mgcp_endpoint *endp, @@ -356,7 +324,7 @@ struct rate_ctr_group *rate_ctrs = cfg->ratectr.mgcp_general_ctr_group; struct mgcp_parse_data pdata; struct mgcp_request_data rq; - int rc, i, code, handled = 0; + int rc, code; struct msgb *resp = NULL; char *data; @@ -385,12 +353,23 @@ return NULL; } - - /* Parse message, extract endpoint name and transaction identifier and request name etc. */ + /* Initialize parsing data. */ memset(&pdata, 0, sizeof(pdata)); memset(&rq, 0, sizeof(rq)); pdata.cfg = cfg; + + /* Parse command name: */ memcpy(rq.name, (const char *)&msg->l2h[0], sizeof(rq.name)-1); + rc = get_string_value(mgcp_verb_names, rq.name); + if (rc < 0) { + LOGP(DLMGCP, LOGL_ERROR, "%s: failed to parse command name in MCGP message\n", rq.name); + rate_ctr_inc(rate_ctr_group_get_ctr(rate_ctrs, MGCP_GENERAL_RX_FAIL_MSG_PARSE)); + rate_ctr_inc(rate_ctr_group_get_ctr(rate_ctrs, MGCP_GENERAL_RX_MSGS_UNHANDLED)); + return create_err_response(cfg, NULL, 504, rq.name, "000000"); + } + rq.verb = rc; + + /* Parse message, extract endpoint name and transaction identifier and request name etc. */ msg->l3h = &msg->l2h[4]; data = mgcp_strline((char *)msg->l3h, &pdata.save); rc = mgcp_parse_header(&pdata, data); @@ -443,31 +422,36 @@ } } - /* Find an appropriate handler for the current request and execute it */ - for (i = 0; i < ARRAY_SIZE(mgcp_requests); i++) { - if (strcmp(mgcp_requests[i].name, rq.name) == 0) { - /* Execute request handler */ - if (rq.endp) - LOGP(DLMGCP, LOGL_INFO, - "%s: executing request handler \"%s\" for endpoint resource \"%s\"\n", rq.name, - mgcp_requests[i].debug_name, rq.endp->name); - else - LOGP(DLMGCP, LOGL_INFO, - "%s: executing request handler \"%s\" for trunk resource of endpoint \"%s\"\n", - rq.name, mgcp_requests[i].debug_name, pdata.epname); - resp = mgcp_requests[i].handle_request(&rq); - handled = 1; - break; - } + /* Execute request handler */ + if (rq.endp) + LOGP(DLMGCP, LOGL_INFO, "%s: executing request handler for endpoint resource \"%s\"\n", + rq.name, rq.endp->name); + else + LOGP(DLMGCP, LOGL_INFO, "%s: executing request handler for trunk resource of endpoint \"%s\"\n", + rq.name, pdata.epname); + switch (rq.verb) { + case MGCP_VERB_AUEP: + resp = handle_audit_endpoint(&rq); + break; + case MGCP_VERB_CRCX: + resp = handle_create_con(&rq); + break; + case MGCP_VERB_DLCX: + resp = handle_delete_con(&rq); + break; + case MGCP_VERB_MDCX: + resp = handle_modify_con(&rq); + break; + case MGCP_VERB_RQNT: + resp = handle_noti_req(&rq); + break; + case MGCP_VERB_RSIP: + resp = handle_rsip(&rq); + break; + default: + OSMO_ASSERT(0); } - - /* Check if the MGCP request was handled and increment rate counters accordingly. */ - if (handled) { - rate_ctr_inc(rate_ctr_group_get_ctr(rate_ctrs, MGCP_GENERAL_RX_MSGS_HANDLED)); - } else { - rate_ctr_inc(rate_ctr_group_get_ctr(rate_ctrs, MGCP_GENERAL_RX_MSGS_UNHANDLED)); - LOGP(DLMGCP, LOGL_ERROR, "MSG with type: '%.4s' not handled\n", &msg->l2h[0]); - } + rate_ctr_inc(rate_ctr_group_get_ctr(rate_ctrs, MGCP_GENERAL_RX_MSGS_HANDLED)); return resp; } -- To view, visit https://gerrit.osmocom.org/c/osmo-mgw/+/39717?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: osmo-mgw Gerrit-Branch: master Gerrit-Change-Id: I2d4b5ddb93376b59413b34c9668c41157ab05497 Gerrit-Change-Number: 39717 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de>
1 0
0 0
[S] Change in osmo-mgw[master]: mgw: Move cfg pointer from pdata to rq
by pespin 06 Mar '25

06 Mar '25
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-mgw/+/39719?usp=email ) Change subject: mgw: Move cfg pointer from pdata to rq ...................................................................... mgw: Move cfg pointer from pdata to rq The externa object context is held in rq object, not in pdata object, which holds parsed msg state only. Change-Id: Ie64fb6250cc84f1e7737b5c1cf5cca314c7020ed --- M include/osmocom/mgcp/mgcp_protocol.h M src/libosmo-mgcp/mgcp_protocol.c 2 files changed, 17 insertions(+), 15 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/19/39719/1 diff --git a/include/osmocom/mgcp/mgcp_protocol.h b/include/osmocom/mgcp/mgcp_protocol.h index dda0fb3..e61669c 100644 --- a/include/osmocom/mgcp/mgcp_protocol.h +++ b/include/osmocom/mgcp/mgcp_protocol.h @@ -72,7 +72,6 @@ /* Internal structure while parsing a request */ struct mgcp_parse_data { - struct mgcp_config *cfg; char *save; /* MGCP Header: */ char *epname; @@ -88,6 +87,9 @@ /* Verb string (e.g. "MDCX") */ char name[4+1]; + /* Global MGW config */ + struct mgcp_config *cfg; + /* parsing results from the MGCP header (trans id, endpoint name ...) */ struct mgcp_parse_data *pdata; diff --git a/src/libosmo-mgcp/mgcp_protocol.c b/src/libosmo-mgcp/mgcp_protocol.c index 74ed14e..1215b95 100644 --- a/src/libosmo-mgcp/mgcp_protocol.c +++ b/src/libosmo-mgcp/mgcp_protocol.c @@ -329,9 +329,9 @@ } /* Initialize parsing data. */ - memset(&pdata, 0, sizeof(pdata)); memset(&rq, 0, sizeof(rq)); - pdata.cfg = cfg; + rq.cfg = cfg; + memset(&pdata, 0, sizeof(pdata)); /* Parse command name: */ memcpy(rq.name, (const char *)&msg->l2h[0], sizeof(rq.name)-1); @@ -360,7 +360,7 @@ if (!rq.wildcarded) rq.null_endp = mgcp_endp_is_null(pdata.epname); if (!rq.null_endp) - rq.endp = mgcp_endp_by_name(&rc, pdata.epname, pdata.cfg); + rq.endp = mgcp_endp_by_name(&rc, pdata.epname, rq.cfg); rq.mgcp_cause = rc; if (!rq.endp) { rate_ctr_inc(rate_ctr_group_get_ctr(rate_ctrs, MGCP_GENERAL_RX_FAIL_NO_ENDPOINT)); @@ -371,7 +371,7 @@ LOGP(DLMGCP, LOGL_NOTICE, "%s: cannot find endpoint \"%s\", cause=%d -- trying to identify trunk...\n", rq.name, pdata.epname, -rq.mgcp_cause); - rq.trunk = mgcp_trunk_by_name(pdata.cfg, pdata.epname); + rq.trunk = mgcp_trunk_by_name(rq.cfg, pdata.epname); if (!rq.trunk) { LOGP(DLMGCP, LOGL_ERROR, "%s: failed to identify trunk for endpoint \"%s\" -- abort\n", rq.name, pdata.epname); @@ -438,7 +438,7 @@ /* Auditing "null" endpoint is allowed for keepalive purposes. There's no rq->endp nor rq->trunk in this case. */ if (rq->null_endp) - return create_ok_response(rq->pdata->cfg, NULL, 200, "AUEP", rq->pdata->trans); + return create_ok_response(rq->cfg, NULL, 200, "AUEP", rq->pdata->trans); if (!rq->endp || !mgcp_endp_avail(rq->endp)) { LOGPENDP(rq->endp, DLMGCP, LOGL_ERROR, "AUEP: selected endpoint not available!\n"); @@ -772,7 +772,7 @@ if (rq->null_endp) { /* trunk not available so rate_ctr aren't available either. */ LOGP(DLMGCP, LOGL_ERROR, "CRCX: Not allowed in 'null' endpoint!\n"); - return create_err_response(pdata->cfg, NULL, 502, "CRCX", pdata->trans); + return create_err_response(rq->cfg, NULL, 502, "CRCX", pdata->trans); } rate_ctrs = trunk->ratectr.mgcp_crcx_ctr_group; @@ -1042,7 +1042,7 @@ if (rq->null_endp) { /* trunk not available so rate_ctr aren't available either. */ LOGP(DLMGCP, LOGL_ERROR, "MDCX: Not allowed in 'null' endpoint!\n"); - return create_err_response(pdata->cfg, NULL, 502, "MDCX", pdata->trans); + return create_err_response(rq->cfg, NULL, 502, "MDCX", pdata->trans); } rate_ctrs = trunk->ratectr.mgcp_mdcx_ctr_group; @@ -1238,7 +1238,7 @@ if (rq->null_endp) { /* trunk not available so rate_ctr aren't available either. */ LOGP(DLMGCP, LOGL_ERROR, "DLCX: Not allowed in 'null' endpoint!\n"); - return create_err_response(pdata->cfg, NULL, 502, "DLCX", pdata->trans); + return create_err_response(rq->cfg, NULL, 502, "DLCX", pdata->trans); } rate_ctrs = trunk->ratectr.mgcp_dlcx_ctr_group; @@ -1377,11 +1377,11 @@ if (rq->null_endp) { /* trunk not available so rate_ctr aren't available either. */ LOGP(DLMGCP, LOGL_ERROR, "RSIP: Not allowed in 'null' endpoint!\n"); - return create_err_response(rq->pdata->cfg, NULL, 502, "RSIP", rq->pdata->trans); + return create_err_response(rq->cfg, NULL, 502, "RSIP", rq->pdata->trans); } - if (rq->pdata->cfg->reset_cb) - rq->pdata->cfg->reset_cb(rq->endp->trunk); + if (rq->cfg->reset_cb) + rq->cfg->reset_cb(rq->endp->trunk); return NULL; } @@ -1408,7 +1408,7 @@ if (rq->null_endp) { /* trunk not available so rate_ctr aren't available either. */ LOGP(DLMGCP, LOGL_ERROR, "RQNT: Not allowed in 'null' endpoint!\n"); - return create_err_response(rq->pdata->cfg, NULL, 502, "RQNT", rq->pdata->trans); + return create_err_response(rq->cfg, NULL, 502, "RQNT", rq->pdata->trans); } for_each_line(line, rq->pdata->save) { @@ -1423,8 +1423,8 @@ if (tone == CHAR_MAX) return create_ok_response(rq->endp, rq->endp, 200, "RQNT", rq->pdata->trans); - if (rq->pdata->cfg->rqnt_cb) - res = rq->pdata->cfg->rqnt_cb(rq->endp, tone); + if (rq->cfg->rqnt_cb) + res = rq->cfg->rqnt_cb(rq->endp, tone); return res == 0 ? create_ok_response(rq->endp, rq->endp, 200, "RQNT", rq->pdata->trans) : create_err_response(rq->endp, rq->endp, res, "RQNT", rq->pdata->trans); -- To view, visit https://gerrit.osmocom.org/c/osmo-mgw/+/39719?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: osmo-mgw Gerrit-Branch: master Gerrit-Change-Id: Ie64fb6250cc84f1e7737b5c1cf5cca314c7020ed Gerrit-Change-Number: 39719 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de>
1 0
0 0
[XS] Change in osmo-mgw[master]: mgw: Add backpointer from pdata to req to have context available
by pespin 06 Mar '25

06 Mar '25
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-mgw/+/39720?usp=email ) Change subject: mgw: Add backpointer from pdata to req to have context available ...................................................................... mgw: Add backpointer from pdata to req to have context available This will also allow eg. parsing/validating differently based on the command being parsed, or incrementing rate counters per cmd group. Change-Id: I464258ca1a8817d58ae5c5426dfc3b7cee6763d3 --- M include/osmocom/mgcp/mgcp_protocol.h M src/libosmo-mgcp/mgcp_msg.c M src/libosmo-mgcp/mgcp_protocol.c 3 files changed, 5 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/20/39720/1 diff --git a/include/osmocom/mgcp/mgcp_protocol.h b/include/osmocom/mgcp/mgcp_protocol.h index e61669c..2ef4c3e 100644 --- a/include/osmocom/mgcp/mgcp_protocol.h +++ b/include/osmocom/mgcp/mgcp_protocol.h @@ -71,7 +71,9 @@ } /* Internal structure while parsing a request */ +struct mgcp_request_data; struct mgcp_parse_data { + struct mgcp_request_data *rq; /* backpointer to request context */ char *save; /* MGCP Header: */ char *epname; diff --git a/src/libosmo-mgcp/mgcp_msg.c b/src/libosmo-mgcp/mgcp_msg.c index 2269a66..af4f9d0 100644 --- a/src/libosmo-mgcp/mgcp_msg.c +++ b/src/libosmo-mgcp/mgcp_msg.c @@ -36,7 +36,7 @@ /* (same fmt as LOGPENDP()) */ #define LOG_MGCP_PDATA(PDATA, LEVEL, FMT, ARGS...) \ - LOGP(DLMGCP, LEVEL, "endpoint:%s " FMT, (PDATA) ? ((PDATA)->epname ? : "null-epname") : "null-pdata", ##ARGS) + LOGP(DLMGCP, LEVEL, "%s: endpoint(%s) " FMT, (PDATA)->rq->name, (PDATA)->epname ? : "null-epname", ##ARGS) /*! Display an mgcp message on the log output. * \param[in] message mgcp message string @@ -212,7 +212,7 @@ hp->have_sdp = true; goto mgcp_header_done; default: - LOG_MGCP_PDATA(pdata, LOGL_NOTICE, "CRCX: unhandled option: '%c'/%d\n", *line, *line); + LOG_MGCP_PDATA(pdata, LOGL_NOTICE, "unhandled option: '%c'/%d\n", *line, *line); return -539; } } diff --git a/src/libosmo-mgcp/mgcp_protocol.c b/src/libosmo-mgcp/mgcp_protocol.c index 1215b95..1eb241b 100644 --- a/src/libosmo-mgcp/mgcp_protocol.c +++ b/src/libosmo-mgcp/mgcp_protocol.c @@ -332,6 +332,7 @@ memset(&rq, 0, sizeof(rq)); rq.cfg = cfg; memset(&pdata, 0, sizeof(pdata)); + pdata.rq = &rq; /* Parse command name: */ memcpy(rq.name, (const char *)&msg->l2h[0], sizeof(rq.name)-1); -- To view, visit https://gerrit.osmocom.org/c/osmo-mgw/+/39720?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: osmo-mgw Gerrit-Branch: master Gerrit-Change-Id: I464258ca1a8817d58ae5c5426dfc3b7cee6763d3 Gerrit-Change-Number: 39720 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de>
1 0
0 0
[XS] Change in osmo-mgw[master]: mgw: Use tall_mgw_ctx to allocate struct mgcp_config
by pespin 06 Mar '25

06 Mar '25
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-mgw/+/39721?usp=email ) Change subject: mgw: Use tall_mgw_ctx to allocate struct mgcp_config ...................................................................... mgw: Use tall_mgw_ctx to allocate struct mgcp_config Change-Id: Ib51f1066bb73da4472bd8967cc1b1c44e964e9e5 --- M include/osmocom/mgcp/mgcp.h M src/libosmo-mgcp/mgcp_protocol.c M tests/mgcp/mgcp_test.c 3 files changed, 6 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/21/39721/1 diff --git a/include/osmocom/mgcp/mgcp.h b/include/osmocom/mgcp/mgcp.h index 41eee42..f72807e 100644 --- a/include/osmocom/mgcp/mgcp.h +++ b/include/osmocom/mgcp/mgcp.h @@ -40,6 +40,8 @@ #include "mgcp_ratectr.h" +extern void *tall_mgw_ctx; + #define RTP_PORT_DEFAULT_RANGE_START 16002 #define RTP_PORT_DEFAULT_RANGE_END RTP_PORT_DEFAULT_RANGE_START + 64 diff --git a/src/libosmo-mgcp/mgcp_protocol.c b/src/libosmo-mgcp/mgcp_protocol.c index 1eb241b..163b816 100644 --- a/src/libosmo-mgcp/mgcp_protocol.c +++ b/src/libosmo-mgcp/mgcp_protocol.c @@ -1505,7 +1505,7 @@ * appropiate place! */ struct mgcp_config *cfg; - cfg = talloc_zero(NULL, struct mgcp_config); + cfg = talloc_zero(tall_mgw_ctx, struct mgcp_config); if (!cfg) { LOGP(DLMGCP, LOGL_FATAL, "Failed to allocate config.\n"); return NULL; diff --git a/tests/mgcp/mgcp_test.c b/tests/mgcp/mgcp_test.c index 1c1a41e..b9224d9 100644 --- a/tests/mgcp/mgcp_test.c +++ b/tests/mgcp/mgcp_test.c @@ -43,6 +43,8 @@ #include <math.h> #include <ctype.h> +void *tall_mgw_ctx; + char *strline_r(char *str, char **saveptr); const char *strline_test_data = @@ -2323,7 +2325,7 @@ INIT_LLIST_HEAD(&endp.conns); - conn = talloc_zero(NULL, struct mgcp_conn); + conn = talloc_zero(tall_mgw_ctx, struct mgcp_conn); OSMO_ASSERT(conn); osmo_strlcpy(conn->id, conn_id_generated, sizeof(conn->id)); llist_add(&conn->entry, &endp.conns); -- To view, visit https://gerrit.osmocom.org/c/osmo-mgw/+/39721?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: osmo-mgw Gerrit-Branch: master Gerrit-Change-Id: Ib51f1066bb73da4472bd8967cc1b1c44e964e9e5 Gerrit-Change-Number: 39721 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de>
1 0
0 0
[M] Change in osmo-mgw[master]: mgw: Allocate req and pdata with talloc
by pespin 06 Mar '25

06 Mar '25
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-mgw/+/39722?usp=email ) Change subject: mgw: Allocate req and pdata with talloc ...................................................................... mgw: Allocate req and pdata with talloc This will allow allocating parsed objects as child of the request and make sure they are freed after handling the request finishes. Change-Id: I2b971d0c8268f4c0a30b84b54a2e5f16ada4ecdb --- M src/libosmo-mgcp/mgcp_protocol.c 1 file changed, 56 insertions(+), 50 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/22/39722/1 diff --git a/src/libosmo-mgcp/mgcp_protocol.c b/src/libosmo-mgcp/mgcp_protocol.c index 163b816..06da91a 100644 --- a/src/libosmo-mgcp/mgcp_protocol.c +++ b/src/libosmo-mgcp/mgcp_protocol.c @@ -297,8 +297,8 @@ struct msgb *mgcp_handle_message(struct mgcp_config *cfg, struct msgb *msg) { struct rate_ctr_group *rate_ctrs = cfg->ratectr.mgcp_general_ctr_group; - struct mgcp_parse_data pdata; - struct mgcp_request_data rq; + struct mgcp_parse_data *pdata = NULL; + struct mgcp_request_data *rq = NULL; int rc, code; struct msgb *resp = NULL; char *data; @@ -329,106 +329,112 @@ } /* Initialize parsing data. */ - memset(&rq, 0, sizeof(rq)); - rq.cfg = cfg; - memset(&pdata, 0, sizeof(pdata)); - pdata.rq = &rq; + rq = talloc_zero(tall_mgw_ctx, struct mgcp_request_data); + rq->cfg = cfg; + rq->pdata = pdata = talloc_zero(rq, struct mgcp_parse_data); + pdata->rq = rq; /* Parse command name: */ - memcpy(rq.name, (const char *)&msg->l2h[0], sizeof(rq.name)-1); - rc = get_string_value(mgcp_verb_names, rq.name); + memcpy(rq->name, (const char *)&msg->l2h[0], sizeof(rq->name)-1); + rc = get_string_value(mgcp_verb_names, rq->name); if (rc < 0) { - LOGP(DLMGCP, LOGL_ERROR, "%s: failed to parse command name in MCGP message\n", rq.name); + LOGP(DLMGCP, LOGL_ERROR, "%s: failed to parse command name in MCGP message\n", rq->name); rate_ctr_inc(rate_ctr_group_get_ctr(rate_ctrs, MGCP_GENERAL_RX_FAIL_MSG_PARSE)); rate_ctr_inc(rate_ctr_group_get_ctr(rate_ctrs, MGCP_GENERAL_RX_MSGS_UNHANDLED)); - return create_err_response(cfg, NULL, 504, rq.name, "000000"); + resp = create_err_response(cfg, NULL, 504, rq->name, "000000"); + goto ret_free; } - rq.verb = rc; + rq->verb = rc; /* Parse message, extract endpoint name and transaction identifier and request name etc. */ msg->l3h = &msg->l2h[4]; - data = mgcp_strline((char *)msg->l3h, &pdata.save); - rc = mgcp_parse_header(&pdata, data); + data = mgcp_strline((char *)msg->l3h, &pdata->save); + rc = mgcp_parse_header(pdata, data); if (rc < 0) { - LOGP(DLMGCP, LOGL_ERROR, "%s: failed to parse MCGP message\n", rq.name); + LOGP(DLMGCP, LOGL_ERROR, "%s: failed to parse MCGP message\n", rq->name); rate_ctr_inc(rate_ctr_group_get_ctr(rate_ctrs, MGCP_GENERAL_RX_FAIL_MSG_PARSE)); - return create_err_response(cfg, NULL, -rc, rq.name, "000000"); + resp = create_err_response(cfg, NULL, -rc, rq->name, "000000"); + goto ret_free; } /* Locate endpoint and trunk, if no endpoint can be located try at least to identify the trunk. */ - rq.pdata = &pdata; - rq.wildcarded = mgcp_endp_is_wildcarded(pdata.epname); - if (!rq.wildcarded) - rq.null_endp = mgcp_endp_is_null(pdata.epname); - if (!rq.null_endp) - rq.endp = mgcp_endp_by_name(&rc, pdata.epname, rq.cfg); - rq.mgcp_cause = rc; - if (!rq.endp) { + rq->wildcarded = mgcp_endp_is_wildcarded(pdata->epname); + if (!rq->wildcarded) + rq->null_endp = mgcp_endp_is_null(pdata->epname); + if (!rq->null_endp) + rq->endp = mgcp_endp_by_name(&rc, pdata->epname, rq->cfg); + rq->mgcp_cause = rc; + if (!rq->endp) { rate_ctr_inc(rate_ctr_group_get_ctr(rate_ctrs, MGCP_GENERAL_RX_FAIL_NO_ENDPOINT)); - if (rq.wildcarded) { + if (rq->wildcarded) { /* If we are unable to find the endpoint we still may be able to identify the trunk. Some * request handlers will still be able to perform a useful action if the request refers to * the whole trunk (wildcarded request). */ LOGP(DLMGCP, LOGL_NOTICE, - "%s: cannot find endpoint \"%s\", cause=%d -- trying to identify trunk...\n", rq.name, - pdata.epname, -rq.mgcp_cause); - rq.trunk = mgcp_trunk_by_name(rq.cfg, pdata.epname); - if (!rq.trunk) { + "%s: cannot find endpoint \"%s\", cause=%d -- trying to identify trunk...\n", rq->name, + pdata->epname, -rq->mgcp_cause); + rq->trunk = mgcp_trunk_by_name(rq->cfg, pdata->epname); + if (!rq->trunk) { LOGP(DLMGCP, LOGL_ERROR, "%s: failed to identify trunk for endpoint \"%s\" -- abort\n", - rq.name, pdata.epname); - return create_err_response(cfg, NULL, -rq.mgcp_cause, rq.name, pdata.trans); + rq->name, pdata->epname); + resp = create_err_response(cfg, NULL, -rq->mgcp_cause, rq->name, pdata->trans); + goto ret_free; } - } else if (!rq.null_endp) { + } else if (!rq->null_endp) { /* If the endpoint name suggests that the request refers to a specific endpoint, then the * request cannot be handled and we must stop early. */ LOGP(DLMGCP, LOGL_NOTICE, - "%s: cannot find endpoint \"%s\", cause=%d -- abort\n", rq.name, - pdata.epname, -rq.mgcp_cause); - return create_err_response(cfg, NULL, -rq.mgcp_cause, rq.name, pdata.trans); - } /* else: Handle special "null" endpoint below (with rq.endp=NULL, rq.trunk=NULL) */ + "%s: cannot find endpoint \"%s\", cause=%d -- abort\n", rq->name, + pdata->epname, -rq->mgcp_cause); + resp = create_err_response(cfg, NULL, -rq->mgcp_cause, rq->name, pdata->trans); + goto ret_free; + } /* else: Handle special "null" endpoint below (with rq->endp=NULL, rq->trunk=NULL) */ } else { - osmo_strlcpy(debug_last_endpoint_name, rq.endp->name, sizeof(debug_last_endpoint_name)); - rq.trunk = rq.endp->trunk; - rq.mgcp_cause = 0; + osmo_strlcpy(debug_last_endpoint_name, rq->endp->name, sizeof(debug_last_endpoint_name)); + rq->trunk = rq->endp->trunk; + rq->mgcp_cause = 0; /* Check if we have to retransmit a response from a previous transaction */ - if (pdata.trans && rq.endp->last_trans && strcmp(rq.endp->last_trans, pdata.trans) == 0) { + if (pdata->trans && rq->endp->last_trans && strcmp(rq->endp->last_trans, pdata->trans) == 0) { rate_ctr_inc(rate_ctr_group_get_ctr(rate_ctrs, MGCP_GENERAL_RX_MSGS_RETRANSMITTED)); - return create_retransmission_response(rq.endp); + resp = create_retransmission_response(rq->endp); + goto ret_free; } } /* Execute request handler */ - if (rq.endp) + if (rq->endp) LOGP(DLMGCP, LOGL_INFO, "%s: executing request handler for endpoint resource \"%s\"\n", - rq.name, rq.endp->name); + rq->name, rq->endp->name); else LOGP(DLMGCP, LOGL_INFO, "%s: executing request handler for trunk resource of endpoint \"%s\"\n", - rq.name, pdata.epname); - switch (rq.verb) { + rq->name, pdata->epname); + switch (rq->verb) { case MGCP_VERB_AUEP: - resp = handle_audit_endpoint(&rq); + resp = handle_audit_endpoint(rq); break; case MGCP_VERB_CRCX: - resp = handle_create_con(&rq); + resp = handle_create_con(rq); break; case MGCP_VERB_DLCX: - resp = handle_delete_con(&rq); + resp = handle_delete_con(rq); break; case MGCP_VERB_MDCX: - resp = handle_modify_con(&rq); + resp = handle_modify_con(rq); break; case MGCP_VERB_RQNT: - resp = handle_noti_req(&rq); + resp = handle_noti_req(rq); break; case MGCP_VERB_RSIP: - resp = handle_rsip(&rq); + resp = handle_rsip(rq); break; default: OSMO_ASSERT(0); } rate_ctr_inc(rate_ctr_group_get_ctr(rate_ctrs, MGCP_GENERAL_RX_MSGS_HANDLED)); +ret_free: + talloc_free(rq); return resp; } -- To view, visit https://gerrit.osmocom.org/c/osmo-mgw/+/39722?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: osmo-mgw Gerrit-Branch: master Gerrit-Change-Id: I2b971d0c8268f4c0a30b84b54a2e5f16ada4ecdb Gerrit-Change-Number: 39722 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de>
1 0
0 0
  • ← Newer
  • 1
  • ...
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • ...
  • 138
  • Older →

HyperKitty Powered by HyperKitty version 1.3.12.