Bug #4109 » ethernet-metadata-packet-context.patch
src/output-json.c | ||
---|---|---|
}
|
||
}
|
||
int CreateJSONEther(JsonBuilder *parent, const Packet *p, const MacSet *ms);
|
||
int CreateJSONEther(JsonBuilder *parent, const Packet *p, const Flow *f);
|
||
void EveAddCommonOptions(const OutputJsonCommonSettings *cfg,
|
||
const Packet *p, const Flow *f, JsonBuilder *js)
|
||
... | ... | |
EveAddMetadata(p, f, js);
|
||
}
|
||
if (cfg->include_ethernet) {
|
||
MacSet *ms = FlowGetStorageById((Flow*) f, MacSetGetFlowStorageID());
|
||
if (ms != NULL)
|
||
CreateJSONEther(js, p, ms);
|
||
CreateJSONEther(js, p, f);
|
||
}
|
||
if (cfg->include_community_id && f != NULL) {
|
||
CreateEveCommunityFlowId(js, f, cfg->community_id_seed);
|
||
... | ... | |
return 0;
|
||
}
|
||
int CreateJSONEther(JsonBuilder *js, const Packet *p, const MacSet *ms)
|
||
int CreateJSONEther(JsonBuilder *js, const Packet *p, const Flow *f)
|
||
{
|
||
jb_open_object(js, "ether");
|
||
if (unlikely(js == NULL))
|
||
return 0;
|
||
/* start new EVE sub-object */
|
||
jb_open_object(js, "ether");
|
||
if (p == NULL) {
|
||
MacSet *ms = NULL;
|
||
/* ensure we have a flow */
|
||
if (unlikely(f == NULL)) {
|
||
jb_close(js);
|
||
return 0;
|
||
}
|
||
/* we are creating an ether object in a flow context, so we need to
|
||
append to arrays */
|
||
if (MacSetSize(ms) > 0) {
|
||
ms = FlowGetStorageById((Flow*) f, MacSetGetFlowStorageID());
|
||
if (ms != NULL && MacSetSize(ms) > 0) {
|
||
JSONMACAddrInfo info;
|
||
info.dst = jb_new_array();
|
||
info.src = jb_new_array();
|
||
... | ... | |
/* should not happen, JSONFlowAppendMACAddrs is sane */
|
||
jb_free(info.dst);
|
||
jb_free(info.src);
|
||
jb_close(js);
|
||
return ret;
|
||
}
|
||
jb_close(info.dst);
|