| Wireshark 4.7.0 The Wireshark network protocol analyzer

Loading...
Searching...
No Matches
packet-f5ethtrailer.h
1/* packet-f5ethtrailer.h
2 *
3 * F5 Ethernet Trailer Copyright 2008-2018 F5 Networks
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 */
7
8/* How to use the fileinfo version tap
9 *
10 * Captures taken on an F5 device in versions 11.2.0 and later contain an
11 * initial packet that has information about how the capture was taken and
12 * about the device it was taken on (tcpdump command line, platform, version,
13 * etc.). This tap allows other dissectors to obtain the version of BIG-IP
14 * software (if it is available).
15 *
16 * There are two functions defined in this header file (f5fileinfo_tap_reset()
17 * and f5fileinfo_tap_pkt()). These functions are registered with the tap and
18 * will populate a structure provided by you with the version information.
19 *
20 * Step 1: Define a static variable of type "struct f5fileinfo". This is where
21 * the version information will be stored.
22 * static struct f5fileinfo myver = F5FILEINFO_TAP_DATA_INIT;
23 *
24 * Step 2: Register with the tap listener using the macro provided in your
25 * proto_reg_handoff function:
26 * F5FILEINFO_TAP_LISTEN(&myver);
27 *
28 * Step 3: Use the version information in other parts of your code.
29 * if(myver.ver[0] == 11) {
30 * ...
31 * }
32 *
33 * If you need to do something additional when you run into a version, you can
34 * define the F5FILEINFO_TAP_POST_FUNC macro before including this header file
35 * to be the name of a fuction to call at the end of the tap function. This
36 * function must have a prototype of
37 * static void F5FILEINFO_TAP_POST_FUNC(struct f5fileinfo_tap_data *);
38 * Note that this function also gets called with version of all zeroes when the
39 * tap gets reset (reload file).
40 * Note that this function does not get called if the version number does not
41 * change.
42 * Example:
43 * #define F5FILEINFO_TAP_POST_FUNC f5info_tap_local
44 * #include <epan/dissectors/packet-f5ethtrailer.h>
45 * ...
46 * static void f5info_tap_local(struct f5fileinfo_tap_data *tap_data)
47 * {
48 * ...
49 * }
50 */
51
52#ifndef _PACKETH_F5ETHTRAILER_H_
53#define _PACKETH_F5ETHTRAILER_H_
54
55#define F5ETH_TAP_TMM_MAX UINT16_MAX
56#define F5ETH_TAP_TMM_BITS 16
57#define F5ETH_TAP_SLOT_MAX UINT16_MAX
58#define F5ETH_TAP_SLOT_BITS 16
59
66#define F5ETH_TAP_MAGIC 0x68744521
67
69 typedef struct f5eth_tap_data {
70 uint32_t magic;
71 uint32_t trailer_len;
72 /* 64 bit align */
73 uint64_t flow;
74 uint64_t peer_flow;
75 /* 64 bit align */
76 char *virtual_name;
77 uint16_t slot;
78 uint16_t tmm;
79 uint8_t noise_low:1;
80 uint8_t noise_med:1;
81 uint8_t noise_high:1;
82 uint8_t flows_set:1;
83 uint8_t ingress:2;
84} f5eth_tap_data_t;
85
98inline static int check_f5eth_tap_magic(f5eth_tap_data_t *tdata)
99{
100 return(tdata->magic == F5ETH_TAP_MAGIC ? 1 : 0);
101} /* check_f5eth_tap_magic() */
102
103#define F5FILEINFO_TAP_MAGIC 0x46350001
104
106 struct f5fileinfo_tap_data {
107 uint32_t magic;
108 uint32_t ver[6];
109};
110
111#define F5FILEINFO_TAP_DATA_INIT { 0, { 0, 0, 0, 0, 0, 0 } }
112
113#define F5VER_KNOWN(v) ((v)->ver[0] > 0)
114
115
116#define F5VER_GE_11_2(v) (((v)->ver[0] > 11) \
117 || ((v)->ver[0] == 11 && (v)->ver[1] >= 2))
118
119#define F5VER_GE_11_2_1(v) (((v)->ver[0] > 11) \
120 || ((v)->ver[0] == 11 && (v)->ver[1] > 2) \
121 || ((v)->ver[0] == 11 && (v)->ver[1] == 2 && (v)->ver[2] >= 1))
122
123#define F5VER_GE_11_3(v) (((v)->ver[0] > 11) \
124 || ((v)->ver[0] == 11 && (v)->ver[1] >= 3))
125
126#define F5VER_GE_11_4(v) (((v)->ver[0] > 11) \
127 || ((v)->ver[0] == 11 && (v)->ver[1] >= 4))
128
129#define F5VER_GE_11_4_1(v) (((v)->ver[0] > 11) \
130 || ((v)->ver[0] == 11 && (v)->ver[1] > 4) \
131 || ((v)->ver[0] == 11 && (v)->ver[1] == 4 && (v)->ver[2] >= 1))
132
133#define F5VER_GE_11_5(v) (((v)->ver[0] > 11) \
134 || ((v)->ver[0] == 11 && (v)->ver[1] >= 5))
135
136#define F5VER_GE_11_5_1(v) (((v)->ver[0] > 11) \
137 || ((v)->ver[0] == 11 && (v)->ver[1] > 5) \
138 || ((v)->ver[0] == 11 && (v)->ver[1] == 5 && (v)->ver[2] >= 1))
139
140#define F5VER_GE_11_6(v) (((v)->ver[0] > 11) \
141 || ((v)->ver[0] == 11 && (v)->ver[1] >= 6))
142
143#define F5VER_GE_12_0(v) (((v)->ver[0] >= 12))
144
145
146#ifndef F5FILEINFOTAP_SRC
147
148#ifdef F5FILEINFO_TAP_POST_FUNC
149static void F5FILEINFO_TAP_POST_FUNC(struct f5fileinfo_tap_data *);
150#endif
151
152static void f5fileinfo_tap_reset(void *p)
153{
154 struct f5fileinfo_tap_data *s;
155
156 s = (struct f5fileinfo_tap_data *)p;
157 s->ver[0] = 0;
158 s->ver[1] = 0;
159 s->ver[2] = 0;
160 s->ver[3] = 0;
161 s->ver[4] = 0;
162 s->ver[5] = 0;
163# ifdef F5FILEINFO_TAP_POST_FUNC
164 F5FILEINFO_TAP_POST_FUNC(s);
165# endif
166} /* f5fileinfo_tap_reset() */
167
168static tap_packet_status f5fileinfo_tap_pkt(
169 void *tapdata,
170 packet_info *pinfo _U_,
171 epan_dissect_t *edt _U_,
172 const void *data,
173 tap_flags_t flags _U_
174) {
175 struct f5fileinfo_tap_data *s;
176 struct f5fileinfo_tap_data *fromtap;
177
178 s = (struct f5fileinfo_tap_data *)tapdata;
179 fromtap = (struct f5fileinfo_tap_data *)data;
180 if(fromtap->magic != F5FILEINFO_TAP_MAGIC) {
181 /* Magic numbers do not match. f5ethtrailer plugin was compiled from
182 * different source than this plugin. */
183 return(TAP_PACKET_DONT_REDRAW);
184 }
185 if (s->ver[0] == fromtap->ver[0] &&
186 s->ver[1] == fromtap->ver[1] &&
187 s->ver[2] == fromtap->ver[2] &&
188 s->ver[3] == fromtap->ver[3] &&
189 s->ver[4] == fromtap->ver[4] &&
190 s->ver[5] == fromtap->ver[5])
191 {
192 return(TAP_PACKET_DONT_REDRAW);
193 }
194 s->ver[0] = fromtap->ver[0];
195 s->ver[1] = fromtap->ver[1];
196 s->ver[2] = fromtap->ver[2];
197 s->ver[3] = fromtap->ver[3];
198 s->ver[4] = fromtap->ver[4];
199 s->ver[5] = fromtap->ver[5];
200# ifdef F5FILEINFO_TAP_POST_FUNC
201 F5FILEINFO_TAP_POST_FUNC(s);
202# endif
203 return(TAP_PACKET_REDRAW);
204} /* f5fileinfo_tap_pkt() */
205
206
207#define F5FILEINFO_TAP_LISTEN(a) \
208 register_tap_listener("f5fileinfo", (a), NULL, TL_REQUIRES_NOTHING, f5fileinfo_tap_reset, f5fileinfo_tap_pkt, NULL, NULL)
209
210
211#endif /* ifndef F5INFOTAP_SRC */
212
213
214#endif /* ifndef _PACKETH_F5ETHTRAILER_H_ */
215
216/*
217 * Editor modelines - https://www.wireshark.org/tools/modelines.html
218 *
219 * Local variables:
220 * c-basic-offset: 4
221 * tab-width: 8
222 * indent-tabs-mode: nil
223 * End:
224 *
225 * vi: set shiftwidth=4 tabstop=8 expandtab:
226 * :indentSize=4:tabSize=8:noTabs=true:
227 */
_packet_info
Definition packet_info.h:43
epan_dissect
Definition epan_dissect.h:28
f5eth_tap_data
Definition packet-f5ethtrailer.h:69
f5eth_tap_data::peer_flow
uint64_t peer_flow
Definition packet-f5ethtrailer.h:74
f5eth_tap_data::noise_low
uint8_t noise_low
Definition packet-f5ethtrailer.h:79
f5eth_tap_data::flows_set
uint8_t flows_set
Definition packet-f5ethtrailer.h:82
f5eth_tap_data::tmm
uint16_t tmm
Definition packet-f5ethtrailer.h:78
f5eth_tap_data::ingress
uint8_t ingress
Definition packet-f5ethtrailer.h:83
f5eth_tap_data::noise_med
uint8_t noise_med
Definition packet-f5ethtrailer.h:80
f5eth_tap_data::magic
uint32_t magic
Definition packet-f5ethtrailer.h:70
f5eth_tap_data::virtual_name
char * virtual_name
Definition packet-f5ethtrailer.h:76
f5eth_tap_data::trailer_len
uint32_t trailer_len
Definition packet-f5ethtrailer.h:71
f5eth_tap_data::flow
uint64_t flow
Definition packet-f5ethtrailer.h:73
f5eth_tap_data::noise_high
uint8_t noise_high
Definition packet-f5ethtrailer.h:81
f5eth_tap_data::slot
uint16_t slot
Definition packet-f5ethtrailer.h:77
f5fileinfo_tap_data
Definition packet-f5ethtrailer.h:106
f5fileinfo_tap_data::magic
uint32_t magic
Definition packet-f5ethtrailer.h:107
f5fileinfo_tap_data::ver
uint32_t ver[6]
Definition packet-f5ethtrailer.h:108
tap_packet_status
tap_packet_status
Definition tap.h:25
TAP_PACKET_REDRAW
@ TAP_PACKET_REDRAW
Definition tap.h:27
TAP_PACKET_DONT_REDRAW
@ TAP_PACKET_DONT_REDRAW
Definition tap.h:26