Ignore:
Timestamp:
07/04/14 11:37:25 (7 years ago)
Author:
Shane Alcock <salcock@…>
Branches:
4.0.1-hotfixes, cachetimestamps, develop, dpdk-ndag, etsilive, libtrace4, master, ndag_format, pfring, rc-4.0.1, rc-4.0.2, rc-4.0.3, rc-4.0.4, ringdecrementfix, ringperformance, ringtimestampfixes
Children:
d14e23d
Parents:
9ad7a35
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libpacketdump/libpacketdump.h

    r66ad025 r387d299  
    66extern "C" {
    77#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
    826
    927void trace_hexdump_packet(libtrace_packet_t *packet);
Note: See TracChangeset for help on using the changeset viewer.