test GGSN support for optional GTP-U sequence numbers
Add VTY functionality to GGSN tests, and use the VTY to enable/disable
GTP-U Tx sequence numbers in the running osmo-ggsn.
The GTPU packet template now makes sequence numbers optional.
A template created with its sequence number set to 'omit' will result in
a packet without a sequence number, i.e. the 'sequence number present' bit
in the packet header is cleared, and the sequence number field is omitted
from the encoded GTPU T-PDU packet.
Re-use the existing TC_pdp4_clients_interact() test for testing the
behaviour of osmo-ggsn. This test is now run twice, once with and
once without GTP-U Tx sequence numbers. Verify that packets relayed by
osmo-ggsn match its "g-pdu tx-sequence-numbers" configuration setting.
Change-Id: I1dc299407c61b1c865035add44067b8ab89001b3
Related: OS#2519
diff --git a/library/GTP_Templates.ttcn b/library/GTP_Templates.ttcn
index d8a43c2..44ec439 100644
--- a/library/GTP_Templates.ttcn
+++ b/library/GTP_Templates.ttcn
@@ -545,15 +545,39 @@
gtpu_IEs := ies
}
+ function f_GTPU_s_bit(template (omit) uint16_t seq) return BIT1 {
+ if (istemplatekind(seq, "omit")) {
+ return '0'B;
+ }
+ return '1'B;
+ }
+
+ function f_GTPU_opt_part(template (omit) uint16_t seq) return template (omit) GTPU_Header_optional_part {
+ if (istemplatekind(seq, "omit")) {
+ return omit;
+ }
+ var GTPU_Header_optional_part ret := {
+ sequenceNumber := int2oct(valueof(seq), 2),
+ npduNumber := '00'O,
+ nextExtHeader := '00'O,
+ gTPU_extensionHeader_List := omit
+ };
+ return ret;
+ }
+
/* generalized GTP-U send template */
- template PDU_GTPU ts_GTP1U_PDU(OCT1 msg_type, uint16_t seq, OCT4 teid, GTPU_IEs ies) := {
+ template PDU_GTPU ts_GTP1U_PDU(OCT1 msg_type, template (omit) uint16_t seq, OCT4 teid, GTPU_IEs ies) := {
/* N-PDU Number flag (PN): the GTP-U header contains a meaningful N-PDU Number field if the PN
* flag is set to 1. */
pn_bit := '0'B, /* we assume the encoder overwrites this if an optional part is given */
/* If the Sequence Number flag (S) is set to '1' the sequence number field is present and
* meaningful otherwise it is set to '0'. For GTP-U messages Echo Request, Echo Response,
- * Error Indication and Supported Extension Headers Notification, the S flag shall be set to '1'. */
- s_bit := '1'B, /* we assume the encoder overwrites this if an optional part is given */
+ * Error Indication and Supported Extension Headers Notification, the S flag shall be set to '1'.
+ *
+ * Note that the caller must ensure that these conditions hold.
+ * The caller can either pass a sequence number (we set s_bit to '1'B) when appropriate,
+ * or may omit the sequence number (we set s_bit to '0'B). */
+ s_bit := f_GTPU_s_bit(seq),
/* Extension header presence */
e_bit := '0'B,
spare := '0'B,
@@ -564,12 +588,7 @@
messageType := msg_type,
lengthf := 0, /* we assume encoder overwrites this */
teid := teid,
- opt_part := {
- sequenceNumber := int2oct(seq, 2),
- npduNumber := '00'O,
- nextExtHeader := '00'O,
- gTPU_extensionHeader_List := omit
- },
+ opt_part := f_GTPU_opt_part(seq),
gtpu_IEs := ies
}
@@ -610,7 +629,7 @@
}
/* master template for sending a GTP-U user plane data */
- template Gtp1uUnitdata ts_GTP1U_GPDU(GtpPeer peer, uint16_t seq, OCT4 teid, octetstring data) := {
+ template Gtp1uUnitdata ts_GTP1U_GPDU(GtpPeer peer, template (omit) uint16_t seq, OCT4 teid, octetstring data) := {
peer := peer,
gtpu := ts_GTP1U_PDU('FF'O, seq, teid, { g_PDU_IEs := { data := data }})
}