diff --git a/configure.ac b/configure.ac index 24bd5e4..f84c8ac 100644 --- a/configure.ac +++ b/configure.ac @@ -97,6 +97,7 @@ AC_OUTPUT( tests/libosmo-gtlv/Makefile tests/libosmo-gtlv/test_gtlv_gen/Makefile tests/libosmo-gtlv/test_tliv/Makefile + tests/libosmo-pfcp/Makefile doc/Makefile contrib/Makefile Makefile) diff --git a/tests/Makefile.am b/tests/Makefile.am index 01cbed5..7fe0692 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,5 +1,6 @@ SUBDIRS = \ libosmo-gtlv \ + libosmo-pfcp \ $(NULL) # The `:;' works around a Bash 3.2 bug when the output is not writeable. diff --git a/tests/libosmo-pfcp/Makefile.am b/tests/libosmo-pfcp/Makefile.am new file mode 100644 index 0000000..fda143f --- /dev/null +++ b/tests/libosmo-pfcp/Makefile.am @@ -0,0 +1,32 @@ +AM_CPPFLAGS = \ + $(all_includes) \ + -I$(top_srcdir)/include \ + -I$(top_builddir)/include \ + $(NULL) + +AM_CFLAGS = \ + -Wall \ + $(LIBOSMOCORE_CFLAGS) \ + $(NULL) + +noinst_PROGRAMS = \ + pfcp_test \ + $(NULL) + +EXTRA_DIST = \ + pfcp_test.ok \ + $(NULL) + +pfcp_test_SOURCES = \ + pfcp_test.c \ + $(NULL) + +pfcp_test_LDADD = \ + $(top_builddir)/src/libosmo-pfcp/libosmo-pfcp.a \ + $(top_builddir)/src/libosmo-gtlv/libosmo-gtlv.a \ + $(LIBOSMOCORE_LIBS) \ + $(NULL) + +.PHONY: update_exp +update_exp: + $(builddir)/pfcp_test >$(srcdir)/pfcp_test.ok diff --git a/tests/libosmo-pfcp/pfcp_test.c b/tests/libosmo-pfcp/pfcp_test.c new file mode 100644 index 0000000..189622e --- /dev/null +++ b/tests/libosmo-pfcp/pfcp_test.c @@ -0,0 +1,512 @@ +/* + * (C) 2021-2022 by sysmocom - s.f.m.c. GmbH + * All Rights Reserved. + * + * Author: Neels Janosch Hofmeyr + * + * SPDX-License-Identifier: GPL-2.0+ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +#include +#include + +#include +#include +#include + +#include + +void *ctx; + +/* struct osmo_sockaddr */ +#define v4_ue { \ + .u.sin = { \ + .sin_family = AF_INET, \ + .sin_addr = { 0x1700a8c0 }, \ + } \ +} + +/* struct osmo_sockaddr */ +#define v4_gtp { \ + .u.sin = { \ + .sin_family = AF_INET, \ + .sin_addr = { 0x0708090a }, \ + } \ +} + +/* struct osmo_pfcp_ie_f_teid */ +#define f_teid_access_local { \ + .choose_flag = true, \ + .choose = { \ + .ipv4_addr = true, \ + }, \ +} + +/* struct osmo_pfcp_ie_f_teid */ +#define f_teid_created { \ + .fixed = { \ + .teid = 1234, \ + .ip_addr = { \ + .v4_present = true, \ + .v4 = v4_gtp, \ + }, \ + }, \ +} + +/* struct osmo_pfcp_ie_outer_header_creation */ +#define ohc_access { \ + .desc_bits = { 0x01 }, \ + .teid_present = true, \ + .teid = 0xabcdef, \ + .ip_addr = { \ + .v4_present = true, \ + .v4 = v4_gtp, \ + }, \ +} + +/* struct osmo_pfcp_ie_apply_action */ +#define aa_forw { \ + .bits = { 0x02 }, \ +} + +/* struct osmo_pfcp_ie_f_seid */ +#define f_seid { \ + .seid = 0x1234567890abcdef, \ + .ip_addr = { \ + .v4_present = true, \ + .v4 = v4_gtp, \ + }, \ +} + +struct osmo_pfcp_msg tests[] = { + { + .h = { + .version = 1, + .message_type = OSMO_PFCP_MSGT_HEARTBEAT_REQ, + .sequence_nr = 1, + }, + .ies.heartbeat_req = { + .recovery_time_stamp = 1234, + }, + }, + { + .h = { + .version = 1, + .message_type = OSMO_PFCP_MSGT_HEARTBEAT_RESP, + .sequence_nr = 2, + }, + .ies.heartbeat_resp = { + .recovery_time_stamp = 5678, + }, + }, + { + .h = { + .version = 1, + .message_type = OSMO_PFCP_MSGT_ASSOC_SETUP_REQ, + .sequence_nr = 3, + }, + .ies.assoc_setup_req = { + .node_id = { + .type = OSMO_PFCP_NODE_ID_T_IPV4, + .ip.u.sin = { + .sin_family = AF_INET, + .sin_addr = { 0x01020304 }, + }, + }, + .recovery_time_stamp = 0x2b2b2b2b, + }, + }, + { + .h = { + .version = 1, + .message_type = OSMO_PFCP_MSGT_ASSOC_SETUP_RESP, + .sequence_nr = 4, + }, + .ies.assoc_setup_resp = { + .node_id = { + .type = OSMO_PFCP_NODE_ID_T_FQDN, + .fqdn = "example.com", + }, + .cause = OSMO_PFCP_CAUSE_REQUEST_ACCEPTED, + .recovery_time_stamp = 0x2b2b2b2b, + .up_function_features_present = true, + .up_function_features.bits = { 1, 2 }, + }, + }, + { + .h = { + .version = 1, + .message_type = OSMO_PFCP_MSGT_ASSOC_RELEASE_REQ, + .sequence_nr = 5, + }, + .ies.assoc_release_req = { + .node_id = { + .type = OSMO_PFCP_NODE_ID_T_IPV6, + .ip.u.sin6 = { + .sin6_family = AF_INET6, + .sin6_addr = {{{ 1, 2, 3, 4 }}}, + }, + }, + }, + }, + { + .h = { + .version = 1, + .message_type = OSMO_PFCP_MSGT_ASSOC_RELEASE_RESP, + .sequence_nr = 6, + }, + .ies.assoc_release_resp = { + .node_id = { + .type = OSMO_PFCP_NODE_ID_T_IPV4, + .ip.u.sin = { + .sin_family = AF_INET, + .sin_addr = { 0x01020304 }, + }, + }, + .cause = OSMO_PFCP_CAUSE_REQUEST_REJECTED, + }, + }, + { + .h = { + .version = 1, + .message_type = OSMO_PFCP_MSGT_SESSION_EST_REQ, + .sequence_nr = 7, + .seid_present = true, + .seid = 0, + }, + .ies.session_est_req = { + .node_id = { + .type = OSMO_PFCP_NODE_ID_T_IPV4, + .ip.u.sin = { + .sin_family = AF_INET, + .sin_addr = { 0x0100007f }, + }, + }, + .cp_f_seid_present = true, + .cp_f_seid = f_seid, + .create_pdr_count = 2, + .create_pdr = { + { + .pdr_id = 1, + .precedence = 255, + .pdi = { + .source_iface = OSMO_PFCP_SOURCE_IFACE_CORE, + .ue_ip_address_present = true, + .ue_ip_address = { + .ip_is_destination = true, + .ip_addr = { + .v4_present = true, + .v4 = v4_ue, + }, + }, + }, + .far_id_present = true, + .far_id = 1, + }, + { + .pdr_id = 2, + .precedence = 255, + .pdi = { + .source_iface = OSMO_PFCP_SOURCE_IFACE_ACCESS, + .local_f_teid_present = true, + .local_f_teid = f_teid_access_local, + }, + .outer_header_removal_present = true, + .outer_header_removal = { + .desc = OSMO_PFCP_OUTER_HEADER_REMOVAL_GTP_U_UDP_IPV4, + }, + .far_id_present = true, + .far_id = 2, + }, + }, + .create_far_count = 2, + .create_far = { + { + .far_id = 1, + .forw_params_present = true, + .forw_params = { + .destination_iface = OSMO_PFCP_DEST_IFACE_ACCESS, + .outer_header_creation_present = true, + .outer_header_creation = ohc_access, + }, + .apply_action = aa_forw, + }, + { + .far_id = 2, + .forw_params_present = true, + .forw_params = { + .destination_iface = OSMO_PFCP_DEST_IFACE_CORE, + }, + .apply_action = aa_forw, + }, + }, + }, + }, + { + .h = { + .version = 1, + .message_type = OSMO_PFCP_MSGT_SESSION_EST_RESP, + .sequence_nr = 8, + .seid_present = true, + .seid = 0x0123456789abcdef, + }, + .ies.session_est_resp = { + .node_id = { + .type = OSMO_PFCP_NODE_ID_T_IPV4, + .ip.u.sin = { + .sin_family = AF_INET, + .sin_addr = { 0x0200007f }, + }, + }, + .cause = OSMO_PFCP_CAUSE_REQUEST_ACCEPTED, + .up_f_seid_present = true, + .up_f_seid = f_seid, + .created_pdr_count = 2, + .created_pdr = { + { + .pdr_id = 1, + }, + { + .pdr_id = 2, + .local_f_teid_present = true, + .local_f_teid = f_teid_created, + }, + }, + }, + }, + { + .h = { + .version = 1, + .message_type = OSMO_PFCP_MSGT_SESSION_MOD_REQ, + .sequence_nr = 9, + .seid_present = true, + .seid = 0, + }, + .ies.session_mod_req = { + .remove_pdr_count = 1, + .remove_pdr = { + { + .pdr_id = 1, + }, + }, + .remove_far_count = 1, + .remove_far = { + { + .far_id = 1, + }, + }, + .create_pdr_count = 1, + .create_pdr = { + { + .pdr_id = 3, + .precedence = 255, + .pdi = { + .source_iface = OSMO_PFCP_SOURCE_IFACE_ACCESS, + .local_f_teid_present = true, + .local_f_teid = f_teid_access_local, + }, + .outer_header_removal_present = true, + .outer_header_removal = { + .desc = OSMO_PFCP_OUTER_HEADER_REMOVAL_GTP_U_UDP_IPV4, + }, + .far_id_present = true, + .far_id = 3, + }, + }, + .create_far_count = 1, + .create_far = { + { + .far_id = 3, + .forw_params_present = true, + .forw_params = { + .destination_iface = OSMO_PFCP_DEST_IFACE_ACCESS, + .outer_header_creation_present = true, + .outer_header_creation = ohc_access, + }, + .apply_action = aa_forw, + }, + }, + .upd_pdr_count = 1, + .upd_pdr = { + { + .pdr_id = 1, + .pdi = { + .source_iface = OSMO_PFCP_SOURCE_IFACE_ACCESS, + .local_f_teid_present = true, + .local_f_teid = f_teid_access_local, + }, + .outer_header_removal_present = true, + .outer_header_removal = { + .desc = OSMO_PFCP_OUTER_HEADER_REMOVAL_GTP_U_UDP_IPV4, + }, + .far_id_present = true, + .far_id = 1, + }, + }, + .upd_far_count = 1, + .upd_far = { + { + .far_id = 1, + .upd_forw_params_present = true, + .upd_forw_params = { + .destination_iface = OSMO_PFCP_DEST_IFACE_CORE, + .network_inst_present = true, + .network_inst = { + .str = "internet", + }, + }, + .apply_action = aa_forw, + }, + }, + }, + }, + { + .h = { + .version = 1, + .message_type = OSMO_PFCP_MSGT_SESSION_MOD_RESP, + .sequence_nr = 10, + .seid_present = true, + .seid = 0x0123456789abcdef, + }, + .ies.session_mod_resp = { + .cause = OSMO_PFCP_CAUSE_REQUEST_ACCEPTED, + .created_pdr_count = 1, + .created_pdr = { + { + .pdr_id = 3, + .local_f_teid_present = true, + .local_f_teid = f_teid_created, + }, + }, + .updated_pdr_count = 1, + .updated_pdr = { + { + .pdr_id = 1, + .local_f_teid_present = true, + .local_f_teid = f_teid_created, + }, + }, + }, + }, + { + .h = { + .version = 1, + .message_type = OSMO_PFCP_MSGT_SESSION_MOD_RESP, + .sequence_nr = 11, + .seid_present = true, + .seid = 0x0123456789abcdef, + }, + .ies.session_mod_resp = { + .cause = OSMO_PFCP_CAUSE_MANDATORY_IE_MISSING, + .offending_ie_present = true, + .offending_ie = OSMO_PFCP_IEI_APPLY_ACTION, + }, + }, + { + .h = { + .version = 1, + .message_type = OSMO_PFCP_MSGT_SESSION_DEL_REQ, + .sequence_nr = 12, + .seid_present = true, + .seid = 0x0123456789abcdef, + }, + }, + { + .h = { + .version = 1, + .message_type = OSMO_PFCP_MSGT_SESSION_DEL_RESP, + .sequence_nr = 13, + .seid_present = true, + .seid = 0x0123456789abcdef, + }, + .ies.session_del_resp = { + .cause = OSMO_PFCP_CAUSE_NO_ESTABLISHED_PFCP_ASSOC, + }, + }, + { + .h = { + .version = 1, + .message_type = OSMO_PFCP_MSGT_SESSION_DEL_RESP, + .sequence_nr = 13, + .seid_present = true, + .seid = 0x0123456789abcdef, + }, + .ies.session_del_resp = { + .cause = OSMO_PFCP_CAUSE_REQUEST_ACCEPTED, + }, + }, +}; + +void test_enc_dec() +{ + int i; + for (i = 0; i < ARRAY_SIZE(tests); i++) { + void *loop_ctx = talloc_named_const(ctx, 0, "loop"); + int rc; + const struct osmo_pfcp_msg *orig = &tests[i]; + struct osmo_pfcp_msg parsed = {}; + struct msgb *msg; + struct osmo_gtlv_load tlv; + + printf("\n=== start %s[%d]\n", __func__, i); + printf("encoding: %s\n", osmo_pfcp_message_type_str(orig->h.message_type)); + printf("%s\n", osmo_pfcp_msg_to_str_c(loop_ctx, orig)); + msg = msgb_alloc(1024, __func__); + rc = osmo_pfcp_msg_encode(msg, orig); + printf("osmo_pfcp_msg_encode() rc = %d\n", rc); + printf("%s.\n", osmo_hexdump(msg->data, msg->len)); + + rc = osmo_pfcp_msg_decode_header(&tlv, &parsed, msg); + printf("osmo_pfcp_msg_decode_header() rc = %d\n", rc); + if (rc != msgb_length(msg)) { + printf("ERROR: expected rc = %d\n", msgb_length(msg)); + exit(1); + } else { + printf("rc == msgb_length()\n"); + } + + rc = osmo_pfcp_msg_decode_tlv(&parsed, &tlv); + printf("osmo_pfcp_msg_decode_tlv() rc = %d\n", rc); + + if (strcmp(osmo_pfcp_msg_to_str_c(loop_ctx, orig), + osmo_pfcp_msg_to_str_c(loop_ctx, &parsed))) { + printf(" ERROR: parsed != orig\n"); + printf(" orig: %s\n", + osmo_pfcp_msg_to_str_c(loop_ctx, orig)); + printf(" parsed: %s\n", + osmo_pfcp_msg_to_str_c(loop_ctx, &parsed)); + exit(1); + } else { + printf("parsed == orig\n"); + } + + msgb_free(msg); + printf("=== end %s[%d]\n", __func__, i); + talloc_free(loop_ctx); + } +} + +int main() +{ + ctx = talloc_named_const(NULL, 0, "pfcp_test"); + msgb_talloc_ctx_init(ctx, 0); + + test_enc_dec(); + + talloc_free(ctx); + return 0; +} diff --git a/tests/libosmo-pfcp/pfcp_test.ok b/tests/libosmo-pfcp/pfcp_test.ok new file mode 100644 index 0000000..2b8cc1a --- /dev/null +++ b/tests/libosmo-pfcp/pfcp_test.ok @@ -0,0 +1,154 @@ + +=== start test_enc_dec[0] +encoding: HEARTBEAT_REQ +PFCPv1 HEARTBEAT_REQ hdr={seq=1} ies={ 'Recovery Time Stamp'=1234 } +osmo_pfcp_msg_encode() rc = 0 +20 01 00 0c 00 00 01 00 00 60 00 04 00 00 04 d2 . +osmo_pfcp_msg_decode_header() rc = 16 +rc == msgb_length() +osmo_pfcp_msg_decode_tlv() rc = 0 +parsed == orig +=== end test_enc_dec[0] + +=== start test_enc_dec[1] +encoding: HEARTBEAT_RESP +PFCPv1 HEARTBEAT_RESP hdr={seq=2} ies={ 'Recovery Time Stamp'=5678 } +osmo_pfcp_msg_encode() rc = 0 +20 02 00 0c 00 00 02 00 00 60 00 04 00 00 16 2e . +osmo_pfcp_msg_decode_header() rc = 16 +rc == msgb_length() +osmo_pfcp_msg_decode_tlv() rc = 0 +parsed == orig +=== end test_enc_dec[1] + +=== start test_enc_dec[2] +encoding: ASSOC_SETUP_REQ +PFCPv1 ASSOC_SETUP_REQ hdr={seq=3} ies={ 'Node ID'=v4:4.3.2.1 'Recovery Time Stamp'=724249387 } +osmo_pfcp_msg_encode() rc = 0 +20 05 00 15 00 00 03 00 00 3c 00 05 00 04 03 02 01 00 60 00 04 2b 2b 2b 2b . +osmo_pfcp_msg_decode_header() rc = 25 +rc == msgb_length() +osmo_pfcp_msg_decode_tlv() rc = 0 +parsed == orig +=== end test_enc_dec[2] + +=== start test_enc_dec[3] +encoding: ASSOC_SETUP_RESP +PFCPv1 ASSOC_SETUP_RESP hdr={seq=4} ies={ 'Node ID'=fqdn:"example.com" 'Cause'=Request accepted (success) 'Recovery Time Stamp'=724249387 'UP Function Features'=( BUCP PDIU ) } +osmo_pfcp_msg_encode() rc = 0 +20 06 00 2b 00 00 04 00 00 3c 00 0c 02 65 78 61 6d 70 6c 65 2e 63 6f 6d 00 13 00 01 01 00 60 00 04 2b 2b 2b 2b 00 2b 00 06 01 02 00 00 00 00 . +osmo_pfcp_msg_decode_header() rc = 47 +rc == msgb_length() +osmo_pfcp_msg_decode_tlv() rc = 0 +parsed == orig +=== end test_enc_dec[3] + +=== start test_enc_dec[4] +encoding: ASSOC_RELEASE_REQ +PFCPv1 ASSOC_RELEASE_REQ hdr={seq=5} ies={ 'Node ID'=v6:[102:304::] } +osmo_pfcp_msg_encode() rc = 0 +20 09 00 19 00 00 05 00 00 3c 00 11 01 01 02 03 04 00 00 00 00 00 00 00 00 00 00 00 00 . +osmo_pfcp_msg_decode_header() rc = 29 +rc == msgb_length() +osmo_pfcp_msg_decode_tlv() rc = 0 +parsed == orig +=== end test_enc_dec[4] + +=== start test_enc_dec[5] +encoding: ASSOC_RELEASE_RESP +PFCPv1 ASSOC_RELEASE_RESP hdr={seq=6} ies={ 'Node ID'=v4:4.3.2.1 'Cause'=Request rejected (reason not specified) } +osmo_pfcp_msg_encode() rc = 0 +20 0a 00 12 00 00 06 00 00 3c 00 05 00 04 03 02 01 00 13 00 01 40 . +osmo_pfcp_msg_decode_header() rc = 22 +rc == msgb_length() +osmo_pfcp_msg_decode_tlv() rc = 0 +parsed == orig +=== end test_enc_dec[5] + +=== start test_enc_dec[6] +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 '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 } '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 c3 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 28 00 38 00 02 00 01 00 1d 00 04 00 00 00 ff 00 02 00 0e 00 14 00 01 01 00 5d 00 05 06 c0 a8 00 17 00 6c 00 04 00 00 00 01 00 01 00 29 00 38 00 02 00 02 00 1d 00 04 00 00 00 ff 00 02 00 0a 00 14 00 01 00 00 15 00 01 05 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 = 199 +rc == msgb_length() +osmo_pfcp_msg_decode_tlv() rc = 0 +parsed == orig +=== end test_enc_dec[6] + +=== start test_enc_dec[7] +encoding: SESSION_EST_RESP +PFCPv1 SESSION_EST_RESP hdr={seq=8 SEID=0x123456789abcdef} ies={ 'Node ID'=v4:127.0.0.2 'Cause'=Request accepted (success) 'F-SEID'=0x1234567890abcdef,v4:10.9.8.7 'Created PDR'={ { 'PDR ID'=1 }, { 'PDR ID'=2 'F-TEID'=TEID-0x4d2,v4:10.9.8.7 } } } +osmo_pfcp_msg_encode() rc = 0 +21 33 00 4c 01 23 45 67 89 ab cd ef 00 00 08 00 00 3c 00 05 00 7f 00 00 02 00 13 00 01 01 00 39 00 0d 02 12 34 56 78 90 ab cd ef 0a 09 08 07 00 08 00 06 00 38 00 02 00 01 00 08 00 13 00 38 00 02 00 02 00 15 00 09 01 00 00 04 d2 0a 09 08 07 . +osmo_pfcp_msg_decode_header() rc = 80 +rc == msgb_length() +osmo_pfcp_msg_decode_tlv() rc = 0 +parsed == orig +=== end test_enc_dec[7] + +=== start test_enc_dec[8] +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 } '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 'FAR ID'=1 } } 'Update FAR'={ { 'FAR ID'=1 'Update Forwarding Parameters'={ 'Network Instance'="internet" } } } } +osmo_pfcp_msg_encode() rc = 0 +21 34 00 ab 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 29 00 38 00 02 00 03 00 1d 00 04 00 00 00 ff 00 02 00 0a 00 14 00 01 00 00 15 00 01 05 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 13 00 38 00 02 00 01 00 5f 00 01 00 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 = 175 +rc == msgb_length() +osmo_pfcp_msg_decode_tlv() rc = 0 +parsed == orig +=== end test_enc_dec[8] + +=== start test_enc_dec[9] +encoding: SESSION_MOD_RESP +PFCPv1 SESSION_MOD_RESP hdr={seq=10 SEID=0x123456789abcdef} ies={ 'Cause'=Request accepted (success) 'Created PDR'={ { 'PDR ID'=3 'F-TEID'=TEID-0x4d2,v4:10.9.8.7 } } 'Updated PDR'={ { 'PDR ID'=1 'F-TEID'=TEID-0x4d2,v4:10.9.8.7 } } } +osmo_pfcp_msg_encode() rc = 0 +21 35 00 3f 01 23 45 67 89 ab cd ef 00 00 0a 00 00 13 00 01 01 00 08 00 13 00 38 00 02 00 03 00 15 00 09 01 00 00 04 d2 0a 09 08 07 01 00 00 13 00 38 00 02 00 01 00 15 00 09 01 00 00 04 d2 0a 09 08 07 . +osmo_pfcp_msg_decode_header() rc = 67 +rc == msgb_length() +osmo_pfcp_msg_decode_tlv() rc = 0 +parsed == orig +=== end test_enc_dec[9] + +=== start test_enc_dec[10] +encoding: SESSION_MOD_RESP +PFCPv1 SESSION_MOD_RESP hdr={seq=11 SEID=0x123456789abcdef} ies={ 'Cause'=Mandatory IE missing 'Offending IE'=Apply Action } +osmo_pfcp_msg_encode() rc = 0 +21 35 00 17 01 23 45 67 89 ab cd ef 00 00 0b 00 00 13 00 01 42 00 28 00 02 00 2c . +osmo_pfcp_msg_decode_header() rc = 27 +rc == msgb_length() +osmo_pfcp_msg_decode_tlv() rc = 0 +parsed == orig +=== end test_enc_dec[10] + +=== start test_enc_dec[11] +encoding: SESSION_DEL_REQ +PFCPv1 SESSION_DEL_REQ hdr={seq=12 SEID=0x123456789abcdef} ies={ } +osmo_pfcp_msg_encode() rc = 0 +21 36 00 0c 01 23 45 67 89 ab cd ef 00 00 0c 00 . +osmo_pfcp_msg_decode_header() rc = 16 +rc == msgb_length() +osmo_pfcp_msg_decode_tlv() rc = 0 +parsed == orig +=== end test_enc_dec[11] + +=== start test_enc_dec[12] +encoding: SESSION_DEL_RESP +PFCPv1 SESSION_DEL_RESP hdr={seq=13 SEID=0x123456789abcdef} ies={ 'Cause'=No established PFCP Association } +osmo_pfcp_msg_encode() rc = 0 +21 37 00 11 01 23 45 67 89 ab cd ef 00 00 0d 00 00 13 00 01 48 . +osmo_pfcp_msg_decode_header() rc = 21 +rc == msgb_length() +osmo_pfcp_msg_decode_tlv() rc = 0 +parsed == orig +=== end test_enc_dec[12] + +=== start test_enc_dec[13] +encoding: SESSION_DEL_RESP +PFCPv1 SESSION_DEL_RESP hdr={seq=13 SEID=0x123456789abcdef} ies={ 'Cause'=Request accepted (success) } +osmo_pfcp_msg_encode() rc = 0 +21 37 00 11 01 23 45 67 89 ab cd ef 00 00 0d 00 00 13 00 01 01 . +osmo_pfcp_msg_decode_header() rc = 21 +rc == msgb_length() +osmo_pfcp_msg_decode_tlv() rc = 0 +parsed == orig +=== end test_enc_dec[13] diff --git a/tests/testsuite.at b/tests/testsuite.at index 0d17305..a365f0e 100644 --- a/tests/testsuite.at +++ b/tests/testsuite.at @@ -24,3 +24,9 @@ AT_KEYWORDS([tliv]) cat $abs_srcdir/libosmo-gtlv/test_tliv/tliv_test.ok > expout AT_CHECK([$abs_top_builddir/tests/libosmo-gtlv/test_tliv/tliv_test], [], [expout], [ignore]) AT_CLEANUP + +AT_SETUP([pfcp]) +AT_KEYWORDS([pfcp]) +cat $abs_srcdir/libosmo-pfcp/pfcp_test.ok > expout +AT_CHECK([$abs_top_builddir/tests/libosmo-pfcp/pfcp_test], [], [expout], [ignore]) +AT_CLEANUP