]>
Commit | Line | Data |
---|---|---|
7dd32dff NM |
1 | /* Copyright (c) 2002-2009 InMon Corp. Licensed under the terms of either the |
2 | * Sun Industry Standards Source License 1.1, that is available at: | |
3 | * http://host-sflow.sourceforge.net/sissl.html | |
4 | * or the InMon sFlow License, that is available at: | |
5 | * http://www.inmon.com/technology/sflowlicense.txt | |
6 | */ | |
c72e245a BP |
7 | |
8 | #ifndef SFLOW_H | |
9 | #define SFLOW_H 1 | |
10 | ||
31b97ffd GS |
11 | #ifdef _WIN32 |
12 | #include "windefs.h" | |
13 | #endif | |
14 | ||
74ff3298 JR |
15 | #include "openvswitch/types.h" |
16 | ||
743cea45 NM |
17 | typedef enum { |
18 | SFL_DSCLASS_IFINDEX = 0, | |
19 | SFL_DSCLASS_VLAN = 1, | |
20 | SFL_DSCLASS_PHYSICAL_ENTITY = 2, | |
21 | SFL_DSCLASS_LOGICAL_ENTITY = 3 | |
22 | } SFL_DSCLASS; | |
23 | ||
c72e245a BP |
24 | enum SFLAddress_type { |
25 | SFLADDRESSTYPE_IP_V4 = 1, | |
26 | SFLADDRESSTYPE_IP_V6 = 2 | |
27 | }; | |
28 | ||
29 | typedef struct { | |
30 | u_int32_t addr; | |
31 | } SFLIPv4; | |
32 | ||
33 | typedef struct { | |
34 | u_char addr[16]; | |
35 | } SFLIPv6; | |
36 | ||
37 | typedef union _SFLAddress_value { | |
38 | SFLIPv4 ip_v4; | |
39 | SFLIPv6 ip_v6; | |
40 | } SFLAddress_value; | |
41 | ||
42 | typedef struct _SFLAddress { | |
43 | u_int32_t type; /* enum SFLAddress_type */ | |
44 | SFLAddress_value address; | |
45 | } SFLAddress; | |
46 | ||
47 | /* Packet header data */ | |
48 | ||
49 | #define SFL_DEFAULT_HEADER_SIZE 128 | |
50 | #define SFL_DEFAULT_COLLECTOR_PORT 6343 | |
51 | #define SFL_DEFAULT_SAMPLING_RATE 400 | |
52 | #define SFL_DEFAULT_POLLING_INTERVAL 30 | |
53 | ||
54 | /* The header protocol describes the format of the sampled header */ | |
55 | enum SFLHeader_protocol { | |
56 | SFLHEADER_ETHERNET_ISO8023 = 1, | |
57 | SFLHEADER_ISO88024_TOKENBUS = 2, | |
58 | SFLHEADER_ISO88025_TOKENRING = 3, | |
59 | SFLHEADER_FDDI = 4, | |
60 | SFLHEADER_FRAME_RELAY = 5, | |
61 | SFLHEADER_X25 = 6, | |
62 | SFLHEADER_PPP = 7, | |
63 | SFLHEADER_SMDS = 8, | |
64 | SFLHEADER_AAL5 = 9, | |
65 | SFLHEADER_AAL5_IP = 10, /* e.g. Cisco AAL5 mux */ | |
66 | SFLHEADER_IPv4 = 11, | |
67 | SFLHEADER_IPv6 = 12, | |
68 | SFLHEADER_MPLS = 13 | |
69 | }; | |
70 | ||
71 | /* raw sampled header */ | |
72 | ||
73 | typedef struct _SFLSampled_header { | |
74 | u_int32_t header_protocol; /* (enum SFLHeader_protocol) */ | |
75 | u_int32_t frame_length; /* Original length of packet before sampling */ | |
76 | u_int32_t stripped; /* header/trailer bytes stripped by sender */ | |
77 | u_int32_t header_length; /* length of sampled header bytes to follow */ | |
78 | u_int8_t *header_bytes; /* Header bytes */ | |
79 | } SFLSampled_header; | |
80 | ||
81 | /* decoded ethernet header */ | |
82 | ||
83 | typedef struct _SFLSampled_ethernet { | |
d295e8e9 | 84 | u_int32_t eth_len; /* The length of the MAC packet excluding |
c72e245a | 85 | lower layer encapsulations */ |
74ff3298 JR |
86 | struct eth_addr src_mac; /* 6 bytes */ |
87 | u_int8_t pad1[2]; /* 2 pad */ | |
88 | struct eth_addr dst_mac; | |
89 | u_int8_t pad2[2]; | |
c72e245a BP |
90 | u_int32_t eth_type; |
91 | } SFLSampled_ethernet; | |
92 | ||
93 | /* decoded IP version 4 header */ | |
94 | ||
95 | typedef struct _SFLSampled_ipv4 { | |
96 | u_int32_t length; /* The length of the IP packet | |
97 | excluding lower layer encapsulations */ | |
98 | u_int32_t protocol; /* IP Protocol type (for example, TCP = 6, UDP = 17) */ | |
99 | SFLIPv4 src_ip; /* Source IP Address */ | |
100 | SFLIPv4 dst_ip; /* Destination IP Address */ | |
101 | u_int32_t src_port; /* TCP/UDP source port number or equivalent */ | |
102 | u_int32_t dst_port; /* TCP/UDP destination port number or equivalent */ | |
103 | u_int32_t tcp_flags; /* TCP flags */ | |
104 | u_int32_t tos; /* IP type of service */ | |
105 | } SFLSampled_ipv4; | |
106 | ||
107 | /* decoded IP version 6 data */ | |
108 | ||
109 | typedef struct _SFLSampled_ipv6 { | |
110 | u_int32_t length; /* The length of the IP packet | |
111 | excluding lower layer encapsulations */ | |
112 | u_int32_t protocol; /* IP Protocol type (for example, TCP = 6, UDP = 17) */ | |
113 | SFLIPv6 src_ip; /* Source IP Address */ | |
114 | SFLIPv6 dst_ip; /* Destination IP Address */ | |
115 | u_int32_t src_port; /* TCP/UDP source port number or equivalent */ | |
116 | u_int32_t dst_port; /* TCP/UDP destination port number or equivalent */ | |
117 | u_int32_t tcp_flags; /* TCP flags */ | |
118 | u_int32_t priority; /* IP priority */ | |
119 | } SFLSampled_ipv6; | |
120 | ||
121 | /* Extended data types */ | |
122 | ||
123 | /* Extended switch data */ | |
124 | ||
125 | typedef struct _SFLExtended_switch { | |
126 | u_int32_t src_vlan; /* The 802.1Q VLAN id of incomming frame */ | |
127 | u_int32_t src_priority; /* The 802.1p priority */ | |
128 | u_int32_t dst_vlan; /* The 802.1Q VLAN id of outgoing frame */ | |
129 | u_int32_t dst_priority; /* The 802.1p priority */ | |
130 | } SFLExtended_switch; | |
131 | ||
132 | /* Extended router data */ | |
133 | ||
134 | typedef struct _SFLExtended_router { | |
135 | SFLAddress nexthop; /* IP address of next hop router */ | |
136 | u_int32_t src_mask; /* Source address prefix mask bits */ | |
137 | u_int32_t dst_mask; /* Destination address prefix mask bits */ | |
138 | } SFLExtended_router; | |
139 | ||
140 | /* Extended gateway data */ | |
141 | enum SFLExtended_as_path_segment_type { | |
142 | SFLEXTENDED_AS_SET = 1, /* Unordered set of ASs */ | |
143 | SFLEXTENDED_AS_SEQUENCE = 2 /* Ordered sequence of ASs */ | |
144 | }; | |
d295e8e9 | 145 | |
c72e245a BP |
146 | typedef struct _SFLExtended_as_path_segment { |
147 | u_int32_t type; /* enum SFLExtended_as_path_segment_type */ | |
148 | u_int32_t length; /* number of AS numbers in set/sequence */ | |
149 | union { | |
150 | u_int32_t *set; | |
151 | u_int32_t *seq; | |
152 | } as; | |
153 | } SFLExtended_as_path_segment; | |
154 | ||
155 | typedef struct _SFLExtended_gateway { | |
156 | SFLAddress nexthop; /* Address of the border router that should | |
157 | be used for the destination network */ | |
158 | u_int32_t as; /* AS number for this gateway */ | |
159 | u_int32_t src_as; /* AS number of source (origin) */ | |
160 | u_int32_t src_peer_as; /* AS number of source peer */ | |
161 | u_int32_t dst_as_path_segments; /* number of segments in path */ | |
162 | SFLExtended_as_path_segment *dst_as_path; /* list of seqs or sets */ | |
163 | u_int32_t communities_length; /* number of communities */ | |
164 | u_int32_t *communities; /* set of communities */ | |
165 | u_int32_t localpref; /* LocalPref associated with this route */ | |
166 | } SFLExtended_gateway; | |
167 | ||
168 | typedef struct _SFLString { | |
169 | u_int32_t len; | |
170 | char *str; | |
171 | } SFLString; | |
172 | ||
173 | /* Extended user data */ | |
174 | ||
175 | typedef struct _SFLExtended_user { | |
176 | u_int32_t src_charset; /* MIBEnum value of character set used to encode a string - See RFC 2978 | |
177 | Where possible UTF-8 encoding (MIBEnum=106) should be used. A value | |
178 | of zero indicates an unknown encoding. */ | |
179 | SFLString src_user; | |
180 | u_int32_t dst_charset; | |
181 | SFLString dst_user; | |
182 | } SFLExtended_user; | |
183 | ||
184 | /* Extended URL data */ | |
185 | ||
186 | enum SFLExtended_url_direction { | |
187 | SFLEXTENDED_URL_SRC = 1, /* URL is associated with source address */ | |
188 | SFLEXTENDED_URL_DST = 2 /* URL is associated with destination address */ | |
189 | }; | |
190 | ||
191 | typedef struct _SFLExtended_url { | |
192 | u_int32_t direction; /* enum SFLExtended_url_direction */ | |
193 | SFLString url; /* URL associated with the packet flow. | |
194 | Must be URL encoded */ | |
195 | SFLString host; /* The host field from the HTTP header */ | |
196 | } SFLExtended_url; | |
197 | ||
198 | /* Extended MPLS data */ | |
199 | ||
200 | typedef struct _SFLLabelStack { | |
201 | u_int32_t depth; | |
202 | u_int32_t *stack; /* first entry is top of stack - see RFC 3032 for encoding */ | |
203 | } SFLLabelStack; | |
204 | ||
205 | typedef struct _SFLExtended_mpls { | |
d295e8e9 | 206 | SFLAddress nextHop; /* Address of the next hop */ |
c72e245a BP |
207 | SFLLabelStack in_stack; |
208 | SFLLabelStack out_stack; | |
209 | } SFLExtended_mpls; | |
210 | ||
211 | /* Extended NAT data | |
212 | Packet header records report addresses as seen at the sFlowDataSource. | |
213 | The extended_nat structure reports on translated source and/or destination | |
d295e8e9 | 214 | addesses for this packet. If an address was not translated it should |
c72e245a BP |
215 | be equal to that reported for the header. */ |
216 | ||
217 | typedef struct _SFLExtended_nat { | |
218 | SFLAddress src; /* Source address */ | |
219 | SFLAddress dst; /* Destination address */ | |
220 | } SFLExtended_nat; | |
221 | ||
222 | /* additional Extended MPLS stucts */ | |
223 | ||
224 | typedef struct _SFLExtended_mpls_tunnel { | |
225 | SFLString tunnel_lsp_name; /* Tunnel name */ | |
226 | u_int32_t tunnel_id; /* Tunnel ID */ | |
227 | u_int32_t tunnel_cos; /* Tunnel COS value */ | |
228 | } SFLExtended_mpls_tunnel; | |
229 | ||
230 | typedef struct _SFLExtended_mpls_vc { | |
231 | SFLString vc_instance_name; /* VC instance name */ | |
232 | u_int32_t vll_vc_id; /* VLL/VC instance ID */ | |
233 | u_int32_t vc_label_cos; /* VC Label COS value */ | |
234 | } SFLExtended_mpls_vc; | |
235 | ||
236 | /* Extended MPLS FEC | |
237 | - Definitions from MPLS-FTN-STD-MIB mplsFTNTable */ | |
238 | ||
239 | typedef struct _SFLExtended_mpls_FTN { | |
240 | SFLString mplsFTNDescr; | |
241 | u_int32_t mplsFTNMask; | |
242 | } SFLExtended_mpls_FTN; | |
243 | ||
244 | /* Extended MPLS LVP FEC | |
245 | - Definition from MPLS-LDP-STD-MIB mplsFecTable | |
246 | Note: mplsFecAddrType, mplsFecAddr information available | |
247 | from packet header */ | |
248 | ||
249 | typedef struct _SFLExtended_mpls_LDP_FEC { | |
250 | u_int32_t mplsFecAddrPrefixLength; | |
251 | } SFLExtended_mpls_LDP_FEC; | |
252 | ||
d295e8e9 JP |
253 | /* Extended VLAN tunnel information |
254 | Record outer VLAN encapsulations that have | |
255 | been stripped. extended_vlantunnel information | |
256 | should only be reported if all the following conditions are satisfied: | |
257 | 1. The packet has nested vlan tags, AND | |
258 | 2. The reporting device is VLAN aware, AND | |
259 | 3. One or more VLAN tags have been stripped, either | |
260 | because they represent proprietary encapsulations, or | |
261 | because switch hardware automatically strips the outer VLAN | |
262 | encapsulation. | |
263 | Reporting extended_vlantunnel information is not a substitute for | |
264 | reporting extended_switch information. extended_switch data must | |
265 | always be reported to describe the ingress/egress VLAN information | |
266 | for the packet. The extended_vlantunnel information only applies to | |
267 | nested VLAN tags, and then only when one or more tags has been | |
268 | stripped. */ | |
c72e245a BP |
269 | |
270 | typedef SFLLabelStack SFLVlanStack; | |
d295e8e9 JP |
271 | typedef struct _SFLExtended_vlan_tunnel { |
272 | SFLVlanStack stack; /* List of stripped 802.1Q TPID/TCI layers. Each | |
273 | TPID,TCI pair is represented as a single 32 bit | |
274 | integer. Layers listed from outermost to | |
275 | innermost. */ | |
c72e245a BP |
276 | } SFLExtended_vlan_tunnel; |
277 | ||
50b9699f NM |
278 | typedef struct _SFLExtended_vni { |
279 | uint32_t vni; /* virtual network identifier */ | |
280 | } SFLExtended_vni; | |
281 | ||
c72e245a BP |
282 | enum SFLFlow_type_tag { |
283 | /* enterprise = 0, format = ... */ | |
284 | SFLFLOW_HEADER = 1, /* Packet headers are sampled */ | |
285 | SFLFLOW_ETHERNET = 2, /* MAC layer information */ | |
286 | SFLFLOW_IPV4 = 3, /* IP version 4 data */ | |
287 | SFLFLOW_IPV6 = 4, /* IP version 6 data */ | |
288 | SFLFLOW_EX_SWITCH = 1001, /* Extended switch information */ | |
289 | SFLFLOW_EX_ROUTER = 1002, /* Extended router information */ | |
290 | SFLFLOW_EX_GATEWAY = 1003, /* Extended gateway router information */ | |
291 | SFLFLOW_EX_USER = 1004, /* Extended TACAS/RADIUS user information */ | |
292 | SFLFLOW_EX_URL = 1005, /* Extended URL information */ | |
293 | SFLFLOW_EX_MPLS = 1006, /* Extended MPLS information */ | |
294 | SFLFLOW_EX_NAT = 1007, /* Extended NAT information */ | |
295 | SFLFLOW_EX_MPLS_TUNNEL = 1008, /* additional MPLS information */ | |
296 | SFLFLOW_EX_MPLS_VC = 1009, | |
297 | SFLFLOW_EX_MPLS_FTN = 1010, | |
298 | SFLFLOW_EX_MPLS_LDP_FEC = 1011, | |
299 | SFLFLOW_EX_VLAN_TUNNEL = 1012, /* VLAN stack */ | |
50b9699f NM |
300 | SFLFLOW_EX_IPV4_TUNNEL_EGRESS = 1023, /* http://sflow.org/sflow_tunnels.txt */ |
301 | SFLFLOW_EX_IPV4_TUNNEL_INGRESS = 1024, | |
302 | SFLFLOW_EX_VNI_EGRESS = 1029, | |
303 | SFLFLOW_EX_VNI_INGRESS = 1030, | |
c72e245a BP |
304 | }; |
305 | ||
306 | typedef union _SFLFlow_type { | |
307 | SFLSampled_header header; | |
308 | SFLSampled_ethernet ethernet; | |
309 | SFLSampled_ipv4 ipv4; | |
310 | SFLSampled_ipv6 ipv6; | |
311 | SFLExtended_switch sw; | |
312 | SFLExtended_router router; | |
313 | SFLExtended_gateway gateway; | |
314 | SFLExtended_user user; | |
315 | SFLExtended_url url; | |
316 | SFLExtended_mpls mpls; | |
317 | SFLExtended_nat nat; | |
318 | SFLExtended_mpls_tunnel mpls_tunnel; | |
319 | SFLExtended_mpls_vc mpls_vc; | |
320 | SFLExtended_mpls_FTN mpls_ftn; | |
321 | SFLExtended_mpls_LDP_FEC mpls_ldp_fec; | |
322 | SFLExtended_vlan_tunnel vlan_tunnel; | |
50b9699f | 323 | SFLExtended_vni tunnel_vni; |
c72e245a BP |
324 | } SFLFlow_type; |
325 | ||
326 | typedef struct _SFLFlow_sample_element { | |
327 | struct _SFLFlow_sample_element *nxt; | |
328 | u_int32_t tag; /* SFLFlow_type_tag */ | |
329 | u_int32_t length; | |
330 | SFLFlow_type flowType; | |
331 | } SFLFlow_sample_element; | |
332 | ||
333 | enum SFL_sample_tag { | |
334 | SFLFLOW_SAMPLE = 1, /* enterprise = 0 : format = 1 */ | |
335 | SFLCOUNTERS_SAMPLE = 2, /* enterprise = 0 : format = 2 */ | |
336 | SFLFLOW_SAMPLE_EXPANDED = 3, /* enterprise = 0 : format = 3 */ | |
337 | SFLCOUNTERS_SAMPLE_EXPANDED = 4 /* enterprise = 0 : format = 4 */ | |
338 | }; | |
d295e8e9 | 339 | |
c72e245a BP |
340 | /* Format of a single flow sample */ |
341 | ||
342 | typedef struct _SFLFlow_sample { | |
343 | /* u_int32_t tag; */ /* SFL_sample_tag -- enterprise = 0 : format = 1 */ | |
344 | /* u_int32_t length; */ | |
345 | u_int32_t sequence_number; /* Incremented with each flow sample | |
346 | generated */ | |
347 | u_int32_t source_id; /* fsSourceId */ | |
348 | u_int32_t sampling_rate; /* fsPacketSamplingRate */ | |
349 | u_int32_t sample_pool; /* Total number of packets that could have been | |
350 | sampled (i.e. packets skipped by sampling | |
351 | process + total number of samples) */ | |
352 | u_int32_t drops; /* Number of times a packet was dropped due to | |
353 | lack of resources */ | |
354 | u_int32_t input; /* SNMP ifIndex of input interface. | |
355 | 0 if interface is not known. */ | |
356 | u_int32_t output; /* SNMP ifIndex of output interface, | |
357 | 0 if interface is not known. | |
358 | Set most significant bit to indicate | |
359 | multiple destination interfaces | |
360 | (i.e. in case of broadcast or multicast) | |
361 | and set lower order bits to indicate | |
362 | number of destination interfaces. | |
363 | Examples: | |
364 | 0x00000002 indicates ifIndex = 2 | |
365 | 0x00000000 ifIndex unknown. | |
366 | 0x80000007 indicates a packet sent | |
367 | to 7 interfaces. | |
368 | 0x80000000 indicates a packet sent to | |
369 | an unknown number of | |
370 | interfaces greater than 1.*/ | |
371 | u_int32_t num_elements; | |
372 | SFLFlow_sample_element *elements; | |
373 | } SFLFlow_sample; | |
374 | ||
375 | /* same thing, but the expanded version (for full 32-bit ifIndex numbers) */ | |
376 | ||
377 | typedef struct _SFLFlow_sample_expanded { | |
378 | /* u_int32_t tag; */ /* SFL_sample_tag -- enterprise = 0 : format = 1 */ | |
379 | /* u_int32_t length; */ | |
380 | u_int32_t sequence_number; /* Incremented with each flow sample | |
381 | generated */ | |
382 | u_int32_t ds_class; /* EXPANDED */ | |
383 | u_int32_t ds_index; /* EXPANDED */ | |
384 | u_int32_t sampling_rate; /* fsPacketSamplingRate */ | |
385 | u_int32_t sample_pool; /* Total number of packets that could have been | |
386 | sampled (i.e. packets skipped by sampling | |
387 | process + total number of samples) */ | |
388 | u_int32_t drops; /* Number of times a packet was dropped due to | |
389 | lack of resources */ | |
390 | u_int32_t inputFormat; /* EXPANDED */ | |
391 | u_int32_t input; /* SNMP ifIndex of input interface. | |
392 | 0 if interface is not known. */ | |
393 | u_int32_t outputFormat; /* EXPANDED */ | |
394 | u_int32_t output; /* SNMP ifIndex of output interface, | |
395 | 0 if interface is not known. */ | |
396 | u_int32_t num_elements; | |
397 | SFLFlow_sample_element *elements; | |
398 | } SFLFlow_sample_expanded; | |
399 | ||
400 | /* Counter types */ | |
401 | ||
50b9699f NM |
402 | #define SFL_UNDEF_COUNTER(c) c=-1 |
403 | #define SFL_UNDEF_GAUGE(c) c=0 | |
404 | ||
c72e245a BP |
405 | /* Generic interface counters - see RFC 1573, 2233 */ |
406 | ||
407 | typedef struct _SFLIf_counters { | |
408 | u_int32_t ifIndex; | |
409 | u_int32_t ifType; | |
410 | u_int64_t ifSpeed; | |
411 | u_int32_t ifDirection; /* Derived from MAU MIB (RFC 2668) | |
412 | 0 = unknown, 1 = full-duplex, | |
413 | 2 = half-duplex, 3 = in, 4 = out */ | |
414 | u_int32_t ifStatus; /* bit field with the following bits assigned: | |
415 | bit 0 = ifAdminStatus (0 = down, 1 = up) | |
416 | bit 1 = ifOperStatus (0 = down, 1 = up) */ | |
417 | u_int64_t ifInOctets; | |
418 | u_int32_t ifInUcastPkts; | |
419 | u_int32_t ifInMulticastPkts; | |
420 | u_int32_t ifInBroadcastPkts; | |
421 | u_int32_t ifInDiscards; | |
422 | u_int32_t ifInErrors; | |
423 | u_int32_t ifInUnknownProtos; | |
424 | u_int64_t ifOutOctets; | |
425 | u_int32_t ifOutUcastPkts; | |
426 | u_int32_t ifOutMulticastPkts; | |
427 | u_int32_t ifOutBroadcastPkts; | |
428 | u_int32_t ifOutDiscards; | |
429 | u_int32_t ifOutErrors; | |
430 | u_int32_t ifPromiscuousMode; | |
431 | } SFLIf_counters; | |
432 | ||
50b9699f NM |
433 | #define SFL_CTR_GENERIC_XDR_SIZE 88 |
434 | ||
c72e245a BP |
435 | /* Ethernet interface counters - see RFC 2358 */ |
436 | typedef struct _SFLEthernet_counters { | |
437 | u_int32_t dot3StatsAlignmentErrors; | |
438 | u_int32_t dot3StatsFCSErrors; | |
439 | u_int32_t dot3StatsSingleCollisionFrames; | |
440 | u_int32_t dot3StatsMultipleCollisionFrames; | |
441 | u_int32_t dot3StatsSQETestErrors; | |
442 | u_int32_t dot3StatsDeferredTransmissions; | |
443 | u_int32_t dot3StatsLateCollisions; | |
444 | u_int32_t dot3StatsExcessiveCollisions; | |
445 | u_int32_t dot3StatsInternalMacTransmitErrors; | |
446 | u_int32_t dot3StatsCarrierSenseErrors; | |
447 | u_int32_t dot3StatsFrameTooLongs; | |
448 | u_int32_t dot3StatsInternalMacReceiveErrors; | |
449 | u_int32_t dot3StatsSymbolErrors; | |
450 | } SFLEthernet_counters; | |
451 | ||
50b9699f NM |
452 | #define SFL_CTR_ETHERNET_XDR_SIZE 52 |
453 | ||
c72e245a BP |
454 | /* Token ring counters - see RFC 1748 */ |
455 | ||
456 | typedef struct _SFLTokenring_counters { | |
457 | u_int32_t dot5StatsLineErrors; | |
458 | u_int32_t dot5StatsBurstErrors; | |
459 | u_int32_t dot5StatsACErrors; | |
460 | u_int32_t dot5StatsAbortTransErrors; | |
461 | u_int32_t dot5StatsInternalErrors; | |
462 | u_int32_t dot5StatsLostFrameErrors; | |
463 | u_int32_t dot5StatsReceiveCongestions; | |
464 | u_int32_t dot5StatsFrameCopiedErrors; | |
465 | u_int32_t dot5StatsTokenErrors; | |
466 | u_int32_t dot5StatsSoftErrors; | |
467 | u_int32_t dot5StatsHardErrors; | |
468 | u_int32_t dot5StatsSignalLoss; | |
469 | u_int32_t dot5StatsTransmitBeacons; | |
470 | u_int32_t dot5StatsRecoverys; | |
471 | u_int32_t dot5StatsLobeWires; | |
472 | u_int32_t dot5StatsRemoves; | |
473 | u_int32_t dot5StatsSingles; | |
474 | u_int32_t dot5StatsFreqErrors; | |
475 | } SFLTokenring_counters; | |
476 | ||
477 | /* 100 BaseVG interface counters - see RFC 2020 */ | |
478 | ||
479 | typedef struct _SFLVg_counters { | |
480 | u_int32_t dot12InHighPriorityFrames; | |
481 | u_int64_t dot12InHighPriorityOctets; | |
482 | u_int32_t dot12InNormPriorityFrames; | |
483 | u_int64_t dot12InNormPriorityOctets; | |
484 | u_int32_t dot12InIPMErrors; | |
485 | u_int32_t dot12InOversizeFrameErrors; | |
486 | u_int32_t dot12InDataErrors; | |
487 | u_int32_t dot12InNullAddressedFrames; | |
488 | u_int32_t dot12OutHighPriorityFrames; | |
489 | u_int64_t dot12OutHighPriorityOctets; | |
490 | u_int32_t dot12TransitionIntoTrainings; | |
491 | u_int64_t dot12HCInHighPriorityOctets; | |
492 | u_int64_t dot12HCInNormPriorityOctets; | |
493 | u_int64_t dot12HCOutHighPriorityOctets; | |
494 | } SFLVg_counters; | |
495 | ||
496 | typedef struct _SFLVlan_counters { | |
497 | u_int32_t vlan_id; | |
498 | u_int64_t octets; | |
499 | u_int32_t ucastPkts; | |
500 | u_int32_t multicastPkts; | |
501 | u_int32_t broadcastPkts; | |
502 | u_int32_t discards; | |
503 | } SFLVlan_counters; | |
504 | ||
50b9699f NM |
505 | /* OpenFlow port */ |
506 | typedef struct { | |
507 | u_int64_t datapath_id; | |
508 | u_int32_t port_no; | |
509 | } SFLOpenFlowPort; | |
510 | ||
511 | #define SFL_CTR_OPENFLOWPORT_XDR_SIZE 12 | |
512 | ||
513 | /* port name */ | |
514 | typedef struct { | |
515 | SFLString portName; | |
516 | } SFLPortName; | |
517 | ||
518 | #define SFL_MAX_PORTNAME_LEN 255 | |
519 | ||
520 | /* LAG Port Statistics - see http://sflow.org/sflow_lag.txt */ | |
521 | /* opaque = counter_data; enterprise = 0; format = 7 */ | |
522 | ||
523 | typedef union _SFLLACP_portState { | |
524 | uint32_t all; | |
525 | struct { | |
526 | uint8_t actorAdmin; | |
527 | uint8_t actorOper; | |
528 | uint8_t partnerAdmin; | |
529 | uint8_t partnerOper; | |
530 | } v; | |
531 | } SFLLACP_portState; | |
532 | ||
533 | typedef struct _SFLLACP_counters { | |
74ff3298 JR |
534 | struct eth_addr actorSystemID; /* 6 bytes */ |
535 | uint8_t pad1[2]; | |
536 | struct eth_addr partnerSystemID; /* 6 bytes */ | |
537 | uint8_t pad2[2]; | |
50b9699f NM |
538 | uint32_t attachedAggID; |
539 | SFLLACP_portState portState; | |
540 | uint32_t LACPDUsRx; | |
541 | uint32_t markerPDUsRx; | |
542 | uint32_t markerResponsePDUsRx; | |
543 | uint32_t unknownRx; | |
544 | uint32_t illegalRx; | |
545 | uint32_t LACPDUsTx; | |
546 | uint32_t markerPDUsTx; | |
547 | uint32_t markerResponsePDUsTx; | |
548 | } SFLLACP_counters; | |
549 | ||
550 | #define SFL_CTR_LACP_XDR_SIZE 56 | |
551 | ||
3d2912f2 NM |
552 | /* Application resource counters */ |
553 | ||
554 | typedef struct _SFLAPPResources_counters { | |
555 | uint32_t user_time; /* in milliseconds */ | |
556 | uint32_t system_time; /* in milliseconds */ | |
557 | uint64_t mem_used; | |
558 | uint64_t mem_max; | |
559 | uint32_t fd_open; | |
560 | uint32_t fd_max; | |
561 | uint32_t conn_open; | |
562 | uint32_t conn_max; | |
563 | } SFLAPPResources_counters; | |
564 | ||
565 | #define SFL_CTR_APP_RESOURCES_XDR_SIZE 40 | |
566 | ||
567 | /* OVS datapath stats */ | |
568 | ||
569 | typedef struct _SFLOVSDP_counters { | |
570 | uint32_t n_hit; | |
571 | uint32_t n_missed; | |
572 | uint32_t n_lost; | |
573 | uint32_t n_mask_hit; | |
574 | uint32_t n_flows; | |
575 | uint32_t n_masks; | |
576 | } SFLOVSDP_counters; | |
577 | ||
578 | #define SFL_CTR_OVSDP_XDR_SIZE 24 | |
579 | ||
c72e245a BP |
580 | /* Counters data */ |
581 | ||
582 | enum SFLCounters_type_tag { | |
583 | /* enterprise = 0, format = ... */ | |
584 | SFLCOUNTERS_GENERIC = 1, | |
585 | SFLCOUNTERS_ETHERNET = 2, | |
586 | SFLCOUNTERS_TOKENRING = 3, | |
587 | SFLCOUNTERS_VG = 4, | |
50b9699f NM |
588 | SFLCOUNTERS_VLAN = 5, |
589 | SFLCOUNTERS_LACP = 7, | |
590 | SFLCOUNTERS_OPENFLOWPORT = 1004, | |
3d2912f2 NM |
591 | SFLCOUNTERS_PORTNAME = 1005, |
592 | SFLCOUNTERS_APP_RESOURCES = 2203, | |
593 | SFLCOUNTERS_OVSDP = 2207 | |
c72e245a BP |
594 | }; |
595 | ||
596 | typedef union _SFLCounters_type { | |
597 | SFLIf_counters generic; | |
598 | SFLEthernet_counters ethernet; | |
599 | SFLTokenring_counters tokenring; | |
600 | SFLVg_counters vg; | |
601 | SFLVlan_counters vlan; | |
50b9699f NM |
602 | SFLLACP_counters lacp; |
603 | SFLOpenFlowPort ofPort; | |
604 | SFLPortName portName; | |
3d2912f2 NM |
605 | SFLAPPResources_counters appResources; |
606 | SFLOVSDP_counters ovsdp; | |
c72e245a BP |
607 | } SFLCounters_type; |
608 | ||
609 | typedef struct _SFLCounters_sample_element { | |
610 | struct _SFLCounters_sample_element *nxt; /* linked list */ | |
611 | u_int32_t tag; /* SFLCounters_type_tag */ | |
612 | u_int32_t length; | |
613 | SFLCounters_type counterBlock; | |
614 | } SFLCounters_sample_element; | |
615 | ||
616 | typedef struct _SFLCounters_sample { | |
617 | /* u_int32_t tag; */ /* SFL_sample_tag -- enterprise = 0 : format = 2 */ | |
618 | /* u_int32_t length; */ | |
619 | u_int32_t sequence_number; /* Incremented with each counters sample | |
620 | generated by this source_id */ | |
621 | u_int32_t source_id; /* fsSourceId */ | |
622 | u_int32_t num_elements; | |
623 | SFLCounters_sample_element *elements; | |
624 | } SFLCounters_sample; | |
625 | ||
626 | /* same thing, but the expanded version, so ds_index can be a full 32 bits */ | |
627 | typedef struct _SFLCounters_sample_expanded { | |
628 | /* u_int32_t tag; */ /* SFL_sample_tag -- enterprise = 0 : format = 2 */ | |
629 | /* u_int32_t length; */ | |
630 | u_int32_t sequence_number; /* Incremented with each counters sample | |
631 | generated by this source_id */ | |
632 | u_int32_t ds_class; /* EXPANDED */ | |
633 | u_int32_t ds_index; /* EXPANDED */ | |
634 | u_int32_t num_elements; | |
635 | SFLCounters_sample_element *elements; | |
636 | } SFLCounters_sample_expanded; | |
637 | ||
638 | #define SFLADD_ELEMENT(_sm, _el) do { (_el)->nxt = (_sm)->elements; (_sm)->elements = (_el); } while(0) | |
639 | ||
640 | /* Format of a sample datagram */ | |
641 | ||
642 | enum SFLDatagram_version { | |
643 | SFLDATAGRAM_VERSION2 = 2, | |
644 | SFLDATAGRAM_VERSION4 = 4, | |
645 | SFLDATAGRAM_VERSION5 = 5 | |
646 | }; | |
647 | ||
648 | typedef struct _SFLSample_datagram_hdr { | |
649 | u_int32_t datagram_version; /* (enum SFLDatagram_version) = VERSION5 = 5 */ | |
650 | SFLAddress agent_address; /* IP address of sampling agent */ | |
651 | u_int32_t sub_agent_id; /* Used to distinguishing between datagram | |
652 | streams from separate agent sub entities | |
653 | within an device. */ | |
654 | u_int32_t sequence_number; /* Incremented with each sample datagram | |
655 | generated */ | |
656 | u_int32_t uptime; /* Current time (in milliseconds since device | |
657 | last booted). Should be set as close to | |
658 | datagram transmission time as possible.*/ | |
659 | u_int32_t num_records; /* Number of tag-len-val flow/counter records to follow */ | |
660 | } SFLSample_datagram_hdr; | |
661 | ||
662 | #define SFL_MAX_DATAGRAM_SIZE 1500 | |
663 | #define SFL_MIN_DATAGRAM_SIZE 200 | |
664 | #define SFL_DEFAULT_DATAGRAM_SIZE 1400 | |
665 | ||
666 | #define SFL_DATA_PAD 400 | |
667 | ||
668 | #endif /* SFLOW_H */ |