Skip to content

Commit 1e42bc6

Browse files
committed
extended_function struct
1 parent ed1e756 commit 1e42bc6

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

src/sflow.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,14 @@ typedef struct _SFLExtended_decap {
602602
uint32_t innerHeaderOffset;
603603
} SFLExtended_decap;
604604

605+
/* Software function */
606+
/* Name of software function generating this event */
607+
/* opaque = flow_data; enterprise = 0; format = 1038 */
608+
typedef struct _SFLExtended_function {
609+
SFLString symbol;
610+
} SFLExtended_function;
611+
#define SFL_MAX_FUNCTION_SYMBOL_LEN 64
612+
605613
enum SFLFlow_type_tag {
606614
/* enterprise = 0, format = ... */
607615
SFLFLOW_HEADER = 1, /* Packet headers are sampled */
@@ -635,6 +643,7 @@ enum SFLFlow_type_tag {
635643
SFLFLOW_EX_DECAP_IN = 1028,
636644
SFLFLOW_EX_VNI_OUT = 1029,
637645
SFLFLOW_EX_VNI_IN = 1030,
646+
SFLFLOW_EX_FUNCTION = 1038,
638647
SFLFLOW_EX_SOCKET4 = 2100,
639648
SFLFLOW_EX_SOCKET6 = 2101,
640649
SFLFLOW_EX_PROXYSOCKET4 = 2102,
@@ -683,6 +692,7 @@ typedef union _SFLFlow_type {
683692
SFLExtended_decap tunnel_decap;
684693
SFLExtended_TCP_info tcp_info;
685694
SFLExtended_entities entities;
695+
SFLExtended_function function;
686696
} SFLFlow_type;
687697

688698
typedef struct _SFLFlow_sample_element {

src/sflowtool.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3481,6 +3481,20 @@ static void readExtendedEntities(SFSample *sample)
34813481
sf_log_next32(sample, "entities_dst_index");
34823482
}
34833483

3484+
/*_________________----------------------------__________________
3485+
_________________ readExtendedFunction __________________
3486+
-----------------____________________________------------------
3487+
*/
3488+
3489+
static void readExtendedFunction(SFSample *sample)
3490+
{
3491+
sf_logf(sample, "extendedType", "function");
3492+
char fnSymbol[SFL_MAX_FUNCTION_SYMBOL_LEN+1];
3493+
if(getString(sample, fnSymbol, SFL_MAX_FUNCTION_SYMBOL_LEN) > 0) {
3494+
sf_logf(sample, "symbol", fnSymbol);
3495+
}
3496+
}
3497+
34843498
/*_________________---------------------------__________________
34853499
_________________ readFlowSample_v2v4 __________________
34863500
-----------------___________________________------------------
@@ -3843,6 +3857,7 @@ static void readDiscardSample(SFSample *sample)
38433857
// TODO: separate fn for flow-sample elements?
38443858
switch(tag) {
38453859
case SFLFLOW_HEADER: readFlowSample_header(sample); break;
3860+
case SFLFLOW_EX_FUNCTION: readExtendedFunction(sample); break;
38463861
default: skipTLVRecord(sample, tag, length, "discard_sample_element"); break;
38473862
}
38483863
lengthCheck(sample, "discard_sample_element", start, length);

0 commit comments

Comments
 (0)