fix coding of Network Instance IE
Network instance names should be coded like in DNS, where each label is preceded by a length byte. Related: SYS#6192 Change-Id: I9d67464ef0f92b0512cfd6e48d203f8828a82a19
This commit is contained in:
parent
2ee6a68045
commit
3df3438afc
|
@ -7,3 +7,4 @@
|
|||
# If any interfaces have been added since the last public release: c:r:a + 1.
|
||||
# If any interfaces have been removed or changed since the last public release: c:r:0.
|
||||
#library what description / commit summary line
|
||||
libosmo-pfcp libosmogsm>=1.7.0 libosmo-pfcp now uses API from libosmogsm (from libosmocore.git)
|
||||
|
|
|
@ -38,6 +38,7 @@ PKG_PROG_PKG_CONFIG([0.20])
|
|||
|
||||
dnl checks for libraries
|
||||
PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore >= 1.7.0)
|
||||
PKG_CHECK_MODULES(LIBOSMOGSM, libosmogsm >= 1.7.0)
|
||||
|
||||
dnl checks for header files
|
||||
AC_HEADER_STDC
|
||||
|
|
|
@ -12,6 +12,7 @@ BuildRequires: libtool >= 2
|
|||
BuildRequires: lksctp-tools-devel
|
||||
BuildRequires: pkgconfig >= 0.20
|
||||
BuildRequires: pkgconfig(libosmocore) >= 1.7.0
|
||||
BuildRequires: pkgconfig(libosmogsm) >= 1.7.0
|
||||
BuildRequires: pkgconfig(talloc)
|
||||
|
||||
%description
|
||||
|
|
|
@ -11,6 +11,7 @@ Build-Depends: debhelper (>=10),
|
|||
libtool,
|
||||
pkg-config,
|
||||
libosmocore-dev (>= 1.7.0),
|
||||
libosmogsm-dev (>= 1.7.0),
|
||||
libtalloc-dev (>= 2.1.0)
|
||||
Standards-Version: 3.9.8
|
||||
Vcs-Git: https://gitea.osmocom.org/osmocom/libosmo-pfcp
|
||||
|
|
|
@ -9,12 +9,14 @@ AM_CPPFLAGS = \
|
|||
AM_CFLAGS = \
|
||||
-Wall \
|
||||
$(LIBOSMOCORE_CFLAGS) \
|
||||
$(LIBOSMOGSM_CFLAGS) \
|
||||
$(LIBOSMOVTY_CFLAGS) \
|
||||
$(COVERAGE_CFLAGS) \
|
||||
$(NULL)
|
||||
|
||||
AM_LDFLAGS = \
|
||||
$(LIBOSMOCORE_LIBS) \
|
||||
$(LIBOSMOGSM_LIBS) \
|
||||
$(LIBOSMOVTY_LIBS) \
|
||||
$(COVERAGE_LDFLAGS) \
|
||||
$(NULL)
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include <osmocom/core/logging.h>
|
||||
#include <osmocom/core/utils.h>
|
||||
#include <osmocom/core/msgb.h>
|
||||
#include <osmocom/gsm/apn.h>
|
||||
|
||||
#include <osmocom/gtlv/gtlv.h>
|
||||
|
||||
|
@ -81,6 +82,13 @@
|
|||
tlv->len - ((POS) - tlv->val)); \
|
||||
} while (0)
|
||||
|
||||
#define ENSURE_RANGE(NAME, VAL, MINVAL, MAXVAL) \
|
||||
do { \
|
||||
if ((VAL) < (MINVAL) || (VAL) > (MAXVAL)) \
|
||||
RETURN_ERROR(-ERANGE, "%s == %d, should be in range %d .. %d", NAME, \
|
||||
(int)(VAL), (int)(MINVAL), (int)(MAXVAL)); \
|
||||
} while (0)
|
||||
|
||||
void osmo_pfcp_ie_f_seid_set(struct osmo_pfcp_ie_f_seid *f_seid, uint64_t seid, const struct osmo_sockaddr *remote_addr)
|
||||
{
|
||||
*f_seid = (struct osmo_pfcp_ie_f_seid) {
|
||||
|
@ -698,16 +706,21 @@ int osmo_pfcp_enc_to_str_apply_action(char *buf, size_t buflen, const void *enco
|
|||
int osmo_pfcp_dec_network_inst(void *decoded_struct, void *decode_to, const struct osmo_gtlv_load *tlv)
|
||||
{
|
||||
struct osmo_pfcp_ie_network_inst *network_inst = decode_to;
|
||||
osmo_strlcpy(network_inst->str, (const char *)tlv->val, OSMO_MIN(sizeof(network_inst->str), tlv->len+1));
|
||||
ENSURE_RANGE("Network Instance value length", tlv->len, 1, sizeof(network_inst->str));
|
||||
if (osmo_apn_to_str(network_inst->str, tlv->val, tlv->len) == NULL)
|
||||
RETURN_ERROR(-EINVAL, "osmo_apn_to_str() failed");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int osmo_pfcp_enc_network_inst(struct osmo_gtlv_put *tlv, const void *decoded_struct, const void *encode_from)
|
||||
{
|
||||
const struct osmo_pfcp_ie_network_inst *network_inst = encode_from;
|
||||
unsigned int l = strlen(network_inst->str);
|
||||
if (l)
|
||||
memcpy(msgb_put(tlv->dst, l), network_inst->str, l);
|
||||
int rc;
|
||||
|
||||
rc = osmo_apn_from_str(tlv->dst->tail, msgb_tailroom(tlv->dst), network_inst->str);
|
||||
if (rc <= 0)
|
||||
RETURN_ERROR(-EINVAL, "osmo_apn_from_str(\"%s\") failed", network_inst->str);
|
||||
msgb_put(tlv->dst, rc);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ AM_CPPFLAGS = \
|
|||
AM_CFLAGS = \
|
||||
-Wall \
|
||||
$(LIBOSMOCORE_CFLAGS) \
|
||||
$(LIBOSMOGSM_CFLAGS) \
|
||||
$(NULL)
|
||||
|
||||
check_PROGRAMS = \
|
||||
|
@ -24,6 +25,7 @@ pfcp_test_SOURCES = \
|
|||
pfcp_test_LDADD = \
|
||||
$(top_builddir)/src/libosmo-pfcp/libosmo-pfcp.la \
|
||||
$(top_builddir)/src/libosmo-gtlv/libosmo-gtlv.la \
|
||||
$(LIBOSMOGSM_LIBS) \
|
||||
$(LIBOSMOCORE_LIBS) \
|
||||
$(NULL)
|
||||
|
||||
|
|
|
@ -69,8 +69,8 @@ parsed == orig
|
|||
encoding: SESSION_EST_REQ
|
||||
PFCPv1 SESSION_EST_REQ hdr={seq=7 SEID=0x0} ies={ 'Node ID'=v4:127.0.0.1 'F-SEID'=0x1234567890abcdef,v4:10.9.8.7 'Create PDR'={ { 'PDR ID'=1 'Precedence'=255 'PDI'={ 'Source Interface'=Core 'Network Instance'="foo" 'UE IP Address'=,dst,v4:192.168.0.23 } 'FAR ID'=1 }, { 'PDR ID'=2 'Precedence'=255 'PDI'={ 'Source Interface'=Access 'F-TEID'=CHOOSE-v4 'Network Instance'="bar" } 'Outer Header Removal'=GTP_U_UDP_IPV4 'FAR ID'=2 } } 'Create FAR'={ { 'FAR ID'=1 'Apply Action'=( FORW ) 'Forwarding Parameters'={ 'Destination Interface'=Access 'Outer Header Creation'=( GTP_U_UDP_IPV4 ),TEID:0xabcdef,v4:10.9.8.7 } }, { 'FAR ID'=2 'Apply Action'=( FORW ) 'Forwarding Parameters'={ 'Destination Interface'=Core } } } }
|
||||
osmo_pfcp_msg_encode() rc = 0
|
||||
21 32 00 d1 00 00 00 00 00 00 00 00 00 00 07 00 00 3c 00 05 00 7f 00 00 01 00 39 00 0d 02 12 34 56 78 90 ab cd ef 0a 09 08 07 00 01 00 2f 00 38 00 02 00 01 00 1d 00 04 00 00 00 ff 00 02 00 15 00 14 00 01 01 00 16 00 03 66 6f 6f 00 5d 00 05 06 c0 a8 00 17 00 6c 00 04 00 00 00 01 00 01 00 30 00 38 00 02 00 02 00 1d 00 04 00 00 00 ff 00 02 00 11 00 14 00 01 00 00 15 00 01 05 00 16 00 03 62 61 72 00 5f 00 01 00 00 6c 00 04 00 00 00 02 00 03 00 25 00 6c 00 04 00 00 00 01 00 2c 00 02 02 00 00 04 00 13 00 2a 00 01 00 00 54 00 0a 01 00 00 ab cd ef 0a 09 08 07 00 03 00 17 00 6c 00 04 00 00 00 02 00 2c 00 02 02 00 00 04 00 05 00 2a 00 01 01 .
|
||||
osmo_pfcp_msg_decode_header() rc = 213
|
||||
21 32 00 d3 00 00 00 00 00 00 00 00 00 00 07 00 00 3c 00 05 00 7f 00 00 01 00 39 00 0d 02 12 34 56 78 90 ab cd ef 0a 09 08 07 00 01 00 30 00 38 00 02 00 01 00 1d 00 04 00 00 00 ff 00 02 00 16 00 14 00 01 01 00 16 00 04 03 66 6f 6f 00 5d 00 05 06 c0 a8 00 17 00 6c 00 04 00 00 00 01 00 01 00 31 00 38 00 02 00 02 00 1d 00 04 00 00 00 ff 00 02 00 12 00 14 00 01 00 00 15 00 01 05 00 16 00 04 03 62 61 72 00 5f 00 01 00 00 6c 00 04 00 00 00 02 00 03 00 25 00 6c 00 04 00 00 00 01 00 2c 00 02 02 00 00 04 00 13 00 2a 00 01 00 00 54 00 0a 01 00 00 ab cd ef 0a 09 08 07 00 03 00 17 00 6c 00 04 00 00 00 02 00 2c 00 02 02 00 00 04 00 05 00 2a 00 01 01 .
|
||||
osmo_pfcp_msg_decode_header() rc = 215
|
||||
rc == msgb_length()
|
||||
osmo_pfcp_msg_decode_tlv() rc = 0
|
||||
parsed == orig
|
||||
|
@ -91,8 +91,8 @@ parsed == orig
|
|||
encoding: SESSION_MOD_REQ
|
||||
PFCPv1 SESSION_MOD_REQ hdr={seq=9 SEID=0x0} ies={ 'Remove PDR'={ { 'PDR ID'=1 } } 'Remove FAR'={ { 'FAR ID'=1 } } 'Create PDR'={ { 'PDR ID'=3 'Precedence'=255 'PDI'={ 'Source Interface'=Access 'F-TEID'=CHOOSE-v4 'Network Instance'="baz" } 'Outer Header Removal'=GTP_U_UDP_IPV4 'FAR ID'=3 } } 'Create FAR'={ { 'FAR ID'=3 'Apply Action'=( FORW ) 'Forwarding Parameters'={ 'Destination Interface'=Access 'Outer Header Creation'=( GTP_U_UDP_IPV4 ),TEID:0xabcdef,v4:10.9.8.7 } } } 'Update PDR'={ { 'PDR ID'=1 'Outer Header Removal'=GTP_U_UDP_IPV4 'PDI'={ 'Source Interface'=Access 'F-TEID'=CHOOSE-v4 'Network Instance'="moo" } 'FAR ID'=1 } } 'Update FAR'={ { 'FAR ID'=1 'Update Forwarding Parameters'={ 'Network Instance'="internet" } } } }
|
||||
osmo_pfcp_msg_encode() rc = 0
|
||||
21 34 00 c7 00 00 00 00 00 00 00 00 00 00 09 00 00 0f 00 06 00 38 00 02 00 01 00 10 00 08 00 6c 00 04 00 00 00 01 00 01 00 30 00 38 00 02 00 03 00 1d 00 04 00 00 00 ff 00 02 00 11 00 14 00 01 00 00 15 00 01 05 00 16 00 03 62 61 7a 00 5f 00 01 00 00 6c 00 04 00 00 00 03 00 03 00 25 00 6c 00 04 00 00 00 03 00 2c 00 02 02 00 00 04 00 13 00 2a 00 01 00 00 54 00 0a 01 00 00 ab cd ef 0a 09 08 07 00 09 00 28 00 38 00 02 00 01 00 5f 00 01 00 00 02 00 11 00 14 00 01 00 00 15 00 01 05 00 16 00 03 6d 6f 6f 00 6c 00 04 00 00 00 01 00 0a 00 18 00 6c 00 04 00 00 00 01 00 0b 00 0c 00 16 00 08 69 6e 74 65 72 6e 65 74 .
|
||||
osmo_pfcp_msg_decode_header() rc = 203
|
||||
21 34 00 ca 00 00 00 00 00 00 00 00 00 00 09 00 00 0f 00 06 00 38 00 02 00 01 00 10 00 08 00 6c 00 04 00 00 00 01 00 01 00 31 00 38 00 02 00 03 00 1d 00 04 00 00 00 ff 00 02 00 12 00 14 00 01 00 00 15 00 01 05 00 16 00 04 03 62 61 7a 00 5f 00 01 00 00 6c 00 04 00 00 00 03 00 03 00 25 00 6c 00 04 00 00 00 03 00 2c 00 02 02 00 00 04 00 13 00 2a 00 01 00 00 54 00 0a 01 00 00 ab cd ef 0a 09 08 07 00 09 00 29 00 38 00 02 00 01 00 5f 00 01 00 00 02 00 12 00 14 00 01 00 00 15 00 01 05 00 16 00 04 03 6d 6f 6f 00 6c 00 04 00 00 00 01 00 0a 00 19 00 6c 00 04 00 00 00 01 00 0b 00 0d 00 16 00 09 08 69 6e 74 65 72 6e 65 74 .
|
||||
osmo_pfcp_msg_decode_header() rc = 206
|
||||
rc == msgb_length()
|
||||
osmo_pfcp_msg_decode_tlv() rc = 0
|
||||
parsed == orig
|
||||
|
|
Loading…
Reference in New Issue