aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStig Bjørlykke <stig@bjorlykke.org>2008-06-22 10:59:08 +0000
committerStig Bjørlykke <stig@bjorlykke.org>2008-06-22 10:59:08 +0000
commit50e372dd666c6c73372b03c77780c643580f0e6b (patch)
treea520478d4301c3967f792a717ed36057ab0bc6e6
parentb17d12b64dc79031a9633f8b6633d169f6ace9cd (diff)
Changes in B.A.T.M.A.N. dissector:
- Fixed last element in value_string arrays - Fixed a possible bug in a loop making a currently unused string - Changed preferences prefix to "batman" - Added udp port preference in batman to be uniform - Fixed some indents - Added break in some switches - Make it compile on win32 svn path=/trunk/; revision=25522
-rw-r--r--epan/dissectors/packet-bat-batman.c26
-rw-r--r--epan/dissectors/packet-bat-gw.c10
-rw-r--r--epan/dissectors/packet-bat-packet.h12
-rw-r--r--epan/dissectors/packet-bat-vis.c21
-rw-r--r--epan/dissectors/packet-bat.c6
5 files changed, 43 insertions, 32 deletions
diff --git a/epan/dissectors/packet-bat-batman.c b/epan/dissectors/packet-bat-batman.c
index 7116388651..4c6f93f7d0 100644
--- a/epan/dissectors/packet-bat-batman.c
+++ b/epan/dissectors/packet-bat-batman.c
@@ -54,6 +54,9 @@ static const gchar *fstr[] = {NULL, NULL, NULL, NULL, NULL, NULL, "DIRECTLINK",
/* gwflags */
/* unknown */
+static guint global_bat_batman_udp_port = BAT_BATMAN_PORT;
+static guint udp_port = 0;
+
static void dissect_bat_batman(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
static void dissect_bat_hna(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
@@ -64,9 +67,9 @@ void register_bat_batman(void)
{
static hf_register_info hf[] = {
{ &hf_bat_batman_version,
- { "Version", "bat.batman.version",
- FT_UINT8, BASE_DEC, NULL, 0x0,
- "", HFILL }
+ { "Version", "bat.batman.version",
+ FT_UINT8, BASE_DEC, NULL, 0x0,
+ "", HFILL }
},
{ &hf_bat_batman_flags,
{ "Flags", "bat.batman.flags",
@@ -145,19 +148,27 @@ void register_bat_batman(void)
proto_register_field_array(proto_bat_plugin, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
+
+ prefs_register_uint_preference(bat_module, "batman.bat.port", "BAT UDP Port",
+ "Set the port for B.A.T.M.A.N. BAT "
+ "messages (if other than the default of 4305)",
+ 10, &global_bat_batman_udp_port);
}
void reg_handoff_bat_batman(void)
{
static gboolean inited = FALSE;
+ static dissector_handle_t batman_handle;
if (!inited) {
- static dissector_handle_t batman_handle;
-
batman_handle = create_dissector_handle(dissect_bat_batman, proto_bat_plugin);
- dissector_add("udp.port", BAT_BATMAN_PORT, batman_handle);
data_handle = find_dissector("data");
+ } else {
+ dissector_delete("udp.port", udp_port, batman_handle);
}
+
+ udp_port = global_bat_batman_udp_port;
+ dissector_add("udp.port", udp_port, batman_handle);
}
static void dissect_bat_batman(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
@@ -180,6 +191,7 @@ static void dissect_bat_batman(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tr
col_append_fstr(pinfo->cinfo, COL_INFO, "Unsupported Version %d", version);
}
call_dissector(data_handle, tvb, pinfo, tree);
+ break;
}
}
@@ -296,7 +308,7 @@ static void dissect_bat_batman_v5(tvbuff_t *tvb, packet_info *pinfo, proto_tree
flags[0] = 0;
for (i = 0; i < 8; i++) {
bpos = 1 << i;
- if ((batman_packeth->flags & bpos) && (fstr[bpos] != NULL)) {
+ if ((batman_packeth->flags & bpos) && (fstr[i] != NULL)) {
returned_length = g_snprintf(&flags[fpos], MAX_FLAGS_LEN - fpos, "%s%s",
fpos ? ", " : "",
fstr[i]);
diff --git a/epan/dissectors/packet-bat-gw.c b/epan/dissectors/packet-bat-gw.c
index 0f66cd3afe..20081aa8a5 100644
--- a/epan/dissectors/packet-bat-gw.c
+++ b/epan/dissectors/packet-bat-gw.c
@@ -45,16 +45,16 @@ static const value_string packettypenames[] = {
{ TUNNEL_IP_INVALID, "IP_INVALID" },
{ TUNNEL_KEEPALIVE_REQUEST, "KEEPALIVE_REQUEST" },
{ TUNNEL_KEEPALIVE_REPLY, "KEEPALIVE_REPLY" },
- { 6, NULL }
+ { 0, NULL }
};
void register_bat_gw()
{
static hf_register_info hf[] = {
{ &hf_bat_gw_type,
- { "Type", "bat.gw.type",
- FT_UINT8, BASE_DEC, VALS(packettypenames), 0x0,
- "", HFILL }
+ { "Type", "bat.gw.type",
+ FT_UINT8, BASE_DEC, VALS(packettypenames), 0x0,
+ "", HFILL }
},
{ &hf_bat_gw_ip,
{ "IP", "bat.gw.ip",
@@ -71,7 +71,7 @@ void register_bat_gw()
proto_register_subtree_array(ett, array_length(ett));
proto_register_field_array(proto_bat_plugin, hf, array_length(hf));
- prefs_register_uint_preference(bat_module, "udp.gw.port", "GW UDP Port",
+ prefs_register_uint_preference(bat_module, "batman.gw.port", "GW UDP Port",
"Set the port for B.A.T.M.A.N. Gateway "
"messages (if other than the default of 4306)",
10, &global_bat_gw_udp_port);
diff --git a/epan/dissectors/packet-bat-packet.h b/epan/dissectors/packet-bat-packet.h
index 8822a3663b..eb6de77d99 100644
--- a/epan/dissectors/packet-bat-packet.h
+++ b/epan/dissectors/packet-bat-packet.h
@@ -42,12 +42,12 @@ struct batman_packet_v5 {
address old_orig;
guint8 tq;
guint8 hna_len;
-} __attribute__((packed));
+};
#define BATMAN_PACKET_V5_SIZE 18
struct gw_packet {
guint8 type;
-} __attribute__((packed));
+};
#define GW_PACKET_SIZE 1
#define TUNNEL_DATA 0x01
@@ -67,14 +67,14 @@ struct vis_packet_v22 {
guint8 version;
guint8 gw_class;
guint16 tq_max;
-} __attribute__((packed));
+};
#define VIS_PACKET_V22_SIZE 8
struct vis_data_v22 {
guint8 type;
guint16 data;
address ip;
-} __attribute__((packed));
+};
#define VIS_PACKET_V22_DATA_SIZE 7
struct vis_packet_v23 {
@@ -82,14 +82,14 @@ struct vis_packet_v23 {
guint8 version;
guint8 gw_class;
guint8 tq_max;
-} __attribute__((packed));
+};
#define VIS_PACKET_V23_SIZE 7
struct vis_data_v23 {
guint8 type;
guint8 data;
address ip;
-} __attribute__((packed));
+};
#define VIS_PACKET_V23_DATA_SIZE 6
#endif /* _PACKET_BAT_PACKET_H */
diff --git a/epan/dissectors/packet-bat-vis.c b/epan/dissectors/packet-bat-vis.c
index e352ed6b69..02d785de80 100644
--- a/epan/dissectors/packet-bat-vis.c
+++ b/epan/dissectors/packet-bat-vis.c
@@ -55,16 +55,16 @@ static const value_string packettypenames[] = {
{ DATA_TYPE_NEIGH, "NEIGH" },
{ DATA_TYPE_SEC_IF, "SEC_IF" },
{ DATA_TYPE_HNA, "HNA" },
- { 3, NULL }
+ { 0, NULL }
};
void register_bat_vis(void)
{
static hf_register_info hf[] = {
{ &hf_bat_vis_vis_orig,
- { "Originator", "bat.vis.sender_ip",
- FT_IPv4, BASE_NONE, NULL, 0x0,
- "", HFILL }
+ { "Originator", "bat.vis.sender_ip",
+ FT_IPv4, BASE_NONE, NULL, 0x0,
+ "", HFILL }
},
{ &hf_bat_vis_version,
{ "Version", "bat.vis.version",
@@ -122,7 +122,7 @@ void register_bat_vis(void)
proto_register_subtree_array(ett, array_length(ett));
proto_register_field_array(proto_bat_plugin, hf, array_length(hf));
- prefs_register_uint_preference(bat_module, "udp.vis.port", "VIS UDP Port",
+ prefs_register_uint_preference(bat_module, "batman.vis.port", "VIS UDP Port",
"Set the port for B.A.T.M.A.N. VIS "
"messages (if other than the default of 4307)",
10, &global_bat_vis_udp_port);
@@ -167,6 +167,7 @@ static void dissect_bat_vis(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
col_append_fstr(pinfo->cinfo, COL_INFO, "Unsupported Version %d", version);
}
call_dissector(data_handle, tvb, pinfo, tree);
+ break;
}
}
@@ -298,10 +299,9 @@ static void dissect_vis_entry_v22(tvbuff_t *tvb, packet_info *pinfo _U_, proto_t
proto_tree_add_item(bat_vis_entry_tree, hf_bat_vis_netmask, tvb, 1, 1, FALSE);
break;
case DATA_TYPE_SEC_IF:
- default: {
- ;
+ default:
+ break;
}
- };
proto_tree_add_ipv4(bat_vis_entry_tree, hf_bat_vis_data_ip, tvb, 3, 4, ip);
}
}
@@ -434,10 +434,9 @@ static void dissect_vis_entry_v23(tvbuff_t *tvb, packet_info *pinfo _U_, proto_t
proto_tree_add_item(bat_vis_entry_tree, hf_bat_vis_netmask, tvb, 1, 1, FALSE);
break;
case DATA_TYPE_SEC_IF:
- default: {
- ;
+ default:
+ break;
}
- };
proto_tree_add_ipv4(bat_vis_entry_tree, hf_bat_vis_data_ip, tvb, 2, 4, ip);
}
}
diff --git a/epan/dissectors/packet-bat.c b/epan/dissectors/packet-bat.c
index 1f496163a2..018e8b07e7 100644
--- a/epan/dissectors/packet-bat.c
+++ b/epan/dissectors/packet-bat.c
@@ -26,11 +26,11 @@
#include "packet-bat.h"
/* forward declaration */
-void proto_register_bat();
-void proto_reg_handoff_bat();
+void proto_register_bat(void);
+void proto_reg_handoff_bat(void);
int proto_bat_plugin = -1;
-module_t *bat_module;
+module_t *bat_module = NULL;
/* tap */
int bat_tap = -1;