source: libpacketdump/libpacketdump.h @ 2b0eae9

4.0.1-hotfixescachetimestampsdevelopdpdk-ndagetsilivelibtrace4ndag_formatpfringrc-4.0.1rc-4.0.2rc-4.0.3rc-4.0.4ringdecrementfixringperformanceringtimestampfixes
Last change on this file since 2b0eae9 was 387d299, checked in by Shane Alcock <salcock@…>, 7 years ago

Remove duplicate macros in libpacketdump

Ensure OSPF libpacketdump module won't segfault or print garbage
if a truncated OSPF header is passed into it.

Renamed 'len' field in OSPF header to 'ospf_len' to avoid
potential conflict with variables named len in libpacketdump
code.

  • Property mode set to 100644
File size: 972 bytes
Line 
1#ifndef __LIBPACKETDUMP_H__
2#define __LIBPACKETDUMP_H__
3#include "libtrace.h"
4
5#ifdef __cplusplus
6extern "C" {
7#endif
8
9#define SAFE(hdr,x) \
10        ((unsigned int)len>=((char*)&hdr->x-(char*)hdr+sizeof(hdr->x)))
11
12#define DISPLAY_EXP(hdr,x,fmt,exp) \
13        if (SAFE(hdr, x)) \
14                printf(fmt,exp); \
15        else {\
16                printf("(Truncated)\n"); \
17                return; \
18        }
19
20#define DISPLAY(hdr,x,fmt) DISPLAY_EXP(hdr,x,fmt,hdr->x)
21
22#define DISPLAYS(hdr,x,fmt) DISPLAY_EXP(hdr,x,fmt,htons(hdr->x))
23#define DISPLAYL(hdr,x,fmt) DISPLAY_EXP(hdr,x,fmt,htonl(hdr->x))
24#define DISPLAYIP(hdr,x,fmt) DISPLAY_EXP(hdr,x,fmt,inet_ntoa(*(struct in_addr*)&hdr->x))
25
26
27void trace_hexdump_packet(libtrace_packet_t *packet);
28void trace_dump_packet(libtrace_packet_t *packet);
29void decode_next(const char *packet,int len,const char *proto_name,int type);
30
31void decode(int link_type, const char *pkt, unsigned len);
32
33#ifdef __cplusplus
34}
35#endif
36
37#endif
Note: See TracBrowser for help on using the repository browser.