source: libpacketdump/libpacketdump.h @ d0f25d4

develop
Last change on this file since d0f25d4 was d0f25d4, checked in by Jacob Van Walraven <jcv9@…>, 22 months ago

Add ERF and PCAPNG decoders to libpacketdump

  • Property mode set to 100644
File size: 2.0 KB
Line 
1/*
2 *
3 * Copyright (c) 2007-2016 The University of Waikato, Hamilton, New Zealand.
4 * All rights reserved.
5 *
6 * This file is part of libtrace.
7 *
8 * This code has been developed by the University of Waikato WAND
9 * research group. For further information please see http://www.wand.net.nz/
10 *
11 * libtrace is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License as published by
13 * the Free Software Foundation; either version 3 of the License, or
14 * (at your option) any later version.
15 *
16 * libtrace is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 * GNU Lesser General Public License for more details.
20 *
21 * You should have received a copy of the GNU Lesser General Public License
22 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
23 *
24 *
25 */
26#ifndef __LIBPACKETDUMP_H__
27#define __LIBPACKETDUMP_H__
28#include "libtrace.h"
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33
34#define SAFE(hdr,x) \
35        ((unsigned int)len>=((char*)&hdr->x-(char*)hdr+sizeof(hdr->x)))
36
37#define DISPLAY_EXP(hdr,x,fmt,exp) \
38        if (SAFE(hdr, x)) \
39                printf(fmt,exp); \
40        else {\
41                printf("(Truncated)\n"); \
42                return; \
43        }
44
45#define DISPLAY(hdr,x,fmt) DISPLAY_EXP(hdr,x,fmt,hdr->x)
46
47#define DISPLAYS(hdr,x,fmt) DISPLAY_EXP(hdr,x,fmt,htons(hdr->x))
48#define DISPLAYL(hdr,x,fmt) DISPLAY_EXP(hdr,x,fmt,htonl(hdr->x))
49#define DISPLAYIP(hdr,x,fmt) DISPLAY_EXP(hdr,x,fmt,inet_ntoa(*(struct in_addr*)(void *)(&hdr->x)))
50
51
52void trace_hexdump_packet(libtrace_packet_t *packet);
53void trace_dump_packet(libtrace_packet_t *packet);
54void decode_next(const char *packet,int len,const char *proto_name,int type);
55
56void decode(int link_type, const char *pkt, unsigned len);
57void decode_meta(int link_type, const char *pkt, unsigned len, libtrace_packet_t *p);
58
59#ifdef __cplusplus
60}
61#endif
62
63#endif
Note: See TracBrowser for help on using the repository browser.