change the signature for the get_pdu_len() function pointer passed to tcp_dissect_pdu...
[obnox/wireshark/wip.git] / asn1 / ulp / packet-ulp-template.c
1 /* packet-ulp.c
2  * Routines for OMA UserPlane Location Protocol packet dissection
3  * Copyright 2006, Anders Broman <anders.broman@ericsson.com>
4  *
5  * $Id$
6  *
7  * Wireshark - Network traffic analyzer
8  * By Gerald Combs <gerald@wireshark.org>
9  * Copyright 1998 Gerald Combs
10  *
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License
13  * as published by the Free Software Foundation; either version 2
14  * of the License, or (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
24  *
25  * ref OMA-TS-ULP-V1_0-20060127-C
26  * http://www.openmobilealliance.org
27  */
28
29 #ifdef HAVE_CONFIG_H
30 # include "config.h"
31 #endif
32
33 #include <glib.h>
34 #include <epan/packet.h>
35 #include <epan/conversation.h>
36 #include <epan/prefs.h>
37
38 #include <stdio.h>
39 #include <string.h>
40
41 #include "packet-ulp.h"
42
43 #include "packet-ber.h"
44 #include "packet-per.h"
45 #include <epan/emem.h>
46 #include "packet-tcp.h"
47
48 #define PNAME  "OMA UserPlane Location Protocol"
49 #define PSNAME "ULP"
50 #define PFNAME "ulp"
51
52 static dissector_handle_t ulp_handle=NULL;
53 static dissector_handle_t rrlp_handle;
54
55 /* IANA Registered Ports  
56  * oma-ulp         7275/tcp    OMA UserPlane Location
57  * oma-ulp         7275/udp    OMA UserPlane Location
58  */
59 guint gbl_ulp_port = 7275;
60
61 /* Initialize the protocol and registered fields */
62 static int proto_ulp = -1;
63
64
65 #define ULP_HEADER_SIZE 2
66
67 gboolean ulp_desegment = TRUE;
68
69 #include "packet-ulp-hf.c"
70
71 /* Initialize the subtree pointers */
72 static gint ett_ulp = -1;
73 #include "packet-ulp-ett.c"
74
75 /* Include constants */
76 #include "packet-ulp-val.h"
77
78
79 #include "packet-ulp-fn.c"
80
81
82 static guint
83 get_ulp_pdu_len(packet_info *pinfo _U_, tvbuff_t *tvb, int offset)
84 {
85         /* PDU length = Message length */
86         return tvb_get_ntohs(tvb,offset);
87 }
88
89 static void
90 dissect_ulp_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
91 {
92         tcp_dissect_pdus(tvb, pinfo, tree, ulp_desegment, ULP_HEADER_SIZE,
93             get_ulp_pdu_len, dissect_ULP_PDU_PDU);
94 }
95 /*--- proto_reg_handoff_ulp ---------------------------------------*/
96 void
97 proto_reg_handoff_ulp(void)
98 {
99
100         ulp_handle = create_dissector_handle(dissect_ulp_tcp, proto_ulp);
101
102         dissector_add("tcp.port", gbl_ulp_port, ulp_handle);
103
104         /* application/oma-supl-ulp */
105         dissector_add_string("media_type","application/oma-supl-ulp", ulp_handle);
106
107         rrlp_handle = find_dissector("rrlp");
108
109 }
110
111
112 /*--- proto_register_ulp -------------------------------------------*/
113 void proto_register_ulp(void) {
114
115   /* List of fields */
116   static hf_register_info hf[] = {
117
118 #include "packet-ulp-hfarr.c"
119   };
120
121   /* List of subtrees */
122   static gint *ett[] = {
123           &ett_ulp,
124 #include "packet-ulp-ettarr.c"
125   };
126
127   module_t *ulp_module;
128
129
130   /* Register protocol */
131   proto_ulp = proto_register_protocol(PNAME, PSNAME, PFNAME);
132   /* Register fields and subtrees */
133   proto_register_field_array(proto_ulp, hf, array_length(hf));
134   proto_register_subtree_array(ett, array_length(ett));
135
136   ulp_module = prefs_register_protocol(proto_ulp,proto_reg_handoff_ulp);
137
138   prefs_register_bool_preference(ulp_module, "desegment_ulp_messages",
139                 "Reassemble ULP messages spanning multiple TCP segments",
140                 "Whether the ULP dissector should reassemble messages spanning multiple TCP segments."
141                 " To use this option, you must also enable \"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.",
142                 &ulp_desegment);
143
144         /* Register a configuration option for port */
145         prefs_register_uint_preference(ulp_module, "tcp.port",
146                                                                    "ULP TCP Port",
147                                                                    "Set the TCP port for Ulp messages(IANA registerd port is 7275)",
148                                                                    10,
149                                                                    &gbl_ulp_port);
150  
151 }
152
153
154
155