/***********************************************************************1* *2* This software is part of the ast package *3* Copyright (c) 2002-2011 AT&T Intellectual Property *4* and is licensed under the *5* Eclipse Public License, Version 1.0 *6* by AT&T Intellectual Property *7* *8* A copy of the License is available at *9* http://www.eclipse.org/org/documents/epl-v10.html *10* (with md5 checksum b35adb5213ca9657e911e9befb180842) *11* *12* Information and Software Systems Research *13* AT&T Research *14* Florham Park NJ *15* *16* Glenn Fowler <[email protected]> *17* *18***********************************************************************/19#pragma prototyped20/*21* cisco netflow data interface22*23* Glenn Fowler24* AT&T Research25*/2627#ifndef _NETFLOW_H28#define _NETFLOW_H2930#include <ast_common.h>3132#define NETFLOW_PACKET 14643334#define NETFLOW_SET_bgp_hopv4 (1<<0)35#define NETFLOW_SET_bgp_hopv6 (1<<1)36#define NETFLOW_SET_dst_addrv4 (1<<2)37#define NETFLOW_SET_dst_addrv6 (1<<3)38#define NETFLOW_SET_hopv4 (1<<4)39#define NETFLOW_SET_hopv6 (1<<5)40#define NETFLOW_SET_router_scv4 (1<<6)41#define NETFLOW_SET_router_scv6 (1<<7)42#define NETFLOW_SET_src_addrv4 (1<<8)43#define NETFLOW_SET_src_addrv6 (1<<9)4445/* (V9) index order */4647#define NETFLOW_in_bytes 148#define NETFLOW_in_packets 249#define NETFLOW_flows 350#define NETFLOW_protocol 451#define NETFLOW_src_tos 552#define NETFLOW_tcp_flags 653#define NETFLOW_src_port 754#define NETFLOW_src_addrv4 855#define NETFLOW_src_maskv4 956#define NETFLOW_input_snmp 1057#define NETFLOW_dst_port 1158#define NETFLOW_dst_addrv4 1259#define NETFLOW_dst_maskv4 1360#define NETFLOW_output_snmp 1461#define NETFLOW_hopv4 1562#define NETFLOW_src_as 1663#define NETFLOW_dst_as 1764#define NETFLOW_bgp_hopv4 1865#define NETFLOW_mul_dst_packets 1966#define NETFLOW_mul_dst_bytes 2067#define NETFLOW_last 2168#define NETFLOW_first 2269#define NETFLOW_out_bytes 2370#define NETFLOW_out_packets 2471#define NETFLOW_min_packet_length 2572#define NETFLOW_max_packet_length 2673#define NETFLOW_src_addrv6 2774#define NETFLOW_dst_addrv6 2875#define NETFLOW_src_maskv6 2976#define NETFLOW_dst_maskv6 3077#define NETFLOW_flow_label 3178#define NETFLOW_icmp_type 3279#define NETFLOW_mul_igmp_type 3380#define NETFLOW_sampler_interval 3481#define NETFLOW_sampler_algorithm 3582#define NETFLOW_flow_active_timeout 3683#define NETFLOW_flow_inactive_timeout 3784#define NETFLOW_engine_type 3885#define NETFLOW_engine_id 3986#define NETFLOW_total_bytes_exp 4087#define NETFLOW_total_packets_exp 4188#define NETFLOW_total_flows_exp 4289#define NETFLOW_vendor_43 4390#define NETFLOW_src_prefixv4 4491#define NETFLOW_dst_prefixv4 4592#define NETFLOW_mpls_top_label_type 4693#define NETFLOW_mpls_top_label_class 4794#define NETFLOW_sampler_id 4895#define NETFLOW_sampler_mode 4996#define NETFLOW_sampler_random_interval 5097#define NETFLOW_vendor_51 5198#define NETFLOW_min_ttl 5299#define NETFLOW_max_ttl 53100#define NETFLOW_ident 54101#define NETFLOW_dst_tos 55102#define NETFLOW_in_src_mac 56103#define NETFLOW_out_dst_mac 57104#define NETFLOW_src_vlan 58105#define NETFLOW_dst_vlan 59106#define NETFLOW_ip_protocol_version 60107#define NETFLOW_direction 61108#define NETFLOW_hopv6 62109#define NETFLOW_bgp_hopv6 63110#define NETFLOW_option_headers 64111#define NETFLOW_vendor_65 65112#define NETFLOW_vendor_66 66113#define NETFLOW_vendor_67 67114#define NETFLOW_vendor_68 68115#define NETFLOW_vendor_69 69116#define NETFLOW_mpls_label_1 70117#define NETFLOW_mpls_label_2 71118#define NETFLOW_mpls_label_3 72119#define NETFLOW_mpls_label_4 73120#define NETFLOW_mpls_label_5 74121#define NETFLOW_mpls_label_6 75122#define NETFLOW_mpls_label_7 76123#define NETFLOW_mpls_label_8 77124#define NETFLOW_mpls_label_9 78125#define NETFLOW_mpls_label_10 79126#define NETFLOW_in_dst_mac 80127#define NETFLOW_out_src_mac 81128#define NETFLOW_if_name 82129#define NETFLOW_if_desc 83130#define NETFLOW_sampler_name 84131#define NETFLOW_in_permanent_bytes 85132#define NETFLOW_in_permanent_packets 86133#define NETFLOW_vendor_87 87134#define NETFLOW_fragment_offset 88135#define NETFLOW_forwarding_status 89136137#define NETFLOW_TEMPLATE 89138139#define NETFLOW_bytes 90140#define NETFLOW_count 91141#define NETFLOW_dst_as16 92142#define NETFLOW_dst_as32 93143#define NETFLOW_end 94144#define NETFLOW_flags 95145#define NETFLOW_flow_sequence 96146#define NETFLOW_forwarding_code 97147#define NETFLOW_nsec 98148#define NETFLOW_packets 99149#define NETFLOW_router_scv4 100150#define NETFLOW_router_scv6 101151#define NETFLOW_src_as16 102152#define NETFLOW_src_as32 103153#define NETFLOW_start 104154#define NETFLOW_tcp_misseq_cnt 105155#define NETFLOW_tcp_retx_cnt 106156#define NETFLOW_tcp_retx_secs 107157#define NETFLOW_time 108158#define NETFLOW_uptime 109159#define NETFLOW_version 110160161#define NETFLOW_HEADER 110162163#define NETFLOW_dst_addr 111164#define NETFLOW_dst_mask 112165#define NETFLOW_dst_prefix 113166#define NETFLOW_dst_prefixv6 114167#define NETFLOW_hop 115168#define NETFLOW_router_sc 116169#define NETFLOW_src_addr 117170#define NETFLOW_src_mask 118171#define NETFLOW_src_prefix 119172#define NETFLOW_src_prefixv6 120173#define NETFLOW_tos 121174175#define NETFLOW_GENERIC 121176177typedef uint8_t Nfbyte_t;178typedef uint16_t Nfshort_t;179typedef uint32_t Nflong_t;180typedef uintmax_t Nftime_t;181typedef uintmax_t Nfcount_t;182typedef unsigned char Nfaddr_t[16];183typedef unsigned char Nfprefix_t[17];184typedef unsigned char Nfname_t[32];185186/*187* canonical netflow data188*/189190typedef struct Netflow_s191{192193/* (V1-7) */194195Nflong_t src_addrv4; /* ipv4 source address */196Nflong_t dst_addrv4; /* ipv4 destination address */197Nflong_t hopv4; /* ipv4 address of next hop router */198Nfshort_t input; /* Input interface index */199Nfshort_t output; /* Output interface index */200Nflong_t packets; /* Packets sent in Duration */201Nflong_t bytes; /* Bytes sent in Duration. */202Nflong_t first; /* SysUptime at start of flow */203Nflong_t last; /* and of last packet of flow */204Nfshort_t src_port; /* TCP/UDP source port number */205Nfshort_t dst_port; /* TCP/UDP destination port number */206207Nfbyte_t flags; /* Reason flow was discarded, etc... */208Nfbyte_t tcp_flags; /* Cumulative OR of tcp flags for this flow */209Nfbyte_t protocol; /* ip protocol, e.g., 6=TCP, 17=UDP, ... */210Nfbyte_t src_tos; /* ip Type-of-Service upon entering incoming interface */211212/* (V5) */213214Nfshort_t src_as16; /* 16 bit source BGP autonomous system number */215Nfshort_t dst_as16; /* 16 bit destination BGP autonomous system number */216Nfbyte_t src_maskv4; /* ipv4 source address prefix mask bits */217Nfbyte_t dst_maskv4; /* ipv4 destination address prefix mask bits */218Nfshort_t pad5;219220/* (V7) */221222Nflong_t router_scv4; /* ipv4 address of router shortcut by switch (V7) */223224/* (V1) */225226Nfbyte_t pad1;227Nfbyte_t tcp_retx_cnt; /* # mis-seq with delay > 1sec (V1) */228Nfbyte_t tcp_retx_secs; /* # seconds between mis-sequenced packets (V1) */229Nfbyte_t tcp_misseq_cnt; /* # mis-sequenced tcp packets (V1) */230231/* (V1-7) header */232233Nfshort_t version; /* Record version (header). */234Nfshort_t count; /* # records in packet (header). */235Nflong_t uptime; /* Elapsed millisecs since router booted (header). */236Nflong_t time; /* Current time since epoch (header). */237Nflong_t nsec; /* Residual nanoseconds (header). */238Nflong_t flow_sequence; /* Seq counter of total flows seen (header). */239Nfbyte_t engine_type; /* Type of flow switching engine 0: RP, 1: Vip/linecard */240Nfbyte_t engine_id; /* ID number of the flow switching engine */241Nfshort_t sampler_interval;/* Sampling interval. */242Nfbyte_t sampler_mode; /* Algorithm used for sampling data: 0x02 random sampling */243244/* header, synthesized, and (V8...) */245246#define NETFLOW_GROUP_8_BEGIN start247248Nftime_t start; /* nanoseconds since epoch at flow start (synthesized) */249Nftime_t end; /* nanoseconds since epoch at flow end (synthesized) */250251Nfcount_t in_packets; /* Incoming counter for the number of packets associated with an ip Flow */252Nfcount_t in_bytes; /* Incoming counter for the number of bytes associated with an ip Flow */253Nfcount_t mul_dst_bytes; /* Multicast outgoing byte count */254Nfcount_t mul_dst_packets;/* Multicast outgoing packet count */255Nfcount_t out_bytes; /* Outgoing counter for the number of bytes associated with an ip Flow */256Nfcount_t out_packets; /* Outgoing counter for the number of packets associated with an ip Flow */257Nfcount_t flows; /* Number of flows that were aggregated */258Nfcount_t total_bytes_exp;/* The number of bytes exported by the observation domain */259Nfcount_t total_packets_exp;/* The number of packets exported by the observation domain */260Nfcount_t total_flows_exp;/* The number of flows exported by the observation domain */261Nfcount_t input_snmp; /* Input interface index */262Nfcount_t output_snmp; /* Output interface index */263Nfcount_t in_src_mac; /* Incoming source MAC address */264Nfcount_t out_dst_mac; /* Outgoing destination MAC address */265Nfcount_t in_dst_mac; /* Incoming destination MAC address */266Nfcount_t out_src_mac; /* Outgoing source MAC address */267Nfcount_t in_permanent_bytes;/* Permanent flow byte count */268Nfcount_t in_permanent_packets;/* Permanent flow packet count */269270Nfcount_t vendor_43; /* vendor private value */271Nfcount_t vendor_51; /* vendor private value */272Nfcount_t vendor_65; /* vendor private value */273Nfcount_t vendor_66; /* vendor private value */274Nfcount_t vendor_67; /* vendor private value */275Nfcount_t vendor_68; /* vendor private value */276Nfcount_t vendor_69; /* vendor private value */277Nfcount_t vendor_87; /* vendor private value */278279#define NETFLOW_GROUP_4_BEGIN set280281Nflong_t set; /* NETFLOW_SET_* set bits */282Nflong_t bgp_hopv4; /* Next hop router's ipv4 address in the BGP domain */283Nflong_t flow_label; /* ipv6 RFC 2460 flow label */284Nflong_t src_prefixv4 ;/* ipv4 source address prefix (catalyst architecture only) */285Nflong_t dst_prefixv4; /* ipv4 destination address prefix (catalyst architecture only) */286Nflong_t src_as32; /* 32 bit source BGP autonomous system number */287Nflong_t dst_as32; /* 32 bit destination BGP autonomous system number */288Nflong_t mpls_top_label_class;/* Forwarding Equivalent Class corresponding to the MPLS Top Label */289Nflong_t sampler_random_interval;/* Packet interval at which to sample */290Nflong_t option_headers;/* Bit-encoded field identifying ipv6 option headers found in the flow */291Nflong_t mpls_label_1; /* Stack position 1 MPLS label: 20 bits MPLS label, 3 bits experimental, 1 bit end-of-stack */292Nflong_t mpls_label_2; /* Stack position 2 MPLS label: 20 bits MPLS label, 3 bits experimental, 1 bit end-of-stack */293Nflong_t mpls_label_3; /* Stack position 3 MPLS label: 20 bits MPLS label, 3 bits experimental, 1 bit end-of-stack */294Nflong_t mpls_label_4; /* Stack position 4 MPLS label: 20 bits MPLS label, 3 bits experimental, 1 bit end-of-stack */295Nflong_t mpls_label_5; /* Stack position 5 MPLS label: 20 bits MPLS label, 3 bits experimental, 1 bit end-of-stack */296Nflong_t mpls_label_6; /* Stack position 6 MPLS label: 20 bits MPLS label, 3 bits experimental, 1 bit end-of-stack */297Nflong_t mpls_label_7; /* Stack position 7 MPLS label: 20 bits MPLS label, 3 bits experimental, 1 bit end-of-stack */298Nflong_t mpls_label_8; /* Stack position 8 MPLS label: 20 bits MPLS label, 3 bits experimental, 1 bit end-of-stack */299Nflong_t mpls_label_9; /* Stack position 9 MPLS label: 20 bits MPLS label, 3 bits experimental, 1 bit end-of-stack */300Nflong_t mpls_label_10; /* Stack position 10 MPLS label: 20 bits MPLS label, 3 bits experimental, 1 bit end-of-stack */301Nflong_t source_id; /* flow source id */302303#define NETFLOW_GROUP_2_BEGIN min_packet_length304305Nfshort_t min_packet_length;/* Minimum incoming ip packet length */306Nfshort_t max_packet_length;/* Maximum incoming ip packet length */307Nfshort_t icmp_type; /* Internet Control Message Protocol packet type coded as ((type*256)+code) */308Nfshort_t mul_igmp_type; /* Internet Group Management Protocol packet type coded */309Nfshort_t flow_active_timeout;/* Timeout value (in seconds) for active flow cache entries */310Nfshort_t flow_inactive_timeout;/* Timeout value (in seconds) for inactive flow cache entries */311Nfshort_t ident; /* ipv4 identification field */312Nfshort_t src_vlan; /* Virtual LAN identifier associated with ingress interface */313Nfshort_t dst_vlan; /* Virtual LAN identifier associated with egress interface */314Nfshort_t fragment_offset;/* Fragmented packet fragment-offset */315316#define NETFLOW_GROUP_1_BEGIN sampler_algorithm317318Nfbyte_t sampler_algorithm;/* 0x01: deterministic, 0x02: random */319Nfbyte_t mpls_top_label_type;/* MPLS Top Label Type: 0x00 UNKNOWN 0x01 TE-MIDPT 0x02 ATOM 0x03 VPN 0x04 BGP 0x05 LDP */320Nfbyte_t sampler_id; /* Flow sampler ID */321Nfbyte_t min_ttl; /* Minimum TTL on incoming packets */322Nfbyte_t max_ttl; /* Maximum TTL on incoming packets */323Nfbyte_t dst_tos; /* Type of Service on exiting outgoing interface */324Nfbyte_t ip_protocol_version; /* ip version 6: ipv6, 4 or not specified: ipv4 */325Nfbyte_t direction; /* Flow direction: 0 - ingress flow, 1 - egress flow */326Nfbyte_t forwarding_status;/* Forwarding status 0: unknown, 1: forwarded, 2: dropped, 3: consumed */327Nfbyte_t forwarding_code;/* Forwarding reason code */328Nfbyte_t src_maskv6; /* ipv6 source address prefix mask bits */329Nfbyte_t dst_maskv6; /* ipv6 destination address prefix mask bits */330331Nfprefix_t src_addrv6; /* ipv6 source address/prefix */332Nfprefix_t dst_addrv6; /* ipv6 destination address/prefix */333334Nfaddr_t bgp_hopv6; /* Next hop router ipv6 address in the BGP domain */335Nfaddr_t hopv6; /* ipv6 address of next hop router */336Nfaddr_t router_scv6; /* ipv4 address of router shortcut by switch (V7) */337338Nfname_t if_name; /* Shortened interface name */339Nfname_t if_desc; /* Full interface name */340Nfname_t sampler_name; /* Flow sampler name */341342} Netflow_t;343344#endif345346347