diff options
Diffstat (limited to 'epan/dissectors/packet-ar_drone.c')
-rw-r--r-- | epan/dissectors/packet-ar_drone.c | 180 |
1 files changed, 93 insertions, 87 deletions
diff --git a/epan/dissectors/packet-ar_drone.c b/epan/dissectors/packet-ar_drone.c index 15682fe7..18a5e960 100644 --- a/epan/dissectors/packet-ar_drone.c +++ b/epan/dissectors/packet-ar_drone.c @@ -25,55 +25,55 @@ void proto_reg_handoff_ar_drone(void); /* ************************************************ */ /* ar_drone Protocol */ -static int proto_ar_drone = -1; +static int proto_ar_drone; /* ar_drone Dissector handle */ static dissector_handle_t ar_drone_handle; /* Headers */ -static int hf_command = -1; -static int hf_PCMD_id = -1; -static int hf_PCMD_flag = -1; -static int hf_PCMD_roll = -1; -static int hf_PCMD_pitch = -1; -static int hf_PCMD_gaz = -1; -static int hf_PCMD_yaw = -1; -static int hf_REF_id = -1; -static int hf_REF_ctrl = -1; -static int hf_FTRIM_seq = -1; -static int hf_CONFIG_seq = -1; -static int hf_CONFIG_name = -1; -static int hf_CONFIG_val = -1; -static int hf_CONFIG_ID_seq = -1; -static int hf_CONFIG_ID_session = -1; -static int hf_CONFIG_ID_user = -1; -static int hf_CONFIG_ID_app = -1; -static int hf_COMWDG = -1; -static int hf_LED_seq = -1; -static int hf_LED_anim = -1; -static int hf_LED_freq = -1; -static int hf_LED_sec = -1; -static int hf_ANIM_seq = -1; -static int hf_ANIM_anim = -1; -static int hf_ANIM_sec = -1; -static int hf_CTRL_seq = -1; -static int hf_CTRL_mode = -1; -static int hf_CTRL_fsize = -1; +static int hf_command; +static int hf_PCMD_id; +static int hf_PCMD_flag; +static int hf_PCMD_roll; +static int hf_PCMD_pitch; +static int hf_PCMD_gaz; +static int hf_PCMD_yaw; +static int hf_REF_id; +static int hf_REF_ctrl; +static int hf_FTRIM_seq; +static int hf_CONFIG_seq; +static int hf_CONFIG_name; +static int hf_CONFIG_val; +static int hf_CONFIG_ID_seq; +static int hf_CONFIG_ID_session; +static int hf_CONFIG_ID_user; +static int hf_CONFIG_ID_app; +static int hf_COMWDG; +static int hf_LED_seq; +static int hf_LED_anim; +static int hf_LED_freq; +static int hf_LED_sec; +static int hf_ANIM_seq; +static int hf_ANIM_anim; +static int hf_ANIM_sec; +static int hf_CTRL_seq; +static int hf_CTRL_mode; +static int hf_CTRL_fsize; /**Subtrees */ -static gint ett_FTRIM = -1; -static gint ett_ar_drone = -1; -static gint ett_PCMD = -1; -static gint ett_REF = -1; -static gint ett_CONFIG = -1; -static gint ett_CONFIG_ID = -1; -static gint ett_COMWDG = -1; -static gint ett_LED = -1; -static gint ett_ANIM = -1; -static gint ett_CTRL = -1; - -static expert_field ei_NO_COMMA = EI_INIT; -static expert_field ei_NO_CR = EI_INIT; +static int ett_FTRIM; +static int ett_ar_drone; +static int ett_PCMD; +static int ett_REF; +static int ett_CONFIG; +static int ett_CONFIG_ID; +static int ett_COMWDG; +static int ett_LED; +static int ett_ANIM; +static int ett_CTRL; + +static expert_field ei_NO_COMMA; +static expert_field ei_NO_CR; /* Value String */ #if 0 /* TODO: Delete these? Or make use of them? */ @@ -94,7 +94,7 @@ static const string_string CTRL_mode_vs[] = { { "4" , " (CFG_GET_CONTROL_MODE)" }, { "5" , " (ACK_CONTROL_MODE)" }, { "6" , " (CUSTOM_CFG_GET_CONTROL_MODE)" }, - { 0, NULL } + { NULL, NULL } }; /* ********************************************** */ @@ -103,13 +103,13 @@ static const string_string CTRL_mode_vs[] = { static int dissect_ar_drone(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) { - gint offset, length; - gint master_offset = 0; + int offset, length; + int master_offset = 0; proto_item *ti, *sub_item; proto_tree *ar_tree, *sub_tree; char *command; - guint8 *complete_str; - guint32 dword; + uint8_t *complete_str; + uint32_t dword; if (tvb_captured_length(tvb) < 4) return 0; @@ -131,7 +131,7 @@ dissect_ar_drone(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data while (tvb_reported_length_remaining(tvb, master_offset) > 3) { /* Get a string to compare our command strings (aka "AT*PCMD", etc.) to */ - offset = tvb_find_guint8(tvb, master_offset, -1, '='); + offset = tvb_find_uint8(tvb, master_offset, -1, '='); if (offset < master_offset) return master_offset; @@ -142,7 +142,7 @@ dissect_ar_drone(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data if (!strncmp(command, "AT*PCMD", 7)) { /** Parse according the PCMD layout: */ - guint8 PCMD_byte; + uint8_t PCMD_byte; const char *PCMD_str; sub_tree = proto_item_add_subtree(sub_item, ett_PCMD); @@ -150,7 +150,7 @@ dissect_ar_drone(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data offset = master_offset + 8; /* Add PCMD ID */ - length = tvb_find_guint8(tvb, offset, -1, ',') - offset; + length = tvb_find_uint8(tvb, offset, -1, ',') - offset; if (length < 0) { expert_add_info(pinfo, sub_item, &ei_NO_COMMA); return offset; @@ -159,7 +159,7 @@ dissect_ar_drone(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data offset += (length + 1); /* Add PCMD Flag */ - length = tvb_find_guint8(tvb, offset, -1, ',') - offset; + length = tvb_find_uint8(tvb, offset, -1, ',') - offset; if (length < 0) { expert_add_info(pinfo, sub_item, &ei_NO_COMMA); return offset; @@ -168,21 +168,21 @@ dissect_ar_drone(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data offset += (length + 1); /* Add PCMD Roll */ - length = tvb_find_guint8(tvb, offset, -1, ',') - offset; + length = tvb_find_uint8(tvb, offset, -1, ',') - offset; if (length < 0) { expert_add_info(pinfo, sub_item, &ei_NO_COMMA); return offset; } ti = proto_tree_add_item(sub_tree, hf_PCMD_roll, tvb, offset, length, ENC_ASCII); - PCMD_byte = tvb_get_guint8(tvb, offset); + PCMD_byte = tvb_get_uint8(tvb, offset); if (PCMD_byte == 0x30) { PCMD_str = " (NO CHANGE)"; } else if (PCMD_byte == 0x2d) { - PCMD_byte = tvb_get_guint8(tvb, offset + 1); + PCMD_byte = tvb_get_uint8(tvb, offset + 1); if (PCMD_byte == 0x30) { PCMD_str = " (NO CHANGE)"; @@ -200,21 +200,21 @@ dissect_ar_drone(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data offset += (length + 1); /* Add PCMD Pitch */ - length = tvb_find_guint8(tvb, offset, -1, ',') - offset; + length = tvb_find_uint8(tvb, offset, -1, ',') - offset; if (length < 0) { expert_add_info(pinfo, sub_item, &ei_NO_COMMA); return offset; } ti = proto_tree_add_item(sub_tree, hf_PCMD_pitch, tvb, offset, length, ENC_ASCII); - PCMD_byte = tvb_get_guint8(tvb, offset); + PCMD_byte = tvb_get_uint8(tvb, offset); if (PCMD_byte == 0x30) { PCMD_str = " (NO CHANGE)"; } else if (PCMD_byte == 0x2d) { - PCMD_byte = tvb_get_guint8(tvb, offset + 1); + PCMD_byte = tvb_get_uint8(tvb, offset + 1); if (PCMD_byte == 0x30) { PCMD_str = " (NO CHANGE)"; @@ -232,21 +232,21 @@ dissect_ar_drone(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data offset += (length + 1); /* Add PCMD Gaz */ - length = tvb_find_guint8(tvb, offset, -1, ',') - offset; + length = tvb_find_uint8(tvb, offset, -1, ',') - offset; if (length < 0) { expert_add_info(pinfo, sub_item, &ei_NO_COMMA); return offset; } ti = proto_tree_add_item(sub_tree, hf_PCMD_gaz, tvb, offset, length, ENC_ASCII); - PCMD_byte = tvb_get_guint8(tvb, offset); + PCMD_byte = tvb_get_uint8(tvb, offset); if (PCMD_byte == 0x30) { PCMD_str = " (NO CHANGE)"; } else if (PCMD_byte == 0x2d) { - PCMD_byte = tvb_get_guint8(tvb, offset + 1); + PCMD_byte = tvb_get_uint8(tvb, offset + 1); if (PCMD_byte == 0x30) { PCMD_str = " (NO CHANGE)"; @@ -264,21 +264,21 @@ dissect_ar_drone(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data offset += (length + 1); /* Add PCMD Yaw */ - length = tvb_find_guint8(tvb, offset, -1, 0x0d) - offset; + length = tvb_find_uint8(tvb, offset, -1, 0x0d) - offset; if (length < 0) { expert_add_info(pinfo, sub_item, &ei_NO_CR); return offset; } ti = proto_tree_add_item(sub_tree, hf_PCMD_yaw, tvb, offset, length, ENC_ASCII); - PCMD_byte = tvb_get_guint8(tvb, offset); + PCMD_byte = tvb_get_uint8(tvb, offset); if (PCMD_byte == 0x30) { PCMD_str = " (NO CHANGE)"; } else if (PCMD_byte == 0x2d) { - PCMD_byte = tvb_get_guint8(tvb, offset + 1); + PCMD_byte = tvb_get_uint8(tvb, offset + 1); if (PCMD_byte == 0x30) { PCMD_str = " (NO CHANGE)"; @@ -303,7 +303,7 @@ dissect_ar_drone(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data offset = master_offset + 7; /* Add REF ID */ - length = tvb_find_guint8(tvb, offset, -1, ',') - offset; + length = tvb_find_uint8(tvb, offset, -1, ',') - offset; if (length < 0) { expert_add_info(pinfo, sub_item, &ei_NO_COMMA); return offset; @@ -312,7 +312,7 @@ dissect_ar_drone(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data offset += (length + 1); /* Add REF ctrl */ - length = tvb_find_guint8(tvb, offset, -1, 0x0d) - offset; + length = tvb_find_uint8(tvb, offset, -1, 0x0d) - offset; if (length < 0) { expert_add_info(pinfo, sub_item, &ei_NO_CR); return offset; @@ -328,7 +328,7 @@ dissect_ar_drone(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data offset = master_offset + 14; /* Add Sequence Number */ - length = tvb_find_guint8(tvb, offset, -1, ',') - offset; + length = tvb_find_uint8(tvb, offset, -1, ',') - offset; if (length < 0) { expert_add_info(pinfo, sub_item, &ei_NO_COMMA); return offset; @@ -337,7 +337,7 @@ dissect_ar_drone(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data offset += (length + 1); /* Add Session ID */ - length = tvb_find_guint8(tvb, offset, -1, ',') - offset; + length = tvb_find_uint8(tvb, offset, -1, ',') - offset; if (length < 0) { expert_add_info(pinfo, sub_item, &ei_NO_COMMA); return offset; @@ -346,7 +346,7 @@ dissect_ar_drone(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data offset += (length + 1); /* Add User ID */ - length = tvb_find_guint8(tvb, offset, -1, ',') - offset; + length = tvb_find_uint8(tvb, offset, -1, ',') - offset; if (length < 0) { expert_add_info(pinfo, sub_item, &ei_NO_COMMA); return offset; @@ -355,7 +355,7 @@ dissect_ar_drone(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data offset += (length + 1); /* Add Application ID */ - length = tvb_find_guint8(tvb, offset, -1, 0x0d) - offset; + length = tvb_find_uint8(tvb, offset, -1, 0x0d) - offset; if (length < 0) { expert_add_info(pinfo, sub_item, &ei_NO_CR); return offset; @@ -371,7 +371,7 @@ dissect_ar_drone(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data offset = master_offset + 8; /* Add sequence */ - length = tvb_find_guint8(tvb, offset, -1, ',') - offset; + length = tvb_find_uint8(tvb, offset, -1, ',') - offset; if (length < 0) { expert_add_info(pinfo, sub_item, &ei_NO_COMMA); return offset; @@ -380,7 +380,7 @@ dissect_ar_drone(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data offset += (length + 1); /* Add Animation */ - length = tvb_find_guint8(tvb, offset, -1, ',') - offset; + length = tvb_find_uint8(tvb, offset, -1, ',') - offset; if (length < 0) { expert_add_info(pinfo, sub_item, &ei_NO_COMMA); return offset; @@ -389,7 +389,7 @@ dissect_ar_drone(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data offset += (length + 1); /* Add animation time(sec) */ - length = tvb_find_guint8(tvb, offset, -1, 0x0d) - offset; + length = tvb_find_uint8(tvb, offset, -1, 0x0d) - offset; if (length < 0) { expert_add_info(pinfo, sub_item, &ei_NO_CR); return offset; @@ -405,7 +405,7 @@ dissect_ar_drone(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data offset = master_offset + 9; /* Add sequence number */ - length = tvb_find_guint8(tvb, offset, -1, 0x0d) - offset; + length = tvb_find_uint8(tvb, offset, -1, 0x0d) - offset; if (length < 0) { expert_add_info(pinfo, sub_item, &ei_NO_CR); return offset; @@ -421,7 +421,7 @@ dissect_ar_drone(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data offset = master_offset + 10; /* Add sequence */ - length = tvb_find_guint8(tvb, offset, -1, ',') - offset; + length = tvb_find_uint8(tvb, offset, -1, ',') - offset; if (length < 0) { expert_add_info(pinfo, sub_item, &ei_NO_COMMA); return offset; @@ -430,7 +430,7 @@ dissect_ar_drone(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data offset += (length + 1); /* Add Name */ - length = tvb_find_guint8(tvb, offset, -1, ',') - offset; + length = tvb_find_uint8(tvb, offset, -1, ',') - offset; if (length < 0) { expert_add_info(pinfo, sub_item, &ei_NO_COMMA); return offset; @@ -439,7 +439,7 @@ dissect_ar_drone(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data offset += (length + 1); /* Add Value */ - length = tvb_find_guint8(tvb, offset, -1, 0x0d) - offset; + length = tvb_find_uint8(tvb, offset, -1, 0x0d) - offset; if (length < 0) { expert_add_info(pinfo, sub_item, &ei_NO_CR); return offset; @@ -455,7 +455,7 @@ dissect_ar_drone(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data offset = master_offset + 7; /* Add sequence */ - length = tvb_find_guint8(tvb, offset, -1, ',') - offset; + length = tvb_find_uint8(tvb, offset, -1, ',') - offset; if (length < 0) { expert_add_info(pinfo, sub_item, &ei_NO_COMMA); return offset; @@ -464,7 +464,7 @@ dissect_ar_drone(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data offset += (length + 1); /* Add animation to play */ - length = tvb_find_guint8(tvb, offset, -1, ',') - offset; + length = tvb_find_uint8(tvb, offset, -1, ',') - offset; if (length < 0) { expert_add_info(pinfo, sub_item, &ei_NO_COMMA); return offset; @@ -473,7 +473,7 @@ dissect_ar_drone(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data offset += (length + 1); /* Add frequency */ - length = tvb_find_guint8(tvb, offset, -1, ',') - offset; + length = tvb_find_uint8(tvb, offset, -1, ',') - offset; if (length < 0) { expert_add_info(pinfo, sub_item, &ei_NO_COMMA); return offset; @@ -482,7 +482,7 @@ dissect_ar_drone(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data offset += (length + 1); /* Add Time to play in sec */ - length = tvb_find_guint8(tvb, offset, -1, 0x0d) - offset; + length = tvb_find_uint8(tvb, offset, -1, 0x0d) - offset; if (length < 0) { expert_add_info(pinfo, sub_item, &ei_NO_CR); return offset; @@ -498,7 +498,7 @@ dissect_ar_drone(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data offset = master_offset + 10; /* Add sequence number */ - length = tvb_find_guint8(tvb, offset, -1, 0x0d) - offset; + length = tvb_find_uint8(tvb, offset, -1, 0x0d) - offset; if (length < 0) { expert_add_info(pinfo, sub_item, &ei_NO_CR); return offset; @@ -508,7 +508,7 @@ dissect_ar_drone(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data }else if (!strncmp(command, "AT*CTRL", 7)) { - const guint8* CTRL_mode_str; + const uint8_t* CTRL_mode_str; /** Parse according to the CTRL layout: */ sub_tree = proto_item_add_subtree(sub_item, ett_CTRL); @@ -516,7 +516,7 @@ dissect_ar_drone(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data offset = master_offset + 8; /* Add sequence */ - length = tvb_find_guint8(tvb, offset, -1, ',') - offset; + length = tvb_find_uint8(tvb, offset, -1, ',') - offset; if (length < 0) { expert_add_info(pinfo, sub_item, &ei_NO_COMMA); return offset; @@ -525,7 +525,7 @@ dissect_ar_drone(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data offset += (length + 1); /* Add Mode */ - length = tvb_find_guint8(tvb, offset, -1, ',') - offset; + length = tvb_find_uint8(tvb, offset, -1, ',') - offset; if (length < 0) { expert_add_info(pinfo, sub_item, &ei_NO_COMMA); return offset; @@ -535,7 +535,7 @@ dissect_ar_drone(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data offset += (length + 1); /* Add File Size */ - length = tvb_find_guint8(tvb, offset, -1, 0x0d) - offset; + length = tvb_find_uint8(tvb, offset, -1, 0x0d) - offset; if (length < 0) { expert_add_info(pinfo, sub_item, &ei_NO_CR); return offset; @@ -556,6 +556,12 @@ dissect_ar_drone(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data return master_offset; } +static bool +dissect_ar_drone_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) +{ + return dissect_ar_drone(tvb, pinfo, tree, data) > 0; +} + void proto_register_ar_drone(void) { @@ -732,7 +738,7 @@ proto_register_ar_drone(void) }; /* Setup protocol subtree array */ - static gint *ett[] = { + static int *ett[] = { &ett_ar_drone, &ett_PCMD, &ett_REF, @@ -766,7 +772,7 @@ proto_register_ar_drone(void) void proto_reg_handoff_ar_drone(void) { - heur_dissector_add("udp", dissect_ar_drone, "AR Drone over UDP", "ar_drone_udp", proto_ar_drone, HEURISTIC_ENABLE); + heur_dissector_add("udp", dissect_ar_drone_heur, "AR Drone over UDP", "ar_drone_udp", proto_ar_drone, HEURISTIC_ENABLE); dissector_add_for_decode_as_with_preference("udp.port", ar_drone_handle); } |