ggsn: Verify presence of DNS addresses in IPCP of PCO

If we request DNS in IPCP in PCO, we also expect a corresponding result.
This commit is contained in:
Harald Welte 2017-12-04 18:55:58 +01:00
parent 961e5c9d3b
commit 71a36023dc
3 changed files with 110 additions and 1 deletions

View File

@ -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);
}

View File

@ -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

55
library/IPCP_Types.ttcn Normal file
View File

@ -0,0 +1,55 @@
module IPCP_Types {
import from Osmocom_Types all;
/* RFC1331 Section 6 */
type enumerated LcpCode {
LCP_Configure_Request ('01'O),
LCP_Configure_Ack ('02'O),
LCP_Configure_Nak ('03'O),
LCP_Configure_Reject ('04'O),
LCP_Terminate_Requeest ('05'O),
LCP_Terminate_Ack ('06'O),
LCP_Code_Reject ('07'O),
LCP_Protocol_Reject ('08'O),
LCP_Echo_Request ('09'O),
LCP_Echo_Reply ('10'O),
LCP_Discarded_Request ('11'O),
LCP_Reserved ('12'O)
} with { variant "FIELDLENGTH(8)" };
type record IpcpPacket {
LcpCode code,
uint8_t identifier,
uint16_t len,
IpcpOptionList options
} with { variant (len) "LENGTHTO(code,identifier,len,options)" };
/* RFC1332 */
type enumerated IpcpConfigOptCode {
IPCP_OPT_IpAddresses ('01'O),
IPCP_OPT_IpCompressionProtocol ('02'O),
IPCP_OPT_IpAddress ('03'O),
IPCP_OPT_MobileIPv4 ('04'O),/* RFC 2290 */
IPCP_OPT_PrimaryDNS (129), /* RFC 1877 */
IPCP_OPT_PrimaryNBNS (130), /* RFC 1877 */
IPCP_OPT_SecondaryDNS (131), /* RFC 1877 */
IPCP_OPT_SecondaryNBNS (132) /* RFC 1877 */
} with { variant "FIELDLENGTH(8)" };
type record IpcpOption {
IpcpConfigOptCode code,
uint8_t len,
octetstring data
} with { variant (len) "LENGTHTO(code,len,data)" };
type record of IpcpOption IpcpOptionList;
external function enc_IpcpPacket(in IpcpPacket inp) return octetstring
with { extension "prototype(convert)" extension "encode(RAW)" };
external function dec_IpcpPacket(in octetstring inp) return IpcpPacket
with { extension "prototype(convert)" extension "decode(RAW)" };
} with { encode "RAW" ; variant "FIELDORDER(msb)" }