pespin has submitted this change. ( 
https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/27313 )

Change subject: GTP_Templates: Fix runtime error in tr_EuaIPv*() templates
......................................................................

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
---
M library/GTP_Templates.ttcn
1 file changed, 40 insertions(+), 3 deletions(-)

Approvals:
  fixeria: Looks good to me, but someone else must approve
  pespin: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/library/GTP_Templates.ttcn b/library/GTP_Templates.ttcn
index 73d0bf0..049614a 100644
--- a/library/GTP_Templates.ttcn
+++ b/library/GTP_Templates.ttcn
@@ -163,6 +163,43 @@
                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 @@
        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 @@
        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 @@
        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)
                        }
                }
        }

--
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/27313
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: I70ad3c10e2ecfed8f733ff906272a9597b2ab9bd
Gerrit-Change-Number: 27313
Gerrit-PatchSet: 3
Gerrit-Owner: pespin <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <[email protected]>
Gerrit-Reviewer: fixeria <[email protected]>
Gerrit-Reviewer: pespin <[email protected]>
Gerrit-MessageType: merged

Reply via email to