[PATCH] osmo-hlr[master]: rewrite subscriber_update_notify() without calls into luop
Hello Neels Hofmeyr, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/7743 to look at the new patch set (#7). rewrite subscriber_update_notify() without calls into luop This function relied on implementation details of the luop code. Port what is necessary for an independent Insert Subscriber Data Tx operation from the luop code into this function. A next possible step would be to try to merge both of these into a common implementation. This will be addressed in a follow-up change as soon as this change is merged. The TTCN3 test TC_vty_msisdn_isd is still passing (it currently triggers the "circuit switched domain" case because it does not advertise itself as an SGSN in the IPA unit name). Change-Id: I06c43ece2b48dc63d599000eb6d6d51e08963067 Related: OS#2785 --- M src/gsup_server.c M src/gsup_server.h M src/hlr.c M src/luop.c 4 files changed, 94 insertions(+), 21 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/43/7743/7 diff --git a/src/gsup_server.c b/src/gsup_server.c index b382c86..24ba738 100644 --- a/src/gsup_server.c +++ b/src/gsup_server.c @@ -24,6 +24,7 @@ #include #include #include +#include #include "gsup_server.h" #include "gsup_router.h" @@ -333,3 +334,20 @@ } talloc_free(gsups); } + +void osmo_gsup_configure_wildcard_apn(struct osmo_gsup_message *gsup) +{ + int l; + uint8_t apn[APN_MAXLEN]; + + l = osmo_apn_from_str(apn, sizeof(apn), "*"); + if (l <= 0) + return; + + gsup->pdp_infos[0].apn_enc = apn; + gsup->pdp_infos[0].apn_enc_len = l; + gsup->pdp_infos[0].have_info = 1; + gsup->num_pdp_infos = 1; + /* FIXME: use real value: */ + gsup->pdp_infos[0].context_id = 1; +} diff --git a/src/gsup_server.h b/src/gsup_server.h index 74062d4..3d36bff 100644 --- a/src/gsup_server.h +++ b/src/gsup_server.h @@ -4,6 +4,7 @@ #include #include #include +#include struct osmo_gsup_conn; @@ -33,6 +34,10 @@ struct tlv_parsed ccm; unsigned int auc_3g_ind; /*!< IND index used for UMTS AKA SQN */ + + /* Set when Location Update is received: */ + bool supports_cs; /* client supports OSMO_GSUP_CN_DOMAIN_CS */ + bool supports_ps; /* client supports OSMO_GSUP_CN_DOMAIN_PS */ }; @@ -48,3 +53,4 @@ void osmo_gsup_server_destroy(struct osmo_gsup_server *gsups); +void osmo_gsup_configure_wildcard_apn(struct osmo_gsup_message *gsup); diff --git a/src/hlr.c b/src/hlr.c index 3845993..479b5cf 100644 --- a/src/hlr.c +++ b/src/hlr.c @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include @@ -62,19 +61,69 @@ return; llist_for_each_entry(co, &g_hlr->gs->clients, list) { - struct lu_operation *luop = lu_op_alloc_conn(co); - if (!luop) { + struct osmo_gsup_message gsup = { + .message_type = OSMO_GSUP_MSGT_INSERT_DATA_REQUEST + }; + uint8_t *peer; + int peer_len; + uint8_t msisdn_enc[43]; /* TODO use constant; TS 24.008 10.5.4.7 */ + int len; + struct msgb *msg_out; + + peer_len = osmo_gsup_conn_ccm_get(co, &peer, IPAC_IDTAG_SERNR); + if (peer_len < 0) { LOGP(DMAIN, LOGL_ERROR, - "IMSI='%s': Cannot notify GSUP client, cannot allocate lu_operation," - " for %s:%u\n", subscr->imsi, + "IMSI='%s': Cannot notify GSUP client, cannot get peer name " + "for %s:%u\n", subscr->imsi, co && co->conn && co->conn->server? co->conn->server->addr : "unset", co && co->conn && co->conn->server? co->conn->server->port : 0); continue; } - luop->subscr = *subscr; - luop->state = LU_S_LU_RECEIVED; /* Pretend we received a location update. */ - lu_op_tx_insert_subscr_data(luop); - lu_op_free(luop); + + osmo_strlcpy(gsup.imsi, subscr->imsi, GSM23003_IMSI_MAX_DIGITS + 1); + + len = gsm48_encode_bcd_number(msisdn_enc, sizeof(msisdn_enc), 0, subscr->msisdn); + if (len < 1) { + LOGP(DMAIN, LOGL_ERROR, "%s: Error: cannot encode MSISDN '%s'\n", +subscr->imsi, subscr->msisdn); + continue; + } + gsup.msisdn_enc = msisdn_enc; + gsup.msisdn_enc_len = len; + + if (co->supports_ps) { + gsup.cn_domain = OSMO_GSUP_CN_DOMAIN_PS; + + /* FIXME: PDP infos - use more fine-grained access control + instead of wildcard APN */ + osmo_gsup_co
[PATCH] osmo-hlr[master]: rewrite subscriber_update_notify() without calls into luop
Hello Neels Hofmeyr, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/7743 to look at the new patch set (#6). rewrite subscriber_update_notify() without calls into luop This function relied on implementation details of the luop code. Port what is necessary for an independent Insert Subscriber Data Tx operation from the luop code into this function. A next possible step would be to try to merge both of these into a common implementation. This will be addressed in a follow-up change as soon as this change is merged. The TTCN3 test TC_vty_msisdn_isd is still passing (it currently triggers the "circuit switched domain" case because it does not advertise itself as an SGSN in the IPA unit name). Change-Id: I06c43ece2b48dc63d599000eb6d6d51e08963067 Related: OS#2785 --- M src/gsup_server.c M src/gsup_server.h M src/hlr.c M src/luop.c 4 files changed, 91 insertions(+), 21 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/43/7743/6 diff --git a/src/gsup_server.c b/src/gsup_server.c index b382c86..24ba738 100644 --- a/src/gsup_server.c +++ b/src/gsup_server.c @@ -24,6 +24,7 @@ #include #include #include +#include #include "gsup_server.h" #include "gsup_router.h" @@ -333,3 +334,20 @@ } talloc_free(gsups); } + +void osmo_gsup_configure_wildcard_apn(struct osmo_gsup_message *gsup) +{ + int l; + uint8_t apn[APN_MAXLEN]; + + l = osmo_apn_from_str(apn, sizeof(apn), "*"); + if (l <= 0) + return; + + gsup->pdp_infos[0].apn_enc = apn; + gsup->pdp_infos[0].apn_enc_len = l; + gsup->pdp_infos[0].have_info = 1; + gsup->num_pdp_infos = 1; + /* FIXME: use real value: */ + gsup->pdp_infos[0].context_id = 1; +} diff --git a/src/gsup_server.h b/src/gsup_server.h index 74062d4..3d36bff 100644 --- a/src/gsup_server.h +++ b/src/gsup_server.h @@ -4,6 +4,7 @@ #include #include #include +#include struct osmo_gsup_conn; @@ -33,6 +34,10 @@ struct tlv_parsed ccm; unsigned int auc_3g_ind; /*!< IND index used for UMTS AKA SQN */ + + /* Set when Location Update is received: */ + bool supports_cs; /* client supports OSMO_GSUP_CN_DOMAIN_CS */ + bool supports_ps; /* client supports OSMO_GSUP_CN_DOMAIN_PS */ }; @@ -48,3 +53,4 @@ void osmo_gsup_server_destroy(struct osmo_gsup_server *gsups); +void osmo_gsup_configure_wildcard_apn(struct osmo_gsup_message *gsup); diff --git a/src/hlr.c b/src/hlr.c index 3845993..a312e50 100644 --- a/src/hlr.c +++ b/src/hlr.c @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include @@ -62,19 +61,69 @@ return; llist_for_each_entry(co, &g_hlr->gs->clients, list) { - struct lu_operation *luop = lu_op_alloc_conn(co); - if (!luop) { + struct osmo_gsup_message gsup = { + .message_type = OSMO_GSUP_MSGT_INSERT_DATA_REQUEST + }; + uint8_t *peer; + int peer_len; + uint8_t msisdn_enc[43]; /* TODO use constant; TS 24.008 10.5.4.7 */ + int len; + struct msgb *msg_out; + + peer_len = osmo_gsup_conn_ccm_get(co, &peer, IPAC_IDTAG_SERNR); + if (peer_len < 0) { LOGP(DMAIN, LOGL_ERROR, - "IMSI='%s': Cannot notify GSUP client, cannot allocate lu_operation," - " for %s:%u\n", subscr->imsi, + "IMSI='%s': Cannot notify GSUP client, cannot get peer name " + "for %s:%u\n", subscr->imsi, co && co->conn && co->conn->server? co->conn->server->addr : "unset", co && co->conn && co->conn->server? co->conn->server->port : 0); continue; } - luop->subscr = *subscr; - luop->state = LU_S_LU_RECEIVED; /* Pretend we received a location update. */ - lu_op_tx_insert_subscr_data(luop); - lu_op_free(luop); + + osmo_strlcpy(gsup.imsi, subscr->imsi, GSM23003_IMSI_MAX_DIGITS + 1); + + len = gsm48_encode_bcd_number(msisdn_enc, sizeof(msisdn_enc), 0, subscr->msisdn); + if (len < 1) { + LOGP(DMAIN, LOGL_ERROR, "%s: Error: cannot encode MSISDN '%s'\n", +subscr->imsi, subscr->msisdn); + continue; + } + gsup.msisdn_enc = msisdn_enc; + gsup.msisdn_enc_len = len; + + if (co->supports_ps) { + gsup.cn_domain = OSMO_GSUP_CN_DOMAIN_PS; + + /* FIXME: PDP infos - use more fine-grained access control + instead of wildcard APN */ + osmo_gsup_co
[PATCH] osmo-hlr[master]: rewrite subscriber_update_notify() without calls into luop
Hello Neels Hofmeyr, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/7743 to look at the new patch set (#5). rewrite subscriber_update_notify() without calls into luop This function relied on implementation details of the luop code. Port what is necessary for an independent Insert Subscriber Data Tx operation from the luop code into this function. A next possible step would be to try to merge both of these into a common implementation. This will be addressed in a follow-up change as soon as this change is merged. The TTCN3 test TC_vty_msisdn_isd is still passing (it currently triggers the "circuit switched domain" case because it does not advertise itself as an SGSN in the IPA unit name). Change-Id: I06c43ece2b48dc63d599000eb6d6d51e08963067 Related: OS#2785 --- M src/gsup_server.h M src/hlr.c 2 files changed, 72 insertions(+), 8 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/43/7743/5 diff --git a/src/gsup_server.h b/src/gsup_server.h index 74062d4..f9a5869 100644 --- a/src/gsup_server.h +++ b/src/gsup_server.h @@ -4,6 +4,7 @@ #include #include #include +#include struct osmo_gsup_conn; @@ -33,6 +34,10 @@ struct tlv_parsed ccm; unsigned int auc_3g_ind; /*!< IND index used for UMTS AKA SQN */ + + /* Set when Location Update is received: */ + bool supports_cs; /* client supports OSMO_GSUP_CN_DOMAIN_CS */ + bool supports_ps; /* client supports OSMO_GSUP_CN_DOMAIN_PS */ }; diff --git a/src/hlr.c b/src/hlr.c index 3845993..8f6f227 100644 --- a/src/hlr.c +++ b/src/hlr.c @@ -62,19 +62,74 @@ return; llist_for_each_entry(co, &g_hlr->gs->clients, list) { - struct lu_operation *luop = lu_op_alloc_conn(co); - if (!luop) { + struct osmo_gsup_message gsup = { + .message_type = OSMO_GSUP_MSGT_INSERT_DATA_REQUEST + }; + uint8_t *peer; + int peer_len; + uint8_t msisdn_enc[43]; /* TODO use constant; TS 24.008 10.5.4.7 */ + uint8_t apn[APN_MAXLEN]; + int len; + struct msgb *msg_out; + + peer_len = osmo_gsup_conn_ccm_get(co, &peer, IPAC_IDTAG_SERNR); + if (peer_len < 0) { LOGP(DMAIN, LOGL_ERROR, - "IMSI='%s': Cannot notify GSUP client, cannot allocate lu_operation," + "IMSI='%s': Cannot notify GSUP client, cannot get peer name " " for %s:%u\n", subscr->imsi, co && co->conn && co->conn->server? co->conn->server->addr : "unset", co && co->conn && co->conn->server? co->conn->server->port : 0); continue; } - luop->subscr = *subscr; - luop->state = LU_S_LU_RECEIVED; /* Pretend we received a location update. */ - lu_op_tx_insert_subscr_data(luop); - lu_op_free(luop); + + osmo_strlcpy(gsup.imsi, subscr->imsi, GSM23003_IMSI_MAX_DIGITS + 1); + + len = gsm48_encode_bcd_number(msisdn_enc, sizeof(msisdn_enc), 0, subscr->msisdn); + if (len < 1) { + LOGP(DMAIN, LOGL_ERROR, "%s: Error: cannot encode MSISDN '%s'\n", +subscr->imsi, subscr->msisdn); + continue; + } + gsup.msisdn_enc = msisdn_enc; + gsup.msisdn_enc_len = len; + + if (co->supports_ps) { + gsup.cn_domain = OSMO_GSUP_CN_DOMAIN_PS; + + /* FIXME: PDP infos - use more fine-grained access control + instead of wildcard APN */ + len = osmo_apn_from_str(apn, sizeof(apn), "*"); + if (len > 0) { + gsup.pdp_infos[0].apn_enc = apn; + gsup.pdp_infos[0].apn_enc_len = len; + gsup.pdp_infos[0].have_info = 1; + gsup.num_pdp_infos = 1; + /* FIXME: use real value: */ + gsup.pdp_infos[0].context_id = 1; + } + } else + gsup.cn_domain = OSMO_GSUP_CN_DOMAIN_CS; + + /* Send ISD to MSC/SGSN */ + msg_out = msgb_alloc_headroom(1024+16, 16, "GSUP ISD UPDATE"); + if (msg_out == NULL) { + LOGP(DMAIN, LOGL_ERROR, + "IMSI='%s': Cannot notify GSUP client; could not allocate msg buffer " + " for %s:%u\n", subscr->imsi, + co && co->conn && co->conn->server? co->conn->server->addr : "unset", + co &
[PATCH] osmo-hlr[master]: rewrite subscriber_update_notify() without calls into luop
Hello Neels Hofmeyr, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/7743 to look at the new patch set (#4). rewrite subscriber_update_notify() without calls into luop This function relied on implementation details of the luop code. Port what is necessary for an independent Insert Subscriber Data Tx operation from the luop code into this function. A next possible step would be to try to merge both of these into a common implementation. This will be addressed in a follow-up change as soon as this change is merged. The TTCN3 test TC_vty_msisdn_isd is still passing (it currently triggers the "circuit switched domain" case because it does not advertise itself as an SGSN in the IPA unit name). Change-Id: I06c43ece2b48dc63d599000eb6d6d51e08963067 Related: OS#2785 --- M src/gsup_server.h M src/hlr.c 2 files changed, 73 insertions(+), 8 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/43/7743/4 diff --git a/src/gsup_server.h b/src/gsup_server.h index 74062d4..f9a5869 100644 --- a/src/gsup_server.h +++ b/src/gsup_server.h @@ -4,6 +4,7 @@ #include #include #include +#include struct osmo_gsup_conn; @@ -33,6 +34,10 @@ struct tlv_parsed ccm; unsigned int auc_3g_ind; /*!< IND index used for UMTS AKA SQN */ + + /* Set when Location Update is received: */ + bool supports_cs; /* client supports OSMO_GSUP_CN_DOMAIN_CS */ + bool supports_ps; /* client supports OSMO_GSUP_CN_DOMAIN_PS */ }; diff --git a/src/hlr.c b/src/hlr.c index 3845993..d068e15 100644 --- a/src/hlr.c +++ b/src/hlr.c @@ -62,19 +62,75 @@ return; llist_for_each_entry(co, &g_hlr->gs->clients, list) { - struct lu_operation *luop = lu_op_alloc_conn(co); - if (!luop) { + struct osmo_gsup_message gsup = { + .message_type = OSMO_GSUP_MSGT_INSERT_DATA_REQUEST + }; + uint8_t *peer; + int peer_len; + uint8_t msisdn_enc[43]; /* TODO use constant; TS 24.008 10.5.4.7 */ + uint8_t apn[APN_MAXLEN]; + int len; + struct msgb *msg_out; + + peer_len = osmo_gsup_conn_ccm_get(co, &peer, IPAC_IDTAG_SERNR); + if (peer_len < 0) { LOGP(DMAIN, LOGL_ERROR, - "IMSI='%s': Cannot notify GSUP client, cannot allocate lu_operation," + "IMSI='%s': Cannot notify GSUP client, cannot get peer name " " for %s:%u\n", subscr->imsi, co && co->conn && co->conn->server? co->conn->server->addr : "unset", co && co->conn && co->conn->server? co->conn->server->port : 0); continue; } - luop->subscr = *subscr; - luop->state = LU_S_LU_RECEIVED; /* Pretend we received a location update. */ - lu_op_tx_insert_subscr_data(luop); - lu_op_free(luop); + + osmo_strlcpy(gsup.imsi, subscr->imsi, GSM23003_IMSI_MAX_DIGITS + 1); + + len = gsm48_encode_bcd_number(msisdn_enc, sizeof(msisdn_enc), 0, subscr->msisdn); + if (len < 1) { + LOGP(DMAIN, LOGL_ERROR, "%s: Error: cannot encode MSISDN '%s'\n", +subscr->imsi, subscr->msisdn); + continue; + } + gsup.msisdn_enc = msisdn_enc; + gsup.msisdn_enc_len = len; + + if (co->supports_ps) { + gsup.cn_domain = OSMO_GSUP_CN_DOMAIN_PS; + + /* FIXME: PDP infos - use more fine-grained access control + gsup.cn_domain = OSMO_GSUP_CN_DOMAIN_CS; + instead of wildcard APN */ + len = osmo_apn_from_str(apn, sizeof(apn), "*"); + if (len > 0) { + gsup.pdp_infos[0].apn_enc = apn; + gsup.pdp_infos[0].apn_enc_len = len; + gsup.pdp_infos[0].have_info = 1; + gsup.num_pdp_infos = 1; + /* FIXME: use real value: */ + gsup.pdp_infos[0].context_id = 1; + } + } else + gsup.cn_domain = OSMO_GSUP_CN_DOMAIN_CS; + + /* Send ISD to MSC/SGSN */ + msg_out = msgb_alloc_headroom(1024+16, 16, "GSUP ISD UPDATE"); + if (msg_out == NULL) { + LOGP(DMAIN, LOGL_ERROR, + "IMSI='%s': Cannot notify GSUP client; could not allocate msg buffer " + " for %s:%u\n", subscr->imsi, + co && co->conn && co->conn->server? co->
[PATCH] osmo-hlr[master]: rewrite subscriber_update_notify() without calls into luop
Hello Neels Hofmeyr, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/7743 to look at the new patch set (#3). rewrite subscriber_update_notify() without calls into luop This function relied on implementation details of the luop code. Port what is necessary for an independent Insert Subscriber Data Tx operation from the luop code into this function. A next possible step would be to try to merge both of these into a common implementation, but that is left for future work. The TTCN3 test TC_vty_msisdn_isd is still passing (it currently triggers the "circuit switched domain" case because it does not advertise itself as an SGSN in the IPA unit name). Change-Id: I06c43ece2b48dc63d599000eb6d6d51e08963067 Related: OS#2785 --- M src/gsup_server.h M src/hlr.c 2 files changed, 73 insertions(+), 8 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/43/7743/3 diff --git a/src/gsup_server.h b/src/gsup_server.h index 74062d4..f9a5869 100644 --- a/src/gsup_server.h +++ b/src/gsup_server.h @@ -4,6 +4,7 @@ #include #include #include +#include struct osmo_gsup_conn; @@ -33,6 +34,10 @@ struct tlv_parsed ccm; unsigned int auc_3g_ind; /*!< IND index used for UMTS AKA SQN */ + + /* Set when Location Update is received: */ + bool supports_cs; /* client supports OSMO_GSUP_CN_DOMAIN_CS */ + bool supports_ps; /* client supports OSMO_GSUP_CN_DOMAIN_PS */ }; diff --git a/src/hlr.c b/src/hlr.c index 3845993..d068e15 100644 --- a/src/hlr.c +++ b/src/hlr.c @@ -62,19 +62,75 @@ return; llist_for_each_entry(co, &g_hlr->gs->clients, list) { - struct lu_operation *luop = lu_op_alloc_conn(co); - if (!luop) { + struct osmo_gsup_message gsup = { + .message_type = OSMO_GSUP_MSGT_INSERT_DATA_REQUEST + }; + uint8_t *peer; + int peer_len; + uint8_t msisdn_enc[43]; /* TODO use constant; TS 24.008 10.5.4.7 */ + uint8_t apn[APN_MAXLEN]; + int len; + struct msgb *msg_out; + + peer_len = osmo_gsup_conn_ccm_get(co, &peer, IPAC_IDTAG_SERNR); + if (peer_len < 0) { LOGP(DMAIN, LOGL_ERROR, - "IMSI='%s': Cannot notify GSUP client, cannot allocate lu_operation," + "IMSI='%s': Cannot notify GSUP client, cannot get peer name " " for %s:%u\n", subscr->imsi, co && co->conn && co->conn->server? co->conn->server->addr : "unset", co && co->conn && co->conn->server? co->conn->server->port : 0); continue; } - luop->subscr = *subscr; - luop->state = LU_S_LU_RECEIVED; /* Pretend we received a location update. */ - lu_op_tx_insert_subscr_data(luop); - lu_op_free(luop); + + osmo_strlcpy(gsup.imsi, subscr->imsi, GSM23003_IMSI_MAX_DIGITS + 1); + + len = gsm48_encode_bcd_number(msisdn_enc, sizeof(msisdn_enc), 0, subscr->msisdn); + if (len < 1) { + LOGP(DMAIN, LOGL_ERROR, "%s: Error: cannot encode MSISDN '%s'\n", +subscr->imsi, subscr->msisdn); + continue; + } + gsup.msisdn_enc = msisdn_enc; + gsup.msisdn_enc_len = len; + + if (co->supports_ps) { + gsup.cn_domain = OSMO_GSUP_CN_DOMAIN_PS; + + /* FIXME: PDP infos - use more fine-grained access control + gsup.cn_domain = OSMO_GSUP_CN_DOMAIN_CS; + instead of wildcard APN */ + len = osmo_apn_from_str(apn, sizeof(apn), "*"); + if (len > 0) { + gsup.pdp_infos[0].apn_enc = apn; + gsup.pdp_infos[0].apn_enc_len = len; + gsup.pdp_infos[0].have_info = 1; + gsup.num_pdp_infos = 1; + /* FIXME: use real value: */ + gsup.pdp_infos[0].context_id = 1; + } + } else + gsup.cn_domain = OSMO_GSUP_CN_DOMAIN_CS; + + /* Send ISD to MSC/SGSN */ + msg_out = msgb_alloc_headroom(1024+16, 16, "GSUP ISD UPDATE"); + if (msg_out == NULL) { + LOGP(DMAIN, LOGL_ERROR, + "IMSI='%s': Cannot notify GSUP client; could not allocate msg buffer " + " for %s:%u\n", subscr->imsi, + co && co->conn && co->conn->server? co->conn->server->addr : "unset", +
[PATCH] osmo-hlr[master]: rewrite subscriber_update_notify() without calls into luop
Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/7743 to look at the new patch set (#2). rewrite subscriber_update_notify() without calls into luop This function relied on implementation details of the luop code. Port what is necessary for an independent Insert Subscriber Data Tx operation from the luop code into this function. A next possible step would be to try to merge both of these into a common implementation, but that is left for future work. The TTCN3 test TC_vty_msisdn_isd is still passing (it currently triggers the "circuit switched domain" case because it does not advertise itself as an SGSN in the IPA unit name). Change-Id: I06c43ece2b48dc63d599000eb6d6d51e08963067 Related: OS#2785 --- M src/gsup_server.h M src/hlr.c M src/luop.c 3 files changed, 79 insertions(+), 7 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/43/7743/2 diff --git a/src/gsup_server.h b/src/gsup_server.h index 74062d4..1f40f21 100644 --- a/src/gsup_server.h +++ b/src/gsup_server.h @@ -4,6 +4,7 @@ #include #include #include +#include struct osmo_gsup_conn; @@ -33,6 +34,8 @@ struct tlv_parsed ccm; unsigned int auc_3g_ind; /*!< IND index used for UMTS AKA SQN */ + + enum osmo_gsup_cn_domain cn_domain; /* Set when first Location Update is received. */ }; diff --git a/src/hlr.c b/src/hlr.c index 4fbc268..80330d1 100644 --- a/src/hlr.c +++ b/src/hlr.c @@ -62,19 +62,72 @@ return; llist_for_each_entry(co, &g_hlr->gs->clients, list) { - struct lu_operation *luop = lu_op_alloc_conn(co); - if (!luop) { + struct osmo_gsup_message gsup = { + .message_type = OSMO_GSUP_MSGT_INSERT_DATA_REQUEST + }; + uint8_t *peer; + int peer_len; + uint8_t msisdn_enc[43]; /* TODO use constant; TS 24.008 10.5.4.7 */ + uint8_t apn[APN_MAXLEN]; + int len; + struct msgb *msg_out; + + peer_len = osmo_gsup_conn_ccm_get(co, &peer, IPAC_IDTAG_SERNR); + if (peer_len < 0) { LOGP(DMAIN, LOGL_ERROR, - "IMSI='%s': Cannot notify GSUP client, cannot allocate lu_operation," + "IMSI='%s': Cannot notify GSUP client, cannot get peer name " " for %s:%u\n", subscr->imsi, co && co->conn && co->conn->server? co->conn->server->addr : "unset", co && co->conn && co->conn->server? co->conn->server->port : 0); continue; } - luop->subscr = *subscr; - luop->state = LU_S_LU_RECEIVED; /* Pretend we received a location update. */ - lu_op_tx_insert_subscr_data(luop); - lu_op_free(luop); + + osmo_strlcpy(gsup.imsi, subscr->imsi, GSM23003_IMSI_MAX_DIGITS + 1); + + len = gsm48_encode_bcd_number(msisdn_enc, sizeof(msisdn_enc), 0, subscr->msisdn); + if (len < 1) { + LOGP(DMAIN, LOGL_ERROR, "%s: Error: cannot encode MSISDN '%s'\n", +subscr->imsi, subscr->msisdn); + continue; + } + gsup.msisdn_enc = msisdn_enc; + gsup.msisdn_enc_len = len; + + gsup.cn_domain = co->cn_domain; + if (gsup.cn_domain == OSMO_GSUP_CN_DOMAIN_PS) { + /* FIXME: PDP infos - use more fine-grained access control + instead of wildcard APN */ + len = osmo_apn_from_str(apn, sizeof(apn), "*"); + if (len > 0) { + gsup.pdp_infos[0].apn_enc = apn; + gsup.pdp_infos[0].apn_enc_len = len; + gsup.pdp_infos[0].have_info = 1; + gsup.num_pdp_infos = 1; + /* FIXME: use real value: */ + gsup.pdp_infos[0].context_id = 1; + } + } + + /* Send ISD to MSC/SGSN */ + msg_out = msgb_alloc_headroom(1024+16, 16, "GSUP ISD UPDATE"); + if (msg_out == NULL) { + LOGP(DMAIN, LOGL_ERROR, + "IMSI='%s': Cannot notify GSUP client; could not allocate msg buffer " + " for %s:%u\n", subscr->imsi, + co && co->conn && co->conn->server? co->conn->server->addr : "unset", + co && co->conn && co->conn->server? co->conn->server->port : 0); + continue; + } + + osmo_gsup_encode(msg_out, &gsup); + if (osmo_gsup_addr_send(g_hlr
[PATCH] osmo-hlr[master]: rewrite subscriber_update_notify() without calls into luop
Review at https://gerrit.osmocom.org/7743 rewrite subscriber_update_notify() without calls into luop This function relied on implementation details of the luop code. Port what is necessary for an independent Insert Subscriber Data Tx operation from the luop code into this function. A next possible step would be to try to merge both of these into a common implementation, but that is left for future work. The TTCN3 test TC_vty_msisdn_isd is still passing (it currently triggers the "circuit switched domain" case because it does not advertise itself as an SGSN in the IPA unit name). Change-Id: I06c43ece2b48dc63d599000eb6d6d51e08963067 Related: OS#2785 --- M src/hlr.c 1 file changed, 76 insertions(+), 7 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/43/7743/1 diff --git a/src/hlr.c b/src/hlr.c index 4fbc268..d06cf0a 100644 --- a/src/hlr.c +++ b/src/hlr.c @@ -62,19 +62,88 @@ return; llist_for_each_entry(co, &g_hlr->gs->clients, list) { - struct lu_operation *luop = lu_op_alloc_conn(co); - if (!luop) { + struct osmo_gsup_message gsup; + uint8_t *unit; + int unit_len; + uint8_t *peer; + int peer_len; + uint8_t msisdn_enc[43]; /* TODO use constant; TS 24.008 10.5.4.7 */ + bool is_ps; + uint8_t apn[APN_MAXLEN]; + int len; + struct msgb *msg_out; + + unit_len = osmo_gsup_conn_ccm_get(co, &unit, IPAC_IDTAG_UNITNAME); + if (unit_len < 0) { LOGP(DMAIN, LOGL_ERROR, - "IMSI='%s': Cannot notify GSUP client, cannot allocate lu_operation," + "IMSI='%s': Cannot notify GSUP client, cannot get unit name" " for %s:%u\n", subscr->imsi, co && co->conn && co->conn->server? co->conn->server->addr : "unset", co && co->conn && co->conn->server? co->conn->server->port : 0); continue; } - luop->subscr = *subscr; - luop->state = LU_S_LU_RECEIVED; /* Pretend we received a location update. */ - lu_op_tx_insert_subscr_data(luop); - lu_op_free(luop); + + peer_len = osmo_gsup_conn_ccm_get(co, &peer, IPAC_IDTAG_SERNR); + if (peer_len < 0) { + LOGP(DMAIN, LOGL_ERROR, + "IMSI='%s': Cannot notify GSUP client, cannot get peer address " + " for %s:%u\n", subscr->imsi, + co && co->conn && co->conn->server? co->conn->server->addr : "unset", + co && co->conn && co->conn->server? co->conn->server->port : 0); + continue; + } + + memset(&gsup, 0, sizeof(gsup)); + gsup.message_type = OSMO_GSUP_MSGT_INSERT_DATA_REQUEST; + osmo_strlcpy(gsup.imsi, subscr->imsi, GSM23003_IMSI_MAX_DIGITS + 1); + + len = gsm48_encode_bcd_number(msisdn_enc, sizeof(msisdn_enc), 0, subscr->msisdn); + if (len < 1) { + LOGP(DMAIN, LOGL_ERROR, "%s: Error: cannot encode MSISDN '%s'\n", +subscr->imsi, subscr->msisdn); + continue; + } + gsup.msisdn_enc = msisdn_enc; + gsup.msisdn_enc_len = len; + + /* XXX Cast to 'char *' avoids a "pointer targets differ in signedness" warning from GCC 7.2.0. */ + is_ps = (strncmp((char *)unit, "SGSN", 4) == 0); + gsup.cn_domain = is_ps ? OSMO_GSUP_CN_DOMAIN_PS : OSMO_GSUP_CN_DOMAIN_CS; + + if (gsup.cn_domain == OSMO_GSUP_CN_DOMAIN_PS) { + /* FIXME: PDP infos - use more fine-grained access control + instead of wildcard APN */ + len = osmo_apn_from_str(apn, sizeof(apn), "*"); + if (len > 0) { + gsup.pdp_infos[0].apn_enc = apn; + gsup.pdp_infos[0].apn_enc_len = len; + gsup.pdp_infos[0].have_info = 1; + gsup.num_pdp_infos = 1; + /* FIXME: use real value: */ + gsup.pdp_infos[0].context_id = 1; + } + } + + /* Send ISD to VLR/SGSN */ + msg_out = msgb_alloc_headroom(1024+16, 16, "GSUP ISD UPDATE"); + if (msg_out == NULL) { + LOGP(DMAIN, LOGL_ERROR, + "IMSI='%s': Cannot notify GSUP client; could not allocate msg buffer " + " for %s:%u\n", subscr->imsi, +