bugfix: packet parser adds checks for packets with UDP port 2152 but not GTP-U
This commit is contained in:
@@ -186,15 +186,15 @@ TEST(GTP1_UTILS, C_SET)
|
||||
* TEID: 0x001e849a (2000026)
|
||||
*/
|
||||
|
||||
unsigned char gtp1_u[] = {
|
||||
unsigned char gtp1_u1[] = {
|
||||
0x30, 0xff, 0x00, 0x28, 0x00, 0x1e, 0x84, 0x9a};
|
||||
|
||||
TEST(GTP1_UTILS, U_GET)
|
||||
TEST(GTP1_UTILS, U1_GET)
|
||||
{
|
||||
const struct gtp1_hdr *hdr = (struct gtp1_hdr *)gtp1_u;
|
||||
const struct gtp1_hdr *hdr = (struct gtp1_hdr *)gtp1_u1;
|
||||
|
||||
// GTP Fixed Header Length + GTPv1-U Optional Headers + GTPv1-U Extension Headers
|
||||
EXPECT_TRUE(calc_gtp1_hdr_len((const char *)gtp1_u, sizeof(gtp1_u)) == 8);
|
||||
EXPECT_TRUE(calc_gtp1_hdr_len((const char *)gtp1_u1, sizeof(gtp1_u1)) == 8);
|
||||
EXPECT_TRUE(gtp1_hdr_get_flags(hdr) == 0x30);
|
||||
EXPECT_TRUE(gtp1_hdr_get_version(hdr) == 1);
|
||||
EXPECT_TRUE(gtp1_hdr_get_proto(hdr) == 1);
|
||||
@@ -214,7 +214,7 @@ TEST(GTP1_UTILS, U_GET)
|
||||
printf("%s\n", buff);
|
||||
}
|
||||
|
||||
TEST(GTP1_UTILS, U_SET)
|
||||
TEST(GTP1_UTILS, U1_SET)
|
||||
{
|
||||
char buff[8] = {0};
|
||||
|
||||
@@ -233,7 +233,82 @@ TEST(GTP1_UTILS, U_SET)
|
||||
gtp1_hdr_set_npdu(hdr, 0);
|
||||
gtp1_hdr_set_next_ext_type(hdr, 0);
|
||||
|
||||
EXPECT_TRUE(memcmp(buff, gtp1_u, 8) == 0);
|
||||
EXPECT_TRUE(memcmp(buff, gtp1_u1, 8) == 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* User Datagram Protocol, Src Port: 2152, Dst Port: 2152
|
||||
* GPRS Tunneling Protocol
|
||||
* Flags: 0x34
|
||||
* 001. .... = Version: GTP release 99 version (1)
|
||||
* ...1 .... = Protocol type: GTP (1)
|
||||
* .... 0... = Reserved: 0
|
||||
* .... .1.. = Is Next Extension Header present?: Yes
|
||||
* .... ..0. = Is Sequence Number present?: No
|
||||
* .... ...0 = Is N-PDU number present?: No
|
||||
* Message Type: T-PDU (0xff)
|
||||
* Length: 445
|
||||
* TEID: 0x01447453 (21263443)
|
||||
* Next extension header type: PDU Session container (0x85)
|
||||
* Extension header (PDU Session container)
|
||||
* Extension Header Length: 1
|
||||
* PDU Session Container
|
||||
* 0001 .... = PDU Type: UL PDU SESSION INFORMATION (1)
|
||||
* .... 0000 = Spare: 0x0
|
||||
* 00.. .... = Spare: 0x0
|
||||
* ..00 0001 = QoS Flow Identifier (QFI): 1
|
||||
* Next extension header type: No more extension headers (0x00)
|
||||
*/
|
||||
|
||||
unsigned char gtp1_u2[] = {
|
||||
0x34, 0xff, 0x01, 0xbd, 0x01, 0x44, 0x74, 0x53, 0x00, 0x00, 0x00, 0x85, 0x01, 0x10, 0x01, 0x00};
|
||||
|
||||
TEST(GTP1_UTILS, U2_GET)
|
||||
{
|
||||
const struct gtp1_hdr *hdr = (struct gtp1_hdr *)gtp1_u2;
|
||||
|
||||
// GTP Fixed Header Length + GTPv1-U Optional Headers + GTPv1-U Extension Headers
|
||||
EXPECT_TRUE(calc_gtp1_hdr_len((const char *)gtp1_u2, sizeof(gtp1_u2)) == 16);
|
||||
EXPECT_TRUE(gtp1_hdr_get_flags(hdr) == 0x34);
|
||||
EXPECT_TRUE(gtp1_hdr_get_version(hdr) == 1);
|
||||
EXPECT_TRUE(gtp1_hdr_get_proto(hdr) == 1);
|
||||
EXPECT_TRUE(gtp1_hdr_get_reserved(hdr) == 0);
|
||||
EXPECT_TRUE(gtp1_hdr_get_ext_flag(hdr) == 1);
|
||||
EXPECT_TRUE(gtp1_hdr_get_seq_flag(hdr) == 0);
|
||||
EXPECT_TRUE(gtp1_hdr_get_npdu_flag(hdr) == 0);
|
||||
EXPECT_TRUE(gtp1_hdr_get_msg_type(hdr) == 0xff);
|
||||
EXPECT_TRUE(gtp1_hdr_get_msg_len(hdr) == 445);
|
||||
EXPECT_TRUE(gtp1_hdr_get_teid(hdr) == 21263443);
|
||||
EXPECT_TRUE(gtp1_hdr_get_seq(hdr) == 0);
|
||||
EXPECT_TRUE(gtp1_hdr_get_npdu(hdr) == 0);
|
||||
EXPECT_TRUE(gtp1_hdr_get_next_ext_type(hdr) == 0x85);
|
||||
|
||||
char buff[1024] = {0};
|
||||
gtp1_hdr_to_str(hdr, buff, sizeof(buff));
|
||||
printf("%s\n", buff);
|
||||
}
|
||||
|
||||
TEST(GTP1_UTILS, U2_SET)
|
||||
{
|
||||
char buff[16] = {0};
|
||||
|
||||
struct gtp1_hdr *hdr = (struct gtp1_hdr *)buff;
|
||||
gtp1_hdr_set_flags(hdr, 0x34);
|
||||
gtp1_hdr_set_version(hdr, 1);
|
||||
gtp1_hdr_set_proto(hdr, 1);
|
||||
gtp1_hdr_set_reserved(hdr, 0);
|
||||
gtp1_hdr_set_ext_flag(hdr, 1);
|
||||
gtp1_hdr_set_seq_flag(hdr, 0);
|
||||
gtp1_hdr_set_npdu_flag(hdr, 0);
|
||||
gtp1_hdr_set_msg_type(hdr, 0xff);
|
||||
gtp1_hdr_set_msg_len(hdr, 445);
|
||||
gtp1_hdr_set_teid(hdr, 21263443);
|
||||
gtp1_hdr_set_seq(hdr, 0);
|
||||
gtp1_hdr_set_npdu(hdr, 0);
|
||||
gtp1_hdr_set_next_ext_type(hdr, 0x85);
|
||||
|
||||
// not compare the extension header
|
||||
EXPECT_TRUE(memcmp(buff, gtp1_u2, 12) == 0);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
|
||||
Reference in New Issue
Block a user