HACK: 2nd try to match RowsetProperties
[wireshark-wip.git] / epan / dissectors / packet-ar_drone.c
blob4ecaa9cd189128e745d3f7bece1a61a14a34d2ad
1 /* packet-ar_drone.c
2 * Routines for AR ar_drone protocol packet disassembly
3 * By Paul Hoisington <hoisingtonp@bit-sys.com>,
4 * Tom Hildesheim <hildesheimt@bit-sys.com>,
5 * and Claire Brantley <brantleyc@bit-sys.com>
6 * Copyright 2012 BIT Systems
8 * $Id$
10 * Wireshark - Network traffic analyzer
11 * By Gerald Combs <gerald@wireshark.org>
12 * Copyright 1998 Gerald Combs
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
29 #include "config.h"
31 #include <glib.h>
33 #include <epan/packet.h>
34 #include <epan/prefs.h>
35 #include <epan/expert.h>
37 void proto_register_ar_drone(void);
38 void proto_reg_handoff_ar_drone(void);
40 static guint ar_drone_port = 0;
42 /* ************************************************ */
43 /* Begin static variable declaration/initialization */
44 /* ************************************************ */
46 /* ar_drone Protocol */
47 static int proto_ar_drone = -1;
49 /* Headers */
50 static int hf_command = -1;
51 static int hf_PCMD_id = -1;
52 static int hf_PCMD_flag = -1;
53 static int hf_PCMD_roll = -1;
54 static int hf_PCMD_pitch = -1;
55 static int hf_PCMD_gaz = -1;
56 static int hf_PCMD_yaw = -1;
57 static int hf_REF_id = -1;
58 static int hf_REF_ctrl = -1;
59 static int hf_FTRIM_seq = -1;
60 static int hf_CONFIG_seq = -1;
61 static int hf_CONFIG_name = -1;
62 static int hf_CONFIG_val = -1;
63 static int hf_CONFIG_ID_seq = -1;
64 static int hf_CONFIG_ID_session = -1;
65 static int hf_CONFIG_ID_user = -1;
66 static int hf_CONFIG_ID_app = -1;
67 static int hf_COMWDG = -1;
68 static int hf_LED_seq = -1;
69 static int hf_LED_anim = -1;
70 static int hf_LED_freq = -1;
71 static int hf_LED_sec = -1;
72 static int hf_ANIM_seq = -1;
73 static int hf_ANIM_anim = -1;
74 static int hf_ANIM_sec = -1;
75 static int hf_CTRL_seq = -1;
76 static int hf_CTRL_mode = -1;
77 static int hf_CTRL_fsize = -1;
79 /**Subtrees */
80 static gint ett_FTRIM = -1;
81 static gint ett_ar_drone = -1;
82 static gint ett_PCMD = -1;
83 static gint ett_REF = -1;
84 static gint ett_CONFIG = -1;
85 static gint ett_CONFIG_ID = -1;
86 static gint ett_COMWDG = -1;
87 static gint ett_LED = -1;
88 static gint ett_ANIM = -1;
89 static gint ett_CTRL = -1;
91 static expert_field ei_NO_COMMA = EI_INIT;
92 static expert_field ei_NO_CR = EI_INIT;
94 /* Value String */
95 #if 0 /* TODO: Delete these? Or make use of them? */
96 static const value_string REF_types_vs[] = {
97 { 0x38323038, "FLYING MODE" },
98 { 0x37393532, "EMERGENCY LANDING" },
99 { 0x37363936, "LANDING MODE" },
100 { 0, NULL }
102 static const value_string PCMD_flag_vs[] = {
103 { 0x30 , "DO NOT ALLOW ROLL/PITCH" },
104 { 0x31 , "ALLOW ROLL/PITCH" },
105 { 0 , NULL }
107 #endif
109 static const string_string CTRL_mode_vs[] = {
110 { "4" , " (CFG_GET_CONTROL_MODE)" },
111 { "5" , " (ACK_CONTROL_MODE)" },
112 { "6" , " (CUSTOM_CFG_GET_CONTROL_MODE)" },
113 { 0, NULL }
116 /* ********************************************** */
117 /* End static variable declaration/initialization */
118 /* ********************************************** */
119 static int
120 dissect_ar_drone(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
122 gint offset, length;
123 gint master_offset = 0;
124 proto_item *ti, *sub_item;
125 proto_tree *ar_tree, *sub_tree;
126 char *command;
127 guint32 dword;
129 if (tvb_length(tvb) < 4)
130 return 0;
132 /* Make sure the packet we're dissecting is a ar_drone packet
133 * Cheap string check for 'AT*'
135 dword = tvb_get_ntoh24(tvb,0);
136 if(dword != 0x41542a)
137 return 0;
139 col_set_str(pinfo->cinfo, COL_PROTOCOL, "ar_drone");
140 col_set_str(pinfo->cinfo, COL_INFO,"AR Drone Packet");
142 /* Initialize ar_drone Packet tree with subtrees */
143 ti = proto_tree_add_item(tree, proto_ar_drone, tvb, 0, -1, ENC_NA);
144 ar_tree = proto_item_add_subtree(ti, ett_ar_drone);
146 while(tvb_reported_length_remaining(tvb, master_offset) > 3)
148 /* Get a string to compare our command strings (aka "AT*PCMD", etc.) to */
149 offset = tvb_find_guint8(tvb, master_offset, -1, '=');
150 if (offset < master_offset)
151 return master_offset;
153 command = tvb_get_string(wmem_packet_scope(), tvb, master_offset, offset-master_offset);
154 sub_item = proto_tree_add_string(ar_tree, hf_command, tvb, master_offset, -1,
155 tvb_get_string(wmem_packet_scope(), tvb, master_offset+3, offset-master_offset-3));
157 if(!strncmp(command,"AT*PCMD",7))
159 /** Parse according the PCMD layout: */
160 guint8 PCMD_byte;
161 const char *PCMD_str;
163 sub_tree = proto_item_add_subtree(sub_item, ett_PCMD);
165 offset = master_offset + 8;
167 /* Add PCMD ID */
168 length = tvb_find_guint8(tvb, offset, -1, ',') - offset;
169 if (length < 0) {
170 expert_add_info(pinfo, sub_item, &ei_NO_COMMA);
171 return offset;
173 proto_tree_add_item(sub_tree, hf_PCMD_id, tvb, offset, length, ENC_ASCII|ENC_NA);
174 offset += (length + 1);
176 /* Add PCMD Flag */
177 length = tvb_find_guint8(tvb, offset, -1, ',') - offset;
178 if (length < 0) {
179 expert_add_info(pinfo, sub_item, &ei_NO_COMMA);
180 return offset;
182 proto_tree_add_item(sub_tree, hf_PCMD_flag, tvb, offset, length, ENC_ASCII|ENC_NA);
183 offset += (length + 1);
185 /* Add PCMD Roll */
186 length = tvb_find_guint8(tvb, offset, -1, ',') - offset;
187 if (length < 0) {
188 expert_add_info(pinfo, sub_item, &ei_NO_COMMA);
189 return offset;
191 ti = proto_tree_add_item(sub_tree, hf_PCMD_roll, tvb, offset, length, ENC_ASCII|ENC_NA);
193 PCMD_byte = tvb_get_guint8(tvb, offset);
194 if (PCMD_byte == 0x30)
196 PCMD_str = " (NO CHANGE)";
198 else if(PCMD_byte == 0x2d)
200 PCMD_byte = tvb_get_guint8(tvb, offset + 1);
201 if(PCMD_byte == 0x30)
203 PCMD_str = " (NO CHANGE)";
205 else
207 PCMD_str = " (ROLL LEFT)";
210 else
212 PCMD_str = " (ROLL RIGHT)";
214 proto_item_append_string(ti, PCMD_str);
215 offset += (length + 1);
217 /* Add PCMD Pitch */
218 length = tvb_find_guint8(tvb, offset, -1, ',') - offset;
219 if (length < 0) {
220 expert_add_info(pinfo, sub_item, &ei_NO_COMMA);
221 return offset;
223 ti = proto_tree_add_item(sub_tree, hf_PCMD_pitch, tvb, offset, length, ENC_ASCII|ENC_NA);
225 PCMD_byte = tvb_get_guint8(tvb, offset);
226 if (PCMD_byte == 0x30)
228 PCMD_str = " (NO CHANGE)";
230 else if(PCMD_byte == 0x2d)
232 PCMD_byte = tvb_get_guint8(tvb, offset + 1);
233 if(PCMD_byte == 0x30)
235 PCMD_str = " (NO CHANGE)";
237 else
239 PCMD_str = " (PITCH FORWARD)";
242 else
244 PCMD_str = " (PITCH BACKWARD)";
246 proto_item_append_string(ti, PCMD_str);
247 offset += (length + 1);
249 /* Add PCMD Gaz */
250 length = tvb_find_guint8(tvb, offset, -1, ',') - offset;
251 if (length < 0) {
252 expert_add_info(pinfo, sub_item, &ei_NO_COMMA);
253 return offset;
255 ti = proto_tree_add_item(sub_tree, hf_PCMD_gaz, tvb, offset, length, ENC_ASCII|ENC_NA);
257 PCMD_byte = tvb_get_guint8(tvb, offset);
258 if (PCMD_byte == 0x30)
260 PCMD_str = " (NO CHANGE)";
262 else if(PCMD_byte == 0x2d)
264 PCMD_byte = tvb_get_guint8(tvb, offset + 1);
265 if(PCMD_byte == 0x30)
267 PCMD_str = " (NO CHANGE)";
269 else
271 PCMD_str = " (DECREASE VERT SPEED)";
274 else
276 PCMD_str = " (INCREASE VERT SPEED)";
278 proto_item_append_string(ti, PCMD_str);
279 offset += (length + 1);
281 /* Add PCMD Yaw */
282 length = tvb_find_guint8(tvb, offset, -1, 0x0d) - offset;
283 if (length < 0) {
284 expert_add_info(pinfo, sub_item, &ei_NO_CR);
285 return offset;
287 ti = proto_tree_add_item(sub_tree, hf_PCMD_yaw, tvb, offset, length, ENC_ASCII|ENC_NA);
289 PCMD_byte = tvb_get_guint8(tvb, offset);
290 if (PCMD_byte == 0x30)
292 PCMD_str = " (NO CHANGE)";
294 else if(PCMD_byte == 0x2d)
296 PCMD_byte = tvb_get_guint8(tvb, offset + 1);
297 if(PCMD_byte == 0x30)
299 PCMD_str = " (NO CHANGE)";
301 else
303 PCMD_str = " (ROTATE LEFT)";
306 else
308 PCMD_str = " (ROTATE RIGHT)";
310 proto_item_append_string(ti, PCMD_str);
311 offset += (length + 1);
313 else if(!strncmp(command, "AT*REF",6))
315 /** Parse according to the REF layout: */
316 sub_tree = proto_item_add_subtree(sub_item, ett_REF);
318 offset = master_offset + 7;
320 /* Add REF ID */
321 length = tvb_find_guint8(tvb, offset, -1, ',') - offset;
322 if (length < 0) {
323 expert_add_info(pinfo, sub_item, &ei_NO_COMMA);
324 return offset;
326 proto_tree_add_item(sub_tree, hf_REF_id, tvb, offset, length, ENC_ASCII|ENC_NA);
327 offset += (length + 1);
329 /* Add REF ctrl */
330 length = tvb_find_guint8(tvb, offset, -1, 0x0d) - offset;
331 if (length < 0) {
332 expert_add_info(pinfo, sub_item, &ei_NO_CR);
333 return offset;
335 proto_tree_add_item(sub_tree, hf_REF_ctrl, tvb, offset, length, ENC_ASCII|ENC_NA);
336 offset += (length + 1);
338 } else if(!strncmp(command, "AT*CONFIG_IDS", 13))
340 /** Parse according to the CONFIG_ID layout: */
341 sub_tree = proto_item_add_subtree(sub_item, ett_CONFIG_ID);
343 offset = master_offset + 14;
345 /* Add Sequence Number */
346 length = tvb_find_guint8(tvb, offset, -1, ',') - offset;
347 if (length < 0) {
348 expert_add_info(pinfo, sub_item, &ei_NO_COMMA);
349 return offset;
351 proto_tree_add_item(sub_tree, hf_CONFIG_ID_seq, tvb, offset, length, ENC_ASCII|ENC_NA);
352 offset += (length + 1);
354 /* Add Session ID */
355 length = tvb_find_guint8(tvb, offset, -1, ',') - offset;
356 if (length < 0) {
357 expert_add_info(pinfo, sub_item, &ei_NO_COMMA);
358 return offset;
360 proto_tree_add_item(sub_tree, hf_CONFIG_ID_session, tvb, offset, length, ENC_ASCII|ENC_NA);
361 offset += (length + 1);
363 /* Add User ID */
364 length = tvb_find_guint8(tvb, offset, -1, ',') - offset;
365 if (length < 0) {
366 expert_add_info(pinfo, sub_item, &ei_NO_COMMA);
367 return offset;
369 proto_tree_add_item(sub_tree, hf_CONFIG_ID_user, tvb, offset, length, ENC_ASCII|ENC_NA);
370 offset += (length + 1);
372 /* Add Application ID */
373 length = tvb_find_guint8(tvb, offset, -1, 0x0d) - offset;
374 if (length < 0) {
375 expert_add_info(pinfo, sub_item, &ei_NO_CR);
376 return offset;
378 proto_tree_add_item(sub_tree, hf_CONFIG_ID_app, tvb, offset, length, ENC_ASCII|ENC_NA);
379 offset += (length + 1);
381 } else if(!strncmp(command, "AT*ANIM", 7))
383 /** Parse according to the ANIM layout: */
384 sub_tree = proto_item_add_subtree(sub_item, ett_ANIM);
386 offset = master_offset + 8;
388 /* Add sequence */
389 length = tvb_find_guint8(tvb, offset, -1, ',') - offset;
390 if (length < 0) {
391 expert_add_info(pinfo, sub_item, &ei_NO_COMMA);
392 return offset;
394 proto_tree_add_item(sub_tree, hf_ANIM_seq, tvb, offset, length, ENC_ASCII|ENC_NA);
395 offset += (length + 1);
397 /* Add Animation */
398 length = tvb_find_guint8(tvb, offset, -1, ',') - offset;
399 if (length < 0) {
400 expert_add_info(pinfo, sub_item, &ei_NO_COMMA);
401 return offset;
403 proto_tree_add_item(sub_tree, hf_ANIM_anim, tvb, offset, length, ENC_ASCII|ENC_NA);
404 offset += (length + 1);
406 /* Add animation time(sec) */
407 length = tvb_find_guint8(tvb, offset, -1, 0x0d) - offset;
408 if (length < 0) {
409 expert_add_info(pinfo, sub_item, &ei_NO_CR);
410 return offset;
412 proto_tree_add_item(sub_tree, hf_ANIM_sec, tvb, offset, length, ENC_ASCII|ENC_NA);
413 offset += (length + 1);
415 } else if(!strncmp(command, "AT*FTRIM", 8))
417 /** Parse according to the FTRIM layout: */
418 sub_tree = proto_item_add_subtree(sub_item, ett_FTRIM);
420 offset = master_offset + 9;
422 /* Add sequence number */
423 length = tvb_find_guint8(tvb, offset, -1, 0x0d) - offset;
424 if (length < 0) {
425 expert_add_info(pinfo, sub_item, &ei_NO_CR);
426 return offset;
428 proto_tree_add_text(sub_tree, tvb, master_offset, length, "(Sets the reference for the horizontal plane)");
429 proto_tree_add_item(sub_tree, hf_FTRIM_seq, tvb, offset, length, ENC_ASCII|ENC_NA);
430 offset += (length + 1);
431 } else if(!strncmp(command, "AT*CONFIG", 9))
433 /** Parse according to the CONFIG layout: */
434 sub_tree = proto_item_add_subtree(sub_item, ett_CONFIG);
436 offset = master_offset + 10;
438 /* Add sequence */
439 length = tvb_find_guint8(tvb, offset, -1, ',') - offset;
440 if (length < 0) {
441 expert_add_info(pinfo, sub_item, &ei_NO_COMMA);
442 return offset;
444 proto_tree_add_item(sub_tree, hf_CONFIG_seq, tvb, offset, length, ENC_ASCII|ENC_NA);
445 offset += (length + 1);
447 /* Add Name */
448 length = tvb_find_guint8(tvb, offset, -1, ',') - offset;
449 if (length < 0) {
450 expert_add_info(pinfo, sub_item, &ei_NO_COMMA);
451 return offset;
453 proto_tree_add_item(sub_tree, hf_CONFIG_name, tvb, offset, length, ENC_ASCII|ENC_NA);
454 offset += (length + 1);
456 /* Add Value */
457 length = tvb_find_guint8(tvb, offset, -1, 0x0d) - offset;
458 if (length < 0) {
459 expert_add_info(pinfo, sub_item, &ei_NO_CR);
460 return offset;
462 proto_tree_add_item(sub_tree, hf_CONFIG_val, tvb, offset, length, ENC_ASCII|ENC_NA);
463 offset += (length + 1);
465 } else if(!strncmp(command, "AT*LED", 6))
467 /** Parse according to the LED layout: */
468 sub_tree = proto_item_add_subtree(sub_item, ett_LED);
470 offset = master_offset + 7;
472 /* Add sequence */
473 length = tvb_find_guint8(tvb, offset, -1, ',') - offset;
474 if (length < 0) {
475 expert_add_info(pinfo, sub_item, &ei_NO_COMMA);
476 return offset;
478 proto_tree_add_item(sub_tree, hf_LED_seq, tvb, offset, length, ENC_ASCII|ENC_NA);
479 offset += (length + 1);
481 /* Add animation to play */
482 length = tvb_find_guint8(tvb, offset, -1, ',') - offset;
483 if (length < 0) {
484 expert_add_info(pinfo, sub_item, &ei_NO_COMMA);
485 return offset;
487 proto_tree_add_item(sub_tree, hf_LED_anim, tvb, offset, length, ENC_ASCII|ENC_NA);
488 offset += (length + 1);
490 /* Add frequency */
491 length = tvb_find_guint8(tvb, offset, -1, ',') - offset;
492 if (length < 0) {
493 expert_add_info(pinfo, sub_item, &ei_NO_COMMA);
494 return offset;
496 proto_tree_add_item(sub_tree, hf_LED_freq, tvb, offset, length, ENC_ASCII|ENC_NA);
497 offset += (length + 1);
499 /* Add Time to play in sec */
500 length = tvb_find_guint8(tvb, offset, -1, 0x0d) - offset;
501 if (length < 0) {
502 expert_add_info(pinfo, sub_item, &ei_NO_CR);
503 return offset;
505 proto_tree_add_item(sub_tree, hf_LED_sec, tvb, offset, length, ENC_ASCII|ENC_NA);
506 offset += (length + 1);
508 } else if(!strncmp(command, "AT*COMWDG", 9))
510 /** Parse according to the COMWDG layout: */
511 sub_tree = proto_item_add_subtree(sub_item, ett_COMWDG);
513 offset = master_offset + 10;
515 /* Add sequence number */
516 length = tvb_find_guint8(tvb, offset, -1, 0x0d) - offset;
517 if (length < 0) {
518 expert_add_info(pinfo, sub_item, &ei_NO_CR);
519 return offset;
521 proto_tree_add_item(sub_tree, hf_COMWDG, tvb, offset, length, ENC_ASCII|ENC_NA);
522 offset += (length + 1);
524 }else if(!strncmp(command, "AT*CTRL", 7))
526 /** Parse according to the CTRL layout: */
527 sub_tree = proto_item_add_subtree(sub_item, ett_CTRL);
529 offset = master_offset + 8;
531 /* Add sequence */
532 length = tvb_find_guint8(tvb, offset, -1, ',') - offset;
533 if (length < 0) {
534 expert_add_info(pinfo, sub_item, &ei_NO_COMMA);
535 return offset;
537 proto_tree_add_item(sub_tree, hf_CTRL_seq, tvb, offset, length, ENC_ASCII|ENC_NA);
538 offset += (length + 1);
540 /* Add Mode */
541 length = tvb_find_guint8(tvb, offset, -1, ',') - offset;
542 if (length < 0) {
543 expert_add_info(pinfo, sub_item, &ei_NO_COMMA);
544 return offset;
546 ti = proto_tree_add_item(sub_tree, hf_CTRL_mode, tvb, offset, length, ENC_ASCII|ENC_NA);
547 proto_item_append_text(ti, "%s",
548 str_to_str(tvb_get_string(wmem_packet_scope(), tvb, offset, length), CTRL_mode_vs, " (Unknown Mode)"));
549 offset += (length + 1);
551 /* Add File Size */
552 length = tvb_find_guint8(tvb, offset, -1, 0x0d) - offset;
553 if (length < 0) {
554 expert_add_info(pinfo, sub_item, &ei_NO_CR);
555 return offset;
557 proto_tree_add_item(sub_tree, hf_CTRL_fsize, tvb, offset, length, ENC_ASCII|ENC_NA);
558 offset += (length + 1);
560 else
562 /* Unknown command, just abort */
563 return master_offset;
566 proto_item_set_len(sub_item, offset-master_offset);
567 master_offset = offset;
570 return master_offset;
573 void
574 proto_register_ar_drone(void)
576 /* Setup protocol header array */
577 static hf_register_info hf[] = {
578 { &hf_command,
579 { "Command", "ar_drone.command",
580 FT_STRING, BASE_NONE,
581 NULL, 0x0,
582 NULL, HFILL }
584 { &hf_PCMD_id,
585 { "Sequence Number", "ar_drone.pcmd.id",
586 FT_STRING, BASE_NONE,
587 NULL, 0x0,
588 "Progressive Command ID", HFILL }
590 { &hf_PCMD_flag,
591 { "Flag", "ar_drone.pcmd.flag",
592 FT_STRING, BASE_NONE,
593 NULL/*VALS(PCMD_flag_vs)*/, 0x0,
594 "Progressive Command Flag", HFILL }
596 { &hf_PCMD_roll,
597 { "Roll", "ar_drone.pcmd.roll",
598 FT_STRING, BASE_NONE,
599 NULL, 0x0,
600 "Progressive Command Roll", HFILL }
602 { &hf_PCMD_pitch,
603 { "Pitch", "ar_drone.pcmd.pitch",
604 FT_STRING, BASE_NONE,
605 NULL, 0x0,
606 "Progressive Command Pitch", HFILL }
608 { &hf_PCMD_gaz,
609 { "Gaz", "ar_drone.pcmd.gaz",
610 FT_STRING, BASE_NONE,
611 NULL, 0x0,
612 "Progressive Command Gaz", HFILL }
614 { &hf_PCMD_yaw,
615 { "Yaw", "ar_drone.pcmd.yaw",
616 FT_STRING, BASE_NONE,
617 NULL, 0x0,
618 "Progressive Command Yaw", HFILL }
620 { &hf_REF_id,
621 { "Sequence Number", "ar_drone.ref.id",
622 FT_STRING, BASE_NONE,
623 NULL, 0x0,
624 "Reference ID", HFILL }
626 { &hf_REF_ctrl,
627 { "Control Command", "ar_drone.ref.ctrl",
628 FT_STRING, BASE_NONE,
629 NULL/*VALS(REF_types_vs)*/, 0x0,
630 NULL, HFILL }
632 { &hf_FTRIM_seq,
633 { "Sequence Number", "ar_drone.ftrim.seq",
634 FT_STRING, BASE_NONE,
635 NULL, 0x0,
636 "Flap Trim / Horizontal Plane Reference", HFILL }
638 { &hf_CONFIG_ID_seq,
639 { "Sequence Number", "ar_drone.configids.seq",
640 FT_STRING, BASE_NONE,
641 NULL, 0x0,
642 "Configuration ID sequence number", HFILL }
644 { &hf_CONFIG_ID_session,
645 { "Current Session ID", "ar_drone.configids.session",
646 FT_STRING, BASE_NONE,
647 NULL, 0x0,
648 "Configuration ID current session ID", HFILL }
650 { &hf_CONFIG_ID_user,
651 { "Current User ID", "ar_drone.configids.user",
652 FT_STRING, BASE_NONE,
653 NULL, 0x0,
654 "Configuration ID current user ID", HFILL }
656 { &hf_CONFIG_ID_app,
657 { "Current Application ID", "ar_drone.configids.app",
658 FT_STRING, BASE_NONE,
659 NULL, 0x0,
660 "Configuration ID current application ID", HFILL }
662 { &hf_COMWDG,
663 { "Command WatchDog Request", "ar_drone.comwdg",
664 FT_STRING, BASE_NONE,
665 NULL, 0x0,
666 "Command WatchDog Reset request", HFILL }
668 { &hf_CONFIG_seq,
669 { "Sequence Number", "ar_drone.config.seq",
670 FT_STRING, BASE_NONE,
671 NULL, 0x0,
672 "Configuration Seq Num", HFILL }
674 { &hf_CONFIG_name,
675 { "Option Name", "ar_drone.config.name",
676 FT_STRING, BASE_NONE,
677 NULL, 0x0,
678 NULL, HFILL }
680 { &hf_CONFIG_val,
681 { "Option Parameter", "ar_drone.config.val",
682 FT_STRING, BASE_NONE,
683 NULL, 0x0,
684 NULL, HFILL }
686 { &hf_LED_seq,
687 { "Sequence Number", "ar_drone.led.seq",
688 FT_STRING, BASE_NONE,
689 NULL, 0x0,
690 "LED Sequence Number", HFILL }
692 { &hf_LED_anim,
693 { "Selected Animation", "ar_drone.led.anim",
694 FT_STRING, BASE_NONE,
695 NULL, 0x0,
696 "Selected LED Animation", HFILL }
698 { &hf_LED_freq,
699 { "Animation Frequency", "ar_drone.led.freq",
700 FT_STRING, BASE_NONE,
701 NULL, 0x0,
702 "LED Animation Frequency", HFILL }
704 { &hf_LED_sec,
705 { "LED Animation Length (Seconds)", "ar_drone.led.sec",
706 FT_STRING, BASE_NONE,
707 NULL, 0x0,
708 "LED Anim Length", HFILL }
710 { &hf_ANIM_seq,
711 { "Animation Sequence Number", "ar_drone.anim.seq",
712 FT_STRING, BASE_NONE,
713 NULL, 0x0,
714 "Movment(Animation) Sequence #", HFILL }
716 { &hf_ANIM_anim,
717 { "Selected Animation Number", "ar_drone.anim.num",
718 FT_STRING, BASE_NONE,
719 NULL, 0x0,
720 "Movment(Animation) to Play", HFILL }
722 { &hf_ANIM_sec,
723 { "Animation Duration (seconds)", "ar_drone.anim.sec",
724 FT_STRING, BASE_NONE,
725 NULL, 0x0,
726 "Movment(Animation) Time in Seconds", HFILL }
728 { &hf_CTRL_seq,
729 { "Sequence Number", "ar_drone.ctrl.seq",
730 FT_STRING, BASE_NONE,
731 NULL, 0x0,
732 NULL, HFILL }
734 { &hf_CTRL_mode,
735 { "Control Mode", "ar_drone.ctrl.mode",
736 FT_STRING, BASE_NONE,
737 NULL, 0x0,
738 NULL, HFILL }
740 { &hf_CTRL_fsize,
741 { "Firmware Update File Size (0 for no update)", "ar_drone.ctrl.filesize",
742 FT_STRING, BASE_NONE,
743 NULL, 0x0,
744 NULL, HFILL }
748 /* Setup protocol subtree array */
749 static gint *ett[] = {
750 &ett_ar_drone,
751 &ett_PCMD,
752 &ett_REF,
753 &ett_FTRIM,
754 &ett_CONFIG,
755 &ett_CONFIG_ID,
756 &ett_COMWDG,
757 &ett_LED,
758 &ett_ANIM,
759 &ett_CTRL
762 static ei_register_info ei[] = {
763 { &ei_NO_COMMA, { "ar_drone.no_comma", PI_MALFORMED, PI_ERROR, "Comma delimiter not found", EXPFILL }},
764 { &ei_NO_CR, { "ar_drone.no_cr", PI_MALFORMED, PI_ERROR, "Carriage return delimiter (0x0d) not found", EXPFILL }},
768 static expert_field = EI_INIT;
769 static expert_field = EI_INIT;
771 module_t *drone_module;
772 expert_module_t* expert_drone;
774 /* Setup protocol info */
775 proto_ar_drone = proto_register_protocol (
776 "AR Drone Packet", /* name */
777 "AR Drone", /* short name */
778 "ar_drone" /* abbrev */
781 proto_register_field_array(proto_ar_drone, hf, array_length(hf));
782 proto_register_subtree_array(ett, array_length(ett));
784 expert_drone = expert_register_protocol(proto_ar_drone);
785 expert_register_field_array(expert_drone, ei, array_length(ei));
787 drone_module = prefs_register_protocol(proto_ar_drone, NULL);
789 prefs_register_uint_preference(drone_module, "udp.port",
790 "AR Drone UDP Port",
791 "AR Drone UDP port",
793 &ar_drone_port);
796 void
797 proto_reg_handoff_ar_drone(void)
799 static dissector_handle_t ar_drone_handle;
800 static guint old_port = 0;
801 static gboolean initialized = FALSE;
803 if (initialized == FALSE)
805 ar_drone_handle = new_create_dissector_handle(dissect_ar_drone, proto_ar_drone);
807 heur_dissector_add("udp", dissect_ar_drone, proto_ar_drone);
809 initialized = TRUE;
812 /* Register UDP port for dissection */
813 if(old_port != 0 && old_port != ar_drone_port)
815 dissector_delete_uint("udp.port", old_port, ar_drone_handle);
818 if(ar_drone_port != 0 && old_port != ar_drone_port)
820 dissector_add_uint("udp.port", ar_drone_port, ar_drone_handle);
823 old_port = ar_drone_port;
827 * Editor modelines - http://www.wireshark.org/tools/modelines.html
829 * Local variables:
830 * c-basic-offset: 4
831 * tab-width: 4
832 * indent-tabs-mode: nil
833 * End:
835 * vi: set shiftwidth=4 tabstop=4 expandtab:
836 * :indentSize=4:tabSize=4:noTabs=true: