IPv4 header generation bug fixed; utils MSG(...) fixed
This commit is contained in:
parent
a46b3a8564
commit
586a9ba733
@ -77,7 +77,7 @@ void insert_ipv4_header(uint8_t *hdr, const PcktHeaderElement *headers) {
|
|||||||
FILL_ADVANCE(hdr, &ipProps->DSF, 1);
|
FILL_ADVANCE(hdr, &ipProps->DSF, 1);
|
||||||
FILL_WORD_H2N_ADVANCE(hdr, ipProps->TotalLength);
|
FILL_WORD_H2N_ADVANCE(hdr, ipProps->TotalLength);
|
||||||
FILL_WORD_H2N_ADVANCE(hdr, ipProps->Identification);
|
FILL_WORD_H2N_ADVANCE(hdr, ipProps->Identification);
|
||||||
uint16_t flags_fragOffset = ((ipProps->Flags & 0x07) << 13) | (flags_fragOffset & ~(0x07 << 13));
|
uint16_t flags_fragOffset = ((ipProps->Flags & 0x07) << 13) | (ipProps->FragmentOffset & ~(0x07 << 13));
|
||||||
FILL_ADVANCE(hdr, &ipProps->TTL, 1);
|
FILL_ADVANCE(hdr, &ipProps->TTL, 1);
|
||||||
FILL_ADVANCE(hdr, &ipProps->Protocol, 1);
|
FILL_ADVANCE(hdr, &ipProps->Protocol, 1);
|
||||||
uint16_t checksum = ip_checksum(ipProps);
|
uint16_t checksum = ip_checksum(ipProps);
|
||||||
|
5
utils.h
5
utils.h
@ -31,9 +31,8 @@
|
|||||||
#define ntohs(a) htons((a))
|
#define ntohs(a) htons((a))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define ERROR(...) printf(__VA_ARGS__)
|
#define ERROR(...) MSG(__VA_ARGS__)
|
||||||
#define INFO(...) printf(__VA_ARGS__)
|
#define INFO(...) MSG(__VA_ARGS__)
|
||||||
#define MSG(...) printf(__VA_ARGS__)
|
|
||||||
|
|
||||||
#define IPv4(a,b,c,d) ((a) | (b << 8) | (c << 16) | (d << 24))
|
#define IPv4(a,b,c,d) ((a) | (b << 8) | (c << 16) | (d << 24))
|
||||||
#define PRINT_IPv4(ip) MSG("%u.%u.%u.%u", (ip & 0xFF), ((ip >> 8) & 0xFF), ((ip >> 16) & 0xFF), ((ip >> 24) & 0xFF))
|
#define PRINT_IPv4(ip) MSG("%u.%u.%u.%u", (ip & 0xFF), ((ip >> 8) & 0xFF), ((ip >> 16) & 0xFF), ((ip >> 24) & 0xFF))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user