source: libpacketdump/eth_0.c @ a82a9e8

4.0.1-hotfixescachetimestampsdevelopdpdk-ndagetsilivendag_formatrc-4.0.1rc-4.0.2rc-4.0.3rc-4.0.4ringdecrementfixringperformanceringtimestampfixes
Last change on this file since a82a9e8 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: 1.9 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 <ctype.h>
31#include "libpacketdump.h"
32
33#define WIDTH 16
34
35/* This is an example of a decoder for a protocol that we know exists, but is undocumented.
36 * We dump the protocol as hex, and then skip onto the next header which we do know exists.
37 */
38
39DLLEXPORT void decode(int link_type UNUSED,const char *packet,unsigned len)
40{
41        unsigned int i=0;
42        printf(" Ubiquity:");
43        for(i=0;i<132; /* Nothing */ ) {
44                unsigned int j;
45                printf("\n ");
46                for(j=0;j<WIDTH;j++) {
47                        if (i+j<len)
48                                printf(" %02x",(unsigned char)packet[i+j]);
49                        else
50                                printf("   ");
51                }
52                printf("    ");
53                for(j=0;j<WIDTH;j++) {
54                        if (i+j<len)
55                                if (isprint((unsigned char)packet[i+j]))
56                                        printf("%c",(unsigned char)packet[i+j]);
57                                else
58                                        printf(".");
59                        else
60                                printf("   ");
61                }
62                if (i+WIDTH>len)
63                        break;
64                else
65                        i+=WIDTH;
66        }
67        printf("\n");
68        if (len>132)
69                decode_next(packet+132,len-132,"link",4);
70        return;
71}
Note: See TracBrowser for help on using the repository browser.