From: Victor Julien Date: Wed, 31 Aug 2016 13:04:58 +0000 (+0200) Subject: flow: introduce function to generate flow id X-Git-Tag: suricata-3.1.2~20 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=78b4db8a954f5937d07ec494e7113e292228e189;p=thirdparty%2Fsuricata.git flow: introduce function to generate flow id The flow id itself is not stored in the flow, but generated based on properties that do not change during the lifetime of the flow. As it's meant for use with the json output, it is limited to a signed 64 bit integer (int64_t) because that is the time json_integer_t uses. --- diff --git a/src/flow.h b/src/flow.h index 0400250e23..b5dbe57085 100644 --- a/src/flow.h +++ b/src/flow.h @@ -536,6 +536,18 @@ static inline void FlowDeReference(Flow **d) } } +/** \brief create a flow id that is as unique as possible + * \retval flow_id signed 64bit id + * \note signed because of the signedness of json_integer_t in + * the json output + */ +static inline int64_t FlowGetId(const Flow *f) +{ + return (int64_t)f->flow_hash << 31 | + (int64_t)(f->startts.tv_sec & 0x0000FFFF) << 16 | + (int64_t)(f->startts.tv_usec & 0x0000FFFF); +} + int FlowClearMemory(Flow *,uint8_t ); AppProto FlowGetAppProtocol(const Flow *f);