Change in osmo-ttcn3-hacks[master]: ggsn: Verify that there are no duplicate PCO protocolIDs

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Wed Apr 10 08:52:06 UTC 2019


Harald Welte has uploaded this change for review. ( https://gerrit.osmocom.org/13563


Change subject: ggsn: Verify that there are no duplicate PCO protocolIDs
......................................................................

ggsn: Verify that there are no duplicate PCO protocolIDs

Introduce a function to verify there's no duplicate ProtocolIDs
in the PCO returned from the GGSN.

Change-Id: I9d439dab1696196cd125f4d7113b426f1711a405
Related: OS#3914
---
M ggsn_tests/GGSN_Tests.ttcn
1 file changed, 25 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/63/13563/1

diff --git a/ggsn_tests/GGSN_Tests.ttcn b/ggsn_tests/GGSN_Tests.ttcn
index 398aed3..9370904 100644
--- a/ggsn_tests/GGSN_Tests.ttcn
+++ b/ggsn_tests/GGSN_Tests.ttcn
@@ -726,6 +726,21 @@
 		T_default.stop;
 	}
 
+	/* ensure that every given protocol Identifier exist only exactly once in the PCO */
+	function f_PCO_ensure_no_duplicates(ProtConfigOptions pco) {
+		var OCT2List protocol_ids := {};
+		var integer i, j;
+		for (i := 0; i < lengthof(pco.protocols); i := i+1) {
+			var OCT2 id := pco.protocols[i].protocolID;
+			for (j := 0; j < lengthof(protocol_ids); j := j+1) {
+				if (id == protocol_ids[j]) {
+					setverdict(fail,  "Duplicate ProtocolID ", id, " already present in ", pco.protocols);
+				}
+			}
+			protocol_ids := protocol_ids & { id };
+		}
+	}
+
 	/* Test IPv6 context activation for dynamic IPv6 EUA without request of IPv6 DNS */
 	testcase TC_pdp6_act_deact() runs on GT_CT {
 		f_init();
@@ -743,6 +758,7 @@
 		ctx.pco_req := valueof(ts_PCO_IPv6_DNS);
 		f_pdp_ctx_act(ctx);
 
+		f_PCO_ensure_no_duplicates(ctx.pco_neg);
 		/* 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)) {
@@ -765,6 +781,7 @@
 		ctx.pco_req := valueof(ts_PCO_IPv6_DNS);
 		f_pdp_ctx_act(ctx);
 
+		f_PCO_ensure_no_duplicates(ctx.pco_neg);
 		//f_send_gtpu(ctx, c_router_solicit);
 		//f_send_gtpu(ctx, c_neigh_solicit);
 
@@ -865,6 +882,7 @@
 		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_IPCP);
 		f_pdp_ctx_act(ctx);
+		f_PCO_ensure_no_duplicates(ctx.pco_neg);
 		/* verify IPCP is at all contained */
 		if (not match(ctx.pco_neg, tr_PCO_Contains('8021'O))) {
 			setverdict(fail, "IPCP not found in PCO");
@@ -888,6 +906,7 @@
 		ctx.pco_req := valueof(ts_PCO_IPv4_DNS_CONT);
 		f_pdp_ctx_act(ctx);
 
+		f_PCO_ensure_no_duplicates(ctx.pco_neg);
 		/* 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)) {
@@ -910,6 +929,7 @@
 		ctx.pco_req := valueof(ts_PCO_IPv4_DNS_CONT);
 		f_pdp_ctx_act(ctx);
 
+		f_PCO_ensure_no_duplicates(ctx.pco_neg);
 		var OCT4 dns1_addr := f_PCO_extract_proto(ctx.pco_neg, '000d'O);
 
 		/* Check if we can use valid global src addr, should work */
@@ -986,6 +1006,7 @@
 		/* PCO with primary DNS only */
 		ctx.pco_req := valueof(ts_PCO_IPv4_PRI_DNS_IPCP);
 		f_pdp_ctx_act(ctx);
+		f_PCO_ensure_no_duplicates(ctx.pco_neg);
 		pco_neg_dns := f_PCO_extract_proto(ctx.pco_neg, '8021'O, 1);
 		pco_neg_dns_expected := '0200000A8106'O & ggsn_ip4_dns1
 		/* Note: The prepended hex bytes encode the following information:
@@ -1063,10 +1084,12 @@
 		var PdpContext ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInet46, valueof(t_EuaIPv4Dynv6Dyn)));
 		ctx.pco_req := valueof(ts_PCO_IPv4_DNS_IPCP);
 		f_pdp_ctx_act(ctx);
+		f_PCO_ensure_no_duplicates(ctx.pco_neg);
 		/* verify IPCP is at all contained */
 		if (not match(ctx.pco_neg, tr_PCO_Contains('8021'O))) {
 			setverdict(fail, "IPCP not found in PCO");
 		}
+		f_PCO_ensure_no_duplicates(ctx.pco_neg);
 		/* verify IPCP contains both primary and secondary IPv4 DNS */
 		var IpcpPacket ipcp := dec_IpcpPacket(f_PCO_extract_proto(ctx.pco_neg, '8021'O));
 		if (not match(ipcp, tr_IPCP_Ack_DNS(0, ggsn_ip4_dns1, ggsn_ip4_dns2))) {
@@ -1101,6 +1124,7 @@
 		ctx.pco_req := valueof(ts_PCO_IPv4_DNS_CONT);
 		f_pdp_ctx_act(ctx);
 
+		f_PCO_ensure_no_duplicates(ctx.pco_neg);
 		/* verify PCO contains both primary and secondary IPv4 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)) {
@@ -1123,6 +1147,7 @@
 		ctx.pco_req := valueof(ts_PCO_IPv6_DNS);
 		f_pdp_ctx_act(ctx);
 
+		f_PCO_ensure_no_duplicates(ctx.pco_neg);
 		/* verify PCO contains both primary and secondary IPv6 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)) {

-- 
To view, visit https://gerrit.osmocom.org/13563
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I9d439dab1696196cd125f4d7113b426f1711a405
Gerrit-Change-Number: 13563
Gerrit-PatchSet: 1
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190410/2893dd18/attachment.htm>


More information about the gerrit-log mailing list