diff options
author | Vladimir Gavrilov <105977161+0xA50C1A1@users.noreply.github.com> | 2023-12-10 14:10:50 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-10 12:10:50 +0100 |
commit | c809e7c0691a77e84036df78067e482700263c71 (patch) | |
tree | 4644bae2ec2a940491bddae04f2e279068766ccb /src/lib/ndpi_utils.c | |
parent | f74cf16c361018fc98d796978013df4ca0c6050f (diff) |
Replace complicated TPKT header validation with an helper function (#2201)
* Replace complicated TPKT header validation with an helper function
* Move tpkt_verify_hdr function definition to ndpi_utils.c
Diffstat (limited to 'src/lib/ndpi_utils.c')
-rw-r--r-- | src/lib/ndpi_utils.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/lib/ndpi_utils.c b/src/lib/ndpi_utils.c index d6f5b7f60..ff56bb61d 100644 --- a/src/lib/ndpi_utils.c +++ b/src/lib/ndpi_utils.c @@ -3023,3 +3023,11 @@ u_int32_t ndpi_nearest_power_of_two(u_int32_t x) { return(x); } +/* ******************************************* */ + +int tpkt_verify_hdr(const struct ndpi_packet_struct * const packet) +{ + return ((packet->tcp != NULL) && (packet->payload_packet_len > 4) && + (packet->payload[0] == 3) && (packet->payload[1] == 0) && + (get_u_int16_t(packet->payload,2) == htons(packet->payload_packet_len))); +} |