diff options
author | Alexander Couzens <lynxis@fe80.eu> | 2023-12-05 18:43:12 +0000 |
---|---|---|
committer | Alexander Couzens <lynxis@fe80.eu> | 2024-01-18 20:13:57 +0100 |
commit | 221fd7669e8f4328718f8e965c3727b85b3be59e (patch) | |
tree | f5fbe9545aa2e455984c0645d536c51a16b0dafe | |
parent | 8dfdfc38add5677c79385af94a798006a60b2ee4 (diff) |
gsup: add support for IPV4/IPV6 in PDP infolynxis/epdg
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
-rw-r--r-- | include/osmocom/gsm/gsup.h | 12 | ||||
-rw-r--r-- | src/gsm/gsup.c | 33 | ||||
-rw-r--r-- | tests/gsup/gsup_test.err | 2 |
3 files changed, 44 insertions, 3 deletions
diff --git a/include/osmocom/gsm/gsup.h b/include/osmocom/gsm/gsup.h index 6c232977..63e4c5fb 100644 --- a/include/osmocom/gsm/gsup.h +++ b/include/osmocom/gsm/gsup.h @@ -47,6 +47,8 @@ #include <osmocom/gsm/protocol/gsm_08_08.h> #include <osmocom/gsm/gsm_utils.h> #include <osmocom/crypt/auth.h> +#include <netinet/in.h> + #define OSMO_GSUP_PORT 4222 @@ -77,6 +79,8 @@ enum osmo_gsup_iei { 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 +281,14 @@ struct osmo_gsup_pdp_info { 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 4e18ddb2..df5def1c 100644 --- a/src/gsm/gsup.c +++ b/src/gsm/gsup.c @@ -133,11 +133,10 @@ static int decode_pdp_info(uint8_t *data, size_t data_len, 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 @@ static int decode_pdp_info(uint8_t *data, size_t data_len, 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 @@ static int decode_pdp_info(uint8_t *data, size_t data_len, } 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 @@ static void encode_pdp_info(struct msgb *msg, enum osmo_gsup_iei iei, 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), (void *) &pdp_info->pdp_ipv4); + } + + if (pdp_info->pdp_ipv6_set) { + msgb_tlv_put(msg, OSMO_GSUP_IPV6_IE, + sizeof(pdp_info->pdp_ipv6), (void *) &pdp_info->pdp_ipv6); + } + /* Update length field */ *len_field = msgb_length(msg) - old_len; } diff --git a/tests/gsup/gsup_test.err b/tests/gsup/gsup_test.err index 7b2fda97..4438f5af 100644 --- a/tests/gsup/gsup_test.err +++ b/tests/gsup/gsup_test.err @@ -164,7 +164,7 @@ DLGSUP Stopping DLGSUP logging message 2: tested 21248 modifications, 2577 parse failures message 3: tested 2816 modifications, 510 parse failures message 4: tested 3584 modifications, 770 parse failures - message 5: tested 20736 modifications, 4025 parse failures + message 5: tested 20736 modifications, 4041 parse failures message 6: tested 3584 modifications, 771 parse failures message 7: tested 3584 modifications, 770 parse failures message 8: tested 2816 modifications, 510 parse failures |