]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
json output: fix vlan byte order in output 869/head
authorVictor Julien <victor@inliniac.net>
Tue, 4 Mar 2014 10:30:08 +0000 (11:30 +0100)
committerVictor Julien <victor@inliniac.net>
Tue, 4 Mar 2014 10:30:08 +0000 (11:30 +0100)
VLAN functions/macros return vlan id in host byte order, so no need
to convert them in output functions.

src/decode-vlan.h
src/output-json.c

index bf9135ec5742f00064ba27fc50e9d22bda80b857..c82e33be12f8de9d0112454521874ba42ef9af38 100644 (file)
@@ -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)
 
index e91f008c608daec351810356f3903354163d28e3..999cbef1dbf9acd44c19358fdec1e2e6cbba1e01 100644 (file)
@@ -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;