Skip to content

Commit

Permalink
add new structures for delay and queue depth
Browse files Browse the repository at this point in the history
  • Loading branch information
sflow committed Feb 17, 2021
1 parent 71bf6ce commit 4be2a17
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 2 deletions.
2 changes: 1 addition & 1 deletion configure.ac
Expand Up @@ -2,7 +2,7 @@
# Process this file with autoconf to produce a configure script.

AC_PREREQ(2.57)
AC_INIT([sflowtool],[5.06])
AC_INIT([sflowtool],[5.07])
AC_CONFIG_SRCDIR([src/sflowtool.c])
AM_INIT_AUTOMAKE
AM_CONFIG_HEADER(config.h)
Expand Down
2 changes: 1 addition & 1 deletion sflowtool.spec
@@ -1,6 +1,6 @@
Summary: tool to ascii-print or forward sFlow datagrams
Name: sflowtool
Version: 5.06
Version: 5.07
Release: 1%{?dist}
License: https://www.inmon.com/technology/sflowlicense.txt
Group: Productivity/Networking/Diagnostic
Expand Down
30 changes: 30 additions & 0 deletions src/sflow.h
Expand Up @@ -602,6 +602,14 @@ typedef struct _SFLExtended_decap {
uint32_t innerHeaderOffset;
} SFLExtended_decap;

/* Selected egress queue */
/* Output port number must be provided in enclosing structure */
/* opaque = flow_data; enterprise = 0; format = 1036 */
typedef struct {
unsigned int queue; /* eqress queue number selected for sampled packet */
} SFLExtended_egress_queue;
#define XDRSIZ_SFLEXTENDED_EGRESS_Q 4

/* Software function */
/* Name of software function generating this event */
/* opaque = flow_data; enterprise = 0; format = 1038 */
Expand All @@ -610,6 +618,22 @@ typedef struct _SFLExtended_function {
} SFLExtended_function;
#define SFL_MAX_FUNCTION_SYMBOL_LEN 64

/* Delay for sampled packet traversing switch */
/* opaque = flow_data; enterprise = 0; format = 1039 */
typedef struct {
unsigned int delay; /* transit delay in nanoseconds
0xffffffff indicates value >= 0xffffffff */
} SFLExtended_transit_delay;
#define XDRSIZ_SFLEXTENDED_TRANSIT 4

/* Queue depth for sampled packet traversing switch */
/* extended_egress_queue structure must be included */
/* opaque = flow_data; enterprise = 0; format = 1040 */
typedef struct {
unsigned int depth; /* queue depth in bytes */
} SFLExtended_queue_depth;
#define XDRSIZ_SFLEXTENDED_Q_DEPTH 4

enum SFLFlow_type_tag {
/* enterprise = 0, format = ... */
SFLFLOW_HEADER = 1, /* Packet headers are sampled */
Expand Down Expand Up @@ -643,7 +667,10 @@ enum SFLFlow_type_tag {
SFLFLOW_EX_DECAP_IN = 1028,
SFLFLOW_EX_VNI_OUT = 1029,
SFLFLOW_EX_VNI_IN = 1030,
SFLFLOW_EX_EGRESS_Q = 1036,
SFLFLOW_EX_FUNCTION = 1038,
SFLFLOW_EX_TRANSIT = 1039,
SFLFLOW_EX_Q_DEPTH = 1040,
SFLFLOW_EX_SOCKET4 = 2100,
SFLFLOW_EX_SOCKET6 = 2101,
SFLFLOW_EX_PROXYSOCKET4 = 2102,
Expand Down Expand Up @@ -693,6 +720,9 @@ typedef union _SFLFlow_type {
SFLExtended_TCP_info tcp_info;
SFLExtended_entities entities;
SFLExtended_function function;
SFLExtended_egress_queue egress_queue;
SFLExtended_queue_depth queue_depth;
SFLExtended_transit_delay transit_delay;
} SFLFlow_type;

typedef struct _SFLFlow_sample_element {
Expand Down
37 changes: 37 additions & 0 deletions src/sflowtool.c
Expand Up @@ -3481,6 +3481,17 @@ static void readExtendedEntities(SFSample *sample)
sf_log_next32(sample, "entities_dst_index");
}

/*_________________----------------------------__________________
_________________ readExtendedEgressQueue __________________
-----------------____________________________------------------
*/

static void readExtendedEgressQueue(SFSample *sample)
{
sf_logf(sample, "extendedType", "egress_queue");
sf_log_next32(sample, "egress_queue_id");
}

/*_________________----------------------------__________________
_________________ readExtendedFunction __________________
-----------------____________________________------------------
Expand All @@ -3495,6 +3506,28 @@ static void readExtendedFunction(SFSample *sample)
}
}

/*_________________----------------------------__________________
_________________ readExtendedTransitDelay __________________
-----------------____________________________------------------
*/

static void readExtendedTransitDelay(SFSample *sample)
{
sf_logf(sample, "extendedType", "transit_delay");
sf_log_next32(sample, "transit_delay_nS");
}

/*_________________----------------------------__________________
_________________ readExtendedQueueDepth __________________
-----------------____________________________------------------
*/

static void readExtendedQueueDepth(SFSample *sample)
{
sf_logf(sample, "extendedType", "queue_depth");
sf_log_next32(sample, "queue_depth_bytes");
}

/*_________________---------------------------__________________
_________________ readFlowSample_v2v4 __________________
-----------------___________________________------------------
Expand Down Expand Up @@ -3731,6 +3764,9 @@ static void readFlowSample(SFSample *sample, int expanded)
case SFLFLOW_EX_VNI_IN: readExtendedVNI(sample, "in_"); break;
case SFLFLOW_EX_TCP_INFO: readExtendedTCPInfo(sample); break;
case SFLFLOW_EX_ENTITIES: readExtendedEntities(sample); break;
case SFLFLOW_EX_EGRESS_Q: readExtendedEgressQueue(sample); break;
case SFLFLOW_EX_TRANSIT: readExtendedTransitDelay(sample); break;
case SFLFLOW_EX_Q_DEPTH: readExtendedQueueDepth(sample); break;
default: skipTLVRecord(sample, tag, length, "flow_sample_element"); break;
}
lengthCheck(sample, "flow_sample_element", start, length);
Expand Down Expand Up @@ -3858,6 +3894,7 @@ static void readDiscardSample(SFSample *sample)
switch(tag) {
case SFLFLOW_HEADER: readFlowSample_header(sample); break;
case SFLFLOW_EX_FUNCTION: readExtendedFunction(sample); break;
case SFLFLOW_EX_EGRESS_Q: readExtendedEgressQueue(sample); break;
default: skipTLVRecord(sample, tag, length, "discard_sample_element"); break;
}
lengthCheck(sample, "discard_sample_element", start, length);
Expand Down

0 comments on commit 4be2a17

Please sign in to comment.