GTP_Templates: Fix runtime error in tr_EuaIPv*() templates

Doing this when receiving an IPv4 EUA thwos an error:
"if (not match(cpr.endUserAddress, tr_EuaIPv4(?)) and not match(cpr.endUserAddress, tr_EuaIPv6(?)))"

Dynamic test case error: Performing lengthof() operation on an octetstring template with no exact length.

This happens if for instance received spare bits are set to '0000'.

Change-Id: I70ad3c10e2ecfed8f733ff906272a9597b2ab9bd
This commit is contained in:
Pau Espin 2022-02-23 18:38:37 +01:00 committed by pespin
parent 835fd300f8
commit 001b3e8767
1 changed files with 40 additions and 3 deletions

View File

@ -163,6 +163,43 @@ module GTP_Templates {
gtpc := ts_GTP1C_PDU(echoRequest, '00000000'O, valueof(ts_EchoReqPDU), seq)
}
private function f_eua_ipv4_len(template OCT4 ip_addr) return template integer {
if (istemplatekind(ip_addr, "omit")) {
return 2;
} else if (istemplatekind(ip_addr, "*")) {
return ?;
} else if (istemplatekind(ip_addr, "?")) {
return 6;
}
return 6;
}
private function f_eua_ipv6_len(template OCT16 ip_addr) return template integer {
if (istemplatekind(ip_addr, "omit")) {
return 2;
} else if (istemplatekind(ip_addr, "*")) {
return ?;
} else if (istemplatekind(ip_addr, "?")) {
return 18;
}
return 18;
}
private function f_eua_ipv4v6_len(template OCT4 ip_addr4, template OCT16 ip_addr6) return template integer {
var integer len := 2;
if (istemplatekind(ip_addr4, "*") or
istemplatekind(ip_addr6, "*")) {
return ?;
}
if (not istemplatekind(ip_addr4, "omit")) {
len := len + 4;
}
if (not istemplatekind(ip_addr6, "omit")) {
len := len + 16;
}
return len;
}
template EndUserAddress t_EuaIPv4(template OCT4 ip_addr) := {
type_gtpc := '80'O,
endUserAddress := {
@ -179,7 +216,7 @@ module GTP_Templates {
template EndUserAddress tr_EuaIPv4(template OCT4 ip_addr) modifies t_EuaIPv4 := {
endUserAddress := {
endUserAddressIPv4 := {
lengthf := 2+lengthof(ip_addr)
lengthf := f_eua_ipv4_len(ip_addr)
}
}
}
@ -200,7 +237,7 @@ module GTP_Templates {
template EndUserAddress tr_EuaIPv6(template OCT16 ip_addr) modifies t_EuaIPv6 := {
endUserAddress := {
endUserAddressIPv6 := {
lengthf := 2+lengthof(ip_addr)
lengthf := f_eua_ipv6_len(ip_addr)
}
}
}
@ -223,7 +260,7 @@ module GTP_Templates {
template EndUserAddress tr_EuaIPv4v6(template OCT4 ip_addr4, template OCT16 ip_addr6) modifies t_EuaIPv4v6 := {
endUserAddress := {
endUserAddressIPv4andIPv6 := {
lengthf := 2+lengthof(ip_addr4)+lengthof(ip_addr6)
lengthf := f_eua_ipv4v6_len(ip_addr4, ip_addr6)
}
}
}