diff --git a/flow.c b/flow.c index 5e94a7a..beb9749 100644 --- a/flow.c +++ b/flow.c @@ -25,6 +25,13 @@ const char *flow_type_str[] = { static_assert(ARRAY_SIZE(flow_type_str) == FLOW_NUM_TYPES, "flow_type_str[] doesn't match enum flow_type"); +const uint8_t flow_proto[] = { + [FLOW_TCP] = IPPROTO_TCP, + [FLOW_TCP_SPLICE] = IPPROTO_TCP, +}; +static_assert(ARRAY_SIZE(flow_proto) == FLOW_NUM_TYPES, + "flow_proto[] doesn't match enum flow_type"); + /* Global Flow Table */ /** diff --git a/flow.h b/flow.h index 48a0ab4..e9b3ce3 100644 --- a/flow.h +++ b/flow.h @@ -27,6 +27,10 @@ extern const char *flow_type_str[]; #define FLOW_TYPE(f) \ ((f)->type < FLOW_NUM_TYPES ? flow_type_str[(f)->type] : "?") +extern const uint8_t flow_proto[]; +#define FLOW_PROTO(f) \ + ((f)->type < FLOW_NUM_TYPES ? flow_proto[(f)->type] : 0) + /** * struct flow_common - Common fields for packet flows * @type: Type of packet flow