forked from CESNET/ipfixcol2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NetFlow converters: added NetFlow v5/v9 to IPFIX converters, NetFlow …
…v9 iterators, etc. (not tested, unit tests will follow)
- Loading branch information
Showing
10 changed files
with
3,401 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,180 @@ | ||
/** | ||
* \file src/core/netflow2ipfix/netflow2ipfix.h | ||
* \author Lukas Hutak <[email protected]> | ||
* \brief Main NetFlow v5/v9 to IPFIX converter functions (header file) | ||
* \date 2018 | ||
*/ | ||
|
||
/* | ||
* Copyright (C) 2018 CESNET, z.s.p.o. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* 1. Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in | ||
* the documentation and/or other materials provided with the | ||
* distribution. | ||
* 3. Neither the name of the Company nor the names of its contributors | ||
* may be used to endorse or promote products derived from this | ||
* software without specific prior written permission. | ||
* | ||
* ALTERNATIVELY, provided that this notice is retained in full, this | ||
* product may be distributed under the terms of the GNU General Public | ||
* License (GPL) version 2 or later, in which case the provisions | ||
* of the GPL apply INSTEAD OF those given above. | ||
* | ||
* This software is provided ``as is``, and any express or implied | ||
* warranties, including, but not limited to, the implied warranties of | ||
* merchantability and fitness for a particular purpose are disclaimed. | ||
* In no event shall the company or contributors be liable for any | ||
* direct, indirect, incidental, special, exemplary, or consequential | ||
* damages (including, but not limited to, procurement of substitute | ||
* goods or services; loss of use, data, or profits; or business | ||
* interruption) however caused and on any theory of liability, whether | ||
* in contract, strict liability, or tort (including negligence or | ||
* otherwise) arising in any way out of the use of this software, even | ||
* if advised of the possibility of such damage. | ||
* | ||
*/ | ||
|
||
#ifndef IPFIXCOL2_NETFLOW2IPFIX_H | ||
#define IPFIXCOL2_NETFLOW2IPFIX_H | ||
|
||
#include <stdint.h> | ||
#include <stddef.h> | ||
#include <ipfixcol2.h> | ||
|
||
/** | ||
* \defgroup nf5_to_ipfix NetFlow v5 to IPFIX | ||
* \brief Conversion from NetFlow v5 Messages to IPFIX Messages | ||
* | ||
* The converter helps to convert a stream of NetFlow Messages from a NetFlow exporter to stream | ||
* of IPFIX Messages. Messages are processed individually and should be passed to the | ||
* converter in the order send by the exporter. If it is necessary to convert streams from | ||
* multiple exporters at time, you MUST create an independent instance for each stream. | ||
* | ||
* @{ | ||
*/ | ||
|
||
/** Auxiliary definition of NetFlow v5 to IPFIX converter internals */ | ||
typedef struct ipx_nf5_conv ipx_nf5_conv_t; | ||
|
||
/** | ||
* \brief Initialize NetFlow v5 to IPFIX converter | ||
* | ||
* \note | ||
* Template refresh interval (\p tmplt_refresh) refers to exporter timestamps in NetFlow | ||
* Messages to convert, not to wall-clock time. | ||
* \param[in] ident Instance identification (only for log messages!) | ||
* \param[in] vlevel Verbosity level of the converter (i.e. amount of log messages) | ||
* \param[in] tmplt_refresh Template refresh interval (seconds, 0 == disabled) | ||
* \param[in] odid Observation Domain ID of IPFIX Messages (e.g. 0) | ||
* \return Pointer to the converter or NULL (memory allocation error) | ||
*/ | ||
ipx_nf5_conv_t * | ||
ipx_nf5_conv_init(const char *ident, enum ipx_verb_level vlevel, uint32_t tmplt_refresh, | ||
uint32_t odid); | ||
|
||
/** | ||
* \brief Destroy NetFlow v5 to IPFIX converter | ||
* \param[in] conv Converter to destroy | ||
*/ | ||
void | ||
ipx_nf5_conv_destroy(ipx_nf5_conv_t *conv); | ||
|
||
/** | ||
* \brief Convert NetFlow v5 message to IPFIX message | ||
* | ||
* The function accepts a message wrapper \p wrapper that should hold a NetFlow v5 Message. | ||
* If the NetFlow Message is successfully converted, a content of the wrapper is replaced | ||
* with the IPFIX Message and the original NetFlow Message is not accessible anymore and it is | ||
* freed. | ||
* | ||
* \note | ||
* In case of an error (i.e. return code different from #IPX_OK) the original NetFlow Message | ||
* in the wrapper is untouched. | ||
* \param[in] conv Message converter | ||
* \param[in] wrapper Message wrapper | ||
* \return #IPX_OK on success | ||
* \return #IPX_ERR_FORMAT in case of invalid NetFlow Message format | ||
* \return #IPX_ERR_NOMEM in case of a memory allocation error | ||
*/ | ||
int | ||
ipx_nf5_conv_process(ipx_nf5_conv_t *conv, ipx_msg_ipfix_t *wrapper); | ||
|
||
/** | ||
* @} | ||
*/ | ||
|
||
/** | ||
* \defgroup nf9_to_ipfix NetFlow v9 to IPFIX | ||
* \brief Conversion from NetFlow v9 Messages to IPFIX Messages | ||
* | ||
* The converter helps to convert a stream of NetFlow Messages from combination of a NetFlow | ||
* exporter and a Source ID (a.k.a. Observation Domain ID) to stream of IPFIX Messages. Messages | ||
* are processed individually and should be passed to the converter in the order send by the | ||
* exporter. If it is necessary to convert streams from the same exporter with different Source | ||
* IDs or from multiple exporters at time, you MUST create an independent instance for each | ||
* stream (i.e. combination of an Exporter and Source ID). | ||
* | ||
* \note | ||
* In the context of IPFIX protocol, the Source ID is referred as Observation Domain ID (ODID) | ||
* | ||
* @{ | ||
*/ | ||
|
||
/** Auxiliary definition of NetFlow v9 to IPFIX converter internals */ | ||
typedef struct ipx_nf9_conv ipx_nf9_conv_t; | ||
|
||
/** | ||
* \brief Initialize NetFlow v9 to IPFIX converter | ||
* | ||
* \param[in] ident Instance identification (only for log messages!) | ||
* \param[in] vlevel Verbosity level of the converter (i.e. amount of log messages) | ||
* \return Pointer to the converter or NULL (memory allocation error) | ||
*/ | ||
ipx_nf9_conv_t * | ||
ipx_nf9_conv_init(const char *ident, enum ipx_verb_level vlevel); | ||
|
||
/** | ||
* \brief Destroy NetFlow v9 to IPFIX converter | ||
* \param[in] conv Converter to destroy | ||
*/ | ||
void | ||
ipx_nf9_conv_destroy(ipx_nf9_conv_t *conv); | ||
|
||
/** | ||
* \brief Convert NetFlow v9 Message to IPFIX Message | ||
* | ||
* The function accepts a message wrapper \p wrapper that should hold a NetFlow v9 Message. | ||
* If the NetFlow Message is successfully converted, a content of the wrapper is replaced | ||
* with the IPFIX Message and the original NetFlow Message is not accessible anymore and it is | ||
* freed. | ||
* | ||
* \note | ||
* In case of an error (i.e. return code different from #IPX_OK) the original NetFlow Message | ||
* in the wrapper is untouched. | ||
* \note | ||
* After conversion the IPFIX Message is not ready to be used for accessing flow records, | ||
* it MUST be processed by the IPFIX Parser first. | ||
* \param[in] conv Message converter | ||
* \param[in] wrapper Message wrapper | ||
* \return #IPX_OK on success | ||
* \return #IPX_ERR_FORMAT in case of invalid NetFlow Message format | ||
* \return #IPX_ERR_NOMEM in case of a memory allocation error | ||
*/ | ||
int | ||
ipx_nf9_conv_process(ipx_nf9_conv_t *conv, ipx_msg_ipfix_t *wrapper); | ||
|
||
/** | ||
* @} | ||
*/ | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif // IPFIXCOL2_NETFLOW2IPFIX_H |
Oops, something went wrong.