source: libpacketdump/eth_2048.c

4.0.1-hotfixescachetimestampsdevelopdpdk-ndagetsilivendag_formatrc-4.0.1rc-4.0.2rc-4.0.3rc-4.0.4ringdecrementfixringperformanceringtimestampfixes
Last change on this file was ee6e802, checked in by Shane Alcock <salcock@…>, 5 years ago

Updated copyright blurb on all source files

In some cases, this meant adding copyright blurbs to files that
had never had them before.

  • Property mode set to 100644
File size: 2.4 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#include <sys/types.h>
27#include <sys/socket.h>
28#include <netinet/in.h>
29#include <stdio.h>
30#include "libpacketdump.h"
31#ifndef WIN32
32        #include <netinet/in_systm.h>
33#endif
34#include <arpa/inet.h>
35#include <netdb.h>
36
37DLLEXPORT void decode(int link_type UNUSED,const char *packet,unsigned len)
38{
39        libtrace_ip_t *ip = (libtrace_ip_t*)packet;
40        if (len>=1) {
41                printf(" IP: Header Len %i",ip->ip_hl*4);
42                printf(" Ver %i",ip->ip_v);
43        }
44        //DISPLAY(ip_tos," TOS %02x")
45        DISPLAY_EXP(ip, ip_tos," DSCP %02x",ip->ip_tos >> 2);
46        DISPLAY_EXP(ip, ip_tos," ECN %x",ip->ip_tos & 0x2);
47        DISPLAYS(ip, ip_len," Total Length %i");
48        printf("\n IP:");
49        DISPLAYS(ip, ip_id," Id %u");
50       
51        if ((unsigned int)len >= ((char *)&ip->ip_ttl - (char *)ip - 2)) {
52                printf(" Fragoff %i", ntohs(ip->ip_off) & 0x1FFF);
53                if (ntohs(ip->ip_off) & 0x2000) printf(" MORE_FRAG");
54                if (ntohs(ip->ip_off) & 0x4000) printf(" DONT_FRAG");
55                if (ntohs(ip->ip_off) & 0x8000) printf(" RESV_FRAG");
56        }
57        //printf("\n IP:");
58        DISPLAY(ip, ip_ttl,"\n IP: TTL %i");
59        if ((unsigned int)len>=((char*)&ip->ip_p-(char*)ip+sizeof(ip->ip_p))) {
60                struct protoent *ent=getprotobynumber(ip->ip_p);
61                if (ent) {
62                        printf(" Proto %i (%s)",ip->ip_p,ent->p_name);
63                }
64                else {
65                        printf(" Proto %i",ip->ip_p);
66                }
67        } else {
68                printf("\n");
69                return;
70        }
71        DISPLAYS(ip, ip_sum," Checksum %i\n");
72        DISPLAYIP(ip, ip_src," IP: Source %s ");
73        DISPLAYIP(ip, ip_dst,"Destination %s\n");
74        decode_next(packet+ip->ip_hl*4,len-ip->ip_hl*4,"ip",ip->ip_p);
75        return;
76}
Note: See TracBrowser for help on using the repository browser.