flow id: quick and dirty first stab at a flow id

Add a 'flow_id' that is the same for all records produced for packets
belonging to the same flow.

This patch simply takes the flow's memory address.
pull/1058/head
Victor Julien 11 years ago
parent 9f55ca0057
commit f1185d051c

@ -107,6 +107,9 @@ static json_t *CreateJSONHeaderFromFlow(Flow *f, char *event_type)
/* time */
json_object_set_new(js, "timestamp", json_string(timebuf));
CreateJSONFlowId(js, (const Flow *)f);
#if 0 // TODO
/* sensor id */
if (sensor_id >= 0)

@ -116,6 +116,9 @@ static json_t *CreateJSONHeaderFromFlow(Flow *f, char *event_type, int dir)
/* time */
json_object_set_new(js, "timestamp", json_string(timebuf));
CreateJSONFlowId(js, (const Flow *)f);
#if 0 // TODO
/* sensor id */
if (sensor_id >= 0)

@ -169,6 +169,18 @@ void JsonTcpFlags(uint8_t flags, json_t *js) {
json_object_set_new(js, "cwr", json_true());
}
void CreateJSONFlowId(json_t *js, const Flow *f)
{
if (f == NULL)
return;
#if __WORDSIZE == 64
uint64_t addr = (uint64_t)f;
#else
uint32_t addr = (uint32_t)f;
#endif
json_object_set_new(js, "flow_id", json_integer(addr));
}
json_t *CreateJSONHeader(Packet *p, int direction_sensitive, char *event_type)
{
char timebuf[64];
@ -227,6 +239,8 @@ json_t *CreateJSONHeader(Packet *p, int direction_sensitive, char *event_type)
/* time & tx */
json_object_set_new(js, "timestamp", json_string(timebuf));
CreateJSONFlowId(js, (const Flow *)p->flow);
/* sensor id */
if (sensor_id >= 0)
json_object_set_new(js, "sensor_id", json_integer(sensor_id));

@ -32,6 +32,7 @@ void TmModuleOutputJsonRegister (void);
#include "util-buffer.h"
#include "util-logopenfile.h"
void CreateJSONFlowId(json_t *js, const Flow *f);
void JsonTcpFlags(uint8_t flags, json_t *js);
json_t *CreateJSONHeader(Packet *p, int direction_sensative, char *event_type);
TmEcode OutputJSON(json_t *js, void *data, uint64_t *count);

Loading…
Cancel
Save