1 /* Copyright (c) 2002-2011 InMon Corp. Licensed under the terms of the InMon sFlow licence: */ 2 /* http://www.inmon.com/technology/sflowlicense.txt */ 3 4 /* 5 ///////////////////////////////////////////////////////////////////////////////// 6 /////////////////////// sFlow Sampling Packet Data Types //////////////////////// 7 ///////////////////////////////////////////////////////////////////////////////// 8 */ 9 10 #ifndef SFLOW_H 11 #define SFLOW_H 1 12 13 #include "config.h" 14 15 #include <sys/types.h> 16 #ifdef HAVE_STDINT_H 17 #include <stdint.h> 18 #endif 19 20 #if defined(__cplusplus) 21 extern "C" { 22 #endif 23 24 typedef struct { 25 uint32_t addr; 26 } SFLIPv4; 27 28 typedef struct { 29 uint8_t addr[16]; 30 } SFLIPv6; 31 32 typedef union _SFLAddress_value { 33 SFLIPv4 ip_v4; 34 SFLIPv6 ip_v6; 35 } SFLAddress_value; 36 37 enum SFLAddress_type { 38 SFLADDRESSTYPE_UNDEFINED = 0, 39 SFLADDRESSTYPE_IP_V4 = 1, 40 SFLADDRESSTYPE_IP_V6 = 2 41 }; 42 43 typedef struct _SFLAddress { 44 uint32_t type; /* enum SFLAddress_type */ 45 SFLAddress_value address; 46 } SFLAddress; 47 48 /* Packet header data */ 49 50 #define SFL_DEFAULT_HEADER_SIZE 128 51 #define SFL_DEFAULT_COLLECTOR_PORT 6343 52 #define SFL_DEFAULT_SAMPLING_RATE 400 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 SFLHEADER_POS = 14, 70 SFLHEADER_IEEE80211MAC = 15, 71 SFLHEADER_IEEE80211_AMPDU = 16, 72 SFLHEADER_IEEE80211_AMSDU_SUBFRAME = 17 73 }; 74 75 /* raw sampled header */ 76 77 typedef struct _SFLSampled_header { 78 uint32_t header_protocol; /* (enum SFLHeader_protocol) */ 79 uint32_t frame_length; /* Original length of packet before sampling */ 80 uint32_t stripped; /* header/trailer bytes stripped by sender */ 81 uint32_t header_length; /* length of sampled header bytes to follow */ 82 uint8_t *header_bytes; /* Header bytes */ 83 } SFLSampled_header; 84 85 /* decoded ethernet header */ 86 87 typedef struct _SFLSampled_ethernet { 88 uint32_t eth_len; /* The length of the MAC packet excluding 89 lower layer encapsulations */ 90 uint8_t src_mac[8]; /* 6 bytes + 2 pad */ 91 uint8_t dst_mac[8]; 92 uint32_t eth_type; 93 } SFLSampled_ethernet; 94 95 /* decoded IP version 4 header */ 96 97 typedef struct _SFLSampled_ipv4 { 98 uint32_t length; /* The length of the IP packet 99 excluding lower layer encapsulations */ 100 uint32_t protocol; /* IP Protocol type (for example, TCP = 6, UDP = 17) */ 101 SFLIPv4 src_ip; /* Source IP Address */ 102 SFLIPv4 dst_ip; /* Destination IP Address */ 103 uint32_t src_port; /* TCP/UDP source port number or equivalent */ 104 uint32_t dst_port; /* TCP/UDP destination port number or equivalent */ 105 uint32_t tcp_flags; /* TCP flags */ 106 uint32_t tos; /* IP type of service */ 107 } SFLSampled_ipv4; 108 109 /* decoded IP version 6 data */ 110 111 typedef struct _SFLSampled_ipv6 { 112 uint32_t length; /* The length of the IP packet 113 excluding lower layer encapsulations */ 114 uint32_t protocol; /* IP Protocol type (for example, TCP = 6, UDP = 17) */ 115 SFLIPv6 src_ip; /* Source IP Address */ 116 SFLIPv6 dst_ip; /* Destination IP Address */ 117 uint32_t src_port; /* TCP/UDP source port number or equivalent */ 118 uint32_t dst_port; /* TCP/UDP destination port number or equivalent */ 119 uint32_t tcp_flags; /* TCP flags */ 120 uint32_t priority; /* IP priority */ 121 } SFLSampled_ipv6; 122 123 /* Extended data types */ 124 125 /* Extended switch data */ 126 127 typedef struct _SFLExtended_switch { 128 uint32_t src_vlan; /* The 802.1Q VLAN id of incomming frame */ 129 uint32_t src_priority; /* The 802.1p priority */ 130 uint32_t dst_vlan; /* The 802.1Q VLAN id of outgoing frame */ 131 uint32_t dst_priority; /* The 802.1p priority */ 132 } SFLExtended_switch; 133 134 /* Extended router data */ 135 136 typedef struct _SFLExtended_router { 137 SFLAddress nexthop; /* IP address of next hop router */ 138 uint32_t src_mask; /* Source address prefix mask bits */ 139 uint32_t dst_mask; /* Destination address prefix mask bits */ 140 } SFLExtended_router; 141 142 /* Extended gateway data */ 143 enum SFLExtended_as_path_segment_type { 144 SFLEXTENDED_AS_SET = 1, /* Unordered set of ASs */ 145 SFLEXTENDED_AS_SEQUENCE = 2 /* Ordered sequence of ASs */ 146 }; 147 148 typedef struct _SFLExtended_as_path_segment { 149 uint32_t type; /* enum SFLExtended_as_path_segment_type */ 150 uint32_t length; /* number of AS numbers in set/sequence */ 151 union { 152 uint32_t *set; 153 uint32_t *seq; 154 } as; 155 } SFLExtended_as_path_segment; 156 157 typedef struct _SFLExtended_gateway { 158 SFLAddress nexthop; /* Address of the border router that should 159 be used for the destination network */ 160 uint32_t as; /* AS number for this gateway */ 161 uint32_t src_as; /* AS number of source (origin) */ 162 uint32_t src_peer_as; /* AS number of source peer */ 163 uint32_t dst_as_path_segments; /* number of segments in path */ 164 SFLExtended_as_path_segment *dst_as_path; /* list of seqs or sets */ 165 uint32_t communities_length; /* number of communities */ 166 uint32_t *communities; /* set of communities */ 167 uint32_t localpref; /* LocalPref associated with this route */ 168 } SFLExtended_gateway; 169 170 typedef struct _SFLString { 171 uint32_t len; 172 char *str; 173 } SFLString; 174 175 /* Extended user data */ 176 177 typedef struct _SFLExtended_user { 178 uint32_t src_charset; /* MIBEnum value of character set used to encode a string - See RFC 2978 179 Where possible UTF-8 encoding (MIBEnum=106) should be used. A value 180 of zero indicates an unknown encoding. */ 181 SFLString src_user; 182 uint32_t dst_charset; 183 SFLString dst_user; 184 } SFLExtended_user; 185 186 /* Extended URL data */ 187 188 enum SFLExtended_url_direction { 189 SFLEXTENDED_URL_SRC = 1, /* URL is associated with source address */ 190 SFLEXTENDED_URL_DST = 2 /* URL is associated with destination address */ 191 }; 192 193 typedef struct _SFLExtended_url { 194 uint32_t direction; /* enum SFLExtended_url_direction */ 195 SFLString url; /* URL associated with the packet flow. 196 Must be URL encoded */ 197 SFLString host; /* The host field from the HTTP header */ 198 } SFLExtended_url; 199 200 /* Extended MPLS data */ 201 202 typedef struct _SFLLabelStack { 203 uint32_t depth; 204 uint32_t *stack; /* first entry is top of stack - see RFC 3032 for encoding */ 205 } SFLLabelStack; 206 207 typedef struct _SFLExtended_mpls { 208 SFLAddress nextHop; /* Address of the next hop */ 209 SFLLabelStack in_stack; 210 SFLLabelStack out_stack; 211 } SFLExtended_mpls; 212 213 /* Extended NAT data 214 Packet header records report addresses as seen at the sFlowDataSource. 215 The extended_nat structure reports on translated source and/or destination 216 addesses for this packet. If an address was not translated it should 217 be equal to that reported for the header. */ 218 219 typedef struct _SFLExtended_nat { 220 SFLAddress src; /* Source address */ 221 SFLAddress dst; /* Destination address */ 222 } SFLExtended_nat; 223 224 typedef struct _SFLExtended_nat_port { 225 uint32_t src_port; 226 uint32_t dst_port; 227 } SFLExtended_nat_port; 228 229 /* additional Extended MPLS stucts */ 230 231 typedef struct _SFLExtended_mpls_tunnel { 232 SFLString tunnel_lsp_name; /* Tunnel name */ 233 uint32_t tunnel_id; /* Tunnel ID */ 234 uint32_t tunnel_cos; /* Tunnel COS value */ 235 } SFLExtended_mpls_tunnel; 236 237 typedef struct _SFLExtended_mpls_vc { 238 SFLString vc_instance_name; /* VC instance name */ 239 uint32_t vll_vc_id; /* VLL/VC instance ID */ 240 uint32_t vc_label_cos; /* VC Label COS value */ 241 } SFLExtended_mpls_vc; 242 243 /* Extended MPLS FEC 244 - Definitions from MPLS-FTN-STD-MIB mplsFTNTable */ 245 246 typedef struct _SFLExtended_mpls_FTN { 247 SFLString mplsFTNDescr; 248 uint32_t mplsFTNMask; 249 } SFLExtended_mpls_FTN; 250 251 /* Extended MPLS LVP FEC 252 - Definition from MPLS-LDP-STD-MIB mplsFecTable 253 Note: mplsFecAddrType, mplsFecAddr information available 254 from packet header */ 255 256 typedef struct _SFLExtended_mpls_LDP_FEC { 257 uint32_t mplsFecAddrPrefixLength; 258 } SFLExtended_mpls_LDP_FEC; 259 260 /* Extended VLAN tunnel information 261 Record outer VLAN encapsulations that have 262 been stripped. extended_vlantunnel information 263 should only be reported if all the following conditions are satisfied: 264 1. The packet has nested vlan tags, AND 265 2. The reporting device is VLAN aware, AND 266 3. One or more VLAN tags have been stripped, either 267 because they represent proprietary encapsulations, or 268 because switch hardware automatically strips the outer VLAN 269 encapsulation. 270 Reporting extended_vlantunnel information is not a substitute for 271 reporting extended_switch information. extended_switch data must 272 always be reported to describe the ingress/egress VLAN information 273 for the packet. The extended_vlantunnel information only applies to 274 nested VLAN tags, and then only when one or more tags has been 275 stripped. */ 276 277 typedef SFLLabelStack SFLVlanStack; 278 typedef struct _SFLExtended_vlan_tunnel { 279 SFLVlanStack stack; /* List of stripped 802.1Q TPID/TCI layers. Each 280 TPID,TCI pair is represented as a single 32 bit 281 integer. Layers listed from outermost to 282 innermost. */ 283 } SFLExtended_vlan_tunnel; 284 285 /* 286 ////////////////// IEEE 802.11 Extension structs //////////////////// 287 288 The 4-byte cipher_suite identifier follows the format of the cipher suite 289 selector value from the 802.11i (TKIP/CCMP amendment to 802.11i) 290 The most significant three bytes contain the OUI and the least significant 291 byte contains the Suite Type. 292 293 The currently assigned values are: 294 295 OUI |Suite type |Meaning 296 ---------------------------------------------------- 297 00-0F-AC | 0 | Use group cipher suite 298 00-0F-AC | 1 | WEP-40 299 00-0F-AC | 2 | TKIP 300 00-0F-AC | 3 | Reserved 301 00-0F-AC | 4 | CCMP 302 00-0F-AC | 5 | WEP-104 303 00-0F-AC | 6-255 | Reserved 304 Vendor OUI | Other | Vendor specific 305 Other | Any | Reserved 306 ---------------------------------------------------- 307 */ 308 309 typedef uint32_t SFLCipherSuite; 310 311 /* Extended wifi Payload 312 Used to provide unencrypted version of 802.11 MAC data. If the 313 MAC data is not encrypted then the agent must not include an 314 extended_wifi_payload structure. 315 If 802.11 MAC data is encrypted then the sampled_header structure 316 should only contain the MAC header (since encrypted data cannot 317 be decoded by the sFlow receiver). If the sFlow agent has access to 318 the unencrypted payload, it should add an extended_wifi_payload 319 structure containing the unencrypted data bytes from the sampled 320 packet header, starting at the beginning of the 802.2 LLC and not 321 including any trailing encryption footers. */ 322 /* opaque = flow_data; enterprise = 0; format = 1013 */ 323 324 typedef struct _SFLExtended_wifi_payload { 325 SFLCipherSuite cipherSuite; 326 SFLSampled_header header; 327 } SFLExtended_wifi_payload; 328 329 typedef enum { 330 IEEE80211_A=1, 331 IEEE80211_B=2, 332 IEEE80211_G=3, 333 IEEE80211_N=4, 334 } SFL_IEEE80211_version; 335 336 /* opaque = flow_data; enterprise = 0; format = 1014 */ 337 338 #define SFL_MAX_SSID_LEN 256 339 340 typedef struct _SFLExtended_wifi_rx { 341 uint32_t ssid_len; 342 char *ssid; 343 char bssid[6]; /* BSSID */ 344 SFL_IEEE80211_version version; /* version */ 345 uint32_t channel; /* channel number */ 346 uint64_t speed; 347 uint32_t rsni; /* received signal to noise ratio, see dot11FrameRprtRSNI */ 348 uint32_t rcpi; /* received channel power, see dot11FrameRprtLastRCPI */ 349 uint32_t packet_duration_us; /* amount of time that the successfully received pkt occupied RF medium.*/ 350 } SFLExtended_wifi_rx; 351 352 /* opaque = flow_data; enterprise = 0; format = 1015 */ 353 354 typedef struct _SFLExtended_wifi_tx { 355 uint32_t ssid_len; 356 char *ssid; /* SSID string */ 357 char bssid[6]; /* BSSID */ 358 SFL_IEEE80211_version version; /* version */ 359 uint32_t transmissions; /* number of transmissions for sampled 360 packet. 361 0 = unkown 362 1 = packet was successfully transmitted 363 on first attempt 364 n > 1 = n - 1 retransmissions */ 365 uint32_t packet_duration_us; /* amount of time that the successfully 366 transmitted packet occupied the 367 RF medium */ 368 uint32_t retrans_duration_us; /* amount of time that failed transmission 369 attempts occupied the RF medium */ 370 uint32_t channel; /* channel number */ 371 uint64_t speed; 372 uint32_t power_mw; /* transmit power in mW. */ 373 } SFLExtended_wifi_tx; 374 375 /* Extended 802.11 Aggregation Data */ 376 /* A flow_sample of an aggregated frame would consist of a packet 377 header for the whole frame + any other extended structures that 378 apply (e.g. 80211_tx/rx etc.) + an extended_wifi_aggregation 379 structure which would contain an array of pdu structures (one 380 for each PDU in the aggregate). A pdu is simply an array of 381 flow records, in the simplest case a packet header for each PDU, 382 but extended structures could be included as well. */ 383 384 /* opaque = flow_data; enterprise = 0; format = 1016 */ 385 386 struct _SFLFlow_Pdu; /* forward decl */ 387 388 typedef struct _SFLExtended_aggregation { 389 uint32_t num_pdus; 390 struct _SFFlow_Pdu *pdus; 391 } SFLExtended_aggregation; 392 /* TCP connection state */ 393 /* Based on struct tcp_info in /usr/include/linux/tcp.h */ 394 /* opaque = flow_data; enterprise=0; format=2209 */ 395 396 typedef enum { 397 PKTDIR_unknown = 0, 398 PKTDIR_received = 1, 399 PKTDIR_sent = 2 400 } EnumPktDirection; 401 402 typedef struct _SFLExtended_TCP_info { 403 uint32_t dirn; /* EnumPktDirection: Sampled packet direction */ 404 uint32_t snd_mss; /* Cached effective mss, not including SACKS */ 405 uint32_t rcv_mss; /* Max. recv. segment size */ 406 uint32_t unacked; /* Packets which are "in flight" */ 407 uint32_t lost; /* Lost packets */ 408 uint32_t retrans; /* Retransmitted packets */ 409 uint32_t pmtu; /* Last pmtu seen by socket */ 410 uint32_t rtt; /* smoothed RTT (microseconds) */ 411 uint32_t rttvar; /* RTT variance (microseconds) */ 412 uint32_t snd_cwnd; /* Sending congestion window */ 413 uint32_t reordering; /* Reordering */ 414 uint32_t min_rtt; /* Minimum RTT (microseconds) */ 415 } SFLExtended_TCP_info; 416 417 #define XDRSIZ_SFLEXTENDED_TCP_INFO 48 418 419 /* Extended socket information, 420 Must be filled in for all application transactions associated with a network socket 421 Omit if transaction associated with non-network IPC */ 422 423 /* IPv4 Socket */ 424 /* opaque = flow_data; enterprise = 0; format = 2100 */ 425 typedef struct _SFLExtended_socket_ipv4 { 426 uint32_t protocol; /* IP Protocol (e.g. TCP = 6, UDP = 17) */ 427 SFLIPv4 local_ip; /* local IP address */ 428 SFLIPv4 remote_ip; /* remote IP address */ 429 uint32_t local_port; /* TCP/UDP local port number or equivalent */ 430 uint32_t remote_port; /* TCP/UDP remote port number of equivalent */ 431 } SFLExtended_socket_ipv4; 432 433 #define XDRSIZ_SFLEXTENDED_SOCKET4 20 434 435 /* IPv6 Socket */ 436 /* opaque = flow_data; enterprise = 0; format = 2101 */ 437 typedef struct _SFLExtended_socket_ipv6 { 438 uint32_t protocol; /* IP Protocol (e.g. TCP = 6, UDP = 17) */ 439 SFLIPv6 local_ip; /* local IP address */ 440 SFLIPv6 remote_ip; /* remote IP address */ 441 uint32_t local_port; /* TCP/UDP local port number or equivalent */ 442 uint32_t remote_port; /* TCP/UDP remote port number of equivalent */ 443 } SFLExtended_socket_ipv6; 444 445 #define XDRSIZ_SFLEXTENDED_SOCKET6 44 446 447 typedef enum { 448 MEMCACHE_PROT_OTHER = 0, 449 MEMCACHE_PROT_ASCII = 1, 450 MEMCACHE_PROT_BINARY = 2 451 } SFLMemcache_prot; 452 453 typedef enum { 454 MEMCACHE_CMD_OTHER = 0, 455 MEMCACHE_CMD_SET = 1, 456 MEMCACHE_CMD_ADD = 2, 457 MEMCACHE_CMD_REPLACE = 3, 458 MEMCACHE_CMD_APPEND = 4, 459 MEMCACHE_CMD_PREPEND = 5, 460 MEMCACHE_CMD_CAS = 6, 461 MEMCACHE_CMD_GET = 7, 462 MEMCACHE_CMD_GETS = 8, 463 MEMCACHE_CMD_INCR = 9, 464 MEMCACHE_CMD_DECR = 10, 465 MEMCACHE_CMD_DELETE = 11, 466 MEMCACHE_CMD_STATS = 12, 467 MEMCACHE_CMD_FLUSH = 13, 468 MEMCACHE_CMD_VERSION = 14, 469 MEMCACHE_CMD_QUIT = 15, 470 MEMCACHE_CMD_TOUCH = 16 471 } SFLMemcache_cmd; 472 473 enum SFLMemcache_operation_status { 474 MEMCACHE_OP_UNKNOWN = 0, 475 MEMCACHE_OP_OK = 1, 476 MEMCACHE_OP_ERROR = 2, 477 MEMCACHE_OP_CLIENT_ERROR = 3, 478 MEMCACHE_OP_SERVER_ERROR = 4, 479 MEMCACHE_OP_STORED = 5, 480 MEMCACHE_OP_NOT_STORED = 6, 481 MEMCACHE_OP_EXISTS = 7, 482 MEMCACHE_OP_NOT_FOUND = 8, 483 MEMCACHE_OP_DELETED = 9 484 }; 485 486 #define SFL_MAX_MEMCACHE_KEY 255 487 488 typedef struct _SFLSampled_memcache { 489 uint32_t protocol; /* SFLMemcache_prot */ 490 uint32_t command; /* SFLMemcache_cmd */ 491 SFLString key; /* up to 255 chars */ 492 uint32_t nkeys; 493 uint32_t value_bytes; 494 uint32_t duration_uS; 495 uint32_t status; /* SFLMemcache_operation_status */ 496 } SFLSampled_memcache; 497 498 typedef enum { 499 SFHTTP_OTHER = 0, 500 SFHTTP_OPTIONS = 1, 501 SFHTTP_GET = 2, 502 SFHTTP_HEAD = 3, 503 SFHTTP_POST = 4, 504 SFHTTP_PUT = 5, 505 SFHTTP_DELETE = 6, 506 SFHTTP_TRACE = 7, 507 SFHTTP_CONNECT = 8 508 } SFLHTTP_method; 509 510 #define SFL_MAX_HTTP_URI 255 511 #define SFL_MAX_HTTP_HOST 64 512 #define SFL_MAX_HTTP_REFERRER 255 513 #define SFL_MAX_HTTP_USERAGENT 128 514 #define SFL_MAX_HTTP_XFF 64 515 #define SFL_MAX_HTTP_AUTHUSER 32 516 #define SFL_MAX_HTTP_MIMETYPE 64 517 518 typedef struct _SFLSampled_http { 519 SFLHTTP_method method; 520 uint32_t protocol; /* 1.1=1001 */ 521 SFLString uri; /* URI exactly as it came from the client (up to 255 bytes) */ 522 SFLString host; /* Host value from request header (<= 64 bytes) */ 523 SFLString referrer; /* Referer value from request header (<=255 bytes) */ 524 SFLString useragent; /* User-Agent value from request header (<= 128 bytes)*/ 525 SFLString xff; /* X-Forwarded-For value from request header (<= 64 bytes)*/ 526 SFLString authuser; /* RFC 1413 identity of user (<=32 bytes)*/ 527 SFLString mimetype; /* Mime-Type (<=64 bytes) */ 528 uint64_t req_bytes; /* Content-Length of request */ 529 uint64_t resp_bytes; /* Content-Length of response */ 530 uint32_t uS; /* duration of the operation (microseconds) */ 531 uint32_t status; /* HTTP status code */ 532 } SFLSampled_http; 533 534 535 typedef enum { 536 SFLAPP_SUCCESS = 0, 537 SFLAPP_OTHER = 1, 538 SFLAPP_TIMEOUT = 2, 539 SFLAPP_INTERNAL_ERROR = 3, 540 SFLAPP_BAD_REQUEST = 4, 541 SFLAPP_FORBIDDEN = 5, 542 SFLAPP_TOO_LARGE = 6, 543 SFLAPP_NOT_IMPLEMENTED = 7, 544 SFLAPP_NOT_FOUND = 8, 545 SFLAPP_UNAVAILABLE = 9, 546 SFLAPP_UNAUTHORIZED = 10, 547 SFLAPP_NUM_STATUS_CODES 548 } EnumSFLAPPStatus; 549 550 #ifdef DEVEL 551 static const char *SFL_APP_STATUS_names[] = { "SUCCESS", 552 "OTHER", 553 "TIMEOUT", 554 "INTERNAL_ERROR", 555 "BAD_REQUEST", 556 "FORBIDDEN", 557 "TOO_LARGE", 558 "NOT_IMPLEMENTED", 559 "NOT_FOUND", 560 "UNAVAILABLE", 561 "UNATHORIZED" }; 562 #endif 563 564 /* Operation context */ 565 typedef struct { 566 SFLString application; 567 SFLString operation; /* type of operation (e.g. authorization, payment) */ 568 SFLString attributes; /* specific attributes associated operation */ 569 } SFLSampled_APP_CTXT; 570 571 #define SFLAPP_MAX_APPLICATION_LEN 32 572 #define SFLAPP_MAX_OPERATION_LEN 32 573 #define SFLAPP_MAX_ATTRIBUTES_LEN 255 574 575 /* Sampled Enterprise Operation */ 576 /* opaque = flow_data; enterprise = 0; format = 2202 */ 577 typedef struct { 578 SFLSampled_APP_CTXT context; /* attributes describing the operation */ 579 SFLString status_descr; /* additional text describing status (e.g. "unknown client") */ 580 uint64_t req_bytes; /* size of request body (exclude headers) */ 581 uint64_t resp_bytes; /* size of response body (exclude headers) */ 582 uint32_t duration_uS; /* duration of the operation (microseconds) */ 583 EnumSFLAPPStatus status; /* status code */ 584 } SFLSampled_APP; 585 586 #define SFLAPP_MAX_STATUS_LEN 32 587 588 typedef struct { 589 SFLString actor; 590 } SFLSampled_APP_ACTOR; 591 592 #define SFLAPP_MAX_ACTOR_LEN 64 593 594 typedef struct _SFLExtended_vni { 595 uint32_t vni; /* virtual network identifier */ 596 } SFLExtended_vni; 597 598 typedef struct _SFLExtended_decap { 599 uint32_t innerHeaderOffset; 600 } SFLExtended_decap; 601 602 enum SFLFlow_type_tag { 603 /* enterprise = 0, format = ... */ 604 SFLFLOW_HEADER = 1, /* Packet headers are sampled */ 605 SFLFLOW_ETHERNET = 2, /* MAC layer information */ 606 SFLFLOW_IPV4 = 3, /* IP version 4 data */ 607 SFLFLOW_IPV6 = 4, /* IP version 6 data */ 608 SFLFLOW_EX_SWITCH = 1001, /* Extended switch information */ 609 SFLFLOW_EX_ROUTER = 1002, /* Extended router information */ 610 SFLFLOW_EX_GATEWAY = 1003, /* Extended gateway router information */ 611 SFLFLOW_EX_USER = 1004, /* Extended TACAS/RADIUS user information */ 612 SFLFLOW_EX_URL = 1005, /* Extended URL information */ 613 SFLFLOW_EX_MPLS = 1006, /* Extended MPLS information */ 614 SFLFLOW_EX_NAT = 1007, /* Extended NAT information */ 615 SFLFLOW_EX_MPLS_TUNNEL = 1008, /* additional MPLS information */ 616 SFLFLOW_EX_MPLS_VC = 1009, 617 SFLFLOW_EX_MPLS_FTN = 1010, 618 SFLFLOW_EX_MPLS_LDP_FEC = 1011, 619 SFLFLOW_EX_VLAN_TUNNEL = 1012, /* VLAN stack */ 620 SFLFLOW_EX_80211_PAYLOAD = 1013, 621 SFLFLOW_EX_80211_RX = 1014, 622 SFLFLOW_EX_80211_TX = 1015, 623 SFLFLOW_EX_AGGREGATION = 1016, 624 SFLFLOW_EX_NAT_PORT = 1020, /* Extended NAT port information */ 625 SFLFLOW_EX_L2_TUNNEL_OUT = 1021, /* http://sflow.org/sflow_tunnels.txt */ 626 SFLFLOW_EX_L2_TUNNEL_IN = 1022, 627 SFLFLOW_EX_IPV4_TUNNEL_OUT = 1023, 628 SFLFLOW_EX_IPV4_TUNNEL_IN = 1024, 629 SFLFLOW_EX_IPV6_TUNNEL_OUT = 1025, 630 SFLFLOW_EX_IPV6_TUNNEL_IN = 1026, 631 SFLFLOW_EX_DECAP_OUT = 1027, 632 SFLFLOW_EX_DECAP_IN = 1028, 633 SFLFLOW_EX_VNI_OUT = 1029, 634 SFLFLOW_EX_VNI_IN = 1030, 635 SFLFLOW_EX_SOCKET4 = 2100, 636 SFLFLOW_EX_SOCKET6 = 2101, 637 SFLFLOW_EX_PROXYSOCKET4 = 2102, 638 SFLFLOW_EX_PROXYSOCKET6 = 2103, 639 SFLFLOW_MEMCACHE = 2200, 640 SFLFLOW_HTTP = 2201, 641 SFLFLOW_APP = 2202, /* transaction sample */ 642 SFLFLOW_APP_CTXT = 2203, /* enclosing server context */ 643 SFLFLOW_APP_ACTOR_INIT = 2204, /* initiator */ 644 SFLFLOW_APP_ACTOR_TGT = 2205, /* target */ 645 SFLFLOW_HTTP2 = 2206, 646 SFLFLOW_EX_TCP_INFO = 2209, 647 }; 648 649 typedef union _SFLFlow_type { 650 SFLSampled_header header; 651 SFLSampled_ethernet ethernet; 652 SFLSampled_ipv4 ipv4; 653 SFLSampled_ipv6 ipv6; 654 SFLSampled_memcache memcache; 655 SFLSampled_http http; 656 SFLSampled_APP app; 657 SFLSampled_APP_CTXT appCtxt; 658 SFLSampled_APP_ACTOR appActor; 659 SFLExtended_switch sw; 660 SFLExtended_router router; 661 SFLExtended_gateway gateway; 662 SFLExtended_user user; 663 SFLExtended_url url; 664 SFLExtended_mpls mpls; 665 SFLExtended_nat nat; 666 SFLExtended_nat_port nat_port; 667 SFLExtended_mpls_tunnel mpls_tunnel; 668 SFLExtended_mpls_vc mpls_vc; 669 SFLExtended_mpls_FTN mpls_ftn; 670 SFLExtended_mpls_LDP_FEC mpls_ldp_fec; 671 SFLExtended_vlan_tunnel vlan_tunnel; 672 SFLExtended_wifi_payload wifi_payload; 673 SFLExtended_wifi_rx wifi_rx; 674 SFLExtended_wifi_tx wifi_tx; 675 SFLExtended_aggregation aggregation; 676 SFLExtended_socket_ipv4 socket4; 677 SFLExtended_socket_ipv6 socket6; 678 SFLExtended_vni tunnel_vni; 679 SFLExtended_decap tunnel_decap; 680 } SFLFlow_type; 681 682 typedef struct _SFLFlow_sample_element { 683 struct _SFLFlow_sample_element *nxt; 684 uint32_t tag; /* SFLFlow_type_tag */ 685 uint32_t length; 686 SFLFlow_type flowType; 687 } SFLFlow_sample_element; 688 689 enum SFL_sample_tag { 690 SFLFLOW_SAMPLE = 1, /* enterprise = 0 : format = 1 */ 691 SFLCOUNTERS_SAMPLE = 2, /* enterprise = 0 : format = 2 */ 692 SFLFLOW_SAMPLE_EXPANDED = 3, /* enterprise = 0 : format = 3 */ 693 SFLCOUNTERS_SAMPLE_EXPANDED = 4, /* enterprise = 0 : format = 4 */ 694 SFLRTMETRIC = ((4300 << 12) + 1002), 695 SFLRTFLOW = ((4300 << 12) + 1003) 696 }; 697 698 typedef struct _SFLFlow_Pdu { 699 struct _SFLFlow_Pdu *nxt; 700 uint32_t num_elements; 701 SFLFlow_sample_element *elements; 702 } SFLFlow_Pdu; 703 704 705 /* Format of a single flow sample */ 706 707 typedef struct _SFLFlow_sample { 708 /* uint32_t tag; */ /* SFL_sample_tag -- enterprise = 0 : format = 1 */ 709 /* uint32_t length; */ 710 uint32_t sequence_number; /* Incremented with each flow sample 711 generated */ 712 uint32_t source_id; /* fsSourceId */ 713 uint32_t sampling_rate; /* fsPacketSamplingRate */ 714 uint32_t sample_pool; /* Total number of packets that could have been 715 sampled (i.e. packets skipped by sampling 716 process + total number of samples) */ 717 uint32_t drops; /* Number of times a packet was dropped due to 718 lack of resources */ 719 uint32_t input; /* SNMP ifIndex of input interface. 720 0 if interface is not known. */ 721 uint32_t output; /* SNMP ifIndex of output interface, 722 0 if interface is not known. 723 Set most significant bit to indicate 724 multiple destination interfaces 725 (i.e. in case of broadcast or multicast) 726 and set lower order bits to indicate 727 number of destination interfaces. 728 Examples: 729 0x00000002 indicates ifIndex = 2 730 0x00000000 ifIndex unknown. 731 0x80000007 indicates a packet sent 732 to 7 interfaces. 733 0x80000000 indicates a packet sent to 734 an unknown number of 735 interfaces greater than 1.*/ 736 uint32_t num_elements; 737 SFLFlow_sample_element *elements; 738 } SFLFlow_sample; 739 740 /* same thing, but the expanded version (for full 32-bit ifIndex numbers) */ 741 742 typedef struct _SFLFlow_sample_expanded { 743 /* uint32_t tag; */ /* SFL_sample_tag -- enterprise = 0 : format = 1 */ 744 /* uint32_t length; */ 745 uint32_t sequence_number; /* Incremented with each flow sample 746 generated */ 747 uint32_t ds_class; /* EXPANDED */ 748 uint32_t ds_index; /* EXPANDED */ 749 uint32_t sampling_rate; /* fsPacketSamplingRate */ 750 uint32_t sample_pool; /* Total number of packets that could have been 751 sampled (i.e. packets skipped by sampling 752 process + total number of samples) */ 753 uint32_t drops; /* Number of times a packet was dropped due to 754 lack of resources */ 755 uint32_t inputFormat; /* EXPANDED */ 756 uint32_t input; /* SNMP ifIndex of input interface. 757 0 if interface is not known. */ 758 uint32_t outputFormat; /* EXPANDED */ 759 uint32_t output; /* SNMP ifIndex of output interface, 760 0 if interface is not known. */ 761 uint32_t num_elements; 762 SFLFlow_sample_element *elements; 763 } SFLFlow_sample_expanded; 764 765 /* Counter types */ 766 767 /* Generic interface counters - see RFC 1573, 2233 */ 768 769 typedef struct _SFLIf_counters { 770 uint32_t ifIndex; 771 uint32_t ifType; 772 uint64_t ifSpeed; 773 uint32_t ifDirection; /* Derived from MAU MIB (RFC 2668) 774 0 = unknown, 1 = full-duplex, 775 2 = half-duplex, 3 = in, 4 = out */ 776 uint32_t ifStatus; /* bit field with the following bits assigned: 777 bit 0 = ifAdminStatus (0 = down, 1 = up) 778 bit 1 = ifOperStatus (0 = down, 1 = up) */ 779 uint64_t ifInOctets; 780 uint32_t ifInUcastPkts; 781 uint32_t ifInMulticastPkts; 782 uint32_t ifInBroadcastPkts; 783 uint32_t ifInDiscards; 784 uint32_t ifInErrors; 785 uint32_t ifInUnknownProtos; 786 uint64_t ifOutOctets; 787 uint32_t ifOutUcastPkts; 788 uint32_t ifOutMulticastPkts; 789 uint32_t ifOutBroadcastPkts; 790 uint32_t ifOutDiscards; 791 uint32_t ifOutErrors; 792 uint32_t ifPromiscuousMode; 793 } SFLIf_counters; 794 795 /* Ethernet interface counters - see RFC 2358 */ 796 typedef struct _SFLEthernet_counters { 797 uint32_t dot3StatsAlignmentErrors; 798 uint32_t dot3StatsFCSErrors; 799 uint32_t dot3StatsSingleCollisionFrames; 800 uint32_t dot3StatsMultipleCollisionFrames; 801 uint32_t dot3StatsSQETestErrors; 802 uint32_t dot3StatsDeferredTransmissions; 803 uint32_t dot3StatsLateCollisions; 804 uint32_t dot3StatsExcessiveCollisions; 805 uint32_t dot3StatsInternalMacTransmitErrors; 806 uint32_t dot3StatsCarrierSenseErrors; 807 uint32_t dot3StatsFrameTooLongs; 808 uint32_t dot3StatsInternalMacReceiveErrors; 809 uint32_t dot3StatsSymbolErrors; 810 } SFLEthernet_counters; 811 812 /* Token ring counters - see RFC 1748 */ 813 814 typedef struct _SFLTokenring_counters { 815 uint32_t dot5StatsLineErrors; 816 uint32_t dot5StatsBurstErrors; 817 uint32_t dot5StatsACErrors; 818 uint32_t dot5StatsAbortTransErrors; 819 uint32_t dot5StatsInternalErrors; 820 uint32_t dot5StatsLostFrameErrors; 821 uint32_t dot5StatsReceiveCongestions; 822 uint32_t dot5StatsFrameCopiedErrors; 823 uint32_t dot5StatsTokenErrors; 824 uint32_t dot5StatsSoftErrors; 825 uint32_t dot5StatsHardErrors; 826 uint32_t dot5StatsSignalLoss; 827 uint32_t dot5StatsTransmitBeacons; 828 uint32_t dot5StatsRecoverys; 829 uint32_t dot5StatsLobeWires; 830 uint32_t dot5StatsRemoves; 831 uint32_t dot5StatsSingles; 832 uint32_t dot5StatsFreqErrors; 833 } SFLTokenring_counters; 834 835 /* 100 BaseVG interface counters - see RFC 2020 */ 836 837 typedef struct _SFLVg_counters { 838 uint32_t dot12InHighPriorityFrames; 839 uint64_t dot12InHighPriorityOctets; 840 uint32_t dot12InNormPriorityFrames; 841 uint64_t dot12InNormPriorityOctets; 842 uint32_t dot12InIPMErrors; 843 uint32_t dot12InOversizeFrameErrors; 844 uint32_t dot12InDataErrors; 845 uint32_t dot12InNullAddressedFrames; 846 uint32_t dot12OutHighPriorityFrames; 847 uint64_t dot12OutHighPriorityOctets; 848 uint32_t dot12TransitionIntoTrainings; 849 uint64_t dot12HCInHighPriorityOctets; 850 uint64_t dot12HCInNormPriorityOctets; 851 uint64_t dot12HCOutHighPriorityOctets; 852 } SFLVg_counters; 853 854 typedef struct _SFLVlan_counters { 855 uint32_t vlan_id; 856 uint64_t octets; 857 uint32_t ucastPkts; 858 uint32_t multicastPkts; 859 uint32_t broadcastPkts; 860 uint32_t discards; 861 } SFLVlan_counters; 862 863 typedef struct _SFLWifi_counters { 864 uint32_t dot11TransmittedFragmentCount; 865 uint32_t dot11MulticastTransmittedFrameCount; 866 uint32_t dot11FailedCount; 867 uint32_t dot11RetryCount; 868 uint32_t dot11MultipleRetryCount; 869 uint32_t dot11FrameDuplicateCount; 870 uint32_t dot11RTSSuccessCount; 871 uint32_t dot11RTSFailureCount; 872 uint32_t dot11ACKFailureCount; 873 uint32_t dot11ReceivedFragmentCount; 874 uint32_t dot11MulticastReceivedFrameCount; 875 uint32_t dot11FCSErrorCount; 876 uint32_t dot11TransmittedFrameCount; 877 uint32_t dot11WEPUndecryptableCount; 878 uint32_t dot11QoSDiscardedFragmentCount; 879 uint32_t dot11AssociatedStationCount; 880 uint32_t dot11QoSCFPollsReceivedCount; 881 uint32_t dot11QoSCFPollsUnusedCount; 882 uint32_t dot11QoSCFPollsUnusableCount; 883 uint32_t dot11QoSCFPollsLostCount; 884 } SFLWifi_counters; 885 886 /* Processor Information */ 887 /* opaque = counter_data; enterprise = 0; format = 1001 */ 888 889 typedef struct _SFLProcessor_counters { 890 uint32_t five_sec_cpu; /* 5 second average CPU utilization */ 891 uint32_t one_min_cpu; /* 1 minute average CPU utilization */ 892 uint32_t five_min_cpu; /* 5 minute average CPU utilization */ 893 uint64_t total_memory; /* total memory (in bytes) */ 894 uint64_t free_memory; /* free memory (in bytes) */ 895 } SFLProcessor_counters; 896 897 typedef struct _SFLRadio_counters { 898 uint32_t elapsed_time; /* elapsed time in ms */ 899 uint32_t on_channel_time; /* time in ms spent on channel */ 900 uint32_t on_channel_busy_time; /* time in ms spent on channel and busy */ 901 } SFLRadio_counters; 902 903 /* host sflow */ 904 905 enum SFLMachine_type { 906 SFLMT_unknown = 0, 907 SFLMT_other = 1, 908 SFLMT_x86 = 2, 909 SFLMT_x86_64 = 3, 910 SFLMT_ia64 = 4, 911 SFLMT_sparc = 5, 912 SFLMT_alpha = 6, 913 SFLMT_powerpc = 7, 914 SFLMT_m68k = 8, 915 SFLMT_mips = 9, 916 SFLMT_arm = 10, 917 SFLMT_hppa = 11, 918 SFLMT_s390 = 12 919 }; 920 921 enum SFLOS_name { 922 SFLOS_unknown = 0, 923 SFLOS_other = 1, 924 SFLOS_linux = 2, 925 SFLOS_windows = 3, 926 SFLOS_darwin = 4, 927 SFLOS_hpux = 5, 928 SFLOS_aix = 6, 929 SFLOS_dragonfly = 7, 930 SFLOS_freebsd = 8, 931 SFLOS_netbsd = 9, 932 SFLOS_openbsd = 10, 933 SFLOS_osf = 11, 934 SFLOS_solaris = 12 935 }; 936 937 typedef struct _SFLMacAddress { 938 uint8_t mac[8]; 939 } SFLMacAddress; 940 941 typedef struct _SFLAdaptor { 942 uint32_t ifIndex; 943 uint32_t num_macs; 944 SFLMacAddress macs[1]; 945 } SFLAdaptor; 946 947 typedef struct _SFLAdaptorList { 948 uint32_t capacity; 949 uint32_t num_adaptors; 950 SFLAdaptor **adaptors; 951 } SFLAdaptorList; 952 953 typedef struct _SFLHost_parent { 954 uint32_t dsClass; /* sFlowDataSource class */ 955 uint32_t dsIndex; /* sFlowDataSource index */ 956 } SFLHost_parent; 957 958 959 #define SFL_MAX_HOSTNAME_LEN 64 960 #define SFL_MAX_OSRELEASE_LEN 32 961 962 typedef struct _SFLHostId { 963 SFLString hostname; 964 uint8_t uuid[16]; 965 uint32_t machine_type; /* enum SFLMachine_type */ 966 uint32_t os_name; /* enum SFLOS_name */ 967 SFLString os_release; /* max len 32 bytes */ 968 } SFLHostId; 969 970 typedef struct _SFLHost_nio_counters { 971 uint64_t bytes_in; 972 uint32_t pkts_in; 973 uint32_t errs_in; 974 uint32_t drops_in; 975 uint64_t bytes_out; 976 uint32_t pkts_out; 977 uint32_t errs_out; 978 uint32_t drops_out; 979 } SFLHost_nio_counters; 980 981 typedef struct _SFLHost_cpu_counters { 982 float load_one; /* 1 minute load avg. */ 983 float load_five; /* 5 minute load avg. */ 984 float load_fifteen; /* 15 minute load avg. */ 985 uint32_t proc_run; /* running threads */ 986 uint32_t proc_total; /* total threads */ 987 uint32_t cpu_num; /* # CPU cores */ 988 uint32_t cpu_speed; /* speed in MHz of CPU */ 989 uint32_t uptime; /* seconds since last reboot */ 990 uint32_t cpu_user; /* time executing in user mode processes (ms) */ 991 uint32_t cpu_nice; /* time executing niced processs (ms) */ 992 uint32_t cpu_system; /* time executing kernel mode processes (ms) */ 993 uint32_t cpu_idle; /* idle time (ms) */ 994 uint32_t cpu_wio; /* time waiting for I/O to complete (ms) */ 995 uint32_t cpu_intr; /* time servicing interrupts (ms) */ 996 uint32_t cpu_sintr; /* time servicing softirqs (ms) */ 997 uint32_t interrupts; /* interrupt count */ 998 uint32_t contexts; /* context switch count */ 999 uint32_t cpu_steal; /* time spent in other OS instances (virtual env) (ms) */ 1000 uint32_t cpu_guest; /* time spent running vcpu for guest OS */ 1001 uint32_t cpu_guest_nice; /* time spent running vcpu for "niced" guest OS */ 1002 } SFLHost_cpu_counters; 1003 1004 typedef struct _SFLHost_mem_counters { 1005 uint64_t mem_total; /* total bytes */ 1006 uint64_t mem_free; /* free bytes */ 1007 uint64_t mem_shared; /* shared bytes */ 1008 uint64_t mem_buffers; /* buffers bytes */ 1009 uint64_t mem_cached; /* cached bytes */ 1010 uint64_t swap_total; /* swap total bytes */ 1011 uint64_t swap_free; /* swap free bytes */ 1012 uint32_t page_in; /* page in count */ 1013 uint32_t page_out; /* page out count */ 1014 uint32_t swap_in; /* swap in count */ 1015 uint32_t swap_out; /* swap out count */ 1016 } SFLHost_mem_counters; 1017 1018 typedef struct _SFLHost_dsk_counters { 1019 uint64_t disk_total; 1020 uint64_t disk_free; 1021 uint32_t part_max_used; /* as percent * 100, so 100==1% */ 1022 uint32_t reads; /* reads issued */ 1023 uint64_t bytes_read; /* bytes read */ 1024 uint32_t read_time; /* read time (ms) */ 1025 uint32_t writes; /* writes completed */ 1026 uint64_t bytes_written; /* bytes written */ 1027 uint32_t write_time; /* write time (ms) */ 1028 } SFLHost_dsk_counters; 1029 1030 /* Virtual Node Statistics */ 1031 /* opaque = counter_data; enterprise = 0; format = 2100 */ 1032 1033 typedef struct _SFLHost_vrt_node_counters { 1034 uint32_t mhz; /* expected CPU frequency */ 1035 uint32_t cpus; /* the number of active CPUs */ 1036 uint64_t memory; /* memory size in bytes */ 1037 uint64_t memory_free; /* unassigned memory in bytes */ 1038 uint32_t num_domains; /* number of active domains */ 1039 } SFLHost_vrt_node_counters; 1040 1041 /* Virtual Domain Statistics */ 1042 /* opaque = counter_data; enterprise = 0; format = 2101 */ 1043 1044 /* virDomainState imported from libvirt.h */ 1045 enum SFLVirDomainState { 1046 SFL_VIR_DOMAIN_NOSTATE = 0, /* no state */ 1047 SFL_VIR_DOMAIN_RUNNING = 1, /* the domain is running */ 1048 SFL_VIR_DOMAIN_BLOCKED = 2, /* the domain is blocked on resource */ 1049 SFL_VIR_DOMAIN_PAUSED = 3, /* the domain is paused by user */ 1050 SFL_VIR_DOMAIN_SHUTDOWN= 4, /* the domain is being shut down */ 1051 SFL_VIR_DOMAIN_SHUTOFF = 5, /* the domain is shut off */ 1052 SFL_VIR_DOMAIN_CRASHED = 6 /* the domain is crashed */ 1053 }; 1054 1055 typedef struct _SFLHost_vrt_cpu_counters { 1056 uint32_t state; /* virtDomainState */ 1057 uint32_t cpuTime; /* the CPU time used in mS */ 1058 uint32_t cpuCount; /* number of virtual CPUs for the domain */ 1059 } SFLHost_vrt_cpu_counters; 1060 1061 /* Virtual Domain Memory statistics */ 1062 /* opaque = counter_data; enterprise = 0; format = 2102 */ 1063 1064 typedef struct _SFLHost_vrt_mem_counters { 1065 uint64_t memory; /* memory in bytes used by domain */ 1066 uint64_t maxMemory; /* memory in bytes allowed */ 1067 } SFLHost_vrt_mem_counters; 1068 1069 /* Virtual Domain Disk statistics */ 1070 /* opaque = counter_data; enterprise = 0; format = 2103 */ 1071 1072 typedef struct _SFLHost_vrt_dsk_counters { 1073 uint64_t capacity; /* logical size in bytes */ 1074 uint64_t allocation; /* current allocation in bytes */ 1075 uint64_t available; /* remaining free bytes */ 1076 uint32_t rd_req; /* number of read requests */ 1077 uint64_t rd_bytes; /* number of read bytes */ 1078 uint32_t wr_req; /* number of write requests */ 1079 uint64_t wr_bytes; /* number of written bytes */ 1080 uint32_t errs; /* read/write errors */ 1081 } SFLHost_vrt_dsk_counters; 1082 1083 /* Virtual Domain Network statistics */ 1084 /* opaque = counter_data; enterprise = 0; format = 2104 */ 1085 1086 typedef struct _SFLHost_vrt_nio_counters { 1087 uint64_t bytes_in; 1088 uint32_t pkts_in; 1089 uint32_t errs_in; 1090 uint32_t drops_in; 1091 uint64_t bytes_out; 1092 uint32_t pkts_out; 1093 uint32_t errs_out; 1094 uint32_t drops_out; 1095 } SFLHost_vrt_nio_counters; 1096 1097 /* NVML statistics */ 1098 /* opaque = counter_data; enterprise = 5703, format=1 */ 1099 typedef struct _SFLHost_gpu_nvml { 1100 uint32_t device_count; /* see nvmlGetDeviceCount */ 1101 uint32_t processes; /* see nvmlDeviceGetComputeRunningProcesses */ 1102 uint32_t gpu_time; /* total milliseconds in which one or more kernels was executing on GPU */ 1103 uint32_t mem_time; /* total milliseconds during which global device memory was being read/written */ 1104 uint64_t mem_total; /* bytes. see nvmlDeviceGetMemoryInfo */ 1105 uint64_t mem_free; /* bytes. see nvmlDeviceGetMemoryInfo */ 1106 uint32_t ecc_errors; /* see nvmlDeviceGetTotalEccErrors */ 1107 uint32_t energy; /* mJ. see nvmlDeviceGetPowerUsage */ 1108 uint32_t temperature; /* C. maximum across devices - see nvmlDeviceGetTemperature */ 1109 uint32_t fan_speed; /* %. maximum across devices - see nvmlDeviceGetFanSpeed */ 1110 } SFLHost_gpu_nvml; 1111 1112 /* Broadcom switch ASIC table utilizations */ 1113 /* opaque = counter_data; enterprise = 4413 (Broadcom); format = 3 */ 1114 typedef struct { 1115 uint32_t bcm_host_entries; 1116 uint32_t bcm_host_entries_max; 1117 uint32_t bcm_ipv4_entries; 1118 uint32_t bcm_ipv4_entries_max; 1119 uint32_t bcm_ipv6_entries; 1120 uint32_t bcm_ipv6_entries_max; 1121 uint32_t bcm_ipv4_ipv6_entries; 1122 uint32_t bcm_ipv4_ipv6_entries_max; 1123 uint32_t bcm_long_ipv6_entries; 1124 uint32_t bcm_long_ipv6_entries_max; 1125 uint32_t bcm_total_routes; 1126 uint32_t bcm_total_routes_max; 1127 uint32_t bcm_ecmp_nexthops; 1128 uint32_t bcm_ecmp_nexthops_max; 1129 uint32_t bcm_mac_entries; 1130 uint32_t bcm_mac_entries_max; 1131 uint32_t bcm_ipv4_neighbors; 1132 uint32_t bcm_ipv6_neighbors; 1133 uint32_t bcm_ipv4_routes; 1134 uint32_t bcm_ipv6_routes; 1135 uint32_t bcm_acl_ingress_entries; 1136 uint32_t bcm_acl_ingress_entries_max; 1137 uint32_t bcm_acl_ingress_counters; 1138 uint32_t bcm_acl_ingress_counters_max; 1139 uint32_t bcm_acl_ingress_meters; 1140 uint32_t bcm_acl_ingress_meters_max; 1141 uint32_t bcm_acl_ingress_slices; 1142 uint32_t bcm_acl_ingress_slices_max; 1143 uint32_t bcm_acl_egress_entries; 1144 uint32_t bcm_acl_egress_entries_max; 1145 uint32_t bcm_acl_egress_counters; 1146 uint32_t bcm_acl_egress_counters_max; 1147 uint32_t bcm_acl_egress_meters; 1148 uint32_t bcm_acl_egress_meters_max; 1149 uint32_t bcm_acl_egress_slices; 1150 uint32_t bcm_acl_egress_slices_max; 1151 } SFLBCM_tables; 1152 1153 ///////////// TCP/UDP/ICMP from MIB-II /////////////////////// 1154 1155 /* IP Group - see MIB-II */ 1156 /* opaque = counter_data; enterprise = 0; format = 2007 */ 1157 1158 typedef struct _SFLHost_IP_counters { 1159 uint32_t ipForwarding; 1160 uint32_t ipDefaultTTL; 1161 uint32_t ipInReceives; 1162 uint32_t ipInHdrErrors; 1163 uint32_t ipInAddrErrors; 1164 uint32_t ipForwDatagrams; 1165 uint32_t ipInUnknownProtos; 1166 uint32_t ipInDiscards; 1167 uint32_t ipInDelivers; 1168 uint32_t ipOutRequests; 1169 uint32_t ipOutDiscards; 1170 uint32_t ipOutNoRoutes; 1171 uint32_t ipReasmTimeout; 1172 uint32_t ipReasmReqds; 1173 uint32_t ipReasmOKs; 1174 uint32_t ipReasmFails; 1175 uint32_t ipFragOKs; 1176 uint32_t ipFragFails; 1177 uint32_t ipFragCreates; 1178 } SFLHost_IP_counters; 1179 1180 /* ICMP Group - see MIB-II */ 1181 /* opaque = counter_data; enterprise = 0; format = 2008 */ 1182 1183 typedef struct _SFLHost_ICMP_counters { 1184 uint32_t icmpInMsgs; 1185 uint32_t icmpInErrors; 1186 uint32_t icmpInDestUnreachs; 1187 uint32_t icmpInTimeExcds; 1188 uint32_t icmpInParamProbs; 1189 uint32_t icmpInSrcQuenchs; 1190 uint32_t icmpInRedirects; 1191 uint32_t icmpInEchos; 1192 uint32_t icmpInEchoReps; 1193 uint32_t icmpInTimestamps; 1194 uint32_t icmpInAddrMasks; 1195 uint32_t icmpInAddrMaskReps; 1196 uint32_t icmpOutMsgs; 1197 uint32_t icmpOutErrors; 1198 uint32_t icmpOutDestUnreachs; 1199 uint32_t icmpOutTimeExcds; 1200 uint32_t icmpOutParamProbs; 1201 uint32_t icmpOutSrcQuenchs; 1202 uint32_t icmpOutRedirects; 1203 uint32_t icmpOutEchos; 1204 uint32_t icmpOutEchoReps; 1205 uint32_t icmpOutTimestamps; 1206 uint32_t icmpOutTimestampReps; 1207 uint32_t icmpOutAddrMasks; 1208 uint32_t icmpOutAddrMaskReps; 1209 } SFLHost_ICMP_counters; 1210 1211 /* TCP Group - see MIB-II */ 1212 /* opaque = counter_data; enterprise = 0; format = 2009 */ 1213 1214 typedef struct _SFLHost_TCP_counters { 1215 uint32_t tcpRtoAlgorithm; 1216 uint32_t tcpRtoMin; 1217 uint32_t tcpRtoMax; 1218 uint32_t tcpMaxConn; 1219 uint32_t tcpActiveOpens; 1220 uint32_t tcpPassiveOpens; 1221 uint32_t tcpAttemptFails; 1222 uint32_t tcpEstabResets; 1223 uint32_t tcpCurrEstab; 1224 uint32_t tcpInSegs; 1225 uint32_t tcpOutSegs; 1226 uint32_t tcpRetransSegs; 1227 uint32_t tcpInErrs; 1228 uint32_t tcpOutRsts; 1229 uint32_t tcpInCsumErrors; 1230 } SFLHost_TCP_counters; 1231 1232 /* UDP Group - see MIB-II */ 1233 /* opaque = counter_data; enterprise = 0; format = 2010 */ 1234 1235 typedef struct _SFLHost_UDP_counters { 1236 uint32_t udpInDatagrams; 1237 uint32_t udpNoPorts; 1238 uint32_t udpInErrors; 1239 uint32_t udpOutDatagrams; 1240 uint32_t udpRcvbufErrors; 1241 uint32_t udpSndbufErrors; 1242 uint32_t udpInCsumErrors; 1243 } SFLHost_UDP_counters; 1244 1245 /* memcache */ 1246 /* opaque = counter_data; enterprise = 0; format = 2204 */ 1247 1248 typedef struct _SFLMemcache_counters { 1249 uint32_t uptime; /* not in 2204 */ 1250 uint32_t rusage_user; /* not in 2204 */ 1251 uint32_t rusage_system; /* not in 2204 */ 1252 uint32_t cmd_get; /* not in 2204 */ 1253 uint32_t accepting_conns; /* not in 2204 */ 1254 uint32_t cmd_set; 1255 uint32_t cmd_touch; /* added for 2204 */ 1256 uint32_t cmd_flush; 1257 uint32_t get_hits; 1258 uint32_t get_misses; 1259 uint32_t delete_hits; 1260 uint32_t delete_misses; 1261 uint32_t incr_hits; 1262 uint32_t incr_misses; 1263 uint32_t decr_hits; 1264 uint32_t decr_misses; 1265 uint32_t cas_hits; 1266 uint32_t cas_misses; 1267 uint32_t cas_badval; 1268 uint32_t auth_cmds; 1269 uint32_t auth_errors; 1270 uint32_t threads; 1271 uint32_t conn_yields; 1272 uint32_t listen_disabled_num; 1273 uint32_t curr_connections; 1274 uint32_t rejected_connections; /* added for 2204 */ 1275 uint32_t total_connections; 1276 uint32_t connection_structures; 1277 uint32_t evictions; 1278 uint32_t reclaimed; /* added for 2204 */ 1279 uint32_t curr_items; 1280 uint32_t total_items; 1281 uint64_t bytes_read; 1282 uint64_t bytes_written; 1283 uint64_t bytes; 1284 uint64_t limit_maxbytes; /* converted to 64-bit for structure 2204 */ 1285 } SFLMemcache_counters; 1286 1287 /* http */ 1288 /* opaque = counter_data; enterprise = 0; format = 2201 */ 1289 1290 typedef struct _SFLHTTP_counters { 1291 uint32_t method_option_count; 1292 uint32_t method_get_count; 1293 uint32_t method_head_count; 1294 uint32_t method_post_count; 1295 uint32_t method_put_count; 1296 uint32_t method_delete_count; 1297 uint32_t method_trace_count; 1298 uint32_t methd_connect_count; 1299 uint32_t method_other_count; 1300 uint32_t status_1XX_count; 1301 uint32_t status_2XX_count; 1302 uint32_t status_3XX_count; 1303 uint32_t status_4XX_count; 1304 uint32_t status_5XX_count; 1305 uint32_t status_other_count; 1306 } SFLHTTP_counters; 1307 1308 1309 /* Enterprise counters */ 1310 /* opaque = counter_data; enterprise = 0; format = 2202 */ 1311 typedef struct _SFLAPP_counters { 1312 SFLString application; 1313 uint32_t status_OK; 1314 uint32_t errors_OTHER; 1315 uint32_t errors_TIMEOUT; 1316 uint32_t errors_INTERNAL_ERROR; 1317 uint32_t errors_BAD_REQUEST; 1318 uint32_t errors_FORBIDDEN; 1319 uint32_t errors_TOO_LARGE; 1320 uint32_t errors_NOT_IMPLEMENTED; 1321 uint32_t errors_NOT_FOUND; 1322 uint32_t errors_UNAVAILABLE; 1323 uint32_t errors_UNAUTHORIZED; 1324 } SFLAPP_counters; 1325 1326 /* Enterprise resource counters */ 1327 /* opaque = counter_data; enterprise = 0; format = 2203 */ 1328 typedef struct { 1329 uint32_t user_time; /* in milliseconds */ 1330 uint32_t system_time; /* in milliseconds */ 1331 uint64_t mem_used; 1332 uint64_t mem_max; 1333 uint32_t fd_open; 1334 uint32_t fd_max; 1335 uint32_t conn_open; 1336 uint32_t conn_max; 1337 } SFLAPP_resources; 1338 1339 /* Enterprise application workers */ 1340 /* opaque = counter_data; enterprise = 0; format = 2206 */ 1341 1342 typedef struct { 1343 uint32_t workers_active; 1344 uint32_t workers_idle; 1345 uint32_t workers_max; 1346 uint32_t req_delayed; 1347 uint32_t req_dropped; 1348 } SFLAPP_workers; 1349 1350 typedef struct _SFLJVM_ID { 1351 SFLString vm_name; 1352 SFLString vm_vendor; 1353 SFLString vm_version; 1354 } SFLJVM_ID; 1355 1356 #define SFLJVM_MAX_VMNAME_LEN 64 1357 #define SFLJVM_MAX_VENDOR_LEN 32 1358 #define SFLJVM_MAX_VERSION_LEN 32 1359 1360 typedef struct _SFLJMX_counters { 1361 uint64_t hmem_initial; 1362 uint64_t hmem_used; 1363 uint64_t hmem_committed; 1364 uint64_t hmem_max; 1365 uint64_t nhmem_initial; 1366 uint64_t nhmem_used; 1367 uint64_t nhmem_committed; 1368 uint64_t nhmem_max; 1369 uint32_t gc_count; 1370 uint32_t gc_ms; 1371 uint32_t cls_loaded; 1372 uint32_t cls_total; 1373 uint32_t cls_unloaded; 1374 uint32_t comp_ms; 1375 uint32_t thread_live; 1376 uint32_t thread_daemon; 1377 uint32_t thread_started; 1378 uint32_t fds_open; 1379 uint32_t fds_max; 1380 } SFLJMX_counters; 1381 1382 #define XDRSIZ_JMX_COUNTERS 108 1383 1384 typedef struct _SFLVdi_counters { 1385 uint32_t sessions_current; /* number of current sessions */ 1386 uint32_t sessions_total; /* total sessions started */ 1387 uint32_t sessions_duration; /* cumulative session time (in seconds) 1388 across all sessions, such that average 1389 session duration = sessions_duration 1390 / sessions_total */ 1391 uint32_t rx_bytes; /* total bytes received */ 1392 uint32_t tx_bytes; /* total bytes sent */ 1393 uint32_t rx_packets; /* total packet received */ 1394 uint32_t tx_packets; /* total packets sent */ 1395 uint32_t rx_packets_lost; /* total received packets lost */ 1396 uint32_t tx_packets_lost; /* total sent packets lost */ 1397 uint32_t rtt_min_ms; /* minimum round trip latency with client 1398 across all current sessions 1399 measured in milliseconds */ 1400 uint32_t rtt_max_ms; /* maximum round trip latency with client 1401 across all current sessions 1402 measured in millisecond */ 1403 uint32_t rtt_avg_ms; /* average round trip latency with client 1404 across all current sessions 1405 measured in milliseconds */ 1406 uint32_t audio_rx_bytes; /* total bytes of audio data received */ 1407 uint32_t audio_tx_bytes; /* total bytes of audio data sent */ 1408 uint32_t audio_tx_limit; /* administrative limit on audio transmission 1409 bandwidth (in bits per second) */ 1410 uint32_t img_rx_bytes; /* total bytes of imaging data recieved */ 1411 uint32_t img_tx_bytes; /* total bytes of imaging data sent */ 1412 uint32_t img_frames; /* total image frames encoded */ 1413 uint32_t img_qual_min; /* minimum image encoding quality across 1414 current sessions, on a scale of 0 to 100 */ 1415 uint32_t img_qual_max; /* best image encoding quality across 1416 current sessions, on a scale of 0 to 100 */ 1417 uint32_t img_qual_avg; /* average image encoding quality across 1418 current sessions, on a scale of 0 to 100 */ 1419 uint32_t usb_rx_bytes; /* total bytes of usb data received */ 1420 uint32_t usb_tx_bytes; /* total bytes of usb data sent */ 1421 } SFLVdi_counters; 1422 1423 /* LAG Port Statistics - see IEEE8023-LAG-MIB */ 1424 /* opaque = counter_data; enterprise = 0; format = 7 */ 1425 typedef union _SFLLACP_portState { 1426 uint32_t all; 1427 struct { 1428 uint8_t actorAdmin; 1429 uint8_t actorOper; 1430 uint8_t partnerAdmin; 1431 uint8_t partnerOper; 1432 } v; 1433 } SFLLACP_portState; 1434 1435 typedef struct _SFLLACP_counters { 1436 uint8_t actorSystemID[8]; /* 6 bytes + 2 pad */ 1437 uint8_t partnerSystemID[8]; /* 6 bytes + 2 pad */ 1438 uint32_t attachedAggID; 1439 SFLLACP_portState portState; 1440 uint32_t LACPDUsRx; 1441 uint32_t markerPDUsRx; 1442 uint32_t markerResponsePDUsRx; 1443 uint32_t unknownRx; 1444 uint32_t illegalRx; 1445 uint32_t LACPDUsTx; 1446 uint32_t markerPDUsTx; 1447 uint32_t markerResponsePDUsTx; 1448 } SFLLACP_counters; 1449 1450 #define XDRSIZ_LACP_COUNTERS 56 1451 1452 /* openflow port */ 1453 /* opaque = counter_data; enterprise = 0; format = 1004 */ 1454 typedef struct { 1455 uint64_t datapath_id; 1456 uint32_t port_no; 1457 } SFLOFPort; 1458 1459 #define XDRSIZ_OFPORT 12 1460 1461 /* port name */ 1462 /* opaque = counter_data; enterprise = 0; format = 1005 */ 1463 typedef struct { 1464 SFLString portName; 1465 } SFLPortName; 1466 1467 #define SFL_MAX_PORTNAME_LEN 255 1468 1469 /* OVS datapath stats */ 1470 typedef struct _SFLOVSDP_counters { 1471 uint32_t n_hit; 1472 uint32_t n_missed; 1473 uint32_t n_lost; 1474 uint32_t n_mask_hit; 1475 uint32_t n_flows; 1476 uint32_t n_masks; 1477 } SFLOVSDP_counters; 1478 1479 #define XDRSIZE_OVSDP 24 1480 1481 /* Optical SFP/QSFP metrics */ 1482 /* opaque = counter_data; enterprise = 0; format = 10 */ 1483 1484 typedef struct { 1485 uint32_t lane_index; /* index of lane in module - starting from 1 */ 1486 uint32_t tx_bias_current; /* microamps */ 1487 uint32_t tx_power; /* microwatts */ 1488 uint32_t tx_power_min; /* microwatts */ 1489 uint32_t tx_power_max; /* microwatts */ 1490 uint32_t tx_wavelength; /* nanometers */ 1491 uint32_t rx_power; /* microwatts */ 1492 uint32_t rx_power_min; /* microwatts */ 1493 uint32_t rx_power_max; /* microwatts */ 1494 uint32_t rx_wavelength; /* nanometers */ 1495 } SFLLane; 1496 1497 #define XDRSIZ_LANE_COUNTERS 40 1498 1499 typedef struct { 1500 uint32_t module_id; 1501 uint32_t module_total_lanes; /* total lanes in module */ 1502 uint32_t module_supply_voltage; /* millivolts */ 1503 int32_t module_temperature; /* signed - in oC / 1000 */ 1504 uint32_t num_lanes; /* number of active lane structs to come */ 1505 SFLLane *lanes; 1506 } SFLSFP_counters; 1507 1508 /* Counters data */ 1509 1510 enum SFLCounters_type_tag { 1511 /* enterprise = 0, format = ... */ 1512 SFLCOUNTERS_GENERIC = 1, 1513 SFLCOUNTERS_ETHERNET = 2, 1514 SFLCOUNTERS_TOKENRING = 3, 1515 SFLCOUNTERS_VG = 4, 1516 SFLCOUNTERS_VLAN = 5, 1517 SFLCOUNTERS_80211 = 6, 1518 SFLCOUNTERS_LACP = 7, 1519 SFLCOUNTERS_SFP = 10, 1520 SFLCOUNTERS_PROCESSOR = 1001, 1521 SFLCOUNTERS_RADIO = 1002, 1522 SFLCOUNTERS_OFPORT = 1004, 1523 SFLCOUNTERS_PORTNAME = 1005, 1524 SFLCOUNTERS_HOST_HID = 2000, /* host id */ 1525 SFLCOUNTERS_ADAPTORS = 2001, /* host adaptors */ 1526 SFLCOUNTERS_HOST_PAR = 2002, /* host parent */ 1527 SFLCOUNTERS_HOST_CPU = 2003, /* host cpu */ 1528 SFLCOUNTERS_HOST_MEM = 2004, /* host memory */ 1529 SFLCOUNTERS_HOST_DSK = 2005, /* host storage I/O */ 1530 SFLCOUNTERS_HOST_NIO = 2006, /* host network I/O */ 1531 SFLCOUNTERS_HOST_IP = 2007, 1532 SFLCOUNTERS_HOST_ICMP = 2008, 1533 SFLCOUNTERS_HOST_TCP = 2009, 1534 SFLCOUNTERS_HOST_UDP = 2010, 1535 SFLCOUNTERS_HOST_VRT_NODE = 2100, /* host virt node */ 1536 SFLCOUNTERS_HOST_VRT_CPU = 2101, /* host virt cpu */ 1537 SFLCOUNTERS_HOST_VRT_MEM = 2102, /* host virt mem */ 1538 SFLCOUNTERS_HOST_VRT_DSK = 2103, /* host virt storage */ 1539 SFLCOUNTERS_HOST_VRT_NIO = 2104, /* host virt network I/O */ 1540 SFLCOUNTERS_JVM = 2105, /* java runtime */ 1541 SFLCOUNTERS_JMX = 2106, /* java JMX stats */ 1542 SFLCOUNTERS_MEMCACHE = 2200, /* memcached (deprecated) */ 1543 SFLCOUNTERS_HTTP = 2201, /* http */ 1544 SFLCOUNTERS_APP = 2202, 1545 SFLCOUNTERS_APP_RESOURCE = 2203, 1546 SFLCOUNTERS_MEMCACHE2 = 2204, /* memcached */ 1547 SFLCOUNTERS_VDI = 2205, 1548 SFLCOUNTERS_APP_WORKERS = 2206, 1549 SFLCOUNTERS_OVSDP = 2207, 1550 SFLCOUNTERS_HOST_GPU_NVML = (5703 << 12) + 1, /* = 23359489 */ 1551 SFLCOUNTERS_BCM_TABLES = (4413 << 12) + 3, 1552 }; 1553 1554 typedef union _SFLCounters_type { 1555 SFLIf_counters generic; 1556 SFLEthernet_counters ethernet; 1557 SFLTokenring_counters tokenring; 1558 SFLVg_counters vg; 1559 SFLVlan_counters vlan; 1560 SFLWifi_counters wifi; 1561 SFLProcessor_counters processor; 1562 SFLRadio_counters radio; 1563 SFLHostId hostId; 1564 SFLAdaptorList *adaptors; 1565 SFLHost_parent host_par; 1566 SFLHost_cpu_counters host_cpu; 1567 SFLHost_mem_counters host_mem; 1568 SFLHost_dsk_counters host_dsk; 1569 SFLHost_nio_counters host_nio; 1570 SFLHost_IP_counters host_ip; 1571 SFLHost_ICMP_counters host_icmp; 1572 SFLHost_TCP_counters host_tcp; 1573 SFLHost_UDP_counters host_udp; 1574 SFLHost_vrt_node_counters host_vrt_node; 1575 SFLHost_vrt_cpu_counters host_vrt_cpu; 1576 SFLHost_vrt_mem_counters host_vrt_mem; 1577 SFLHost_vrt_dsk_counters host_vrt_dsk; 1578 SFLHost_vrt_nio_counters host_vrt_nio; 1579 SFLHost_gpu_nvml host_gpu_nvml; 1580 SFLBCM_tables bcm_tables; 1581 SFLMemcache_counters memcache; 1582 SFLHTTP_counters http; 1583 SFLJVM_ID jvm; 1584 SFLJMX_counters jmx; 1585 SFLAPP_counters app; 1586 SFLAPP_resources appResources; 1587 SFLAPP_workers appWorkers; 1588 SFLVdi_counters vdi; 1589 SFLLACP_counters lacp; 1590 SFLPortName portName; 1591 SFLSFP_counters sfp; 1592 SFLOVSDP_counters ovsdp; 1593 } SFLCounters_type; 1594 1595 typedef struct _SFLCounters_sample_element { 1596 struct _SFLCounters_sample_element *nxt; /* linked list */ 1597 uint32_t tag; /* SFLCounters_type_tag */ 1598 uint32_t length; 1599 SFLCounters_type counterBlock; 1600 } SFLCounters_sample_element; 1601 1602 typedef struct _SFLCounters_sample { 1603 /* uint32_t tag; */ /* SFL_sample_tag -- enterprise = 0 : format = 2 */ 1604 /* uint32_t length; */ 1605 uint32_t sequence_number; /* Incremented with each counters sample 1606 generated by this source_id */ 1607 uint32_t source_id; /* fsSourceId */ 1608 uint32_t num_elements; 1609 SFLCounters_sample_element *elements; 1610 } SFLCounters_sample; 1611 1612 /* same thing, but the expanded version, so ds_index can be a full 32 bits */ 1613 typedef struct _SFLCounters_sample_expanded { 1614 /* uint32_t tag; */ /* SFL_sample_tag -- enterprise = 0 : format = 2 */ 1615 /* uint32_t length; */ 1616 uint32_t sequence_number; /* Incremented with each counters sample 1617 generated by this source_id */ 1618 uint32_t ds_class; /* EXPANDED */ 1619 uint32_t ds_index; /* EXPANDED */ 1620 uint32_t num_elements; 1621 SFLCounters_sample_element *elements; 1622 } SFLCounters_sample_expanded; 1623 1624 #define SFLADD_ELEMENT(_sm, _el) do { (_el)->nxt = (_sm)->elements; (_sm)->elements = (_el); } while(0) 1625 1626 /* Format of a sample datagram */ 1627 1628 enum SFLDatagram_version { 1629 SFLDATAGRAM_VERSION2 = 2, 1630 SFLDATAGRAM_VERSION4 = 4, 1631 SFLDATAGRAM_VERSION5 = 5 1632 }; 1633 1634 typedef struct _SFLSample_datagram_hdr { 1635 uint32_t datagram_version; /* (enum SFLDatagram_version) = VERSION5 = 5 */ 1636 SFLAddress agent_address; /* IP address of sampling agent */ 1637 uint32_t sub_agent_id; /* Used to distinguishing between datagram 1638 streams from separate agent sub entities 1639 within an device. */ 1640 uint32_t sequence_number; /* Incremented with each sample datagram 1641 generated */ 1642 uint32_t uptime; /* Current time (in milliseconds since device 1643 last booted). Should be set as close to 1644 datagram transmission time as possible.*/ 1645 uint32_t num_records; /* Number of tag-len-val flow/counter records to follow */ 1646 } SFLSample_datagram_hdr; 1647 1648 #define SFL_MAX_DATAGRAM_SIZE 1500 1649 #define SFL_MIN_DATAGRAM_SIZE 200 1650 #define SFL_DEFAULT_DATAGRAM_SIZE 1400 1651 1652 #define SFL_DATA_PAD 400 1653 1654 #if defined(__cplusplus) 1655 } /* extern "C" */ 1656 #endif 1657 1658 #endif /* SFLOW_H */ 1659