Change in osmo-hlr[master]: move creation of insert subscriber data messages to a common function
Stefan Sperling has submitted this change and it was merged. ( https://gerrit.osmocom.org/7992 ) Change subject: move creation of insert subscriber data messages to a common function .. move creation of insert subscriber data messages to a common function Move code to create an Insert Subscriber Data message into a common function which can be shared by hlr.c and luop.c. As a consequence, we always encode gsup.cn_domain in the corresponding msgb and must adjust expected output of the 'gsup' test accordingly. Change-Id: I6a92ca34cdaadca9eacc774bb1ca386c325ba865 Requested-by: neels Related: OS#2785 --- M src/gsup_server.c M src/gsup_server.h M src/hlr.c M src/luop.c M tests/gsup/gsup_test.err 5 files changed, 103 insertions(+), 67 deletions(-) Approvals: Jenkins Builder: Verified Neels Hofmeyr: Looks good to me, approved diff --git a/src/gsup_server.c b/src/gsup_server.c index 07d4feb..4b8a0fa 100644 --- a/src/gsup_server.c +++ b/src/gsup_server.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include "gsup_server.h" @@ -357,3 +358,56 @@ return 0; } + +/** + * Populate a gsup message structure with an Insert Subscriber Data Message. + * All required memory buffers for data pointed to by pointers in struct omso_gsup_message + * must be allocated by the caller and should have the same lifetime as the gsup parameter. + * + * \param[out] gsup The gsup message to populate. + * \param[in] imsi The subscriber's IMSI. + * \param[in] msisdn The subscriber's MSISDN. + * \param[out] msisdn_enc A buffer large enough to store the MSISDN in encoded form. + * \param[in] msisdn_enc_size Size of the buffer (must be >= OSMO_GSUP_MAX_CALLED_PARTY_BCD_LEN). + * \param[out] apn_buf A buffer large enough to store an APN (required if cn_domain is OSMO_GSUP_CN_DOMAIN_PS). + * \param[in] apn_buf_size Size of APN buffer (must be >= APN_MAXLEN). + * \param[in] cn_domain The CN Domain of the subscriber connection. + * \returns 0 on success, and negative on error. + */ +int osmo_gsup_create_insert_subscriber_data_msg(struct osmo_gsup_message *gsup, const char *imsi, const char *msisdn, + uint8_t *msisdn_enc, size_t msisdn_enc_size, + uint8_t *apn_buf, size_t apn_buf_size, + enum osmo_gsup_cn_domain cn_domain) +{ + int len; + + OSMO_ASSERT(gsup); + + gsup->message_type = OSMO_GSUP_MSGT_INSERT_DATA_REQUEST; + osmo_strlcpy(gsup->imsi, imsi, sizeof(gsup->imsi)); + + if (msisdn_enc_size < OSMO_GSUP_MAX_CALLED_PARTY_BCD_LEN) + return -ENOSPC; + + OSMO_ASSERT(msisdn_enc); + len = gsm48_encode_bcd_number(msisdn_enc, msisdn_enc_size, 0, msisdn); + if (len < 1) { + LOGP(DLGSUP, LOGL_ERROR, "%s: Error: cannot encode MSISDN '%s'\n", imsi, msisdn); + return -ENOSPC; + } + gsup->msisdn_enc = msisdn_enc; + gsup->msisdn_enc_len = len; + + #pragma message "FIXME: deal with encoding the following data: gsup.hlr_enc" + + gsup->cn_domain = cn_domain; + if (gsup->cn_domain == OSMO_GSUP_CN_DOMAIN_PS) { + OSMO_ASSERT(apn_buf_size >= APN_MAXLEN); + OSMO_ASSERT(apn_buf); + /* FIXME: PDP infos - use more fine-grained access control + instead of wildcard APN */ + osmo_gsup_configure_wildcard_apn(gsup, apn_buf, apn_buf_size); + } + + return 0; +} diff --git a/src/gsup_server.h b/src/gsup_server.h index 66c1a9c..e49d283 100644 --- a/src/gsup_server.h +++ b/src/gsup_server.h @@ -6,6 +6,10 @@ #include #include +#ifndef OSMO_GSUP_MAX_CALLED_PARTY_BCD_LEN +#define OSMO_GSUP_MAX_CALLED_PARTY_BCD_LEN 43 /* TS 24.008 10.5.4.7 */ +#endif + struct osmo_gsup_conn; /* Expects message in msg->l2h */ @@ -55,3 +59,7 @@ int osmo_gsup_configure_wildcard_apn(struct osmo_gsup_message *gsup, uint8_t *apn_buf, size_t apn_buf_size); +int osmo_gsup_create_insert_subscriber_data_msg(struct osmo_gsup_message *gsup, const char *imsi, const char *msisdn, + uint8_t *msisdn_enc, size_t msisdn_enc_size, + uint8_t *apn_buf, size_t apn_buf_size, + enum osmo_gsup_cn_domain cn_domain); diff --git a/src/hlr.c b/src/hlr.c index 1c72f45..4da7b9b 100644 --- a/src/hlr.c +++ b/src/hlr.c @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include @@ -62,54 +61,33 @@ return; llist_for_each_entry(co, &g_hlr->gs->clients, list) { - struct osmo_gsup_message gsup = { - .message_type = OSMO_GSUP_MSGT_INSERT_DATA_REQUEST - }; + struct osm
Change in osmo-hlr[master]: move creation of insert subscriber data messages to a common function
Neels Hofmeyr has posted comments on this change. ( https://gerrit.osmocom.org/7992 ) Change subject: move creation of insert subscriber data messages to a common function .. Patch Set 6: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/7992 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-MessageType: comment Gerrit-Change-Id: I6a92ca34cdaadca9eacc774bb1ca386c325ba865 Gerrit-Change-Number: 7992 Gerrit-PatchSet: 6 Gerrit-Owner: Stefan Sperling Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: Stefan Sperling Gerrit-Reviewer: neels Gerrit-Comment-Date: Fri, 18 May 2018 12:17:31 + Gerrit-HasComments: No Gerrit-HasLabels: Yes
Change in osmo-hlr[master]: move creation of insert subscriber data messages to a common function
Hello neels, Neels Hofmeyr, Harald Welte, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/7992 to look at the new patch set (#6). Change subject: move creation of insert subscriber data messages to a common function .. move creation of insert subscriber data messages to a common function Move code to create an Insert Subscriber Data message into a common function which can be shared by hlr.c and luop.c. As a consequence, we always encode gsup.cn_domain in the corresponding msgb and must adjust expected output of the 'gsup' test accordingly. Change-Id: I6a92ca34cdaadca9eacc774bb1ca386c325ba865 Requested-by: neels Related: OS#2785 --- M src/gsup_server.c M src/gsup_server.h M src/hlr.c M src/luop.c M tests/gsup/gsup_test.err 5 files changed, 103 insertions(+), 67 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/92/7992/6 -- To view, visit https://gerrit.osmocom.org/7992 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-MessageType: newpatchset Gerrit-Change-Id: I6a92ca34cdaadca9eacc774bb1ca386c325ba865 Gerrit-Change-Number: 7992 Gerrit-PatchSet: 6 Gerrit-Owner: Stefan Sperling Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: Stefan Sperling Gerrit-Reviewer: neels
Change in osmo-hlr[master]: move creation of insert subscriber data messages to a common function
Neels Hofmeyr has posted comments on this change. ( https://gerrit.osmocom.org/7992 ) Change subject: move creation of insert subscriber data messages to a common function .. Patch Set 5: Code-Review-1 (1 comment) https://gerrit.osmocom.org/#/c/7992/5/src/gsup_server.c File src/gsup_server.c: https://gerrit.osmocom.org/#/c/7992/5/src/gsup_server.c@377 PS5, Line 377: int osmo_gsup_create_insert_subscriber_data_msg(struct osmo_gsup_message *gsup, char *imsi, char *msisdn, imsi and msisdn should be const, as laforge requested earlier -- To view, visit https://gerrit.osmocom.org/7992 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-MessageType: comment Gerrit-Change-Id: I6a92ca34cdaadca9eacc774bb1ca386c325ba865 Gerrit-Change-Number: 7992 Gerrit-PatchSet: 5 Gerrit-Owner: Stefan Sperling Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: Stefan Sperling Gerrit-Reviewer: neels Gerrit-Comment-Date: Thu, 17 May 2018 15:30:47 + Gerrit-HasComments: Yes Gerrit-HasLabels: Yes
Change in osmo-hlr[master]: move creation of insert subscriber data messages to a common function
Hello neels, Neels Hofmeyr, Harald Welte, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/7992 to look at the new patch set (#5). Change subject: move creation of insert subscriber data messages to a common function .. move creation of insert subscriber data messages to a common function Move code to create an Insert Subscriber Data message into a common function which can be shared by hlr.c and luop.c. As a consequence, we always encode gsup.cn_domain in the corresponding msgb and must adjust expected output of the 'gsup' test accordingly. Change-Id: I6a92ca34cdaadca9eacc774bb1ca386c325ba865 Requested-by: neels Related: OS#2785 --- M src/gsup_server.c M src/gsup_server.h M src/hlr.c M src/luop.c M tests/gsup/gsup_test.err 5 files changed, 103 insertions(+), 67 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/92/7992/5 -- To view, visit https://gerrit.osmocom.org/7992 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-MessageType: newpatchset Gerrit-Change-Id: I6a92ca34cdaadca9eacc774bb1ca386c325ba865 Gerrit-Change-Number: 7992 Gerrit-PatchSet: 5 Gerrit-Owner: Stefan Sperling Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: Stefan Sperling Gerrit-Reviewer: neels
Change in osmo-hlr[master]: move creation of insert subscriber data messages to a common function
Neels Hofmeyr has posted comments on this change. ( https://gerrit.osmocom.org/7992 ) Change subject: move creation of insert subscriber data messages to a common function .. Patch Set 4: Code-Review+1 (3 comments) https://gerrit.osmocom.org/#/c/7992/4/src/gsup_server.c File src/gsup_server.c: https://gerrit.osmocom.org/#/c/7992/4/src/gsup_server.c@370 PS4, Line 370: * \param[in] msisdn_enc A buffer large enough to store the MSISDN in encoded form. technically that's an [out] param, right? https://gerrit.osmocom.org/#/c/7992/4/src/gsup_server.c@372 PS4, Line 372: * \param[in] apn_buf A buffer large enough to store an APN (required if cn_domain is OSMO_GSUP_CN_DOMAIN_PS). out? https://gerrit.osmocom.org/#/c/7992/4/src/hlr.c File src/hlr.c: https://gerrit.osmocom.org/#/c/7992/4/src/hlr.c@103 PS4, Line 103: peer_len = osmo_gsup_conn_ccm_get(co, &peer, IPAC_IDTAG_SERNR); unrelated change? ... ah no, the diff just makes the re-arrangement hard to spot. -- To view, visit https://gerrit.osmocom.org/7992 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-MessageType: comment Gerrit-Change-Id: I6a92ca34cdaadca9eacc774bb1ca386c325ba865 Gerrit-Change-Number: 7992 Gerrit-PatchSet: 4 Gerrit-Owner: Stefan Sperling Gerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: Stefan Sperling Gerrit-Reviewer: neels Gerrit-Comment-Date: Mon, 14 May 2018 15:17:09 + Gerrit-HasComments: Yes Gerrit-HasLabels: Yes