lynxis lazus has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/35237?usp=email )
Change subject: gsup: add support for IPV4/IPV6 in PDP info ...................................................................... gsup: add support for IPV4/IPV6 in PDP info The IPV4/IPV6 in the PDP will be used by the ePDG to send back the allocated IP from the PGW. Further it could be used at a later point to assign static IPs, saved in the HLR/HSS. Change-Id: I17ccbe8b78e92e2f03c18e4e42e8b62f0a7bcbd1 --- M include/osmocom/gsm/gsup.h M src/gsm/gsup.c 2 files changed, 56 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/37/35237/1 diff --git a/include/osmocom/gsm/gsup.h b/include/osmocom/gsm/gsup.h index 6e7fcf0..3edbdd0 100644 --- a/include/osmocom/gsm/gsup.h +++ b/include/osmocom/gsm/gsup.h @@ -47,6 +47,7 @@ #include <osmocom/gsm/protocol/gsm_08_08.h> #include <osmocom/gsm/gsm_utils.h> #include <osmocom/crypt/auth.h> +#include <sys/socket.h> #define OSMO_GSUP_PORT 4222 @@ -77,6 +78,8 @@ OSMO_GSUP_ACCESS_POINT_NAME_IE = 0x12, OSMO_GSUP_PDP_QOS_IE = 0x13, OSMO_GSUP_CHARG_CHAR_IE = 0x14, + OSMO_GSUP_IPV4_IE = 0x15, + OSMO_GSUP_IPV6_IE = 0x16, OSMO_GSUP_RAND_IE = 0x20, OSMO_GSUP_SRES_IE = 0x21, OSMO_GSUP_KC_IE = 0x22, @@ -277,6 +280,14 @@ const uint8_t *pdp_charg_enc; /*! length (in octets) of pdp_charg_enc */ size_t pdp_charg_enc_len; + /*! True if pdp_ipv4 is set */ + bool pdp_ipv4_set; + /*! IPv4 address of the PDP context */ + struct in_addr pdp_ipv4; + /*! True if pdp_ipv6 is set */ + bool pdp_ipv6_set; + /*! IPv6 address of the PDP context */ + struct in6_addr pdp_ipv6; }; enum osmo_gsup_message_class { diff --git a/src/gsm/gsup.c b/src/gsm/gsup.c index 4e18ddb..9bdd1f5 100644 --- a/src/gsm/gsup.c +++ b/src/gsm/gsup.c @@ -133,11 +133,10 @@ uint8_t tag; uint8_t *value; size_t value_len; + enum osmo_gsup_iei iei; /* specific parts */ while (data_len > 0) { - enum osmo_gsup_iei iei; - rc = osmo_shift_tlv(&data, &data_len, &tag, &value, &value_len); if (rc < 0) return -GMM_CAUSE_PROTO_ERR_UNSPEC; @@ -169,6 +168,20 @@ pdp_info->pdp_charg_enc_len = value_len; break; + case OSMO_GSUP_IPV4_IE: + if (value_len != sizeof(pdp_info->pdp_ipv4)) + goto parse_error; + memcpy(&pdp_info->pdp_ipv4, value, value_len); + pdp_info->pdp_ipv4_set = 1; + break; + + case OSMO_GSUP_IPV6_IE: + if (value_len != sizeof(pdp_info->pdp_ipv6)) + goto parse_error; + memcpy(&pdp_info->pdp_ipv6, value, value_len); + pdp_info->pdp_ipv6_set = 1; + break; + default: LOGP(DLGSUP, LOGL_ERROR, "GSUP IE type %d not expected in PDP info\n", iei); @@ -177,6 +190,12 @@ } return 0; + +parse_error: + LOGP(DLGSUP, LOGL_ERROR, + "GSUP IE type %d, length %zu invalid in PDP info\n", iei, value_len); + + return -1; } static int decode_auth_info(uint8_t *data, size_t data_len, @@ -623,6 +642,16 @@ pdp_info->pdp_charg_enc_len, pdp_info->pdp_charg_enc); } + if (pdp_info->pdp_ipv4_set) { + msgb_tlv_put(msg, OSMO_GSUP_IPV4_IE, + sizeof(pdp_info->pdp_ipv4), &pdp_info->pdp_ipv4); + } + + if (pdp_info->pdp_ipv6_set) { + msgb_tlv_put(msg, OSMO_GSUP_IPV6_IE, + sizeof(pdp_info->pdp_ipv6), &pdp_info->pdp_ipv6); + } + /* Update length field */ *len_field = msgb_length(msg) - old_len; } -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/35237?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: I17ccbe8b78e92e2f03c18e4e42e8b62f0a7bcbd1 Gerrit-Change-Number: 35237 Gerrit-PatchSet: 1 Gerrit-Owner: lynxis lazus <lyn...@fe80.eu> Gerrit-MessageType: newchange