#define GTP_EVENT_BAD_MSG_LEN_STR "message length is invalid"
#define GTP_EVENT_BAD_IE_LEN_STR "information element length is invalid"
#define GTP_EVENT_OUT_OF_ORDER_IE_STR "information elements are out of order"
+#define GTP_EVENT_MISSING_TEID_STR "TEID is missing"
//-------------------------------------------------------------------------
// stats
{ GTP_EVENT_BAD_MSG_LEN, GTP_EVENT_BAD_MSG_LEN_STR },
{ GTP_EVENT_BAD_IE_LEN, GTP_EVENT_BAD_IE_LEN_STR },
{ GTP_EVENT_OUT_OF_ORDER_IE, GTP_EVENT_OUT_OF_ORDER_IE_STR },
+ { GTP_EVENT_MISSING_TEID, GTP_EVENT_MISSING_TEID_STR },
{ 0, nullptr }
};
#define GTP_EVENT_BAD_MSG_LEN (1)
#define GTP_EVENT_BAD_IE_LEN (2)
#define GTP_EVENT_OUT_OF_ORDER_IE (3)
+#define GTP_EVENT_MISSING_TEID (4)
#define GTP_NAME "gtp_inspect"
#define GTP_HELP "gtp control channel inspection"
uint16_t length; /* length */
};
-struct GTP_C_Hdr_v0
-{
- GTP_C_Hdr hdr;
- uint16_t sequence_num;
- uint16_t flow_lable;
- uint64_t tid;
-};
-
/* GTP Information element Header */
struct GTP_IE_Hdr
{
static int gtp_parse_v1(GTPMsg* msg, const uint8_t* buff, uint16_t gtp_len)
{
const GTP_C_Hdr* hdr;
+ const uint32_t* teid;
hdr = (const GTP_C_Hdr*)buff;
+ /*TEID value at 5-8 octets*/
+ teid = (const uint32_t*)(buff + 4);
+
+ if ((msg->msg_type > 3) && (*teid == 0))
+ {
+ alert(GTP_EVENT_MISSING_TEID);
+ }
/*Check the length based on optional fields and extension header*/
if (hdr->flag & 0x07)
static int gtp_parse_v2(GTPMsg* msg, const uint8_t* buff, uint16_t gtp_len)
{
const GTP_C_Hdr* hdr;
+ const uint32_t* teid;
hdr = (const GTP_C_Hdr*)buff;
+ /*TEID value at 5-8 octet*/
+ teid = (const uint32_t*)(buff + 4);
+
+ if ((msg->msg_type > 3) && (hdr->flag & 0x08) && (*teid == 0))
+ {
+ alert(GTP_EVENT_MISSING_TEID);
+ }
if (hdr->flag & 0x8)
msg->header_len = GTP_HEADER_LEN_EPC_V2;