From 363ba48b1f7671c6cd7182de48c9f3e042da6565 Mon Sep 17 00:00:00 2001 From: Pau Espin Pedrol Date: Mon, 29 Jan 2018 18:42:00 +0100 Subject: [PATCH] ggsn_tests: Validate DNS PCO values Change-Id: I54124cb5269c0992e6c72af1a1ecaa8e3202bf05 --- ggsn_tests/GGSN_Tests.cfg | 2 ++ ggsn_tests/GGSN_Tests.ttcn | 34 ++++++++++++++++++++++++++++++++-- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/ggsn_tests/GGSN_Tests.cfg b/ggsn_tests/GGSN_Tests.cfg index 90368b9f3..d8994df58 100644 --- a/ggsn_tests/GGSN_Tests.cfg +++ b/ggsn_tests/GGSN_Tests.cfg @@ -18,6 +18,8 @@ GGSN_Tests.m_ggsn_ip_gtpc := "127.0.0.2" GGSN_Tests.m_ggsn_ip_gtpu := "127.0.0.2" GGSN_Tests.m_ggsn_ip4_dns1 := "192.168.100.1" GGSN_Tests.m_ggsn_ip4_dns2 := "8.8.8.8" +GGSN_Tests.m_ggsn_ip6_dns1 := "2001:4860:4860::8888" +GGSN_Tests.m_ggsn_ip6_dns2 := "2001:4860:4860::8844" [EXECUTE] #GGSN_Tests.TC_dummy diff --git a/ggsn_tests/GGSN_Tests.ttcn b/ggsn_tests/GGSN_Tests.ttcn index 06d9dcf60..f7814db70 100644 --- a/ggsn_tests/GGSN_Tests.ttcn +++ b/ggsn_tests/GGSN_Tests.ttcn @@ -26,6 +26,8 @@ module GGSN_Tests { charstring m_ggsn_ip4_dns1 := "192.168.100.1" charstring m_ggsn_ip4_dns2 := "8.8.8.8" + charstring m_ggsn_ip6_dns1 := "2001:4860:4860::8888" + charstring m_ggsn_ip6_dns2 := "2001:4860:4860::8844" } type set PdpContext { @@ -426,11 +428,15 @@ module GGSN_Tests { } /* extract a given protocol payload from PCO */ - function f_PCO_extract_proto(ProtConfigOptions pco, OCT2 protocol) return octetstring { + function f_PCO_extract_proto(ProtConfigOptions pco, OCT2 protocol, integer nth_match := 1) return octetstring { var integer i; + var integer num_matches := 0; for (i := 0; i < lengthof(pco.protocols); i := i + 1) { if (pco.protocols[i].protocolID == protocol) { - return pco.protocols[i].protoIDContents; + num_matches := num_matches + 1; + if (num_matches == nth_match) { + return pco.protocols[i].protoIDContents; + } } } setverdict(fail); @@ -925,6 +931,18 @@ module GGSN_Tests { var PdpContext ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInet6, valueof(t_EuaIPv6Dyn))); ctx.pco_req := valueof(ts_PCO_IPv6_DNS); f_pdp_ctx_act(ctx); + + /* verify PCO contains both primary and secondary DNS */ + var OCT4 ggsn_ip6_dns1 := f_inet6_addr(m_ggsn_ip6_dns1); + if (not match(f_PCO_extract_proto(ctx.pco_neg, '0003'O, 1), ggsn_ip6_dns1)) { + setverdict(fail, "Primary DNS IPv6 PCO option not found"); + } + + var OCT4 ggsn_ip6_dns2 := f_inet6_addr(m_ggsn_ip6_dns2); + if (not match(f_PCO_extract_proto(ctx.pco_neg, '0003'O, 2), ggsn_ip6_dns2)) { + setverdict(fail, "Secondary DNS IPv6 PCO option not found"); + } + f_pdp_ctx_del(ctx, '1'B); } @@ -984,6 +1002,18 @@ module GGSN_Tests { var PdpContext ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInternet, valueof(t_EuaIPv4Dyn))); ctx.pco_req := valueof(ts_PCO_IPv4_DNS_CONT); f_pdp_ctx_act(ctx); + + /* verify PCO contains both primary and secondary DNS */ + var OCT4 ggsn_ip4_dns1 := f_inet_addr(m_ggsn_ip4_dns1); + if (not match(f_PCO_extract_proto(ctx.pco_neg, '000d'O, 1), ggsn_ip4_dns1)) { + setverdict(fail, "Primary DNS IPv4 PCO option not found"); + } + + var OCT4 ggsn_ip4_dns2 := f_inet_addr(m_ggsn_ip4_dns2); + if (not match(f_PCO_extract_proto(ctx.pco_neg, '000d'O, 2), ggsn_ip4_dns2)) { + setverdict(fail, "Secondary DNS IPv4 PCO option not found"); + } + f_pdp_ctx_del(ctx, '1'B); }