dRonin  adbada4
dRonin GCS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
packet-op-uavobjects-template.c
Go to the documentation of this file.
1 /*
2  * !!! Autogenerated from $(XMLFILE) Do NOT Edit !!!
3  *
4  * Routines for OpenPilot UAVObject dissection
5  * Copyright 2012 Stacey Sheldon <stac@solidgoldbomb.org>
6  *
7  * $Id$
8  *
9  * Wireshark - Network traffic analyzer
10  * By Gerald Combs <gerald@wireshark.org>
11  * Copyright 1998 Gerald Combs
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, see <http://www.gnu.org/licenses/>
25  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26  */
27 
28 
29 #ifdef HAVE_CONFIG_H
30 # include "config.h"
31 #endif
32 
33 #include <epan/packet.h>
34 #include <epan/ptvcursor.h> /* ptvcursor_* */
35 
36 #include <glib.h>
37 #include <string.h>
38 
39 static int proto_uavo = -1;
40 
41 /* Subtree expansion tracking */
43 
44 /* Field handles */
45 $(FIELDHANDLES)
46 
47 /* Enum string mappings */
48 $(ENUMFIELDNAMES)
49 
50 void proto_reg_handoff_op_uavobjects_$(NAMELC)(void);
51 
52 static int dissect_uavo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
53 {
54  int offset = 0;
55 
56  col_append_str(pinfo->cinfo, COL_INFO, "($(NAME))");
57 
58  if (tree) { /* we are being asked for details */
59  proto_tree *uavo_tree = NULL;
60  ptvcursor_t * cursor;
61  proto_item *ti = NULL;
62 
63  /* Add a top-level entry to the dissector tree for this protocol */
64  ti = proto_tree_add_item(tree, proto_uavo, tvb, 0, -1, ENC_NA);
65 
66  /* Create a subtree to contain the dissection of this protocol */
67  uavo_tree = proto_item_add_subtree(ti, ett_uavo);
68 
69  /* Dissect the packet and populate the subtree */
70  cursor = ptvcursor_new(uavo_tree, tvb, 0);
71 
72  /* Populate the fields in this protocol */
73 $(POPULATETREE)
74 
75  offset += ptvcursor_current_offset(cursor);
76 
77  ptvcursor_free(cursor);
78  } else {
79  offset = 0;
80  }
81 
82  return offset;
83 }
84 
85 void proto_register_op_objects_$(NAMELC)(void)
86 {
87 $(HEADERFIELDS)
88 
89  /* Setup protocol subtree array */
90 
91  static gint *ett[] = {
92  $(SUBTREES)
93  };
94 
95  /* Register this protocol */
96  proto_uavo = proto_register_protocol("UAVO $(NAME)",
97  "UAVO $(NAME)",
98  "uavo-$(NAMELC)");
99 
100  /* Register the field definitions for this protocol */
101  proto_register_subtree_array(ett, array_length(ett));
102  proto_register_field_array(proto_uavo, hf, array_length(hf));
103 }
104 
105 void proto_reg_handoff_op_uavobjects_$(NAMELC)(void)
106 {
107  dissector_handle_t uavo_handle;
108  uavo_handle = new_create_dissector_handle(dissect_uavo, proto_uavo);
109 
110  /* Bind this protocol to its UAV ObjID in UAVTalk */
111  dissector_add_uint("uavtalk.objid", $(OBJIDHEX), uavo_handle);
112 }
DataFields data
void(NAME)
SUBTREESTATICS(FIELDHANDLES)
void proto_register_op_objects_() NAMELC(void)