GTPv2_Emulation: routing improvements: Prioritize response, fallback to TEID
First try forwarding to component transmitting the originating request,
since this is the most fine-grained match.
Finally, if no specific match was found and if messages belongs to
TEID0, send it over that port as a fallback.
Fixes: 1d2cc67036e95a0c3ee3ac7738d7e15d5f76b8a2
Change-Id: Ie96d65085fb352489150183415dbd6cc8237a47c
diff --git a/library/GTPv2_Emulation.ttcn b/library/GTPv2_Emulation.ttcn
index eb2b977..240cce4 100644
--- a/library/GTPv2_Emulation.ttcn
+++ b/library/GTPv2_Emulation.ttcn
@@ -560,7 +560,12 @@
/* route inbound GTP2-C based on TEID, SEQ or IMSI */
[] GTP2C.receive(Gtp2cUnitdata:?) -> value g2c_ud {
var template hexstring imsi_t := f_gtp2c_extract_imsi(g2c_ud.gtpc);
- if (isvalue(imsi_t) and f_imsi_known(valueof(imsi_t))) {
+ /* if this is a response, route by SEQ: */
+ if (match(g2c_ud.gtpc, tr_PDU_GTP2C_msgtypes(gtp2_responses))
+ and f_seq_known(g2c_ud.gtpc.sequenceNumber)) {
+ vc_conn := f_comp_by_seq(g2c_ud.gtpc.sequenceNumber);
+ CLIENT.send(g2c_ud.gtpc) to vc_conn;
+ }else if (isvalue(imsi_t) and f_imsi_known(valueof(imsi_t))) {
vc_conn := f_comp_by_imsi(valueof(imsi_t));
CLIENT.send(g2c_ud.gtpc) to vc_conn;
} else if ((ispresent(g2c_ud.gtpc.tEID) and g2c_ud.gtpc.tEID != '00000000'O)
@@ -571,13 +576,11 @@
and f_teid_known('00000000'O)) {
vc_conn := f_comp_by_teid(g2c_ud.gtpc.tEID);
CLIENT.send(g2c_ud.gtpc) to vc_conn;
- /* if this is a response, route by SEQ: */
- } else if (match(g2c_ud.gtpc, tr_PDU_GTP2C_msgtypes(gtp2_responses))
- and f_seq_known(g2c_ud.gtpc.sequenceNumber)) {
- vc_conn := f_comp_by_seq(g2c_ud.gtpc.sequenceNumber);
- CLIENT.send(g2c_ud.gtpc) to vc_conn;
} else {
SendToUdMsgTable(g2c_ud);
+ if (not ispresent(g2c_ud.gtpc.tEID) or g2c_ud.gtpc.tEID == '00000000'O) {
+ TEID0.send(g2c_ud.gtpc);
+ }
}
/* remove sequence number if response was received */