Flow: Rename IPFIX exporter.
Change-Id: I9363cf54b73f7cfd8622af6f1cb250438ea0d3b6 Signed-off-by: Ole Troan <ot@cisco.com>
This commit is contained in:
@ -1,149 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015-2016 Cisco and/or its affiliates.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
option version = "1.0.0";
|
||||
|
||||
/** \brief Configure IPFIX exporter process request
|
||||
@param client_index - opaque cookie to identify the sender
|
||||
@param context - sender context, to match reply w/ request
|
||||
@param collector_address - address of IPFIX collector
|
||||
@param collector_port - port of IPFIX collector
|
||||
@param src_address - address of IPFIX exporter
|
||||
@param vrf_id - VRF / fib table ID
|
||||
@param path_mtu - Path MTU between exporter and collector
|
||||
@param template_interval - number of seconds after which to resend template
|
||||
@param udp_checksum - UDP checksum calculation enable flag
|
||||
*/
|
||||
autoreply define set_ipfix_exporter
|
||||
{
|
||||
u32 client_index;
|
||||
u32 context;
|
||||
u8 collector_address[16];
|
||||
u16 collector_port;
|
||||
u8 src_address[16];
|
||||
u32 vrf_id;
|
||||
u32 path_mtu;
|
||||
u32 template_interval;
|
||||
u8 udp_checksum;
|
||||
};
|
||||
|
||||
/** \brief IPFIX exporter dump request
|
||||
@param client_index - opaque cookie to identify the sender
|
||||
@param context - sender context, to match reply w/ request
|
||||
*/
|
||||
define ipfix_exporter_dump
|
||||
{
|
||||
u32 client_index;
|
||||
u32 context;
|
||||
};
|
||||
|
||||
/** \brief Reply to IPFIX exporter dump request
|
||||
@param context - sender context which was passed in the request
|
||||
@param collector_address - address of IPFIX collector
|
||||
@param collector_port - port of IPFIX collector
|
||||
@param src_address - address of IPFIX exporter
|
||||
@param fib_index - fib table index
|
||||
@param path_mtu - Path MTU between exporter and collector
|
||||
@param template_interval - number of seconds after which to resend template
|
||||
@param udp_checksum - UDP checksum calculation enable flag
|
||||
*/
|
||||
define ipfix_exporter_details
|
||||
{
|
||||
u32 context;
|
||||
u8 collector_address[16];
|
||||
u16 collector_port;
|
||||
u8 src_address[16];
|
||||
u32 vrf_id;
|
||||
u32 path_mtu;
|
||||
u32 template_interval;
|
||||
u8 udp_checksum;
|
||||
};
|
||||
|
||||
/** \brief IPFIX classify stream configure request
|
||||
@param client_index - opaque cookie to identify the sender
|
||||
@param context - sender context, to match reply w/ request
|
||||
@param domain_id - domain ID reported in IPFIX messages for classify stream
|
||||
@param src_port - source port of UDP session for classify stream
|
||||
*/
|
||||
autoreply define set_ipfix_classify_stream {
|
||||
u32 client_index;
|
||||
u32 context;
|
||||
u32 domain_id;
|
||||
u16 src_port;
|
||||
};
|
||||
|
||||
/** \brief IPFIX classify stream dump request
|
||||
@param client_index - opaque cookie to identify the sender
|
||||
@param context - sender context, to match reply w/ request
|
||||
*/
|
||||
define ipfix_classify_stream_dump {
|
||||
u32 client_index;
|
||||
u32 context;
|
||||
};
|
||||
|
||||
/** \brief Reply to IPFIX classify stream dump request
|
||||
@param context - sender context, to match reply w/ request
|
||||
@param domain_id - domain ID reported in IPFIX messages for classify stream
|
||||
@param src_port - source port of UDP session for classify stream
|
||||
*/
|
||||
define ipfix_classify_stream_details {
|
||||
u32 context;
|
||||
u32 domain_id;
|
||||
u16 src_port;
|
||||
};
|
||||
|
||||
/** \brief IPFIX add or delete classifier table request
|
||||
@param client_index - opaque cookie to identify the sender
|
||||
@param context - sender context, to match reply w/ request
|
||||
@param table_id - classifier table ID
|
||||
@param ip_version - version of IP used in the classifier table
|
||||
@param transport_protocol - transport protocol used in the classifier table or 255 for unspecified
|
||||
*/
|
||||
autoreply define ipfix_classify_table_add_del {
|
||||
u32 client_index;
|
||||
u32 context;
|
||||
u32 table_id;
|
||||
u8 ip_version;
|
||||
u8 transport_protocol;
|
||||
u8 is_add;
|
||||
};
|
||||
|
||||
/** \brief IPFIX classify tables dump request
|
||||
@param client_index - opaque cookie to identify the sender
|
||||
@param context - sender context, to match reply w/ request
|
||||
*/
|
||||
define ipfix_classify_table_dump {
|
||||
u32 client_index;
|
||||
u32 context;
|
||||
};
|
||||
|
||||
/** \brief Reply to IPFIX classify tables dump request
|
||||
@param context - sender context, to match reply w/ request
|
||||
@param table_id - classifier table ID
|
||||
@param ip_version - version of IP used in the classifier table
|
||||
@param transport_protocol - transport protocol used in the classifier table or 255 for unspecified
|
||||
*/
|
||||
define ipfix_classify_table_details {
|
||||
u32 context;
|
||||
u32 table_id;
|
||||
u8 ip_version;
|
||||
u8 transport_protocol;
|
||||
};
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* eval: (c-set-style "gnu")
|
||||
* End:
|
||||
*/
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,159 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015 Cisco and/or its affiliates.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef __included_vnet_flow_report_h__
|
||||
#define __included_vnet_flow_report_h__
|
||||
|
||||
#include <vlib/vlib.h>
|
||||
#include <vnet/vnet.h>
|
||||
#include <vnet/pg/pg.h>
|
||||
#include <vnet/ethernet/ethernet.h>
|
||||
#include <vnet/ethernet/packet.h>
|
||||
#include <vnet/ip/ip_packet.h>
|
||||
#include <vnet/ip/ip4_packet.h>
|
||||
#include <vnet/ip/ip6_packet.h>
|
||||
#include <vnet/udp/udp.h>
|
||||
#include <vlib/cli.h>
|
||||
#include <vppinfra/error.h>
|
||||
#include <vppinfra/hash.h>
|
||||
#include <vppinfra/cache.h>
|
||||
|
||||
#include <vnet/flow/ipfix_packet.h>
|
||||
|
||||
/* Used to build the rewrite */
|
||||
typedef struct
|
||||
{
|
||||
ip4_header_t ip4;
|
||||
udp_header_t udp;
|
||||
ipfix_template_packet_t ipfix;
|
||||
} ip4_ipfix_template_packet_t;
|
||||
|
||||
struct flow_report_main;
|
||||
struct flow_report;
|
||||
|
||||
typedef u8 *(vnet_flow_rewrite_callback_t) (struct flow_report_main *,
|
||||
struct flow_report *,
|
||||
ip4_address_t *,
|
||||
ip4_address_t *, u16);
|
||||
|
||||
typedef vlib_frame_t *(vnet_flow_data_callback_t) (struct flow_report_main *,
|
||||
struct flow_report *,
|
||||
vlib_frame_t *, u32 *,
|
||||
u32);
|
||||
|
||||
typedef union
|
||||
{
|
||||
void *as_ptr;
|
||||
uword as_uword;
|
||||
} opaque_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u32 domain_id;
|
||||
u32 sequence_number;
|
||||
u16 src_port;
|
||||
u16 n_reports;
|
||||
u16 next_template_no;
|
||||
} flow_report_stream_t;
|
||||
|
||||
typedef struct flow_report
|
||||
{
|
||||
/* ipfix rewrite, set by callback */
|
||||
u8 *rewrite;
|
||||
u16 template_id;
|
||||
u32 stream_index;
|
||||
f64 last_template_sent;
|
||||
int update_rewrite;
|
||||
|
||||
/* Bitmap of fields to send */
|
||||
uword *fields_to_send;
|
||||
|
||||
/* Opaque data */
|
||||
opaque_t opaque;
|
||||
|
||||
/* build-the-rewrite callback */
|
||||
vnet_flow_rewrite_callback_t *rewrite_callback;
|
||||
|
||||
/* Send-flow-data callback */
|
||||
vnet_flow_data_callback_t *flow_data_callback;
|
||||
} flow_report_t;
|
||||
|
||||
typedef struct flow_report_main
|
||||
{
|
||||
flow_report_t *reports;
|
||||
flow_report_stream_t *streams;
|
||||
|
||||
/* ipfix collector ip address, port, our ip address, fib index */
|
||||
ip4_address_t ipfix_collector;
|
||||
u16 collector_port;
|
||||
ip4_address_t src_address;
|
||||
u32 fib_index;
|
||||
|
||||
/* Path MTU */
|
||||
u32 path_mtu;
|
||||
|
||||
/* time interval in seconds after which to resend templates */
|
||||
u32 template_interval;
|
||||
|
||||
/* UDP checksum calculation enable flag */
|
||||
u8 udp_checksum;
|
||||
|
||||
/* time scale transform. Joy. */
|
||||
u32 unix_time_0;
|
||||
f64 vlib_time_0;
|
||||
|
||||
/* convenience variables */
|
||||
vlib_main_t *vlib_main;
|
||||
vnet_main_t *vnet_main;
|
||||
} flow_report_main_t;
|
||||
|
||||
extern flow_report_main_t flow_report_main;
|
||||
|
||||
extern vlib_node_registration_t flow_report_process_node;
|
||||
|
||||
int vnet_flow_report_enable_disable (u32 sw_if_index, u32 table_index,
|
||||
int enable_disable);
|
||||
typedef struct
|
||||
{
|
||||
vnet_flow_data_callback_t *flow_data_callback;
|
||||
vnet_flow_rewrite_callback_t *rewrite_callback;
|
||||
opaque_t opaque;
|
||||
int is_add;
|
||||
u32 domain_id;
|
||||
u16 src_port;
|
||||
} vnet_flow_report_add_del_args_t;
|
||||
|
||||
int vnet_flow_report_add_del (flow_report_main_t * frm,
|
||||
vnet_flow_report_add_del_args_t * a,
|
||||
u16 * template_id);
|
||||
|
||||
clib_error_t *flow_report_add_del_error_to_clib_error (int error);
|
||||
|
||||
void vnet_flow_reports_reset (flow_report_main_t * frm);
|
||||
|
||||
void vnet_stream_reset (flow_report_main_t * frm, u32 stream_index);
|
||||
|
||||
int vnet_stream_change (flow_report_main_t * frm,
|
||||
u32 old_domain_id, u16 old_src_port,
|
||||
u32 new_domain_id, u16 new_src_port);
|
||||
|
||||
#endif /* __included_vnet_flow_report_h__ */
|
||||
|
||||
/*
|
||||
* fd.io coding-style-patch-verification: ON
|
||||
*
|
||||
* Local Variables:
|
||||
* eval: (c-set-style "gnu")
|
||||
* End:
|
||||
*/
|
File diff suppressed because it is too large
Load Diff
@ -1,134 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015 Cisco and/or its affiliates.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef __included_flow_report_classify_h__
|
||||
#define __included_flow_report_classify_h__
|
||||
|
||||
#define foreach_ipfix_ip4_field \
|
||||
_(ip->src_address.as_u32, ((u32[]){0xFFFFFFFF}), sourceIPv4Address, 4) \
|
||||
_(ip->dst_address.as_u32, ((u32[]){0xFFFFFFFF}), destinationIPv4Address, 4) \
|
||||
_(ip->protocol, ((u8[]){0xFF}), protocolIdentifier, 1)
|
||||
|
||||
#define foreach_ipfix_ip6_field \
|
||||
_(ip6->src_address.as_u8, \
|
||||
((u32[]){0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF}), \
|
||||
sourceIPv6Address, 16) \
|
||||
_(ip6->dst_address.as_u8, \
|
||||
((u32[]){0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF}), \
|
||||
destinationIPv6Address, 16) \
|
||||
_(ip6->protocol, ((u8[]){0xFF}), protocolIdentifier, 1)
|
||||
|
||||
#define foreach_ipfix_tcpudp_field \
|
||||
_(tcpudp->src_port, ((u16[]){0xFFFF}), sourceTransportPort, 2) \
|
||||
_(tcpudp->dst_port, ((u16[]){0xFFFF}), destinationTransportPort, 2)
|
||||
|
||||
#define foreach_ipfix_tcp_field \
|
||||
_(tcpudp->src_port, ((u16[]){0xFFFF}), tcpSourcePort, 2) \
|
||||
_(tcpudp->dst_port, ((u16[]){0xFFFF}), tcpDestinationPort, 2)
|
||||
|
||||
#define foreach_ipfix_udp_field \
|
||||
_(tcpudp->src_port, ((u16[]){0xFFFF}), udpSourcePort, 2) \
|
||||
_(tcpudp->dst_port, ((u16[]){0xFFFF}), udpDestinationPort, 2)
|
||||
|
||||
#define foreach_ipfix_transport_protocol_field \
|
||||
switch (transport_protocol) { \
|
||||
case 255: \
|
||||
foreach_ipfix_tcpudp_field; \
|
||||
break; \
|
||||
case 6: \
|
||||
foreach_ipfix_tcp_field; \
|
||||
break; \
|
||||
case 17: \
|
||||
foreach_ipfix_udp_field; \
|
||||
break; \
|
||||
}
|
||||
|
||||
#define foreach_ipfix_field \
|
||||
if (ip_version == 4) { \
|
||||
ip = (ip4_header_t *)ip_start; \
|
||||
tcpudp = (tcpudp_header_t *)(ip+1); \
|
||||
foreach_ipfix_ip4_field; \
|
||||
} else { \
|
||||
ip6 = (ip6_header_t *)ip_start; \
|
||||
tcpudp = (tcpudp_header_t *)(ip6+1); \
|
||||
foreach_ipfix_ip6_field; \
|
||||
} \
|
||||
foreach_ipfix_transport_protocol_field
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u32 classify_table_index;
|
||||
u8 ip_version;
|
||||
u8 transport_protocol;
|
||||
} ipfix_classify_table_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u32 domain_id;
|
||||
u16 src_port;
|
||||
ipfix_classify_table_t *tables;
|
||||
} flow_report_classify_main_t;
|
||||
|
||||
extern flow_report_classify_main_t flow_report_classify_main;
|
||||
|
||||
static_always_inline u8
|
||||
ipfix_classify_table_index_valid (u32 index)
|
||||
{
|
||||
flow_report_classify_main_t *fcm = &flow_report_classify_main;
|
||||
return index < vec_len (fcm->tables) &&
|
||||
fcm->tables[index].classify_table_index != ~0;
|
||||
}
|
||||
|
||||
static_always_inline ipfix_classify_table_t *
|
||||
ipfix_classify_add_table (void)
|
||||
{
|
||||
flow_report_classify_main_t *fcm = &flow_report_classify_main;
|
||||
u32 i;
|
||||
for (i = 0; i < vec_len (fcm->tables); i++)
|
||||
if (!ipfix_classify_table_index_valid (i))
|
||||
return &fcm->tables[i];
|
||||
u32 index = vec_len (fcm->tables);
|
||||
vec_validate (fcm->tables, index);
|
||||
return &fcm->tables[index];
|
||||
}
|
||||
|
||||
static_always_inline void
|
||||
ipfix_classify_delete_table (u32 index)
|
||||
{
|
||||
flow_report_classify_main_t *fcm = &flow_report_classify_main;
|
||||
ASSERT (index < vec_len (fcm->tables));
|
||||
ASSERT (fcm->tables[index].classify_table_index != ~0);
|
||||
fcm->tables[index].classify_table_index = ~0;
|
||||
}
|
||||
|
||||
u8 *ipfix_classify_template_rewrite (flow_report_main_t * frm,
|
||||
flow_report_t * fr,
|
||||
ip4_address_t * collector_address,
|
||||
ip4_address_t * src_address,
|
||||
u16 collector_port);
|
||||
|
||||
vlib_frame_t *ipfix_classify_send_flows (flow_report_main_t * frm,
|
||||
flow_report_t * fr,
|
||||
vlib_frame_t * f,
|
||||
u32 * to_next, u32 node_index);
|
||||
|
||||
#endif /* __included_flow_report_classify_h__ */
|
||||
|
||||
/*
|
||||
* fd.io coding-style-patch-verification: ON
|
||||
*
|
||||
* Local Variables:
|
||||
* eval: (c-set-style "gnu")
|
||||
* End:
|
||||
*/
|
File diff suppressed because it is too large
Load Diff
@ -1,206 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015 Cisco and/or its affiliates.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef __included_ipfix_packet_h__
|
||||
#define __included_ipfix_packet_h__
|
||||
|
||||
#include <vnet/flow/ipfix_info_elements.h>
|
||||
|
||||
/* From RFC-7011:
|
||||
* https://tools.ietf.org/html/rfc7011
|
||||
*/
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u32 version_length;
|
||||
u32 export_time;
|
||||
u32 sequence_number;
|
||||
u32 domain_id;
|
||||
} ipfix_message_header_t;
|
||||
|
||||
static inline u32
|
||||
version_length (u16 length)
|
||||
{
|
||||
return clib_host_to_net_u32 (0x000a0000 | length);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* The Field Specifier format is shown in Figure G.
|
||||
*
|
||||
* 0 1 2 3
|
||||
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* |E| Information Element ident. | Field Length |
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* | Enterprise Number |
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
*
|
||||
* Figure G: Field Specifier Format
|
||||
*
|
||||
* Where:
|
||||
*
|
||||
* E
|
||||
*
|
||||
* Enterprise bit. This is the first bit of the Field Specifier. If
|
||||
* this bit is zero, the Information Element identifier identifies an
|
||||
* Information Element in [IANA-IPFIX], and the four-octet Enterprise
|
||||
* Number field MUST NOT be present. If this bit is one, the
|
||||
* Information Element identifier identifies an enterprise-specific
|
||||
* Information Element, and the Enterprise Number field MUST be
|
||||
* present.
|
||||
*/
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u32 e_id_length;
|
||||
u32 enterprise;
|
||||
} ipfix_enterprise_field_specifier_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u32 e_id_length;
|
||||
} ipfix_field_specifier_t;
|
||||
|
||||
static inline u32
|
||||
ipfix_e_id_length (int e, u16 id, u16 length)
|
||||
{
|
||||
u32 value;
|
||||
value = (e << 31) | ((id & 0x7FFF) << 16) | length;
|
||||
return clib_host_to_net_u32 (value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Every Set contains a common header. This header is defined in
|
||||
* Figure I.
|
||||
*
|
||||
* 0 1 2 3
|
||||
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* | Set ID | Length |
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
*
|
||||
* Figure I: Set Header Format
|
||||
*
|
||||
* Each Set Header field is exported in network format. The fields are
|
||||
* defined as follows:
|
||||
*
|
||||
* Set ID
|
||||
*
|
||||
* Identifies the Set. A value of 2 is reserved for Template Sets.
|
||||
* A value of 3 is reserved for Options Template Sets. Values from 4
|
||||
* to 255 are reserved for future use. Values 256 and above are used
|
||||
* for Data Sets. The Set ID values of 0 and 1 are not used, for
|
||||
* historical reasons [RFC3954].
|
||||
*
|
||||
* Length
|
||||
*
|
||||
* Total length of the Set, in octets, including the Set Header, all
|
||||
* records, and the optional padding. Because an individual Set MAY
|
||||
* contain multiple records, the Length value MUST be used to
|
||||
* determine the position of the next Set.
|
||||
*/
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u32 set_id_length;
|
||||
} ipfix_set_header_t;
|
||||
|
||||
static inline u32
|
||||
ipfix_set_id_length (u16 set_id, u16 length)
|
||||
{
|
||||
return clib_host_to_net_u32 ((set_id << 16) | length);
|
||||
}
|
||||
|
||||
/*
|
||||
* The format of the Template Record is shown in Figure J. It consists
|
||||
* of a Template Record Header and one or more Field Specifiers. Field
|
||||
* Specifiers are defined in Figure G above.
|
||||
*
|
||||
* +--------------------------------------------------+
|
||||
* | Template Record Header |
|
||||
* +--------------------------------------------------+
|
||||
* | Field Specifier |
|
||||
* +--------------------------------------------------+
|
||||
* | Field Specifier |
|
||||
* +--------------------------------------------------+
|
||||
* ...
|
||||
* +--------------------------------------------------+
|
||||
* | Field Specifier |
|
||||
* +--------------------------------------------------+
|
||||
*
|
||||
* Figure J: Template Record Format
|
||||
*
|
||||
* The format of the Template Record Header is shown in Figure K.
|
||||
*
|
||||
* 0 1 2 3
|
||||
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
* | Template ID (> 255) | Field Count |
|
||||
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
*
|
||||
* Figure K: Template Record Header Format
|
||||
*
|
||||
* The Template Record Header Field definitions are as follows:
|
||||
*
|
||||
* Template ID
|
||||
*
|
||||
* Each Template Record is given a unique Template ID in the range
|
||||
* 256 to 65535. This uniqueness is local to the Transport Session
|
||||
* and Observation Domain that generated the Template ID. Since
|
||||
* Template IDs are used as Set IDs in the Sets they describe (see
|
||||
* Section 3.4.3), values 0-255 are reserved for special Set types
|
||||
* (e.g., Template Sets themselves), and Templates and Options
|
||||
* Templates (see Section 3.4.2) cannot share Template IDs within a
|
||||
* Transport Session and Observation Domain. There are no
|
||||
* constraints regarding the order of the Template ID allocation. As
|
||||
* Exporting Processes are free to allocate Template IDs as they see
|
||||
* fit, Collecting Processes MUST NOT assume incremental Template
|
||||
* IDs, or anything about the contents of a Template based on its
|
||||
* Template ID alone.
|
||||
*
|
||||
* Field Count
|
||||
*
|
||||
* Number of fields in this Template Record.
|
||||
*/
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u32 id_count;
|
||||
} ipfix_template_header_t;
|
||||
|
||||
static inline u32
|
||||
ipfix_id_count (u16 id, u16 count)
|
||||
{
|
||||
return clib_host_to_net_u32 ((id << 16) | count);
|
||||
}
|
||||
|
||||
/* Template packet */
|
||||
typedef struct
|
||||
{
|
||||
ipfix_message_header_t h;
|
||||
ipfix_set_header_t s;
|
||||
ipfix_template_header_t t;
|
||||
ipfix_field_specifier_t fields[0];
|
||||
} ipfix_template_packet_t;
|
||||
|
||||
#endif /* __included_ipfix_packet_h__ */
|
||||
|
||||
/*
|
||||
* fd.io coding-style-patch-verification: ON
|
||||
*
|
||||
* Local Variables:
|
||||
* eval: (c-set-style "gnu")
|
||||
* End:
|
||||
*/
|
Reference in New Issue
Block a user