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 _PARSER_H |
---|
27 | #define _PARSER_H |
---|
28 | |
---|
29 | #include <inttypes.h> |
---|
30 | |
---|
31 | enum node_type_t { |
---|
32 | NEXTHEADER, |
---|
33 | FIELD |
---|
34 | }; |
---|
35 | |
---|
36 | enum byte_order_t { |
---|
37 | BIGENDIAN, |
---|
38 | LITTLEENDIAN |
---|
39 | }; |
---|
40 | |
---|
41 | enum display_t { |
---|
42 | DISPLAY_NONE, |
---|
43 | DISPLAY_HEX, |
---|
44 | DISPLAY_INT, |
---|
45 | DISPLAY_IPV4, |
---|
46 | DISPLAY_MAC, |
---|
47 | DISPLAY_FLAG |
---|
48 | }; |
---|
49 | |
---|
50 | /* This is more complicated that I feel it needs to be... */ |
---|
51 | |
---|
52 | typedef struct next { |
---|
53 | char *prefix; /* search prefix for nextheader file */ |
---|
54 | char *fieldname; /* name of the field whose value we use */ |
---|
55 | struct field *target; /* link to the field whose value we use */ |
---|
56 | } next_t; |
---|
57 | |
---|
58 | typedef struct field { |
---|
59 | enum byte_order_t order; /* byte order of field */ |
---|
60 | uint16_t size; /* size of the field in bits */ |
---|
61 | enum display_t display; /* how the data should be displayed */ |
---|
62 | char *identifier; /* display prefix + field identifier */ |
---|
63 | uint64_t value; /* calculated value for this field */ |
---|
64 | } field_t; |
---|
65 | |
---|
66 | typedef union node { |
---|
67 | field_t *field; |
---|
68 | next_t *nextheader; |
---|
69 | } node_t; |
---|
70 | |
---|
71 | typedef struct element { |
---|
72 | enum node_type_t type; |
---|
73 | struct element *next; |
---|
74 | node_t *data; |
---|
75 | } element_t; |
---|
76 | |
---|
77 | element_t *parse_protocol_file(char *filename); |
---|
78 | void decode_protocol_file(uint16_t link_type,const char *packet,int len, element_t* el); |
---|
79 | |
---|
80 | typedef uint64_t bitbuffer_t; |
---|
81 | #endif |
---|