|
|
|
@ -63,9 +63,115 @@ uint8_t ip_tst_message2[] = {
|
|
|
|
|
0x88, 0x29, 0x60, 0x02, 0xde, 0x41, 0x11, 0xc2, 0xaa, 0x5e, 0x9e, 0x27, 0x74, 0xa5, 0xd3, 0x19};
|
|
|
|
|
uint32_t ip_message_len2 = sizeof(ip_tst_message2);
|
|
|
|
|
|
|
|
|
|
// IPv6 test filter
|
|
|
|
|
// Packet filter: 0
|
|
|
|
|
// Packet filter component type identifier: Protocol identifier/Next header type (48)
|
|
|
|
|
// Protocol/header: UDP (0x11)
|
|
|
|
|
// Packet filter component type identifier: IPv6 remote address type (32)
|
|
|
|
|
// IPv6 address: 2a02:14f:ffc0:51::6
|
|
|
|
|
// IPv6 address mask: ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff
|
|
|
|
|
// Packet filter component type identifier: Single remote port type (80)
|
|
|
|
|
// Port: 35082
|
|
|
|
|
// Packet filter component type identifier: Single local port type (64)
|
|
|
|
|
// Port: 50010
|
|
|
|
|
uint8_t ipv6_filter[] = {0x30, 0x11, 0x20, 0x2a, 0x02, 0x01, 0x4f, 0xff, 0xc0, 0x00, 0x51, 0x00, 0x00, 0x00,
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x06, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x50, 0x89, 0x0a, 0x40, 0xc3, 0x5a};
|
|
|
|
|
|
|
|
|
|
// IPv6 test packets
|
|
|
|
|
uint8_t ipv6_matched_packet[] = {0x60, 0x0e, 0xa3, 0x96, 0x00, 0x16, 0x11, 0xff, 0x2a, 0x02, 0x01, 0x4f, 0x01,
|
|
|
|
|
0x9f, 0xec, 0xe9, 0xfc, 0xf5, 0x73, 0x48, 0xc6, 0xed, 0x19, 0xe6, 0x2a, 0x02,
|
|
|
|
|
0x01, 0x4f, 0xff, 0xc0, 0x00, 0x51, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
|
0x06, 0xc3, 0x5a, 0x89, 0x0a, 0x00, 0x16, 0x31, 0xd9, 0x80, 0x61, 0x00, 0x01,
|
|
|
|
|
0x00, 0x00, 0x0c, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77};
|
|
|
|
|
|
|
|
|
|
uint8_t ipv6_unmatched_packet_tcp[] = {
|
|
|
|
|
0x60, 0x0e, 0xa3, 0x96, 0x00, 0x16, /**/ 0x06 /**/, 0xff, 0x2a, 0x02, 0x01, 0x4f, 0x01, 0x9f, 0xec, 0xe9,
|
|
|
|
|
0xfc, 0xf5, 0x73, 0x48, 0xc6, 0xed, 0x19, 0xe6, 0x2a, 0x02, 0x01, 0x4f, 0xff, 0xc0, 0x00, 0x51,
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0xc3, 0x5a, 0x89, 0x0a, 0x00, 0x16, 0x31, 0xd9,
|
|
|
|
|
0x80, 0x61, 0x00, 0x01, 0x00, 0x00, 0x0c, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77};
|
|
|
|
|
|
|
|
|
|
uint8_t ipv6_unmatched_packet_daddr[] = {
|
|
|
|
|
0x60, 0x0e, 0xa3, 0x96, 0x00, 0x16, 0x11, 0xff, 0x2a, 0x02, 0x01, 0x4f, 0x01, 0x9f, 0xec, 0xe9,
|
|
|
|
|
0xfc, 0xf5, 0x73, 0x48, 0xc6, 0xed, 0x19, 0xe6, 0x2a, 0x02, 0x01, 0x4f, 0xff, 0xc0, 0x00, 0x51,
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /**/ 0x07, /**/ 0xc3, 0x5a, 0x89, 0x0a, 0x00, 0x16, 0x31, 0xd9,
|
|
|
|
|
0x80, 0x61, 0x00, 0x01, 0x00, 0x00, 0x0c, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77};
|
|
|
|
|
|
|
|
|
|
uint8_t ipv6_unmatched_packet_rport[] = {
|
|
|
|
|
0x60, 0x0e, 0xa3, 0x96, 0x00, 0x16, 0x11, 0xff, 0x2a, 0x02, 0x01, 0x4f, 0x01, 0x9f, 0xec, 0xe9,
|
|
|
|
|
0xfc, 0xf5, 0x73, 0x48, 0xc6, 0xed, 0x19, 0xe6, 0x2a, 0x02, 0x01, 0x4f, 0xff, 0xc0, 0x00, 0x51,
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0xc3, 0x5a, 0x89, /**/ 0x0b /**/, 0x00, 0x16, 0x31, 0xd9,
|
|
|
|
|
0x80, 0x61, 0x00, 0x01, 0x00, 0x00, 0x0c, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77};
|
|
|
|
|
|
|
|
|
|
uint8_t ipv6_unmatched_packet_lport[] = {
|
|
|
|
|
0x60, 0x0e, 0xa3, 0x96, 0x00, 0x16, 0x11, 0xff, 0x2a, 0x02, 0x01, 0x4f, 0x01, 0x9f, 0xec, 0xe9,
|
|
|
|
|
0xfc, 0xf5, 0x73, 0x48, 0xc6, 0xed, 0x19, 0xe6, 0x2a, 0x02, 0x01, 0x4f, 0xff, 0xc0, 0x00, 0x51,
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0xc3, /**/ 0x5b /**/, 0x89, 0x0b, 0x00, 0x16, 0x31, 0xd9,
|
|
|
|
|
0x80, 0x61, 0x00, 0x01, 0x00, 0x00, 0x0c, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77};
|
|
|
|
|
|
|
|
|
|
#define EPS_BEARER_ID 6
|
|
|
|
|
#define LCID 1
|
|
|
|
|
|
|
|
|
|
int tft_filter_test_ipv6_combined()
|
|
|
|
|
{
|
|
|
|
|
srslte::log_filter log1("TFT");
|
|
|
|
|
log1.set_level(srslte::LOG_LEVEL_DEBUG);
|
|
|
|
|
log1.set_hex_limit(128);
|
|
|
|
|
srslte::byte_buffer_pool* pool = srslte::byte_buffer_pool::get_instance();
|
|
|
|
|
srslte::unique_byte_buffer_t ip_msg1, ip_msg2, ip_msg3, ip_msg4, ip_msg5;
|
|
|
|
|
ip_msg1 = allocate_unique_buffer(*pool);
|
|
|
|
|
ip_msg2 = allocate_unique_buffer(*pool);
|
|
|
|
|
ip_msg3 = allocate_unique_buffer(*pool);
|
|
|
|
|
ip_msg4 = allocate_unique_buffer(*pool);
|
|
|
|
|
ip_msg5 = allocate_unique_buffer(*pool);
|
|
|
|
|
|
|
|
|
|
// Set IP test message
|
|
|
|
|
ip_msg1->N_bytes = sizeof(ipv6_matched_packet);
|
|
|
|
|
memcpy(ip_msg1->msg, ipv6_matched_packet, sizeof(ipv6_matched_packet));
|
|
|
|
|
log1.info_hex(ip_msg1->msg, ip_msg1->N_bytes, "IPv6 test message - match\n");
|
|
|
|
|
|
|
|
|
|
// Set IP test message
|
|
|
|
|
ip_msg2->N_bytes = sizeof(ipv6_unmatched_packet_tcp);
|
|
|
|
|
memcpy(ip_msg2->msg, ipv6_unmatched_packet_tcp, sizeof(ipv6_unmatched_packet_tcp));
|
|
|
|
|
log1.info_hex(ip_msg2->msg, ip_msg2->N_bytes, "IPv6 test message - unmatched tcp\n");
|
|
|
|
|
|
|
|
|
|
// Set IP test message
|
|
|
|
|
ip_msg3->N_bytes = sizeof(ipv6_unmatched_packet_daddr);
|
|
|
|
|
memcpy(ip_msg3->msg, ipv6_unmatched_packet_daddr, sizeof(ipv6_unmatched_packet_daddr));
|
|
|
|
|
log1.info_hex(ip_msg3->msg, ip_msg3->N_bytes, "IPv6 test message - unmatched daddr\n");
|
|
|
|
|
|
|
|
|
|
// Set IP test message
|
|
|
|
|
ip_msg4->N_bytes = sizeof(ipv6_unmatched_packet_rport);
|
|
|
|
|
memcpy(ip_msg4->msg, ipv6_unmatched_packet_rport, sizeof(ipv6_unmatched_packet_rport));
|
|
|
|
|
log1.info_hex(ip_msg4->msg, ip_msg4->N_bytes, "IPv6 test message - unmatched rport\n");
|
|
|
|
|
|
|
|
|
|
// Set IP test message
|
|
|
|
|
ip_msg5->N_bytes = sizeof(ipv6_unmatched_packet_lport);
|
|
|
|
|
memcpy(ip_msg5->msg, ipv6_unmatched_packet_lport, sizeof(ipv6_unmatched_packet_lport));
|
|
|
|
|
log1.info_hex(ip_msg5->msg, ip_msg5->N_bytes, "IPv6 test message - unmatched lport\n");
|
|
|
|
|
|
|
|
|
|
// Packet filter
|
|
|
|
|
LIBLTE_MME_PACKET_FILTER_STRUCT packet_filter;
|
|
|
|
|
|
|
|
|
|
packet_filter.dir = LIBLTE_MME_TFT_PACKET_FILTER_DIRECTION_BIDIRECTIONAL;
|
|
|
|
|
packet_filter.id = 1;
|
|
|
|
|
packet_filter.eval_precedence = 0;
|
|
|
|
|
packet_filter.filter_size = sizeof(ipv6_filter);
|
|
|
|
|
memcpy(packet_filter.filter, ipv6_filter, sizeof(ipv6_filter));
|
|
|
|
|
|
|
|
|
|
srsue::tft_packet_filter_t filter(EPS_BEARER_ID, LCID, packet_filter, &log1);
|
|
|
|
|
|
|
|
|
|
// Check filter
|
|
|
|
|
TESTASSERT(filter.match(ip_msg1));
|
|
|
|
|
TESTASSERT(!filter.match(ip_msg2));
|
|
|
|
|
TESTASSERT(!filter.match(ip_msg3));
|
|
|
|
|
TESTASSERT(!filter.match(ip_msg4));
|
|
|
|
|
TESTASSERT(!filter.match(ip_msg5));
|
|
|
|
|
|
|
|
|
|
printf("Test TFT filter ipv6 combined successfull\n");
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int tft_filter_test_single_local_port()
|
|
|
|
|
{
|
|
|
|
|
srslte::log_filter log1("TFT");
|
|
|
|
@ -326,4 +432,8 @@ int main(int argc, char** argv)
|
|
|
|
|
if (tft_filter_test_ipv4_tos()) {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
if (tft_filter_test_ipv6_combined()) {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
srslte::byte_buffer_pool::cleanup();
|
|
|
|
|
}
|
|
|
|
|