fixbuf IPFIX protocol library public interface. More...
#include <fixbuf/autoinc.h>
Go to the source code of this file.
Data Structures | |
struct | fbVarfield_st |
A variable-length field value. More... | |
struct | fbInfoElement_st |
A single IPFIX Information Element definition. More... | |
struct | fbInfoElementSpec_st |
A single IPFIX Information Element specification. More... | |
struct | fbConnSpec_st |
Connection specifier. More... | |
struct | fbListenerEntry_st |
ListenerEntry's make up a listener group as a linked list. More... | |
struct | fbListenerGroupResult_st |
ListenerGroupResult's contain the listener who's listening socket got a new connection. More... | |
struct | fbListenerGroup_st |
Structure that holds the listeners that are added to the group. More... | |
struct | fbBasicList_st |
A basic list element in a template which structure represents a basic list on the internal side, basic lists in an IPFIX Message must be represented by this structure within the application record. More... | |
struct | fbSubTemplateList_st |
Structure used to hold information of a sub template list. More... | |
struct | fbSubTemplateMultiListEntry_st |
Entries contain the same type of information at SubTemplateLists: template ID and template pointers to describe the data the number of data elements and the data pointer and data length. More... | |
struct | fbSubTemplateMultiList_st |
Multilists just contain the semantic to describe the sub lists, the number of sub lists, and a pointer to the first entry. More... | |
Defines | |
#define | FB_ERROR_DOMAIN g_quark_from_string("fixbufError") |
All fixbuf errors are returned within the FB_ERROR_DOMAIN domain. | |
#define | FB_ERROR_TMPL 1 |
No template was available for the given template ID. | |
#define | FB_ERROR_EOM 2 |
End of IPFIX message. | |
#define | FB_ERROR_EOF 3 |
End of IPFIX Message stream. | |
#define | FB_ERROR_IPFIX 4 |
Illegal IPFIX mesaage content on read. | |
#define | FB_ERROR_BUFSZ 5 |
A message was received larger than the collector buffer size. | |
#define | FB_ERROR_IMPL 6 |
The requested feature is not yet implemented. | |
#define | FB_ERROR_IO 7 |
An unspecified I/O error occured. | |
#define | FB_ERROR_NLREAD 8 |
No data is available for reading from the transport layer. | |
#define | FB_ERROR_NLWRITE 9 |
An attempt to write data to the transport layer failed due to closure of the remote end of the connection. | |
#define | FB_ERROR_NOELEMENT 10 |
The specified Information Element does not exist in the Information Model. | |
#define | FB_ERROR_CONN 11 |
A connection or association could not be established or maintained. | |
#define | FB_ERROR_NETFLOWV9 12 |
Illegal NetflowV9 content on a read. | |
#define | FB_ERROR_TRANSMISC 13 |
Miscellaneous error occured during translator operation. | |
#define | FB_IE_INIT(_name_, _ent_, _num_, _len_, _flags_) { {.name = _name_}, 0, _ent_, _num_, _len_, _flags_ } |
Convenience macro for creating fbInfoElement_t static initializers. | |
#define | FB_IE_NULL { {.name = NULL}, 0, 0, 0, 0, 0 } |
Convenience macro defining a null information element initializer to terminate a constant information element array for passing to fbInfoModelAddElementArray(). | |
#define | FB_IE_F_NONE 0x00000000 |
Default treatment flags value. | |
#define | FB_IE_F_ENDIAN 0x00000001 |
Information element endian conversion flag. | |
#define | FB_IE_F_REVERSIBLE 0x00000040 |
Information element reversible flag. | |
#define | FB_IE_F_ALIEN 0x00000080 |
Information element alien flag. | |
#define | FB_IE_VARLEN 65535 |
Information element length constant for variable-length IE. | |
#define | FB_IE_BASIC_LIST 0x7FFD |
Information element number constant for basic lists This will change upon updates to the specification. | |
#define | FB_IE_SUBTEMPLATE_LIST 0x7FFE |
Information element number constant for sub template lists This will change upon updates to the IPFIX lists specification. | |
#define | FB_IE_SUBTEMPLATE_MULTILIST 0x7FFF |
Information element number constant for sub template multi lists This will change upon updates to the IPFIX lists specification. | |
#define | FB_IE_PEN_REVERSE 29305 |
Private enterprise number for reverse information elements (see draft-ietf-ipfix-biflow-03 section 6.1). | |
#define | FB_IE_VENDOR_BIT_REVERSE 0x4000 |
Reverse information element bit for vendor-specific information elements (see draft-ietf-ipfix-biflow-03 section 6.2). | |
#define | FB_IE_REVERSE_STR "reverse" |
Reverse information element name prefix. | |
#define | FB_IE_REVERSE_STRLEN 7 |
Length of reverse information element name prefix. | |
#define | FB_TID_AUTO 0 |
Template ID argument to pass to fbSessionAddTemplate to automatically assign a template ID. | |
#define | FB_TID_TS 2 |
Reserved set ID for template sets. | |
#define | FB_TID_OTS 3 |
Reserved set ID for options template sets. | |
#define | FB_TID_MIN_DATA 256 |
Minimum non-reserved template ID available for data sets. | |
#define | FB_IESPEC_NULL { NULL, 0, 0 } |
Convenience macro defining a null information element specification initializer to terminate a constant information element specifier array for passing to fbTemplateAppendSpecArray(). | |
#define | FB_CONNSPEC_INIT |
Convenience macro defining a null static fbConnSpec_t. | |
#define | UNDEFINED 0xFF |
Semantic field indicating the value has not been set. | |
#define | NONE_OF 0x00 |
Semantic field for none-of value defined in the spec. | |
#define | EXACTLY_ONE_OF 0x01 |
Semantic field for exactly-one-of value defined in the spec. | |
#define | ONE_OR_MORE_OF 0x02 |
Semantic field for the one-or-more-of value defined in the spec. | |
#define | ALL_OF 0x03 |
Semantic field for the all-of value defined in the spec. | |
#define | ORDERED 0x04 |
Semantic field for the ordered value defined in the spec. | |
Typedefs | |
typedef struct fBuf_st | fBuf_t |
An IPFIX message buffer. | |
typedef struct fbVarfield_st | fbVarfield_t |
A variable-length field value. | |
typedef struct fbInfoModel_st | fbInfoModel_t |
An IPFIX information model. | |
typedef struct fbInfoElement_st | fbInfoElement_t |
A single IPFIX Information Element definition. | |
typedef struct fbTemplate_st | fbTemplate_t |
An IPFIX Template or Options Template. | |
typedef struct fbInfoElementSpec_st | fbInfoElementSpec_t |
A single IPFIX Information Element specification. | |
typedef struct fbSession_st | fbSession_t |
An IPFIX Transport Session state container. | |
typedef enum fbTransport_en | fbTransport_t |
Transport protocol for connection specifier. | |
typedef struct fbConnSpec_st | fbConnSpec_t |
Connection specifier. | |
typedef struct fbExporter_st | fbExporter_t |
IPFIX Exporting Process endpoint. | |
typedef struct fbCollector_st | fbCollector_t |
IPFIX Collecting Process endpoint. | |
typedef struct fbListener_st | fbListener_t |
IPFIX Collecting Process session listener. | |
typedef struct fbListenerEntry_st | fbListenerEntry_t |
ListenerGroup and associated data type definitions. | |
typedef struct fbListenerGroupResult_st | fbListenerGroupResult_t |
typedef for listener group result | |
typedef struct fbListenerGroup_st | fbListenerGroup_t |
Structure that holds the listeners that are added to the group. | |
typedef gboolean(* | fbAcceptCallback_fn )(fBuf_t *buf, fbListener_t *listener, struct sockaddr *sAddr, GError **err) |
the callback function to be called when a new connection to a listener has been received. | |
typedef void(* | fbNewTemplateCallback_fn )(fbSession_t *session, uint16_t tid, fbTemplate_t *tmpl) |
The callback function to be called when the session receives a new external template from the connected node. | |
typedef struct fbBasicList_st | fbBasicList_t |
A basic list element in a template which structure represents a basic list on the internal side, basic lists in an IPFIX Message must be represented by this structure within the application record. | |
typedef struct fbSubTemplateList_st | fbSubTemplateList_t |
Structure used to hold information of a sub template list. | |
typedef struct fbSubTemplateMultiListEntry_st | fbSubTemplateMultiListEntry_t |
Entries contain the same type of information at SubTemplateLists: template ID and template pointers to describe the data the number of data elements and the data pointer and data length. | |
typedef struct fbSubTemplateMultiList_st | fbSubTemplateMultiList_t |
Multilists just contain the semantic to describe the sub lists, the number of sub lists, and a pointer to the first entry. | |
typedef gboolean(* | fbListenerAppInit_fn )(fbListener_t *listener, void **ctx, int fd, struct sockaddr *peer, size_t peerlen, GError **err) |
Application context initialization function type for fbListener_t. | |
typedef void(* | fbListenerAppFree_fn )(void *ctx) |
Application context free function type for fbListener_t. | |
Enumerations | |
enum | fbTransport_en { FB_SCTP, FB_TCP, FB_UDP, FB_DTLS_SCTP, FB_TLS_TCP, FB_DTLS_UDP } |
Transport protocol for connection specifier. More... | |
Functions | |
gboolean | fbListValidSemantic (uint8_t semantic) |
validates the value of the semantic field, | |
fbBasicList_t * | fbBasicListAlloc (void) |
allocates a Basic List Structure | |
void * | fbBasicListInit (fbBasicList_t *basicListPtr, uint8_t semantic, const fbInfoElement_t *infoElement, uint16_t numElements) |
Initializes the basic list structure based on the parameters. | |
void * | fbBasicListInitWithOwnBuffer (fbBasicList_t *basicListPtr, uint8_t semantic, const fbInfoElement_t *infoElement, uint16_t numElements, uint16_t dataLength, uint8_t *dataPtr) |
use this function to initialize the basic list, but it gets the pointer to a buffer and its length allocated independently from these functions This will generally be used by a collector that does not want to free and allocate new buffers for each incoming message | |
void | fbBasicListCollectorInit (fbBasicList_t *basicListPtr) |
This initializes a basic list structure for collection. | |
uint8_t | fbBasicListGetSemantic (fbBasicList_t *basicListPtr) |
Get Semantic field for Basic List presumably used in collectors after decoding. | |
void | fbBasicListSetSemantic (fbBasicList_t *basicListPtr, uint8_t semantic) |
Sets the semantic for describing a basic list generally used in exporters before decoding. | |
const fbInfoElement_t * | fbBasicListGetInfoElement (fbBasicList_t *basicListPtr) |
This function returns a pointer to the information element used in the list it is mainly used in collectors to retrieve information. | |
void * | fbBasicListGetDataPtr (fbBasicList_t *basicListPtr) |
void * | fbBasicListGetIndexedDataPtr (fbBasicList_t *basicListPtr, uint16_t index) |
Function retrieves the index'th element in the list index is 0-based. | |
void * | fbBasicListGetNextPtr (fbBasicList_t *basicListPtr, void *currentPtr) |
Function returns the next element in the list based on the currentPtr. | |
void * | fbBasicListRealloc (fbBasicList_t *basicList, uint16_t newNumElements) |
Free the current data pointer, allocating a new buffer to accomodate the new number of elements. | |
void * | fbBasicListAddNewElements (fbBasicList_t *basicList, uint16_t numNewElements) |
Allocates an additional elememnt into the basic list must be called after calling BasicListInit. | |
void | fbBasicListClear (fbBasicList_t *basicListPtr) |
Clear the parameters of the basic list and free the data buffer. | |
void | fbBasicListClearWithoutFree (fbBasicList_t *basicList) |
Clear the parameters of the basic list, but do not free the buffer. | |
void | fbBasicListFree (fbBasicList_t *basicListPtr) |
Clear the basic list, then free the basic list pointer. | |
fbSubTemplateList_t * | fbSubTemplateListAlloc (void) |
Allocates a subTemplateList_t Based on how subTemplateLists will be used and set up amidst data structures, this function may never be used. | |
void * | fbSubTemplateListInit (fbSubTemplateList_t *sTL, uint8_t semantic, uint16_t tmplID, const fbTemplate_t *tmpl, uint16_t numElements) |
Initializes a subTemplateList structure and alloc's the dataPtr to get a buffer able to hold numElements in the template This will mainly be used in exporters preparing to encode. | |
void * | fbSubTemplateListInitWithOwnBuffer (fbSubTemplateList_t *subTemplateList, uint8_t semantic, uint16_t tmplID, const fbTemplate_t *tmpl, uint16_t numElements, uint16_t dataLength, uint8_t *dataPtr) |
Initializes the subTemplateList but does not allocate a buffer. | |
void | fbSubTemplateListCollectorInit (fbSubTemplateList_t *STL) |
Initializes a sub template list variable on a collector. | |
void * | fbSubTemplateListGetDataPtr (const fbSubTemplateList_t *subTemplateListPtr) |
Returns a pointer to the buffer that contains the data for the list. | |
void * | fbSubTemplateListGetIndexedDataPtr (const fbSubTemplateList_t *subTemplateListPtr, uint16_t index) |
This function is used to iterate over the elements in the list by passing in a counter to indicate which element is to be returned. | |
void * | fbSubTemplateListGetNextPtr (const fbSubTemplateList_t *subTemplateListPtr, void *currentPtr) |
This function also traverses the elements in the list by accepting a pointer to the last element the user accessed, moves it to the next element and returns a pointer to the next element. | |
void | fbSubTemplateListSetSemantic (fbSubTemplateList_t *subTemplateListPtr, uint8_t semantic) |
Sets the semantic parameter of a subTemplateList. | |
uint8_t | fbSubTemplateListGetSemantic (fbSubTemplateList_t *subTemplateListPtr) |
Gets the semantic value from a sub template list. | |
const fbTemplate_t * | fbSubTemplateListGetTemplate (fbSubTemplateList_t *subTemplateListPtr) |
Gets the template pointer from the list structure. | |
uint16_t | fbSubTemplateListGetTemplateID (fbSubTemplateList_t *subTemplateListPtr) |
Gets the template ID for the template used by the list. | |
void * | fbSubTemplateListRealloc (fbSubTemplateList_t *subTemplateList, uint16_t newNumElements) |
Free the current data pointer, allocating a new buffer to accomodate the new number of elements. | |
void * | fbSubTemplateListAddNewElements (fbSubTemplateList_t *subTemplateList, uint16_t numNewElements) |
Allocates space for a number of additional element in the sub template list must be called after the list has been fbSubTemplateListInit()'d. | |
void | fbSubTemplateListClear (fbSubTemplateList_t *subTemplateListPtr) |
Clears a subtemplate list struct, notably freeing the dataPtr and setting it to NULL. | |
void | fbSubTemplateListClearWithoutFree (fbSubTemplateList_t *subTemplateListPtr) |
Clears the sub template list parameters but does not free the data ptr. | |
void | fbSubTemplateListFree (fbSubTemplateList_t *subTemplateListPtr) |
Frees and clears a subTemplateList struct. | |
fbSubTemplateMultiListEntry_t * | fbSubTemplateMultiListInit (fbSubTemplateMultiList_t *STML, uint8_t semantic, uint16_t numElements) |
Initializes the multi list with semantic, numbers of elements, and allocates memory to store numElements worth of entries. | |
void | fbSubTemplateMultiListSetSemantic (fbSubTemplateMultiList_t *STML, uint8_t semantic) |
Sets the semantic field for the multi list. | |
uint8_t | fbSubTemplateMultiListGetSemantic (fbSubTemplateMultiList_t *STML) |
Get the semantic paramter from the multi list. | |
void | fbSubTemplateMultiListClear (fbSubTemplateMultiList_t *STML) |
Clears all of the entries (frees their data pointers), then frees the memory containing the entries. | |
void | fbSubTemplateMultiListClearEntries (fbSubTemplateMultiList_t *STML) |
Clears the memory used by the entries of a sub template multi list NOTE: if any of those entries contain another layer of structures, that second layer must be freed by the user, this function cannot do that. | |
void | fbSubTemplateMultiListFree (fbSubTemplateMultiList_t *STML) |
Clears the multi list, then frees the memory pointed to by STML. | |
fbSubTemplateMultiListEntry_t * | fbSubTemplateMultiListRealloc (fbSubTemplateMultiList_t *STML, uint16_t newNumEntries) |
Clears the entries used by the multi list, then if newNumElements is different than numElements, frees the entries buffer and allocates a new one. | |
fbSubTemplateMultiListEntry_t * | fbSubTemplateMultiListAddNewEntries (fbSubTemplateMultiList_t *STML, uint16_t numNewEntries) |
Adds entries to the multi list of entries can only be run after the list has been initialized. | |
fbSubTemplateMultiListEntry_t * | fbSubTemplateMultiListGetFirstEntry (fbSubTemplateMultiList_t *STML) |
Retrieve the first entry in the multi list. | |
fbSubTemplateMultiListEntry_t * | fbSubTemplateMultiListGetIndexedEntry (fbSubTemplateMultiList_t *STML, uint16_t index) |
Retrieve a pointer to the entry of a specific index. | |
fbSubTemplateMultiListEntry_t * | fbSubTemplateMultiListGetNextEntry (fbSubTemplateMultiList_t *STML, fbSubTemplateMultiListEntry_t *currentEntry) |
This function also traverses the elements in the list by accepting a pointer to the last element the user accessed, moves it to the next element and returns a pointer to the next element. | |
void * | fbSubTemplateMultiListEntryInit (fbSubTemplateMultiListEntry_t *entry, uint16_t tmplID, fbTemplate_t *tmpl, uint16_t numElements) |
Initializes the multi list entry with the template values, and allocates the memory used by the entry to hold the data. | |
void * | fbSubTemplateMultiListEntryRealloc (fbSubTemplateMultiListEntry_t *entry, uint16_t newNumElements) |
Frees the memory for the data used by the entry, then allocates a new buffer based on the size of the template and newNumElements. | |
void | fbSubTemplateMultiListEntryClear (fbSubTemplateMultiListEntry_t *entry) |
Frees the memory pointed to by the data buffer holding the data elements. | |
void * | fbSubTemplateMultiListEntryGetDataPtr (fbSubTemplateMultiListEntry_t *entry) |
Retrieves the data pointer for this entry. | |
void * | fbSubTemplateMultiListEntryNextDataPtr (fbSubTemplateMultiListEntry_t *entry, void *currentPtr) |
This function traverses the elements in the entry by accepting a pointer to the last element the user accessed, moves it to the next element and returns a pointer to the next element. | |
void * | fbSubTemplateMultiListEntryGetIndexedPtr (fbSubTemplateMultiListEntry_t *entry, uint16_t index) |
Returns a pointer to a data element in the entry based on the index. | |
const fbTemplate_t * | fbSubTemplateMultiListEntryGetTemplate (fbSubTemplateMultiListEntry_t *entry) |
Retrieve the template pointer used to structure the data elements. | |
uint16_t | fbSubTemplateMultiListEntryGetTemplateID (fbSubTemplateMultiListEntry_t *entry) |
Retrieve the template ID for the template used to structure the data. | |
fbListenerGroup_t * | fbListenerGroupAlloc (void) |
Allocates and returns a fbListenerGroup with no entries. | |
int | fbListenerGroupAddListener (fbListenerGroup_t *group, const fbListener_t *listener) |
Adds a previously allocated listener to the previously allocated group. | |
int | fbListenerGroupDeleteListener (fbListenerGroup_t *group, const fbListener_t *listener) |
Removes the listener from the group. | |
fbListenerGroupResult_t * | fbListenerGroupWait (fbListenerGroup_t *group, GError **err) |
Similar to fbListenerWait, except that is looks for connections for multiple listeners. | |
gboolean | fbListenerWaitAcceptCallback (fbListener_t *listener, fbAcceptCallback_fn callback, GError **err) |
Takes one listener, and instead of returning the fBuf created from the new collector, like fbListenerWait(), it calls the callback function provided. | |
gboolean | fbListenerGroupWaitAcceptCallback (fbListenerGroup_t *group, fbAcceptCallback_fn callback, GError **err) |
A combination of ListenerGroupWait and ListenerWaitAcceptCallback. | |
fBuf_t * | fbListenerOwnSocketCollectorTCP (fbListener_t *listener, int sock, GError **err) |
Returns an fBuf wrapped around an independently managed socket and a properly created listener for TCP connections. | |
fBuf_t * | fbListenerOwnSocketCollectorTLS (fbListener_t *listener, int sock, GError **err) |
Same as fbListenerOwnSocketCollectorTCP but for TLS (not tested). | |
void | fBufInterruptSocket (fBuf_t *fbuf) |
Interrupts the select call of a specific collector by way of its fBuf. | |
gboolean | fBufSetInternalTemplate (fBuf_t *fbuf, uint16_t int_tid, GError **err) |
Set the internal template on a buffer to the given template ID. | |
gboolean | fBufSetExportTemplate (fBuf_t *fbuf, uint16_t ext_tid, GError **err) |
Set the external template for export on a buffer to the given template ID. | |
void | fBufSetAutomaticMode (fBuf_t *fbuf, gboolean automatic) |
Set the automatic mode flag on a buffer. | |
fbSession_t * | fBufGetSession (fBuf_t *fbuf) |
Retrieve the session associated with a buffer. | |
void | fBufFree (fBuf_t *fbuf) |
Free a buffer. | |
fBuf_t * | fBufAllocForExport (fbSession_t *session, fbExporter_t *exporter) |
Allocate a new buffer for export. | |
fbExporter_t * | fBufGetExporter (fBuf_t *fbuf) |
Retrieve the exporting process endpoint associated with a buffer. | |
void | fBufSetExporter (fBuf_t *fbuf, fbExporter_t *exporter) |
Associate an exporting process endpoint with a buffer. | |
gboolean | fBufAppend (fBuf_t *fbuf, uint8_t *recbase, size_t recsize, GError **err) |
Append a record to a buffer. | |
gboolean | fBufEmit (fBuf_t *fbuf, GError **err) |
Emit the message currently in a buffer using the associated exporting process endpoint. | |
void | fBufSetExportTime (fBuf_t *fbuf, uint32_t extime) |
Set the export time on the message currently in a buffer. | |
fBuf_t * | fBufAllocForCollection (fbSession_t *session, fbCollector_t *collector) |
Allocate a new buffer for collection. | |
fbCollector_t * | fBufGetCollector (fBuf_t *fbuf) |
Retrieve the collecting process endpoint associated with a buffer. | |
void | fBufSetCollector (fBuf_t *fbuf, fbCollector_t *collector) |
Associate an collecting process endpoint with a buffer. | |
gboolean | fBufNext (fBuf_t *fbuf, uint8_t *recbase, size_t *recsize, GError **err) |
Retrieve a record from a buffer. | |
gboolean | fBufNextMessage (fBuf_t *fbuf, GError **err) |
Read a new message into a buffer using the associated collecting process endpoint. | |
uint32_t | fBufGetExportTime (fBuf_t *fbuf) |
Retrieve the export time on the message currently in a buffer. | |
fbTemplate_t * | fBufGetCollectionTemplate (fBuf_t *fbuf, uint16_t *ext_tid) |
Retrieve the external template used to read the last record from the buffer. | |
fbTemplate_t * | fBufNextCollectionTemplate (fBuf_t *fbuf, uint16_t *ext_tid, GError **err) |
Retrieve the external template that will be used to read the next record from the buffer. | |
fbInfoModel_t * | fbInfoModelAlloc () |
Allocate a new information model. | |
void | fbInfoModelFree (fbInfoModel_t *model) |
Free an information model. | |
void | fbInfoModelAddElement (fbInfoModel_t *model, fbInfoElement_t *ie) |
Add a single information element to an information model. | |
void | fbInfoModelAddElementArray (fbInfoModel_t *model, fbInfoElement_t *ie) |
Add multiple information elements in an array to an information model. | |
const fbInfoElement_t * | fbInfoModelGetElementByName (fbInfoModel_t *model, const char *name) |
Return a pointer to the canonical information element within an information model given the information element name. | |
const fbInfoElement_t * | fbInfoModelGetElementByID (fbInfoModel_t *model, uint16_t id, uint32_t ent) |
Return a pointer to the canonical information element within an information model given the information element ID and enterprise ID. | |
fbTemplate_t * | fbTemplateAlloc (fbInfoModel_t *model) |
Allocate a new empty template. | |
gboolean | fbTemplateAppend (fbTemplate_t *tmpl, fbInfoElement_t *ex_ie, GError **err) |
Append an information element to a template. | |
gboolean | fbTemplateAppendSpec (fbTemplate_t *tmpl, fbInfoElementSpec_t *spec, uint32_t flags, GError **err) |
Append an information element described by specifier to a template. | |
gboolean | fbTemplateAppendSpecArray (fbTemplate_t *tmpl, fbInfoElementSpec_t *spec, uint32_t flags, GError **err) |
Append information elements described by a specifier array to a template. | |
uint32_t | fbTemplateCountElements (fbTemplate_t *tmpl) |
Determine number of information elements in a template. | |
void | fbTemplateSetOptionsScope (fbTemplate_t *tmpl, uint16_t scope_count) |
Set the number of information elements in a template that are scope. | |
uint32_t | fbTemplateGetOptionsScope (fbTemplate_t *tmpl) |
Determine number of scope information elements in a template. | |
gboolean | fbTemplateContainsElement (fbTemplate_t *tmpl, const fbInfoElement_t *ex_ie) |
Determine if a template contains a given information element. | |
gboolean | fbTemplateContainsElementByName (fbTemplate_t *tmpl, fbInfoElementSpec_t *spec) |
Determine if a template contains at least one instance of a given information element, specified by name in the template's information model. | |
gboolean | fbTemplateContainsAllElementsByName (fbTemplate_t *tmpl, fbInfoElementSpec_t *spec) |
Determine if a template contains at least one instance of each information element in a given information element specifier array. | |
void | fbTemplateFreeUnused (fbTemplate_t *tmpl) |
Free a template if it is not currently in use by any Session. | |
fbSession_t * | fbSessionAlloc (fbInfoModel_t *model) |
Allocate a transport session state container. | |
void | fbSessionAddTemplateCallback (fbSession_t *session, fbNewTemplateCallback_fn callback) |
This function sets the callback to let the user know when a new template has arrived from the connected IPFIX node. | |
void | fbSessionAddTemplatePair (fbSession_t *session, uint16_t ent_tid, uint16_t int_tid) |
Adds an external-internal template pair to the session. | |
void | fbSessionRemoveTemplatePair (fbSession_t *session, uint16_t ext_tid) |
remove a template pair from the list this is called by fixbuf when a template is revoked from the session by the node on the other end of the connection | |
uint16_t | fbSessionLookupTemplatePair (fbSession_t *session, uint16_t ext_tid) |
Function to find a pair, uniquely identified by the external ID, and return the associated internal template ID. | |
void | fbSessionFree (fbSession_t *session) |
Free a transport session state container. | |
void | fbSessionResetExternal (fbSession_t *session) |
Reset the external state (sequence numbers and templates) in a session state container. | |
void | fbSessionSetDomain (fbSession_t *session, uint32_t domain) |
Set the current observation domain on a session. | |
uint32_t | fbSessionGetDomain (fbSession_t *session) |
Retrieve the current domain on a session. | |
gboolean | fbSessionExportTemplate (fbSession_t *session, uint16_t tid, GError **err) |
Export a single external template in the current domain of a given session. | |
gboolean | fbSessionExportTemplates (fbSession_t *session, GError **err) |
Export all external templates in the current domain of a given session. | |
uint16_t | fbSessionAddTemplate (fbSession_t *session, gboolean internal, uint16_t tid, fbTemplate_t *tmpl, GError **err) |
Add a template to a session. | |
gboolean | fbSessionRemoveTemplate (fbSession_t *session, gboolean internal, uint16_t tid, GError **err) |
Remove a template from a session. | |
fbTemplate_t * | fbSessionGetTemplate (fbSession_t *session, gboolean internal, uint16_t tid, GError **err) |
Retrieve a template from a session by ID. | |
fbExporter_t * | fbExporterAllocNet (fbConnSpec_t *spec) |
Allocate an exporting process endpoint for a network connection. | |
fbExporter_t * | fbExporterAllocFile (const char *path) |
Allocate an exporting process endpoint for a named file. | |
fbExporter_t * | fbExporterAllocFP (FILE *fp) |
Allocate an exporting process endpoint for an opened ANSI C file pointer. | |
void | fbExporterSetStream (fbExporter_t *exporter, int sctp_stream) |
Set the SCTP stream for the next message exported. | |
void | fbExporterAutoStream (fbExporter_t *exporter) |
Enable automatic SCTP stream selection for the next message exported. | |
void | fbExporterClose (fbExporter_t *exporter) |
Force the file or socket underlying an exporting process endpoint to close. | |
fbCollector_t * | fbCollectorAllocFile (void *ctx, const char *path, GError **err) |
Allocate a collecting process endpoint for a named file. | |
fbCollector_t * | fbCollectorAllocFP (void *ctx, FILE *fp) |
Allocate a collecting process endpoint for an open file. | |
void * | fbCollectorGetContext (fbCollector_t *collector) |
Retrieve the application context associated with a collector. | |
void | fbCollectorClose (fbCollector_t *collector) |
Close the file or socket underlying a collecting process endpoint. | |
fbListener_t * | fbListenerAlloc (fbConnSpec_t *spec, fbSession_t *session, fbListenerAppInit_fn appinit, fbListenerAppFree_fn appfree, GError **err) |
Allocate a listener. | |
void | fbListenerFree (fbListener_t *listener) |
Free a listener. | |
fBuf_t * | fbListenerWait (fbListener_t *listener, GError **err) |
Wait on a listener. | |
fBuf_t * | fbListenerWaitNoCollectors (fbListener_t *listener, GError **err) |
Waits for an incoming connection, just like fbListenerWait, except that this function doesn't monitor active collectors. | |
void | fbListenerInterrupt (fbListener_t *listener) |
Cause the current or next call to fbListenerWait to unblock and return. | |
gboolean | fbListenerGetCollector (fbListener_t *listener, fbCollector_t **collector, GError **err) |
fbListenerGetCollector | |
gboolean | fbCollectorClearTranslator (fbCollector_t *collector, GError **err) |
fbCollectorClearTranslator | |
gboolean | fbCollectorSetNetflowV9Translator (fbCollector_t *collector, GError **err) |
fbCollectorSetNetflowV9Translator | |
struct sockaddr * | fbCollectorGetPeer (fbCollector_t *collector) |
Retrieves information about the node connected to this collector. |
fixbuf IPFIX protocol library public interface.
Include fixbuf/public.h in order to use the public fixbuf API. Calls defined in this header file will not change from version to version after fixbuf 1.0.0, and should not change aside from additions and bugfixes before fixbuf 1.0.0.
This documentation uses IPFIX terminology as defined in RFC 5101, "Specification of the IPFIX Protocol for the Exchange of IP Traffic Flow Information"
This file defines the data types and routines required to support IPFIX Exporting Process and IPFIX Collecting Process creation. Each data type is manipulated primarily by routines named "fb" followed by the type name (e.g., "Session", "Collector") followed by a description of the routine's action. The routines operating on the fBuf_t IPFIX Mesaage buffer type are named beginning with "fBuf".
The fBuf_t opaque type implements a transcoding IPFIX Message buffer for both export and collection, and is the "core" interface to the fixbuf library.
The fbInfoModel_t opaque type implements an IPFIX Information Model, including both IANA managed Information Elements and vendor-specific Information Elements. The fbTemplate_t opaque type implements an IPFIX Template or an IPFIX Options Template. Both are defined in terms of Information Elements, represented by the fbInfoElement_t public type. An fBuf_t message buffer maintains internal Templates, which represent records within the fixbuf application client, and external Templates, which represent records as they appear on the wire, for use during transcoding. For a Spread Exporter, Templates are managed per group. For a Spread Collector, Templates are managed per Session.
The state of an IPFIX Transport Session, including IPFIX Message Sequence Number tracking and the internal and external Templates in use within the Session, are maintained by the fbSession_t opaque type.
An Exporting Process' connection to its corresponding Collecting Process is encapsulated by the fbExporter_t opaque type. Exporters may be created to connect via the network using one of the supported IPFIX transport protocols, or to write to IPFIX Files specified by name or by open ANSI C file pointer.
A Collecting Process' connection to a corresponding Exporting Process is encapsulated by the fbCollector_t opaque type. The passive connection used to listen for connections from Exporting Processes is managed by the fbListener_t opaque type; Collectors can be made to read from IPFIX Files specified directly by name or by open ANSI C file pointer, as well.
Network addresses are specified for Exporters, Collectors, and Listeners using the fbConnSpec_t and fbTransport_t public types.
This file also defines the GError error codes used by all the fixbuf types and routines within the FB_ERROR_DOMAIN domain.
Each fixbuf application must have a single fbInfoModel_t instance that represents the Information Elements that the application understands. The fbInfoModelAlloc() call allocates a new Information Model with the IANA-managed information elements (current as of the fixbuf release date) preloaded. Additional vendor-specific information elements may be added with fbInfoModelAddElement() and fbInfoModelAddElementArray().
To create an Exporter, first create an fbSession_t attached to the application's fbInfoModel_t to hold the Exporter's Transport Session state using fbSessionAlloc(). If exporting via the Spread protocol, create an fbSpreadParams_t and set its session to your newly defined session, group names (a null terminated array), and Spread daemon name.
Then create an fbExporter_t to encapsulate the connection to the Collecting Process or the file on disk, using the fbExporterAllocFP(), fbExporterAllocFile(), fbExporterAllocNet(), or fbExporterAllocSpread() calls.
With an fbSession_t and an fbExporter_t available, create a buffer for writing via fBufAllocForExport(). Set the internal and external template IDs with fBufSetInternalTemplate() and fBufSetExportTemplate(), and use fBufAppend() to write records into IPFIX Messages and Messages to the output stream.
Create and populate templates for addition to this session using the fbTemplate calls, then add them to the session via fbSessionAddTemplate(). If exporting via Spread, before calling fbSessionAddTemplate(), set the group that should receive this template with the fBufSetSpreadExportGroup() call. If more than 1 group should receive the template, use the fbSessionAddTemplatesMulticast() which will call fBufSetSpreadExportGroup() on the given group(s) multicast the template to the given group(s). For Spread, do not use fbSessionAddTemplate() to send to multiple groups.
Note that Templates use internal reference counting, so they may be added to multiple sessions, or to the same session using multiple template IDs or multiple domains, or as both an internal and an external template on the same session.
By default, fBufAppend() will emit an IPFIX Message to the output stream when the end of the message buffer is reached on write. The fBufSetAutomaticMode() call can be used to modify this behavior, causing fBufAppend() to return FB_ERROR_EOM when at end of message. Use this if your application requires manual control of message export. In this case, fBufEmit() will emit a Message to the output stream. If using Spread, call fBufSetSpreadExportGroup() to set the groups to export to on the buffer before calling fBufAppend().
Using fixbuf to read from IPFIX Files as a Collecting Process is very much like the Export case. Create an fbInfoModel_t and an fbSession_t as above, though you should not define external templates in the new session for collection (instead requiring them to be loaded from templates in the file).
Then create an fbCollector_t to encapsulate the file, using the fbCollectorAllocFP() or fbCollectorAllocFile() calls.
With an fbSession_t and an fbCollector_t available, create a buffer for writing via fBufAllocForCollection(). Set the internal template ID with fBufSetInternalTemplate(), and use fBufNext() to read records from IPFIX Messages and Messages from the input stream.
By default, fBufNext() will consume an IPFIX Message from the input stream when the end of the message buffer is reached on read. The fBufSetAutomaticMode() call can be used to modify this behavior, causing fBufNext() to return FB_ERROR_EOM when at end of message. Use this if your application requires manual control of message collection. In this case, fBufNextMessage() will consume a Message from the input stream.
An additional type, fbListener_t, is used to build Collecting Processes to listen for connections from IPFIX Exporting Processes via the network. To use a listener, first create an fbInfoModel_t and an fbSession_t as above, without defining any external templates. Instead of maintaining state for a particular Transport Session, this fbSession_t instance will be used as a template for each Transport Session created by the listener.
Then create an fbListener_t to encapsulate a passive socket on the network to wait for connections from Exporting Processes using the fbListenerAlloc() call.
To wait for a connection from an Exporting Process, call fbListenerWait(), which handles the cloning of the fbSession_t, the creation of the fbCollector_t, and the creation of the buffer for reading from that collector, and returns the newly created fBuf_t instance.
Each listener tracks every active collector/buffer (i.e., each active Session) it created; the fbListenerWait() call will return an fBuf_t from which another IPFIX Message may be read if no new connections are available. The preferred parameter may be used to request an fBuf_t to try first, to minimize switching among available Sessions. See the documentation for fbListenerWait() for more details.
Similar to reading from IPFIX Files, Create an fbInfoModel_t and an fbSession_t as above, though you should not define external templates in the new session for collection (instead requiring them to be sent from the group that you are subscribing to). Define an fbSpreadParams_t and set the session, groups to subscribe to, and Spread Daemon name.
Then create an fbCollector_t to connect and listen to the Spread Daemon using fbCollectorAllocSpread().
With an fbSession_t and fbcollector_t available, create a buffer for writing via fBufAllocForCollection(). Set the internal template ID with fBufSetInternalTemplate(), and use fBufNext() to read records from IPFIX Messages published to the group your collector is subscribing to.
To view all the Spread Groups that were sent the incoming record, call fbCollectorGetSpreadReturnGroups() on the collector.
Each of the list structures uses a nested list of data. The basic list nests a single information element, while the others use a nested template. The template used for nesting is part of the listed templates sent to the collector when the connection is made, or when the data transfer begins. There is no way to mark a template from this list as one that will be nested, or one that will be used as the highest level template. Each of the templates in the list are treated as equals.
The collector does not learn which template or information element is nested until the data arrives. This requires flexbility in the collectors to handle each of the possible results.
The setting of the internal template has not changed with the addition of the list structures. The internal template is still used to do the initial decoding of the data that arrives at the collector.
Basic lists are not transcoded in the same way as templates because they contain just one information element, thus having no order, so the data can just be parsed and copied to a buffer.
The question with decoding sub templates becomes, what do we use as an internal template for any sub templates that arrive? The answer is a new structure in fixbuf that pairs external and internal template IDs for use in decoding sub templates. The pairs are added to the session that is used for the connection, using fbSessionAddTemplatePair().
Because the external template IDs are only unique for that session, the collector must wait and see which templates arrive attached to which ID to be able to pair that ID up to an internal template. As a result, callback functionality has been added to fixbuf to alert the user when a new external template has arrived. The function to be called is stored in the session structure, which manages the templates. The callback gives the user a pointer to the template structure which contains the information elements, allowing the user to know what's inside the template. The template ID used for this template, along with the session pointer is enough for the user to successfully add template pairs to the session for sub template decoding.
If the user chooses not to use the callback, or does not add any template pairs to the session, then fixbuf will transcode each of the sub templates as if the external and internal template were same. This causes all of the fields sent over the wire to be transcoded into the data buffer on the collecting side. The details of that template are passed up to the collector upon receipt of data so it knows how the data is structured in the buffer.
If the user adds any template pair to the list, then the list will be referenced for each transcode. Any external template the user wishes to process must have an entry in the list. There are 3 cases for entries in the list: 1. There is no listing for the given external template ID, so the entire sub template is ignored by the transcoder. The collector will be given a sub template list (or multi list entry) struct with the number of elements in the list set 0, and the data pointer set to NULL. 2. The listing exists, and the external and internal template IDs are set to the same value. This causes the transcoder to decode each of the information elements, in the same order, into the buffer. 3. The listing exists, and the external and internal template IDs are different. This will transcode in the standard way external templates have been transcoded into internal templates, selecting the desired elements (listed in the internal template) from the data that arrived in the external template.
There are four scenerios in which the user needs to iterate through the elements in a list, whether to fill in, or process the data: 1. Iterating over the repeated information element data in a basic list 2. Iterating over the decoded data elements in a sub template list 3. Iterating over the entries that make up a sub template multi list 4. Iterating over the docoded data elements in an entry of a sub template multi list The two iterating mechanisms are the same in each case: Each of the function names start with the structure being iterated over, e.g., fbBasicList, or fbSubTemplateMultiListEntry 1. Indexing The function used here is (structName)GetIndexed(dataPtr or entry)() It takes a pointer to the struct, and the index to be retrieved. Example usage: for(i = 0; myStructPtr = ...GetIndexedDataPtr(listPtr, i); i++) { process the data that myStructPtr points to. } The loop will end because when i is passed the bounds of the list the GetIndexedDataPtr() returns NULL.
2. Incrementing The function used here is (structName)GetNext(dataPtr or entry)() It takes a pointer to the struct, and a pointer to an element in the list. Pass in NULL at the beginning to get the first element back. Example usage: myStructPtr = NULL; while(myStructPtr = ...GetNextPtr(listPtr, myStructPtr)) { process the data that myStructPtr points to. } The loop will end because the function will return NULL when it gets passed the end of the list. A key part here is initializing myStructPtr to NULL at the beginning!
#define FB_CONNSPEC_INIT |
{ FB_SCTP, NULL, NULL, \ NULL, NULL, NULL, NULL, \ NULL, NULL }
Convenience macro defining a null static fbConnSpec_t.
#define FB_ERROR_BUFSZ 5 |
A message was received larger than the collector buffer size.
Should never occur. This condition is checked at the transport layer in case future versions of fixbuf support dynamic buffer sizing.
#define FB_ERROR_DOMAIN g_quark_from_string("fixbufError") |
All fixbuf errors are returned within the FB_ERROR_DOMAIN domain.
#define FB_ERROR_EOF 3 |
End of IPFIX Message stream.
No more messages are available from the transport layer on read, either because the session has closed, or the file has been processed.
#define FB_ERROR_EOM 2 |
End of IPFIX message.
Either there are no more records present in the message on read, or the message MTU has been reached on write.
#define FB_ERROR_IMPL 6 |
The requested feature is not yet implemented.
#define FB_ERROR_IO 7 |
An unspecified I/O error occured.
#define FB_ERROR_IPFIX 4 |
Illegal IPFIX mesaage content on read.
The input stream is malformed, or is not an IPFIX Message after all.
#define FB_ERROR_NETFLOWV9 12 |
Illegal NetflowV9 content on a read.
Can't parse the Netflow header or the stream is not a NetflowV9 stream
#define FB_ERROR_NLREAD 8 |
No data is available for reading from the transport layer.
Either a transport layer read was interrupted, or timed out.
#define FB_ERROR_NLWRITE 9 |
An attempt to write data to the transport layer failed due to closure of the remote end of the connection.
Currently only occurs with the TCP transport layer.
#define FB_ERROR_TMPL 1 |
No template was available for the given template ID.
#define FB_IE_F_ALIEN 0x00000080 |
Information element alien flag.
If set, IE is enterprise-specific and was recieved via an external template at a Collecting Process. It is therefore subject to semantic typing via options (not yet implemented). Do not set this flag on information elements added programmatically to an information model via fbInfoModelAddElement() or fbInfoModelAddElementArray().
#define FB_IE_F_ENDIAN 0x00000001 |
Information element endian conversion flag.
If set, IE is an integer and will be endian-converted on transcode.
#define FB_IE_F_NONE 0x00000000 |
Default treatment flags value.
Provided for initializer convenience. Corresponds to octet-array semantics for a non-reversible, non-alien IE.
#define FB_IE_F_REVERSIBLE 0x00000040 |
Information element reversible flag.
If set for an information element with an enterprise number of 0 (an IETF/IANA IE), adding the information element via fbInfoModelAddElement() or fbInfoModelAddElementArray() will cause a second, reverse information element to be added to the model following the conventions in IETF Internet-Draft draft-ietf-ipfix-biflow-03. Note that the reverse PEN has not yet been assigned, so this implementation uses a provisional reverse IE as defined by the macro FB_IE_PEN_REVERSE.
#define FB_IE_INIT | ( | _name_, | |||
_ent_, | |||||
_num_, | |||||
_len_, | |||||
_flags_ | ) | { {.name = _name_}, 0, _ent_, _num_, _len_, _flags_ } |
Convenience macro for creating fbInfoElement_t static initializers.
Used for creating information element arrays suitable for passing to fbInfoModelAddElementArray().
#define FB_IE_PEN_REVERSE 29305 |
Private enterprise number for reverse information elements (see draft-ietf-ipfix-biflow-03 section 6.1).
If an information element with FB_IE_F_REVERSIBLE and a zero enterprise number (i.e., an IANA-assigned information element) is added to a model, the reverse IE will be generated by setting the enterprise number to this constant.
#define FB_IE_REVERSE_STR "reverse" |
Reverse information element name prefix.
This string is prepended to an information element name, and the first character after this string is capitalized, when generating a reverse information element.
#define FB_IE_REVERSE_STRLEN 7 |
Length of reverse information element name prefix.
#define FB_IE_VENDOR_BIT_REVERSE 0x4000 |
Reverse information element bit for vendor-specific information elements (see draft-ietf-ipfix-biflow-03 section 6.2).
If an information element with FB_IE_F_REVERSIBLE and a non-zero enterprise number (i.e., a vendor-specific information element) is added to a model, the reverse IE number will be generated by ORing this bit with the given forward information element number.
typedef gboolean(* fbAcceptCallback_fn)(fBuf_t *buf, fbListener_t *listener, struct sockaddr *sAddr, GError **err) |
the callback function to be called when a new connection to a listener has been received.
The memory pointed to by buf and listener will not be cleared so copies of that memory do not need to be done in this function, just copies of the pointers themselves will need to be retained.
buf | pointer to the new buffer created for the new collector | |
listener | pointer to the listener that received the connection | |
sAddr | sockaddr struct describing the connecting node | |
err | error buffer containing error string |
typedef struct fbCollector_st fbCollector_t |
IPFIX Collecting Process endpoint.
Used to collect messages into an associated IPFIX Message Buffer from a remote Exporting Process, or from an IPFIX File. Use this with the fbListener_t structure to implement a full Collecting Process, including Transport Session setup. The internals of this structure are private to libfixbuf.
typedef struct fbConnSpec_st fbConnSpec_t |
Connection specifier.
Used to define a peer address for fbExporter_t, or a passive address for fbListener_t.
typedef struct fbExporter_st fbExporter_t |
IPFIX Exporting Process endpoint.
Used to export messages from an associated IPFIX Message Buffer to a remote Collecting Process, or to an IPFIX File. The internals of this structure are private to libfixbuf.
typedef struct fbInfoElement_st fbInfoElement_t |
A single IPFIX Information Element definition.
An Information Element defines the type of data in each field of a record. This structure may be contained in an fbInfoModel_t, in which case the name field contians the information element name, or an an fbTemplate_t, in which case the canon field references the fbInfoElement_t contained within the Information Model.
typedef struct fbInfoElementSpec_st fbInfoElementSpec_t |
A single IPFIX Information Element specification.
Used to name an information element for inclusion in a template by fbTemplateAppendSpecArray().
typedef struct fbInfoModel_st fbInfoModel_t |
An IPFIX information model.
Contains information element definitions. The internals of this structure are private to libfixbuf.
typedef struct fbListener_st fbListener_t |
IPFIX Collecting Process session listener.
Used to wait for connections from IPFIX Exporting Processes, and to manage open connections via a select(2)-based mechanism. The internals of this structure are private to libfixbuf.
typedef void(* fbListenerAppFree_fn)(void *ctx) |
Application context free function type for fbListener_t.
Called during fbCollector_t cleanup.
typedef gboolean(* fbListenerAppInit_fn)(fbListener_t *listener, void **ctx, int fd, struct sockaddr *peer, size_t peerlen, GError **err) |
Application context initialization function type for fbListener_t.
This function is called after accept(2) for TCP or SCTP with the peer address in the peer argument. For UDP, it is called during fbListener_t initialization. The application may veto fbCollector_t creation by returning FALSE. The context (returned via out-parameter ctx) will be stored in the fbCollector_t, and is retrievable via a call to fbCollectorGetContext().
typedef void(* fbNewTemplateCallback_fn)(fbSession_t *session, uint16_t tid, fbTemplate_t *tmpl) |
The callback function to be called when the session receives a new external template from the connected node.
The point of this callback is to be able to assign an internal template to a received external template for subTemplates
session | a pointer to the session that received the template | |
tid | the template ID for the template that was received | |
tmpl | pointer to the template information of the received template |
typedef struct fbSession_st fbSession_t |
An IPFIX Transport Session state container.
Though Session creation and lifetime are managed by the fbCollector_t and fbExporter_t types, each fBuf_t buffer uses this type to store session state, including internal and external Templates and Message Sequence Number information.
typedef struct fbSubTemplateList_st fbSubTemplateList_t |
Structure used to hold information of a sub template list.
This structure is filled in by the user in an exporter to tell fixbuf how to encode the data. This structure is filled in by the transcoder in a collector, feeding the useful information up to the user
typedef struct fbSubTemplateMultiListEntry_st fbSubTemplateMultiListEntry_t |
Entries contain the same type of information at SubTemplateLists: template ID and template pointers to describe the data the number of data elements and the data pointer and data length.
Sub template multi lists are inherently nested constructions. At a high level, they are a list of sub template lists. The first level is a list of fbSubTemplateMultiListEntry_t's, which each contain the information that describes the data contained in them. Initializing a fbSubTemplateMultiList_t with a semantic and number of elements returns memory that contains numElements blocks of memory containing fbSubTemplateMultiListEntry_t's. It is not ready to accept data. Each of the fbSubTemplateMultiListEntry_t's needed to be set up then data is copied into the entries.
typedef struct fbTemplate_st fbTemplate_t |
An IPFIX Template or Options Template.
Templates define the structure of data records and options records within an IPFIX Message. The internals of this structure are private to libfixbuf.
typedef enum fbTransport_en fbTransport_t |
Transport protocol for connection specifier.
typedef struct fBuf_st fBuf_t |
An IPFIX message buffer.
Used to encode and decode records from IPFIX Messages. The internals of this structure are private to libfixbuf.
typedef struct fbVarfield_st fbVarfield_t |
A variable-length field value.
Variable-length information element content is represented by an fbVarfield_t on the internal side of the transcoder; that is, variable length fields in an IPFIX Message must be represented by this structure within the application record.
enum fbTransport_en |
Transport protocol for connection specifier.
void* fbBasicListAddNewElements | ( | fbBasicList_t * | basicList, | |
uint16_t | numNewElements | |||
) |
Allocates an additional elememnt into the basic list must be called after calling BasicListInit.
basicList | pointer to the basic list to add elements to | |
numNewElements | number of elements to add to the list |
fbBasicList_t* fbBasicListAlloc | ( | void | ) |
allocates a Basic List Structure
void fbBasicListClear | ( | fbBasicList_t * | basicListPtr | ) |
Clear the parameters of the basic list and free the data buffer.
basicListPtr | pointer to the basic list to clear |
void fbBasicListClearWithoutFree | ( | fbBasicList_t * | basicList | ) |
Clear the parameters of the basic list, but do not free the buffer.
This should get used when the user provides their own buffer
basicList | pointer to the basic list to clear without freeing |
void fbBasicListCollectorInit | ( | fbBasicList_t * | basicListPtr | ) |
This initializes a basic list structure for collection.
The key part of this function is it sets the dataPtr to NULL. If your basic list is declared as a pointer, then allocated using something like g_slice_alloc0 which sets it all to zero, you do not need to call this function. But if your basic list struct isn't a pointer, there dataPtr parameter will be set to garbage, which will break other fixbuf calls, so this function is required
basicListPtr | pointer to the basic list to be initialized |
void fbBasicListFree | ( | fbBasicList_t * | basicListPtr | ) |
Clear the basic list, then free the basic list pointer.
basicListPtr | pointer to the basic list to free |
void* fbBasicListGetDataPtr | ( | fbBasicList_t * | basicListPtr | ) |
basicListPtr | pointer to the basic list to get the data pointer from |
void* fbBasicListGetIndexedDataPtr | ( | fbBasicList_t * | basicListPtr, | |
uint16_t | index | |||
) |
Function retrieves the index'th element in the list index is 0-based.
Goes from 0 - (numElements-1)
basicListPtr | pointer to the basic list to retrieve the dataPtr | |
index | the index of the element to retrieve |
const fbInfoElement_t* fbBasicListGetInfoElement | ( | fbBasicList_t * | basicListPtr | ) |
This function returns a pointer to the information element used in the list it is mainly used in collectors to retrieve information.
basicListPtr | pointer to the basic list to get the infoElement from |
void* fbBasicListGetNextPtr | ( | fbBasicList_t * | basicListPtr, | |
void * | currentPtr | |||
) |
Function returns the next element in the list based on the currentPtr.
basicListPtr | pointer to the basic list | |
currentPtr | pointer to the current element being used. Set to NULL to retrieve the first element. |
uint8_t fbBasicListGetSemantic | ( | fbBasicList_t * | basicListPtr | ) |
Get Semantic field for Basic List presumably used in collectors after decoding.
basicListPtr | pointer to the basic list to retrieve the semantic from |
void* fbBasicListInit | ( | fbBasicList_t * | basicListPtr, | |
uint8_t | semantic, | |||
const fbInfoElement_t * | infoElement, | |||
uint16_t | numElements | |||
) |
Initializes the basic list structure based on the parameters.
This function allocates a buffer large enough to hold num elements amount of the infoElements.
basicListPtr | a pointer to the basic list structure to fill | |
semantic | the semantic value to be used in the basic list | |
infoElement | a pointer to the info element to be used in the list | |
numElements | number of elements in the list |
void* fbBasicListInitWithOwnBuffer | ( | fbBasicList_t * | basicListPtr, | |
uint8_t | semantic, | |||
const fbInfoElement_t * | infoElement, | |||
uint16_t | numElements, | |||
uint16_t | dataLength, | |||
uint8_t * | dataPtr | |||
) |
use this function to initialize the basic list, but it gets the pointer to a buffer and its length allocated independently from these functions This will generally be used by a collector that does not want to free and allocate new buffers for each incoming message
basicListPtr | a pointer to the basic list structure to fill | |
semantic | the semantic value to be used in the basic list | |
infoElement | a pointer to the info element to be used in the list | |
numElements | number of elements in the list | |
dataLength | length of the buffer passed to the function | |
dataPtr | pointer to the buffer previously allocated for the list |
void* fbBasicListRealloc | ( | fbBasicList_t * | basicList, | |
uint16_t | newNumElements | |||
) |
Free the current data pointer, allocating a new buffer to accomodate the new number of elements.
The remaining parameters are unchanged. If the number of elements hasn't changed the original buffer is used and its pointer is returned
basicList | pointer to the basic list to realloc | |
newNumElements | new number of elements to allocate for the list |
void fbBasicListSetSemantic | ( | fbBasicList_t * | basicListPtr, | |
uint8_t | semantic | |||
) |
Sets the semantic for describing a basic list generally used in exporters before decoding.
basicListPtr | pointer to the basic list to set the semantic | |
semantic | value to set the semantic field to |
fbCollector_t* fbCollectorAllocFile | ( | void * | ctx, | |
const char * | path, | |||
GError ** | err | |||
) |
Allocate a collecting process endpoint for a named file.
The underlying file will be opened immediately.
ctx | application context; for application use, retrievable by fbCollectorGetContext | |
path | path of file to read, or "-" to read standard input. Used to get fp, user creates and frees. | |
err | An error description, set on failure. |
fbCollector_t* fbCollectorAllocFP | ( | void * | ctx, | |
FILE * | fp | |||
) |
Allocate a collecting process endpoint for an open file.
ctx | application context; for application use, retrievable by fbCollectorGetContext | |
fp | file pointer to file to read. Created and freed by user. Must be kept around for the life of the collector. |
gboolean fbCollectorClearTranslator | ( | fbCollector_t * | collector, | |
GError ** | err | |||
) |
fbCollectorClearTranslator
this removes an input translator from a given collector such that it will operate on IPFIX protocol again
collector | the collector on which to remove the translator | |
err | when an error occurs, a Glib GError structure is set with an error description |
void fbCollectorClose | ( | fbCollector_t * | collector | ) |
Close the file or socket underlying a collecting process endpoint.
No effect on open file endpoints. If the collector is attached to a buffer managed by a listener, the buffer will be removed from the listener (that is, it will not be returned by subsequent fbListenerWait() calls).
collector | a collecting process endpoint. |
void* fbCollectorGetContext | ( | fbCollector_t * | collector | ) |
Retrieve the application context associated with a collector.
This context is taken from the ctx argument of fbCollectorAllocFile() or fbCollectorAllocFP(), or passed out via the ctx argument to the appinit function argument to fbListenerAlloc().
collector | a collecting process endpoint. |
struct sockaddr* fbCollectorGetPeer | ( | fbCollector_t * | collector | ) | [read] |
Retrieves information about the node connected to this collector.
collector | pointer to the collector to get peer information from |
gboolean fbCollectorSetNetflowV9Translator | ( | fbCollector_t * | collector, | |
GError ** | err | |||
) |
fbCollectorSetNetflowV9Translator
this sets the collector input translator to convert NetFlowV9 into IPFIX for the given collector
collector | pointer to the collector state to perform Netflow V9 conversion on | |
err | GError structure that holds the error message if an error occurs |
fbExporter_t* fbExporterAllocFile | ( | const char * | path | ) |
Allocate an exporting process endpoint for a named file.
The underlying file will not be opened until the first message is emitted from the buffer associated with the exporter.
path | pathname of the IPFIX File to write, or "-" to open standard output. Path is duplicated and handled. Original pointer is up to the user. |
fbExporter_t* fbExporterAllocFP | ( | FILE * | fp | ) |
Allocate an exporting process endpoint for an opened ANSI C file pointer.
fp | open file pointer to write to. File pointer is created and freed outside of the Exporter functions. |
fbExporter_t* fbExporterAllocNet | ( | fbConnSpec_t * | spec | ) |
Allocate an exporting process endpoint for a network connection.
The remote collecting process is specified by the given connection specifier. The underlying socket connection will not be opened until the first message is emitted from the buffer associated with the exporter.
spec | remote endpoint connection specifier. A copy is made for the exporter, it is freed later. User is responsible for original spec pointer |
void fbExporterAutoStream | ( | fbExporter_t * | exporter | ) |
Enable automatic SCTP stream selection for the next message exported.
Automatic stream selection is the default; use this call to re-enable it on a given exporter after using fbExporterSetStream(). With automatic stream selection, the minimal behavior specified in the original IPFIX protocol (RFC xxxx) is used: all templates and options templates are exported on stream 0, and all data is exported on stream 1. This call is a no-op for non-SCTP exporters.
exporter | an exporting process endpoint. |
void fbExporterClose | ( | fbExporter_t * | exporter | ) |
Force the file or socket underlying an exporting process endpoint to close.
No effect on open file endpoints. The file or socket may be reopened on a subsequent message emission from the associated buffer.
exporter | an exporting process endpoint. |
void fbExporterSetStream | ( | fbExporter_t * | exporter, | |
int | sctp_stream | |||
) |
Set the SCTP stream for the next message exported.
To change the SCTP stream used for export, first emit any message in the exporter's associated buffer with fbufEmit(), then use this call to set the stream for the next message. This call cancels automatic stream selection, use fbExporterAutoStream() to re-enable it. This call is a no-op for non-SCTP exporters.
exporter | an exporting process endpoint. | |
sctp_stream | SCTP stream to use for next message. |
void fbInfoModelAddElement | ( | fbInfoModel_t * | model, | |
fbInfoElement_t * | ie | |||
) |
Add a single information element to an information model.
The information element is assumed to be in "canonical" form; that is, its ref.name field should contain the information element name. The information element and its name are copied into the model; the caller may free or reuse its storage after this call.
See fbInfoModelAddElementArray() for a more convenient method of statically adding information elements to information models.
model | An information model | |
ie | Pointer to an information element to copy into the model |
void fbInfoModelAddElementArray | ( | fbInfoModel_t * | model, | |
fbInfoElement_t * | ie | |||
) |
Add multiple information elements in an array to an information model.
The information elements are assumed to be in "canonical" form; that is, their ref.name fields should contain the information element name. Each information element and its name are copied into the model; the caller may free or reuse its storage after this call.
The ie parameter points to the first information element in an array, usually statically initialized with an array of FB_IE_INIT macros followed by an FB_IE_NULL macro.
model | An information model | |
ie | Pointer to an IE array to copy into the model |
fbInfoModel_t* fbInfoModelAlloc | ( | ) |
Allocate a new information model.
The information model will contain all the default information elements in the IANA-managed number space, and may be extended via fbInfoModelAddElement() and fbInfoModelAddElementArray().
An Information Model is required to create Templates and Sessions. Each application should have only one Information Model.
void fbInfoModelFree | ( | fbInfoModel_t * | model | ) |
Free an information model.
Must not be called until all sessions and templates depending on the information model have also been freed; i.e., at application cleanup time.
model | An information model |
const fbInfoElement_t* fbInfoModelGetElementByID | ( | fbInfoModel_t * | model, | |
uint16_t | id, | |||
uint32_t | ent | |||
) |
Return a pointer to the canonical information element within an information model given the information element ID and enterprise ID.
The returned information element is owned by the information model and must not be modified.
model | An information model | |
id | An information element id | |
ent | An enterprise id |
const fbInfoElement_t* fbInfoModelGetElementByName | ( | fbInfoModel_t * | model, | |
const char * | name | |||
) |
Return a pointer to the canonical information element within an information model given the information element name.
The returned information element is owned by the information model and must not be modified.
model | An information model | |
name | The name of the information element to look up |
fbListener_t* fbListenerAlloc | ( | fbConnSpec_t * | spec, | |
fbSession_t * | session, | |||
fbListenerAppInit_fn | appinit, | |||
fbListenerAppFree_fn | appfree, | |||
GError ** | err | |||
) |
Allocate a listener.
The listener will listen on a specified local endpoint, and create a new collecting process endpoint and collection buffer for each incoming connection. Each new buffer will be associated with a clone of a given session state container.
The application may associate context with each created collecting process endpoint, or veto a connection attempt, via a function colled on each connection attempt passed in via the appinit parameter. If this function will create application context, provide a function via the appfree parameter which will free it.
spec | local endpoint connection specifier. A copy is made of this, which is freed by listener. Original pointer freeing is up to the user. | |
session | session state container to clone for each collection buffer created by the listener. Not freed by listener. Must be kept alive while listener exists. | |
appinit | application connection initiation function. Called on each collection attempt; vetoes connection attempts and creates application context. | |
appfree | application context free function. | |
err | An error description, set on failure. |
void fbListenerFree | ( | fbListener_t * | listener | ) |
Free a listener.
Stops listening on the local endpoint, and frees any open buffers still managed by the listener.
listener | a listener |
gboolean fbListenerGetCollector | ( | fbListener_t * | listener, | |
fbCollector_t ** | collector, | |||
GError ** | err | |||
) |
fbListenerGetCollector
If a collector is associated with the listener class, this will return a handle to the collector state structure.
listener | handle to the listener state | |
collector | pointer to a collector state pointer, set on return if there is no error | |
err | a GError structure holding an error message on error |
int fbListenerGroupAddListener | ( | fbListenerGroup_t * | group, | |
const fbListener_t * | listener | |||
) |
Adds a previously allocated listener to the previously allocated group.
The listener is placed at the head of the list
group | pointer to the allocated group to add the listener to | |
listener | pointer to the listener structure to add to the group |
fbListenerGroup_t* fbListenerGroupAlloc | ( | void | ) |
Allocates and returns a fbListenerGroup with no entries.
int fbListenerGroupDeleteListener | ( | fbListenerGroup_t * | group, | |
const fbListener_t * | listener | |||
) |
Removes the listener from the group.
IT DOES NOT FREE THE LISTENER OR THE GROUP
group | pointer to the group to remove from the listener from | |
listener | pointer to the listener to remove from the group |
fbListenerGroupResult_t* fbListenerGroupWait | ( | fbListenerGroup_t * | group, | |
GError ** | err | |||
) |
Similar to fbListenerWait, except that is looks for connections for multiple listeners.
It takes a previously allocated and filled listener group. It returns a pointer to the head of a list of listenerGroupResults.
group | pointer to the group of listeners to wait on | |
err | error string structure seen throughout fixbuf |
gboolean fbListenerGroupWaitAcceptCallback | ( | fbListenerGroup_t * | group, | |
fbAcceptCallback_fn | callback, | |||
GError ** | err | |||
) |
A combination of ListenerGroupWait and ListenerWaitAcceptCallback.
It monitors the list of listeners in the group, and calls the callback if any of them find a new connection.
group | pointer to the group to wait for connections on | |
callback | function to call when a listener in the group gets a new connection | |
err | standard error string structure in fixbuf |
void fbListenerInterrupt | ( | fbListener_t * | listener | ) |
Cause the current or next call to fbListenerWait to unblock and return.
Use this from a thread or a signal handler to interrupt a blocked listener.
listener | listener to interrupt. |
fBuf_t* fbListenerOwnSocketCollectorTCP | ( | fbListener_t * | listener, | |
int | sock, | |||
GError ** | err | |||
) |
Returns an fBuf wrapped around an independently managed socket and a properly created listener for TCP connections.
The caller is only responsible for creating the socket. The existing collector code will close the socket and cleanup everything.
listener | pointer to the listener to wrap around the socket | |
sock | the socket descriptor of the independently managed socket | |
err | standard fixbuf err structure pointer |
fBuf_t* fbListenerOwnSocketCollectorTLS | ( | fbListener_t * | listener, | |
int | sock, | |||
GError ** | err | |||
) |
Same as fbListenerOwnSocketCollectorTCP but for TLS (not tested).
listener | pointer to the listener to wait on | |
sock | independently managed socket descriptor | |
err | standard fixbuf err structure pointer |
fBuf_t* fbListenerWait | ( | fbListener_t * | listener, | |
GError ** | err | |||
) |
Wait on a listener.
Accepts pending connections from exporting processes. Returns the next collection buffer with available data to read; if the collection buffer returned by the last call to fbListenerWait() is available, it is preferred. Blocks forever (or until fbListenerInterrupt() is called) if no messages or connections are available.
To effectively use fbListenerWait(), the application should set up an session state container with internal templates, call fbListenerWait() to accept a first connection, then read records from the collector buffer to end of message (FB_ERROR_EOM). At end of message, the application should then call fbListenerWait() to accept pending connections or switch to another collector buffer with available data. Note that each collector buffer returned created by fbListenerWait() is set to manual mode using fBufSetAutomaticMode().
listener | a listener | |
err | An error description, set on failure. |
gboolean fbListenerWaitAcceptCallback | ( | fbListener_t * | listener, | |
fbAcceptCallback_fn | callback, | |||
GError ** | err | |||
) |
Takes one listener, and instead of returning the fBuf created from the new collector, like fbListenerWait(), it calls the callback function provided.
listener | listenr to wait on | |
callback | function to call upon receiving a new connection | |
err | standard fixbuf err string structure |
fBuf_t* fbListenerWaitNoCollectors | ( | fbListener_t * | listener, | |
GError ** | err | |||
) |
Waits for an incoming connection, just like fbListenerWait, except that this function doesn't monitor active collectors.
This allows for a multi threaded application to have one thread monitoring the listeners, and one keeping track of collectors
listener | The listener to wait for connections on | |
err | An error description, set on failure. |
gboolean fbListValidSemantic | ( | uint8_t | semantic | ) |
validates the value of the semantic field,
semantic | The value of the semantic field to be validated * |
uint16_t fbSessionAddTemplate | ( | fbSession_t * | session, | |
gboolean | internal, | |||
uint16_t | tid, | |||
fbTemplate_t * | tmpl, | |||
GError ** | err | |||
) |
Add a template to a session.
If external, adds the template to the current domain, and exports the template if the session is associated with an export buffer. Assigns the template ID given in tid, or assigns a template ID if tid is FB_TID_AUTO.
session | A session state container | |
internal | TRUE if the template is internal, FALSE if external. | |
tid | Template ID to assign, replacing any current template in case of collision; or FB_TID_AUTO to assign a new tId. | |
tmpl | Template to add | |
err | An error description, set on failure |
void fbSessionAddTemplateCallback | ( | fbSession_t * | session, | |
fbNewTemplateCallback_fn | callback | |||
) |
This function sets the callback to let the user know when a new template has arrived from the connected IPFIX node.
Assigning a callback here is NOT required. Not using one will cause all sub templates to be fully decoded, transcoding all information elements in the external template. This function needs to be called AFTER a new connection has been made, usually after the call to fbListenerWait, which creates a new fBuf and session for that connection.
session | pointer to the session to assign the callback to | |
callback | the function to be called when a new template is received |
void fbSessionAddTemplatePair | ( | fbSession_t * | session, | |
uint16_t | ent_tid, | |||
uint16_t | int_tid | |||
) |
Adds an external-internal template pair to the session.
This tells the transcoder which internal template to use for a given external template used in a sub template list, or a sub template multi list
session | pointer to the session to add the pair to | |
ent_tid | the external template ID | |
int_tid | the internal template ID used to decode the data when the associated external template is used |
fbSession_t* fbSessionAlloc | ( | fbInfoModel_t * | model | ) |
Allocate a transport session state container.
The new session is associated with the given information model, contains no templates, and is usable either for collection or export.
Each fbExporter_t, fbListener_t, and fbCollector_t must have its own session; session state cannot be shared.
model | An information model. Not freed by sessionFree. Must be freed by user after calling SessionFree |
gboolean fbSessionExportTemplate | ( | fbSession_t * | session, | |
uint16_t | tid, | |||
GError ** | err | |||
) |
Export a single external template in the current domain of a given session.
Writes the template to the associated export buffer. May cause a message to be emitted if the associated export buffer is in automatic mode, or return with FB_ERROR_EOM if the associated export buffer is not in automatic mode.
session | a session state container associated with an export buffer | |
tid | template ID within current domain to export | |
err | an error description, set on failure. |
gboolean fbSessionExportTemplates | ( | fbSession_t * | session, | |
GError ** | err | |||
) |
Export all external templates in the current domain of a given session.
Writes templates to the associated export buffer. May cause a message to be emitted if the associated export buffer is in automatic mode, or return with FB_ERROR_EOM if the associated export buffer is not in automatic mode.
session | a session state container associated with an export buffer | |
err | an error description, set on failure. |
void fbSessionFree | ( | fbSession_t * | session | ) |
Free a transport session state container.
This is done automatically when freeing the listener or buffer with which the session is associated. Use this call if a session needs to be destroyed before it is associated.
session | session state container to free. |
uint32_t fbSessionGetDomain | ( | fbSession_t * | session | ) |
Retrieve the current domain on a session.
session | a session state container |
fbTemplate_t* fbSessionGetTemplate | ( | fbSession_t * | session, | |
gboolean | internal, | |||
uint16_t | tid, | |||
GError ** | err | |||
) |
Retrieve a template from a session by ID.
If external, retrieves the template within the current domain.
session | A session state container | |
internal | TRUE if the template is internal, FALSE if external. | |
tid | ID of the template to retrieve. | |
err | An error description, set on failure. |
uint16_t fbSessionLookupTemplatePair | ( | fbSession_t * | session, | |
uint16_t | ext_tid | |||
) |
Function to find a pair, uniquely identified by the external ID, and return the associated internal template ID.
session | pointer to the session used to find the pair | |
ext_tid | external template ID used to find a pair |
gboolean fbSessionRemoveTemplate | ( | fbSession_t * | session, | |
gboolean | internal, | |||
uint16_t | tid, | |||
GError ** | err | |||
) |
Remove a template from a session.
If external, removes the template from the current domain, and exports a template revocation set if the session is associated with an export buffer.
session | A session state container | |
internal | TRUE if the template is internal, FALSE if external. | |
tid | Template ID to remove. | |
err | An error description, set on failure |
void fbSessionRemoveTemplatePair | ( | fbSession_t * | session, | |
uint16_t | ext_tid | |||
) |
remove a template pair from the list this is called by fixbuf when a template is revoked from the session by the node on the other end of the connection
session | pointer to the session to remove the pair from | |
ext_tid | the external template ID for the pair |
void fbSessionResetExternal | ( | fbSession_t * | session | ) |
Reset the external state (sequence numbers and templates) in a session state container.
FIXME: Verify that this call actually makes sense; either that a session is reassociatable with a new collector, or that you need to do this when reassociating a collector with a connection. Once this is done, rewrite this documentation
session | session state container to reset |
void fbSessionSetDomain | ( | fbSession_t * | session, | |
uint32_t | domain | |||
) |
Set the current observation domain on a session.
The domain is used to scope sequence numbers and external templates. This is called automatically during collection, but must be called to set the domain for export before adding external templates or writing records.
Notice that a domain change does not automatically cause any associated export buffers to emit messages; a domain change takes effect with the next message started. Therefore, call fBufEmit() before setting the domain on the buffer's associated session.
session | a session state container | |
domain | ID of the observation domain to set |
void* fbSubTemplateListAddNewElements | ( | fbSubTemplateList_t * | subTemplateList, | |
uint16_t | numNewElements | |||
) |
Allocates space for a number of additional element in the sub template list must be called after the list has been fbSubTemplateListInit()'d.
subTemplateList | pointer to the sub template list | |
numNewElements | number of new elements to add to the list |
fbSubTemplateList_t* fbSubTemplateListAlloc | ( | void | ) |
Allocates a subTemplateList_t Based on how subTemplateLists will be used and set up amidst data structures, this function may never be used.
void fbSubTemplateListClear | ( | fbSubTemplateList_t * | subTemplateListPtr | ) |
Clears a subtemplate list struct, notably freeing the dataPtr and setting it to NULL.
This should be used after each call to fBufNext: If the dataPtr is not NULL in DecodeSubTemplateList, it will not allocate new memory for the new record, which could cause a buffer overflow if the new record has a longer list than the current one. An alternative is to allocate a large buffer and assign it to dataPtr on your own, then never clear it with this. Be certain this buffer is longer than needed for all possible lists
subTemplateListPtr | pointer to the sub template list to clear |
void fbSubTemplateListClearWithoutFree | ( | fbSubTemplateList_t * | subTemplateListPtr | ) |
Clears the sub template list parameters but does not free the data ptr.
This is used in conjuction with STLInitOwnBuffer because that buffer is allocated at the beginning by the user and will be freed at the end by the user, outside of fixbuf api calls
subTemplateListPtr | pointer to the sub template list to clear |
void fbSubTemplateListCollectorInit | ( | fbSubTemplateList_t * | STL | ) |
Initializes a sub template list variable on a collector.
If the fbSubTemplateList variable is in a struct, it will likely not be set to 0's If not, the dataPtr will not be NULL, so the transcoder will not allocate the right memory for it, as it will assuming it's set up. This will break. Call this function right after declaring the struct variable that contains the fbSubTemplateList. It only needs to be called once for each STL
STL | pointer to the sub template list to initialize for collection |
void fbSubTemplateListFree | ( | fbSubTemplateList_t * | subTemplateListPtr | ) |
Frees and clears a subTemplateList struct.
This frees the dataPtr AND frees the memory pointed to by the subTemplateListPtr Used in conjunction with subTemplateListAlloc(), unlikely to be used
subTemplateListPtr | pointer to the sub template list to free |
void* fbSubTemplateListGetDataPtr | ( | const fbSubTemplateList_t * | subTemplateListPtr | ) |
Returns a pointer to the buffer that contains the data for the list.
subTemplateListPtr | pointer to the STL to get the pointer from |
void* fbSubTemplateListGetIndexedDataPtr | ( | const fbSubTemplateList_t * | subTemplateListPtr, | |
uint16_t | index | |||
) |
This function is used to iterate over the elements in the list by passing in a counter to indicate which element is to be returned.
subTemplateListPtr | pointer to the STL | |
index | The index of the element to be retrieved (0-based) |
void* fbSubTemplateListGetNextPtr | ( | const fbSubTemplateList_t * | subTemplateListPtr, | |
void * | currentPtr | |||
) |
This function also traverses the elements in the list by accepting a pointer to the last element the user accessed, moves it to the next element and returns a pointer to the next element.
A current element of NULL tells the function to return the first element in the list.
subTemplateListPtr | pointer to the STL to get data from | |
currentPtr | pointer to the last element accessed. NULL causes the pointer to the first element to be returned |
uint8_t fbSubTemplateListGetSemantic | ( | fbSubTemplateList_t * | subTemplateListPtr | ) |
Gets the semantic value from a sub template list.
subTemplateListPtr | pointer to the sub template list |
const fbTemplate_t* fbSubTemplateListGetTemplate | ( | fbSubTemplateList_t * | subTemplateListPtr | ) |
Gets the template pointer from the list structure.
subTemplateListPtr | pointer to the sub template list |
uint16_t fbSubTemplateListGetTemplateID | ( | fbSubTemplateList_t * | subTemplateListPtr | ) |
Gets the template ID for the template used by the list.
subTemplateListPtr | pointer to the sub template list |
void* fbSubTemplateListInit | ( | fbSubTemplateList_t * | sTL, | |
uint8_t | semantic, | |||
uint16_t | tmplID, | |||
const fbTemplate_t * | tmpl, | |||
uint16_t | numElements | |||
) |
Initializes a subTemplateList structure and alloc's the dataPtr to get a buffer able to hold numElements in the template This will mainly be used in exporters preparing to encode.
sTL | pointer to the sub template list to initialize | |
semantic | the semantic value used to describe the list contents | |
tmplID | id of the template used for encoding the list data | |
tmpl | pointer to the template struct used for encoding the list data | |
numElements | number of elements in the list |
void* fbSubTemplateListInitWithOwnBuffer | ( | fbSubTemplateList_t * | subTemplateList, | |
uint8_t | semantic, | |||
uint16_t | tmplID, | |||
const fbTemplate_t * | tmpl, | |||
uint16_t | numElements, | |||
uint16_t | dataLength, | |||
uint8_t * | dataPtr | |||
) |
Initializes the subTemplateList but does not allocate a buffer.
It accepts a previously allocated buffer and data length and uses it. This will generally be used in collectors providing their own buffer
subTemplateList | pointer to the sub template list to initialize | |
semantic | the semantic value used to describe the list contents | |
tmplID | id of the template used for encoding the list data | |
tmpl | pointer to the template struct used for encoding the list data | |
numElements | number of elements in the list | |
dataLength | length of the data buffer | |
dataPtr | pointer to the previously allocated data buffer |
void* fbSubTemplateListRealloc | ( | fbSubTemplateList_t * | subTemplateList, | |
uint16_t | newNumElements | |||
) |
Free the current data pointer, allocating a new buffer to accomodate the new number of elements.
The remaining parameters are unchanged. If the number of elements hasn't changed the original buffer is used and its pointer is returned
subTemplateList | pointer to the sub template list to realloc | |
newNumElements | value for the new number of elements for the list |
void fbSubTemplateListSetSemantic | ( | fbSubTemplateList_t * | subTemplateListPtr, | |
uint8_t | semantic | |||
) |
Sets the semantic parameter of a subTemplateList.
subTemplateListPtr | pointer to the sub template list | |
semantic | Semantic value for the list |
fbSubTemplateMultiListEntry_t* fbSubTemplateMultiListAddNewEntries | ( | fbSubTemplateMultiList_t * | STML, | |
uint16_t | numNewEntries | |||
) |
Adds entries to the multi list of entries can only be run after the list has been initialized.
STML | pointer to the sub template multi list | |
numNewEntries | number of entries to add to the list |
void fbSubTemplateMultiListClear | ( | fbSubTemplateMultiList_t * | STML | ) |
Clears all of the entries (frees their data pointers), then frees the memory containing the entries.
STML | pointer to the sub template mutli list to clear |
void fbSubTemplateMultiListClearEntries | ( | fbSubTemplateMultiList_t * | STML | ) |
Clears the memory used by the entries of a sub template multi list NOTE: if any of those entries contain another layer of structures, that second layer must be freed by the user, this function cannot do that.
example: an entry's template contains an element of type basicList. The memory used by that basicList isn't freed by this function
STML | pointer to the sub template multi list |
void fbSubTemplateMultiListEntryClear | ( | fbSubTemplateMultiListEntry_t * | entry | ) |
Frees the memory pointed to by the data buffer holding the data elements.
entry | pointer to the entry to clear the contents of. |
void* fbSubTemplateMultiListEntryGetDataPtr | ( | fbSubTemplateMultiListEntry_t * | entry | ) |
Retrieves the data pointer for this entry.
entry | pointer to the entry to get the data pointer from |
void* fbSubTemplateMultiListEntryGetIndexedPtr | ( | fbSubTemplateMultiListEntry_t * | entry, | |
uint16_t | index | |||
) |
Returns a pointer to a data element in the entry based on the index.
If the index is >= to the number of elements in the list, NULL is returned. The elements are 0-based, so index = 0 is returns the first elements.
entry | pointer to the entry to get a data pointer from. | |
index | the number of the element in the list to return |
const fbTemplate_t* fbSubTemplateMultiListEntryGetTemplate | ( | fbSubTemplateMultiListEntry_t * | entry | ) |
Retrieve the template pointer used to structure the data elements.
entry | pointer to the entry to get the template from |
uint16_t fbSubTemplateMultiListEntryGetTemplateID | ( | fbSubTemplateMultiListEntry_t * | entry | ) |
Retrieve the template ID for the template used to structure the data.
entry | pointer to the entry to get the template ID from |
void* fbSubTemplateMultiListEntryInit | ( | fbSubTemplateMultiListEntry_t * | entry, | |
uint16_t | tmplID, | |||
fbTemplate_t * | tmpl, | |||
uint16_t | numElements | |||
) |
Initializes the multi list entry with the template values, and allocates the memory used by the entry to hold the data.
entry | pointer to the entry to initialize | |
tmplID | ID of the template used to structure the data elements | |
tmpl | pointer to the template used to structure the data elements | |
numElements | number of data elements in the entry |
void* fbSubTemplateMultiListEntryNextDataPtr | ( | fbSubTemplateMultiListEntry_t * | entry, | |
void * | currentPtr | |||
) |
This function traverses the elements in the entry by accepting a pointer to the last element the user accessed, moves it to the next element and returns a pointer to the next element.
A current element of NULL tells the function to return the first element in the list.
entry | pointer to the entry to get the next element from | |
currentPtr | pointer to the last element accessed. NULL means return a pointer to the first element. |
void* fbSubTemplateMultiListEntryRealloc | ( | fbSubTemplateMultiListEntry_t * | entry, | |
uint16_t | newNumElements | |||
) |
Frees the memory for the data used by the entry, then allocates a new buffer based on the size of the template and newNumElements.
(if numElements doesn't change, the pointer is returned without freeing and allocating)
entry | pointer to the entry to realloc | |
newNumElements | the new number of elements for the entry |
void fbSubTemplateMultiListFree | ( | fbSubTemplateMultiList_t * | STML | ) |
Clears the multi list, then frees the memory pointed to by STML.
STML | pointer to the sub template multi list |
fbSubTemplateMultiListEntry_t* fbSubTemplateMultiListGetFirstEntry | ( | fbSubTemplateMultiList_t * | STML | ) |
Retrieve the first entry in the multi list.
STML | pointer to the sub template multi list |
fbSubTemplateMultiListEntry_t* fbSubTemplateMultiListGetIndexedEntry | ( | fbSubTemplateMultiList_t * | STML, | |
uint16_t | index | |||
) |
Retrieve a pointer to the entry of a specific index.
The entry indexes are zero based. NULL is returned if the index requested is too high
STML | pointer to the sub template mutli list | |
index | index of the entry to be returned |
fbSubTemplateMultiListEntry_t* fbSubTemplateMultiListGetNextEntry | ( | fbSubTemplateMultiList_t * | STML, | |
fbSubTemplateMultiListEntry_t * | currentEntry | |||
) |
This function also traverses the elements in the list by accepting a pointer to the last element the user accessed, moves it to the next element and returns a pointer to the next element.
A current element of NULL tells the function to return the first element in the list.
STML | pointer to the sub template multi list to get data from | |
currentEntry | pointer to the last element accessed. NULL means none have been accessed yet |
uint8_t fbSubTemplateMultiListGetSemantic | ( | fbSubTemplateMultiList_t * | STML | ) |
Get the semantic paramter from the multi list.
STML | pointer to the sub template multi list |
fbSubTemplateMultiListEntry_t* fbSubTemplateMultiListInit | ( | fbSubTemplateMultiList_t * | STML, | |
uint8_t | semantic, | |||
uint16_t | numElements | |||
) |
Initializes the multi list with semantic, numbers of elements, and allocates memory to store numElements worth of entries.
STML | pointer to the sub template multi list to initialize | |
semantic | value used to describe the entries in the multi list | |
numElements | number of entries in the multi list |
fbSubTemplateMultiListEntry_t* fbSubTemplateMultiListRealloc | ( | fbSubTemplateMultiList_t * | STML, | |
uint16_t | newNumEntries | |||
) |
Clears the entries used by the multi list, then if newNumElements is different than numElements, frees the entries buffer and allocates a new one.
STML | pointer to the sub template mutli list | |
newNumEntries | the new number of entries for the STML |
void fbSubTemplateMultiListSetSemantic | ( | fbSubTemplateMultiList_t * | STML, | |
uint8_t | semantic | |||
) |
Sets the semantic field for the multi list.
STML | pointer to the sub template multi list | |
semantic | Value for the semantic field of the sub template multi list |
fbTemplate_t* fbTemplateAlloc | ( | fbInfoModel_t * | model | ) |
Allocate a new empty template.
The template will be associated with the given Information Model, and only able to use Information Elements defined within that Information Model. Templates may be associated with multiple sessions, with different template IDs each time, and as such are reference counted and owned by sessions. A template must be associated with at least one session or it will be leaked; each template is freed after its last associated session is freed.
Use fbTemplateAppend(), fbTemplateAppendSpec(), and fbTemplateAppendSpecArray() to "fill in" a template after creating it, and before associating it with any session.
model | An information model |
gboolean fbTemplateAppend | ( | fbTemplate_t * | tmpl, | |
fbInfoElement_t * | ex_ie, | |||
GError ** | err | |||
) |
Append an information element to a template.
The information element is taken to be an example; the canonical element from the template's associated model is looked up by enterprise and element number and copied. If no information element exists in the model with the given enterprise and element number, it is copied to the model with the name "_alienInformationElement".
This call is intended primarily for use by fBuf_t's template reader, but can also be useful to simulate receipt of templates over the wire.
tmpl | Template to append information element to | |
ex_ie | Example IE to add to the template | |
err | an error description, set on failure. |
gboolean fbTemplateAppendSpec | ( | fbTemplate_t * | tmpl, | |
fbInfoElementSpec_t * | spec, | |||
uint32_t | flags, | |||
GError ** | err | |||
) |
Append an information element described by specifier to a template.
The information element named by the specifier is copied from the template's associated model, and the length and flags are overriden from the specifier.
tmpl | Template to append information element to. | |
spec | Specifier describing information element to append. | |
flags | Application flags. Must match one bit of spec flags word or the append will be silently skipped. Used for building multiple templates with different information element features from a single specifier. | |
err | an error description, set on failure. |
gboolean fbTemplateAppendSpecArray | ( | fbTemplate_t * | tmpl, | |
fbInfoElementSpec_t * | spec, | |||
uint32_t | flags, | |||
GError ** | err | |||
) |
Append information elements described by a specifier array to a template.
The information elements named by the specifiers are copied from the template's associated model, and the length and flags are overriden from each specifier. The array is read until the FB_IESPEC_NULL convenience macro is encountered.
tmpl | Template to append information element to. | |
spec | Pointer to first specifier in specifier array to append. | |
flags | Application flags. Must contain all bits of spec flags word or the append will be silently skipped. Used for building multiple templates with different information element features from a single specifier. | |
err | an error description, set on failure. |
gboolean fbTemplateContainsAllElementsByName | ( | fbTemplate_t * | tmpl, | |
fbInfoElementSpec_t * | spec | |||
) |
Determine if a template contains at least one instance of each information element in a given information element specifier array.
tmpl | Template to search | |
spec | Pointer to specifier array to search for |
gboolean fbTemplateContainsElement | ( | fbTemplate_t * | tmpl, | |
const fbInfoElement_t * | ex_ie | |||
) |
Determine if a template contains a given information element.
Matches against information element private enterprise number, number, and multiple-IE index (i.e., to determine if a given template contains six instances of a given information element, set ex_ie->midx = 5 before this call).
tmpl | Template to search | |
ex_ie | Pointer to an information element to search for |
gboolean fbTemplateContainsElementByName | ( | fbTemplate_t * | tmpl, | |
fbInfoElementSpec_t * | spec | |||
) |
Determine if a template contains at least one instance of a given information element, specified by name in the template's information model.
tmpl | Template to search | |
spec | Specifier of information element to search for |
uint32_t fbTemplateCountElements | ( | fbTemplate_t * | tmpl | ) |
Determine number of information elements in a template.
tmpl | A template |
void fbTemplateFreeUnused | ( | fbTemplate_t * | tmpl | ) |
Free a template if it is not currently in use by any Session.
Use this to clean up while creating templates in case of error.
tmpl | template to free |
uint32_t fbTemplateGetOptionsScope | ( | fbTemplate_t * | tmpl | ) |
Determine number of scope information elements in a template.
The template is an options template if nonzero.
tmpl | A template |
void fbTemplateSetOptionsScope | ( | fbTemplate_t * | tmpl, | |
uint16_t | scope_count | |||
) |
Set the number of information elements in a template that are scope.
This causes the template to become an options template, and must be called after all the scope information elements have been appended to the template.
tmpl | Template to set scope on | |
scope_count | Number of scope information elements |
fBuf_t* fBufAllocForCollection | ( | fbSession_t * | session, | |
fbCollector_t * | collector | |||
) |
Allocate a new buffer for collection.
Associates the buffer with a given session and collecting process endpoint; these become owned by the buffer. Session and collector are freed by fBufFree. Must not be freed by user
session | a session initialized with appropriate internal templates | |
collector | an collecting process endpoint |
fBuf_t* fBufAllocForExport | ( | fbSession_t * | session, | |
fbExporter_t * | exporter | |||
) |
Allocate a new buffer for export.
Associates the buffer with a given session and exporting process endpoint; these become owned by the buffer. Session and exporter are freed by fBufFree. Must never be freed by user
session | a session initialized with appropriate internal and external templates | |
exporter | an exporting process endpoint |
gboolean fBufAppend | ( | fBuf_t * | fbuf, | |
uint8_t * | recbase, | |||
size_t | recsize, | |||
GError ** | err | |||
) |
Append a record to a buffer.
Uses the present internal template set via fBufSetInternalTemplate() to describe the record of size recsize located in memory at recbase. Uses the present export template set via fBufSetExportTemplate() to describe the record structure to be written to the buffer. Information Elements present in the external template that are not present in the internal template are transcoded into the message as zeroes. If the buffer is in automatic mode, may cause a message to be emitted via fBufEmit() if there is insufficient space in the buffer for the record.
If the internal template contains any variable length Information Elements, those must be represented in the record by fbVarfield_t structures.
fbuf | an IPFIX message buffer | |
recbase | pointer to internal record | |
recsize | size of internal record in bytes | |
err | an error description, set on failure. Must not be NULL, as it is used internally in automatic mode to detect message restart. |
gboolean fBufEmit | ( | fBuf_t * | fbuf, | |
GError ** | err | |||
) |
Emit the message currently in a buffer using the associated exporting process endpoint.
fbuf | an IPFIX message buffer | |
err | an error description, set on failure. |
void fBufFree | ( | fBuf_t * | fbuf | ) |
Free a buffer.
Also frees any associated session, exporter, or collector, closing exporting process or collecting process endpoint connections and removing collecting process endpoints from any listeners, as necessary.
fbuf | an IPFIX message buffer |
fbTemplate_t* fBufGetCollectionTemplate | ( | fBuf_t * | fbuf, | |
uint16_t * | ext_tid | |||
) |
Retrieve the external template used to read the last record from the buffer.
If no record has been read, returns NULL. Stores the external template ID within the current domain in ext_tid, if not NULL.
This routine is not particularly useful to applications, as it would be called after the record described by the external template had been transcoded, and as such could not be used to select an appropriate internal template for a given external template. However, it is used by fBufNextCollectionTemplate(), and may be useful in certain contexts, so is made public.
Usually, you'll want to use fBufNextCollectionTemplate() instead.
fbuf | an IPFIX message buffer | |
ext_tid | pointer to external template ID storage, or NULL. |
fbCollector_t* fBufGetCollector | ( | fBuf_t * | fbuf | ) |
Retrieve the collecting process endpoint associated with a buffer.
The buffer must have been allocated with fBufAllocForCollection(); otherwise, returns NULL.
fbuf | an IPFIX message buffer |
fbExporter_t* fBufGetExporter | ( | fBuf_t * | fbuf | ) |
Retrieve the exporting process endpoint associated with a buffer.
The buffer must have been allocated with fBufAllocForExport(); otherwise, returns NULL.
fbuf | an IPFIX message buffer |
uint32_t fBufGetExportTime | ( | fBuf_t * | fbuf | ) |
Retrieve the export time on the message currently in a buffer.
fbuf | an IPFIX message buffer |
fbSession_t* fBufGetSession | ( | fBuf_t * | fbuf | ) |
Retrieve the session associated with a buffer.
fbuf | an IPFIX message buffer |
void fBufInterruptSocket | ( | fBuf_t * | fbuf | ) |
Interrupts the select call of a specific collector by way of its fBuf.
This is mainly used by fbListenerInterrupt to interrupt all of the collector sockets well.
gboolean fBufNext | ( | fBuf_t * | fbuf, | |
uint8_t * | recbase, | |||
size_t * | recsize, | |||
GError ** | err | |||
) |
Retrieve a record from a buffer.
Uses the external template taken from the message to read the next record available from a data set in the message. Copies the record to a buffer at recbase, with a maximum record size pointed to by recsize, described by the present internal template set via fBufSetInternalTemplate(). Reads and processes any templates and options templates between the last record read (or beginning of message) and the next data record. Information Elements present in the internal template that are not present in the external template are transcoded into the record at recbase as zeroes. If the buffer is in automatic mode, may cause a message to be read via fBufNextMessage() if there are no more records available in the message buffer.
If the internal template contains any variable length Information Elements, those must be represented in the record at recbase by fbVarfield_t structures.
fbuf | an IPFIX message buffer | |
recbase | pointer to internal record buffer; will contain record data after call. | |
recsize | On call, pointer to size of internal record buffer in bytes. Contains number of bytes actually transcoded at end of call. | |
err | an error description, set on failure. Must not be NULL, as it is used internally in automatic mode to detect message restart. |
fbTemplate_t* fBufNextCollectionTemplate | ( | fBuf_t * | fbuf, | |
uint16_t * | ext_tid, | |||
GError ** | err | |||
) |
Retrieve the external template that will be used to read the next record from the buffer.
If no next record is available, returns NULL. Stores the external template ID within the current domain in ext_tid, if not NULL. Reads and processes any templates and options templates between the last record read (or beginning of message) and the next data record. If the buffer is in automatic mode, may cause a message to be read via fBufNextMessage() if there are no more records available in the message buffer.
fbuf | an IPFIX message buffer | |
ext_tid | pointer to external template ID storage, or NULL. | |
err | an error description, set on failure. Must not be NULL, as it is used internally in automatic mode to detect message restart. |
gboolean fBufNextMessage | ( | fBuf_t * | fbuf, | |
GError ** | err | |||
) |
Read a new message into a buffer using the associated collecting process endpoint.
Called by fBufNext() on end of message in automatic mode; should be called after an FB_ERROR_EOM return from fBufNext in manual mode, or to skip the current message and go on to the next in the stream.
fbuf | an IPFIX message buffer | |
err | an error description, set on failure. |
void fBufSetAutomaticMode | ( | fBuf_t * | fbuf, | |
gboolean | automatic | |||
) |
Set the automatic mode flag on a buffer.
In automatic mode, a call to fBufAppend() or fbSessionExportTemplates() that overruns the available space in the buffer will cause a call to fBufEmit() to emit the message in the buffer to the exporter before starting a new message; and a call to fBufNext() that overruns the buffer will cause a call to fBufNextMessage() to read another message from the collector before attempting to read a record. In manual mode, end of message on any buffer read/write call results in FB_ERROR_EOM. Buffers are created in automatic mode by default.
fbuf | an IPFIX message buffer | |
automatic | TRUE for this buffer to be automatic, FALSE for manual. |
void fBufSetCollector | ( | fBuf_t * | fbuf, | |
fbCollector_t * | collector | |||
) |
Associate an collecting process endpoint with a buffer.
The collector will be used to read IPFIX messgaes from a transport. The collector becomes owned by the buffer; any previous collector associated with the buffer is closed if necessary and freed.
fbuf | an IPFIX message buffer | |
collector | an collecting process endpoint |
void fBufSetExporter | ( | fBuf_t * | fbuf, | |
fbExporter_t * | exporter | |||
) |
Associate an exporting process endpoint with a buffer.
The exporter will be used to write IPFIX messgaes to a transport. The exporter becomes owned by the buffer; any previous exporter associated with the buffer is closed if necessary and freed.
fbuf | an IPFIX message buffer | |
exporter | an exporting process endpoint |
gboolean fBufSetExportTemplate | ( | fBuf_t * | fbuf, | |
uint16_t | ext_tid, | |||
GError ** | err | |||
) |
Set the external template for export on a buffer to the given template ID.
The external template describes the record that will be written to the IPFIX message. The buffer must be initialized for export. The given ID is scoped to the observation domain of the associated session (see fbSessionSetDomain()), and must identify a current external template for the current domain in the buffer's associated session.
An export template must be set on a buffer before calling fBufAppend().
fbuf | an IPFIX message buffer | |
ext_tid | template ID of the new external template within the current domain. | |
err | An error description, set on failure. |
void fBufSetExportTime | ( | fBuf_t * | fbuf, | |
uint32_t | extime | |||
) |
Set the export time on the message currently in a buffer.
This will be used as the export time of the message created by the first call to fBufAppend() after the current message, if any, is emitted. Use 0 for the export time to cause the export time to be taken from the system clock at message creation time.
fbuf | an IPFIX message buffer | |
extime | the export time in epoch seconds. |
gboolean fBufSetInternalTemplate | ( | fBuf_t * | fbuf, | |
uint16_t | int_tid, | |||
GError ** | err | |||
) |
Set the internal template on a buffer to the given template ID.
The internal template describes the format of the record pointed to by the recbase parameter to fBufAppend() (for export) and fBufNext() (for collection). The given template ID must identify a current internal template in the buffer's associated session.
An internal template must be set on a buffer before calling fBufAppend() or fBufNext().
fbuf | an IPFIX message buffer | |
int_tid | template ID of the new internal template | |
err | An error description, set on failure. |