json output: fix vlan byte order in output

VLAN functions/macros return vlan id in host byte order, so no need
to convert them in output functions.
pull/869/head
Victor Julien 11 years ago
parent 872bb5664e
commit 88e9c85e36

@ -24,6 +24,7 @@
#ifndef __DECODE_VLAN_H__
#define __DECODE_VLAN_H__
/* return vlan id in host byte order */
uint16_t DecodeVLANGetId(const struct Packet_ *, uint8_t layer);
/** Vlan type */
@ -35,6 +36,7 @@ uint16_t DecodeVLANGetId(const struct Packet_ *, uint8_t layer);
#define GET_VLAN_ID(vlanh) ((uint16_t)(ntohs((vlanh)->vlan_cfi) & 0x0FFF))
#define GET_VLAN_PROTO(vlanh) ((ntohs((vlanh)->protocol)))
/* return vlan id in host byte order */
#define VLAN_GET_ID1(p) DecodeVLANGetId((p), 0)
#define VLAN_GET_ID2(p) DecodeVLANGetId((p), 1)

@ -225,15 +225,15 @@ json_t *CreateJSONHeader(Packet *p, int direction_sensitive, char *event_type)
switch (p->vlan_idx) {
case 1:
json_object_set_new(js, "vlan",
json_integer(ntohs(VLAN_GET_ID1(p))));
json_integer(VLAN_GET_ID1(p)));
break;
case 2:
js_vlan = json_array();
if (unlikely(js != NULL)) {
json_array_append_new(js_vlan,
json_integer(ntohs(VLAN_GET_ID1(p))));
json_integer(VLAN_GET_ID1(p)));
json_array_append_new(js_vlan,
json_integer(ntohs(VLAN_GET_ID2(p))));
json_integer(VLAN_GET_ID2(p)));
json_object_set_new(js, "vlan", js_vlan);
}
break;

Loading…
Cancel
Save