aboutsummaryrefslogtreecommitdiffstats
path: root/ggsn_tests
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2017-12-04 18:55:58 +0100
committerHarald Welte <laforge@gnumonks.org>2017-12-04 19:04:24 +0100
commit71a36023dce72dd69aa110e09e1130a4b3cece67 (patch)
tree290bc7fdfc51d23d2a6c49d49fe106de929855dc /ggsn_tests
parent961e5c9d3b39670f2cf274af88738c205664e316 (diff)
ggsn: Verify presence of DNS addresses in IPCP of PCO
If we request DNS in IPCP in PCO, we also expect a corresponding result.
Diffstat (limited to 'ggsn_tests')
-rw-r--r--ggsn_tests/GGSN_Tests.ttcn54
-rwxr-xr-xggsn_tests/gen_links.sh2
2 files changed, 55 insertions, 1 deletions
diff --git a/ggsn_tests/GGSN_Tests.ttcn b/ggsn_tests/GGSN_Tests.ttcn
index dd9acbcd..8b0d5e40 100644
--- a/ggsn_tests/GGSN_Tests.ttcn
+++ b/ggsn_tests/GGSN_Tests.ttcn
@@ -8,6 +8,7 @@ module GGSN_Tests {
import from GTP_CodecPort_CtrlFunct all;
import from GTPC_Types all;
import from GTPU_Types all;
+ import from IPCP_Types all;
import from IP_Types all;
import from ICMPv6_Types all;
import from Native_Functions all;
@@ -400,6 +401,15 @@ module GGSN_Tests {
}
}
+ template ProtocolElement tr_PCO_Proto(OCT2 prot_id) := {
+ protocolID := prot_id,
+ lengthProtoID := ?,
+ protoIDContents := ?
+ }
+ template ProtConfigOptions tr_PCO_Contains(OCT2 prot_id) modifies tr_PCO := {
+ protocols := { *, tr_PCO_Proto(prot_id), * }
+ }
+
template ProtConfigOptions ts_PCO_IPv4_DNS_CONT modifies ts_PCO := {
protocols := {
{ protocolID := '000d'O, lengthProtoID := 0, protoIDContents := ''O }
@@ -411,6 +421,41 @@ module GGSN_Tests {
}
}
+ /* extract a given protocol payload from PCO */
+ function f_PCO_extract_proto(ProtConfigOptions pco, OCT2 protocol) return octetstring {
+ var integer i;
+ for (i := 0; i < lengthof(pco.protocols); i := i + 1) {
+ if (pco.protocols[i].protocolID == protocol) {
+ return pco.protocols[i].protoIDContents;
+ }
+ }
+ setverdict(fail);
+ return ''O;
+ }
+
+ template IpcpPacket tr_IPCP(template LcpCode code, template uint8_t identifier,
+ template IpcpOptionList opts) := {
+ code := code,
+ identifier := identifier,
+ len := ?,
+ options := opts
+ }
+ template IpcpOption tr_IPCP_PrimaryDns(template OCT4 addr) := {
+ code := IPCP_OPT_PrimaryDNS,
+ len := 6,
+ data := addr
+ }
+ template IpcpOption tr_IPCP_SecondaryDns(template OCT4 addr) := {
+ code := IPCP_OPT_SecondaryDNS,
+ len := 6,
+ data := addr
+ }
+
+ template IpcpPacket tr_IPCP_Ack_DNS(template uint8_t identifier := ?, template OCT4 dns1 := ?,
+ template OCT4 dns2 := ?) :=
+ tr_IPCP(LCP_Configure_Ack, identifier,
+ { *, tr_IPCP_PrimaryDns(dns1), *, tr_IPCP_SecondaryDns(dns2), * });
+
function f_teardown_ind_IE(in template BIT1 ind) return template TearDownInd {
/*
@@ -937,6 +982,15 @@ 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_IPCP);
f_pdp_ctx_act(ctx);
+ /* verify IPCP is at all contained */
+ if (not match(ctx.pco_neg, tr_PCO_Contains('8021'O))) {
+ setverdict(fail, "IPCP not found in PCO");
+ }
+ /* verify IPCP contains both primary and secondary DNS */
+ var IpcpPacket ipcp := dec_IpcpPacket(f_PCO_extract_proto(ctx.pco_neg, '8021'O));
+ if (not match(ipcp, tr_IPCP_Ack_DNS)) {
+ setverdict(fail, "Primary/Secondary DNS not found in IPCP");
+ }
f_pdp_ctx_del(ctx, '1'B);
}
diff --git a/ggsn_tests/gen_links.sh b/ggsn_tests/gen_links.sh
index ee8d7b06..6dd2d621 100755
--- a/ggsn_tests/gen_links.sh
+++ b/ggsn_tests/gen_links.sh
@@ -44,5 +44,5 @@ FILES="GTPC_EncDec.cc GTPC_Types.ttcn GTPU_EncDec.cc GTPU_Types.ttcn"
gen_links $DIR $FILES
DIR=../library
-FILES="General_Types.ttcn GSM_Types.ttcn Osmocom_Types.ttcn Native_Functions.ttcn Native_FunctionDefs.cc"
+FILES="General_Types.ttcn GSM_Types.ttcn Osmocom_Types.ttcn Native_Functions.ttcn Native_FunctionDefs.cc IPCP_Types.ttcn"
gen_links $DIR $FILES