31 lines
760 B
C++
31 lines
760 B
C++
|
|
#include <gtest/gtest.h>
|
||
|
|
|
||
|
|
#include "udp_helpers.h"
|
||
|
|
|
||
|
|
/*
|
||
|
|
* User Datagram Protocol, Src Port: 4001, Dst Port: 8000
|
||
|
|
* Source Port: 4001
|
||
|
|
* Destination Port: 8000
|
||
|
|
* Length: 155
|
||
|
|
* Checksum: 0x1e1e [correct]
|
||
|
|
* [Calculated Checksum: 0x1e1e]
|
||
|
|
* [Checksum Status: Good]
|
||
|
|
*/
|
||
|
|
|
||
|
|
unsigned char data[] = {0x0f, 0xa1, 0x1f, 0x40, 0x00, 0x9b, 0x1e, 0x1e};
|
||
|
|
|
||
|
|
TEST(UDP_HELPERS, GET)
|
||
|
|
{
|
||
|
|
const struct udphdr *hdr = (struct udphdr *)data;
|
||
|
|
EXPECT_TRUE(udp_hdr_get_sport(hdr) == 4001);
|
||
|
|
EXPECT_TRUE(udp_hdr_get_dport(hdr) == 8000);
|
||
|
|
EXPECT_TRUE(udp_hdr_get_len(hdr) == 155);
|
||
|
|
EXPECT_TRUE(udp_hdr_get_checksum(hdr) == 0x1e1e);
|
||
|
|
}
|
||
|
|
|
||
|
|
int main(int argc, char **argv)
|
||
|
|
{
|
||
|
|
::testing::InitGoogleTest(&argc, argv);
|
||
|
|
return RUN_ALL_TESTS();
|
||
|
|
}
|