source: libpacketdump/eth_33024.c @ 8485d99

4.0.1-hotfixescachetimestampsdevelopdpdk-ndagetsilivendag_formatrc-4.0.1rc-4.0.2rc-4.0.3rc-4.0.4ringdecrementfixringperformanceringtimestampfixes
Last change on this file since 8485d99 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.7 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 <stdio.h>
27#include "libpacketdump.h"
28
29#define LE(lhs,n)                                               \
30        do {                                                    \
31                uint64_t num=0;                                 \
32                int size=0;                                     \
33                if ((offset+n)>len*8) return;                   \
34                if (n>16) {                                     \
35                        num=htonl(*(uint32_t*)(packet+offset/8));\
36                        size = 32;\
37                } else if (n>8) {                               \
38                        num=htons(*(uint16_t*)(packet+offset/8));\
39                        size = 16;                              \
40                } else {                                        \
41                        num=*(uint8_t*)(packet+offset/8);       \
42                        size = 8;                               \
43                }                                               \
44                num=num>>(size - (n + (offset % 8)));           \
45                offset+=n;                                      \
46                lhs=num&((1<<(n))-1);                           \
47        } while(0)
48
49DLLEXPORT void decode(int link_type UNUSED,const char *packet,unsigned len)
50{
51        unsigned int offset=0;
52        int value;
53        uint16_t ethertype;
54
55        LE(value, 3);   printf(" VLAN: User Priority: %d\n", value);
56        LE(value, 1);   printf(" VLAN: Format Indicator: %d\n", value);
57        LE(value, 12);  printf(" VLAN: ID: %d\n", value);
58        LE(value, 16);  printf(" VLAN: EtherType: 0x%04x\n", (uint16_t)value);
59        ethertype = (uint16_t) value;
60
61        decode_next(packet + 4, len - 4, "eth", ethertype);
62
63        return;
64}
65
Note: See TracBrowser for help on using the repository browser.