2 * Routines for OPSI protocol dissection
3 * Copyright 2004, Laurent Rabret (France Telecom R&D) <laurent.rabret@i.hate.spams.org>
7 * Ethereal - Network traffic analyzer
8 * By Gerald Combs <gerald@ethereal.com>
9 * Copyright 1998 Gerald Combs
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.
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.
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.
30 #include "moduleinfo.h"
39 #include <epan/packet.h>
40 #include <epan/dissectors/packet-tcp.h>
41 #include <epan/prefs.h>
43 #include "packet-opsi.h"
45 /* Plugin exported constants */
47 G_MODULE_EXPORT const gchar version[] = VERSION;
51 /* Initialize the protocol and registered fields */
52 static int proto_opsi = -1;
53 static int hf_opsi_major_version = -1;
54 static int hf_opsi_minor_version = -1;
55 static int hf_opsi_opcode = -1;
56 static int hf_opsi_hook_id = -1;
57 static int hf_opsi_length = -1;
58 static int hf_opsi_session_id = -1;
59 static int hf_user_name_att = -1;
60 static int hf_password_att = -1;
61 static int hf_chap_password_att = -1;
62 static int hf_nas_ip_add_att = -1;
63 static int hf_nas_port_att = -1;
64 static int hf_service_type_att = -1;
65 static int hf_framed_protocol_att = -1;
66 static int hf_framed_address_att = -1;
67 static int hf_framed_netmask_att = -1;
68 static int hf_framed_routing_att = -1;
69 static int hf_framed_filter_att = -1;
70 static int hf_framed_mtu_att = -1;
71 static int hf_framed_compression_att = -1;
72 static int hf_called_station_att = -1;
73 static int hf_calling_station_att = -1;
74 static int hf_nas_identifier_att = -1;
75 static int hf_accounting_att = -1;
76 static int hf_acct_session_id_att = -1;
77 static int hf_chap_challenge_att = -1;
78 static int hf_nas_port_type_att = -1;
79 static int hf_designation_num_att = -1;
80 static int hf_nas_port_id_att = -1;
81 static int hf_smc_aaa_id_att = -1;
82 static int hf_smc_vpn_id_att = -1;
83 static int hf_smc_vpn_name_att = -1;
84 static int hf_smc_ran_id_att = -1;
85 static int hf_smc_ran_ip_att = -1;
86 static int hf_smc_ran_name_att = -1;
87 static int hf_smc_pop_id_att = -1;
88 static int hf_smc_pop_name_att = -1;
89 static int hf_smc_id_att = -1;
90 static int hf_smc_receive_time_att = -1;
91 static int hf_smc_stat_time_att = -1;
92 static int hf_opsi_flags_att = -1;
93 static int hf_opsi_application_name_att = -1;
95 /* Initialize the subtree pointers */
96 static gint ett_opsi = -1;
97 static gint ett_opsi_user_name = -1;
98 static gint ett_opsi_user_password = -1;
99 static gint ett_opsi_chap_password = -1;
100 static gint ett_opsi_nas_ip_address = -1;
101 static gint ett_opsi_nas_port = -1;
102 static gint ett_opsi_service_type = -1;
103 static gint ett_opsi_framed_protocol = -1;
104 static gint ett_opsi_framed_address = -1;
105 static gint ett_opsi_framed_netmask = -1;
106 static gint ett_opsi_framed_routing = -1;
107 static gint ett_opsi_framed_filter = -1;
108 static gint ett_opsi_framed_mtu = -1;
109 static gint ett_opsi_framed_compression = -1;
110 static gint ett_opsi_called_station_id = -1;
111 static gint ett_opsi_calling_station_id = -1;
112 static gint ett_opsi_nas_identifier = -1;
113 static gint ett_opsi_accounting = -1;
114 static gint ett_opsi_acct_session_id = -1;
115 static gint ett_opsi_chap_challenge = -1;
116 static gint ett_opsi_nas_port_type = -1;
117 static gint ett_opsi_designation_number = -1;
118 static gint ett_opsi_nas_port_id = -1;
119 static gint ett_opsi_smc_aaa_id = -1;
120 static gint ett_opsi_smc_vpn_id = -1;
121 static gint ett_opsi_smc_vpn_name = -1;
122 static gint ett_opsi_smc_ran_id = -1;
123 static gint ett_opsi_smc_ran_ip = -1;
124 static gint ett_opsi_smc_ran_name = -1;
125 static gint ett_opsi_smc_pop_id = -1;
126 static gint ett_opsi_smc_pop_name = -1;
127 static gint ett_opsi_smc_id = -1;
128 static gint ett_opsi_smc_receive_time = -1;
129 static gint ett_opsi_smc_stat_time = -1;
130 static gint ett_opsi_flags = -1;
131 static gint ett_opsi_application_name = -1;
135 static const value_string opsi_opcode[] = {
136 { DISCOVER_REQUEST, "Discover Request" },
137 { DISCOVER_RESPONSE, "Discover Response" },
138 { SERVICE_REQUEST, "Service Request" },
139 { SERVICE_ACCEPT, "Service Accept" },
140 { SERVICE_REJECT, "Service Reject" },
141 { TERMINATE_REQUEST, "Terminate Request" },
145 static const value_string opsi_service_type_code[] = {
148 { 3, "Callback Login" },
149 { 4, "Callback Framed" },
151 { 6, "Administrative" },
153 { 8, "Authenticate Only" },
154 { 9, "Callback NAS Prompt" },
158 static const value_string opsi_framed_protocol_code[] = {
161 { 3, "AppleTalk Remote Access Protocol (ARAP)" },
162 { 4, "Gandalf proprietary SingleLink/MultiLink protocol" },
163 { 5, "Xylogics proprietary IPX/SLIP" },
164 { 255, "Ascend ARA" },
176 static const value_string opsi_framed_routing_code[] = {
180 { 3, "Broadcast-Listen" },
181 { 4, "Broadcast V2" },
183 { 6, "Broadcast-Listen V2" },
187 static const value_string opsi_framed_compression_code[] = {
189 { 1, "Van Jacobsen TCP/IP" },
190 { 2, "IPX header compression" },
194 static const value_string opsi_nas_port_type_code[] = {
198 { 3, "ISDN Async V.120" },
199 { 4, "ISDN Async V.110" },
202 { 7, "HDLC Clear Channel" },
206 { 11, "SDSL - Symmetric DSL" },
207 { 12, "ADSL-CAP - Asymmetric DSL, Carrierless Amplitude Phase Modulation" },
208 { 13, "ADSL-DMT - Asymmetric DSL, Discrete Multi-Tone" },
209 { 14, "IDSL - ISDN Digital Subscriber Line" },
211 { 16, "xDSL - Digital Subscriber Line of unknown type" },
213 { 18, "Wireless - Other" },
214 { 19, "Wireless - IEEE 802.11" },
215 { 201,"Voice over IP" },
220 /* Structure used to decode OPSI frame attributes */
221 /* CAUTION : it is compulsory to sort this array */
222 /* (first argument of the opsi_attribute_handle_t) */
223 /* in ascending order */
225 static opsi_attribute_handle_t opsi_attributes[] = {
226 { USER_NAME_ATTRIBUTE, /* 1 */
227 "User name attribute", &ett_opsi_user_name, &hf_user_name_att, decode_string_attribute },
228 { USER_PASSWD_ATTRIBUTE, /* 2 */
229 "User password attribute" , &ett_opsi_user_password, &hf_password_att, decode_string_attribute },
230 { CHAP_PASSWD_ATTRIBUTE, /* 3 */
231 "CHAP password attribute", &ett_opsi_chap_password, &hf_chap_password_att, decode_string_attribute },
232 { NAS_IP_ADDRESS_ATTRIBUTE, /* 4 */
233 "NAS IP address attribute", &ett_opsi_nas_ip_address, &hf_nas_ip_add_att, decode_ipv4_attribute },
234 {NAS_PORT_ATTRIBUTE, /* 5 */
235 "NAS port attribute", &ett_opsi_nas_port, &hf_nas_port_att, decode_longint_attribute },
236 {SERVICE_TYPE_ATTRIBUTE, /* 6 */
237 "Service type attribute", &ett_opsi_service_type, &hf_service_type_att, decode_value_string_attribute },
238 {FRAMED_PROTOCOL_ATTRIBUTE, /* 7 */
239 "Framed protocol attribute", &ett_opsi_framed_protocol, &hf_framed_protocol_att, decode_value_string_attribute },
240 {FRAMED_ADDRESS_ATTRIBUTE, /* 8 */
241 "Framed address attribute", &ett_opsi_framed_address, &hf_framed_address_att, decode_ipv4_attribute },
242 {FRAMED_NETMASK_ATTRIBUTE, /* 9 */
243 "Framed netmask attribute", &ett_opsi_framed_netmask, &hf_framed_netmask_att, decode_ipv4_attribute },
244 {FRAMED_ROUTING_ATTRIBUTE, /* 10 */
245 "Framed routing attribute", &ett_opsi_framed_routing, &hf_framed_routing_att, decode_value_string_attribute },
246 {FRAMED_FILTER_ATTRIBUTE, /* 11 */
247 "Framed filter attribute", &ett_opsi_framed_filter, &hf_framed_filter_att, decode_string_attribute },
248 {FRAMED_MTU_ATTRIBUTE, /* 12 */
249 "Framed MTU attribute", &ett_opsi_framed_mtu, &hf_framed_mtu_att, decode_longint_attribute },
250 {FRAMED_COMPRESSION_ATTRIBUTE, /* 13 */
251 "Framed compression attribute", &ett_opsi_framed_compression, &hf_framed_compression_att, decode_value_string_attribute },
252 {CALLED_STATION_ID_ATTRIBUTE, /* 30 */
253 "Called station ID attribute", &ett_opsi_called_station_id, &hf_called_station_att, decode_string_attribute },
254 {CALLING_STATION_ID_ATTRIBUTE, /* 31 */
255 "Calling station ID attribute", &ett_opsi_calling_station_id, &hf_calling_station_att, decode_string_attribute },
256 {NAS_IDENTIFIER, /* 32 */
257 "NAS Identifier attribute", &ett_opsi_nas_identifier, &hf_nas_identifier_att, decode_string_attribute },
258 {ACCOUNTING_40_ATTRIBUTE, /* 40 */
259 "Accounting attribute", &ett_opsi_accounting, &hf_accounting_att, decode_string_attribute },
260 {ACCOUNTING_41_ATTRIBUTE, /* 41 */
261 "Accounting attribute", &ett_opsi_accounting, &hf_accounting_att, decode_string_attribute },
262 {ACCOUNTING_42_ATTRIBUTE, /* 42 */
263 "Accounting attribute", &ett_opsi_accounting, &hf_accounting_att, decode_string_attribute },
264 {ACCOUNTING_43_ATTRIBUTE, /* 43 */
265 "Accounting attribute", &ett_opsi_accounting, &hf_accounting_att, decode_string_attribute },
266 {ACCOUNTING_SESSION_ID_ATTRIBUTE, /* 44 */
267 "Accounting session ID attribute", &ett_opsi_acct_session_id, &hf_acct_session_id_att, decode_string_attribute },
268 {ACCOUNTING_45_ATTRIBUTE, /* 45 */
269 "Accounting attribute", &ett_opsi_accounting, &hf_accounting_att, decode_string_attribute },
270 {ACCOUNTING_46_ATTRIBUTE, /* 46 */
271 "Accounting attribute", &ett_opsi_accounting, &hf_accounting_att, decode_string_attribute },
272 {ACCOUNTING_47_ATTRIBUTE, /* 47 */
273 "Accounting attribute", &ett_opsi_accounting, &hf_accounting_att, decode_string_attribute },
274 {ACCOUNTING_48_ATTRIBUTE, /* 48 */
275 "Accounting attribute", &ett_opsi_accounting, &hf_accounting_att, decode_string_attribute },
276 {ACCOUNTING_49_ATTRIBUTE, /* 49 */
277 "Accounting attribute", &ett_opsi_accounting, &hf_accounting_att, decode_string_attribute },
278 {ACCOUNTING_50_ATTRIBUTE, /* 50 */
279 "Accounting attribute", &ett_opsi_accounting, &hf_accounting_att, decode_string_attribute },
280 {ACCOUNTING_51_ATTRIBUTE, /* 51 */
281 "Accounting attribute", &ett_opsi_accounting, &hf_accounting_att, decode_string_attribute },
282 {ACCOUNTING_52_ATTRIBUTE, /* 52 */
283 "Accounting attribute", &ett_opsi_accounting, &hf_accounting_att, decode_string_attribute },
284 {ACCOUNTING_53_ATTRIBUTE, /* 53 */
285 "Accounting attribute", &ett_opsi_accounting, &hf_accounting_att, decode_string_attribute },
286 {ACCOUNTING_54_ATTRIBUTE, /* 54 */
287 "Accounting attribute", &ett_opsi_accounting, &hf_accounting_att, decode_string_attribute },
288 {ACCOUNTING_55_ATTRIBUTE, /* 55 */
289 "Accounting attribute", &ett_opsi_accounting, &hf_accounting_att, decode_string_attribute },
290 {ACCOUNTING_56_ATTRIBUTE, /* 56 */
291 "Accounting attribute", &ett_opsi_accounting, &hf_accounting_att, decode_string_attribute },
292 {ACCOUNTING_57_ATTRIBUTE, /* 57 */
293 "Accounting attribute", &ett_opsi_accounting, &hf_accounting_att, decode_string_attribute },
294 {ACCOUNTING_58_ATTRIBUTE, /* 58 */
295 "Accounting attribute", &ett_opsi_accounting, &hf_accounting_att, decode_string_attribute },
296 {ACCOUNTING_59_ATTRIBUTE, /* 59 */
297 "Accounting attribute", &ett_opsi_accounting, &hf_accounting_att, decode_string_attribute },
298 {CHAP_CHALLENGE_ATTRIBUTE, /* 60 */
299 "CHAP challenge", &ett_opsi_chap_challenge, &hf_chap_challenge_att, decode_string_attribute },
300 {NAS_PORT_TYPE_ATTRIBUTE, /* 61 */
301 "NAS port type attribute", &ett_opsi_nas_port_type, &hf_nas_port_type_att, decode_value_string_attribute },
302 {DESIGNATION_NUMBER_ATTRIBUTE, /* 77 */
303 "Designation number attribute", &ett_opsi_designation_number, &hf_designation_num_att, decode_string_attribute },
304 {NAS_PORT_ID_ATTRIBUTE, /* 87 */
305 "NAS port ID attribute", &ett_opsi_nas_port_id, &hf_nas_port_id_att, decode_string_attribute },
306 {SMC_AAAID_ATTRIBUTE, /* 651 */
307 "SMC AAA ID attribute", &ett_opsi_smc_aaa_id, &hf_smc_aaa_id_att, decode_longint_attribute },
308 {SMC_VPNID_ATTRIBUTE, /* 652 */
309 "SMC VPN ID attribute", &ett_opsi_smc_vpn_id, &hf_smc_vpn_id_att, decode_longint_attribute },
310 {SMC_VPNNAME_ATTRIBUTE, /* 653 */
311 "SMC VPN name attribute", &ett_opsi_smc_vpn_name, &hf_smc_vpn_name_att, decode_string_attribute },
312 {SMC_RANID_ATTRIBUTE, /* 654 */
313 "SMC RAN ID attribute", &ett_opsi_smc_ran_id, &hf_smc_ran_id_att, decode_longint_attribute },
314 {SMC_RANIP_ATTRIBUTE, /* 655 */
315 "SMC RAN IP attribute", &ett_opsi_smc_ran_ip, &hf_smc_ran_ip_att, decode_ipv4_attribute },
316 {SMC_RANNAME_ATTRIBUTE, /* 656 */
317 "SMC RAN name attribute", &ett_opsi_smc_ran_name, &hf_smc_ran_name_att, decode_string_attribute },
318 {SMC_POPID_ATTRIBUTE, /* 657 */
319 "SMC POP ID attribute", &ett_opsi_smc_pop_id, &hf_smc_pop_id_att, decode_longint_attribute },
320 {SMC_POPNAME_ATTRIBUTE, /* 658 */
321 "SMC POP name attribute", &ett_opsi_smc_pop_name, &hf_smc_pop_name_att, decode_string_attribute },
322 {SMC_SMCID_ATTRIBUTE, /* 659 */
323 "SMC ID attribute", &ett_opsi_smc_id, &hf_smc_id_att, decode_longint_attribute },
324 {SMC_RECEIVE_TIME_ATTRIBUTE, /* 660 */
325 "SMC receive time attribute", &ett_opsi_smc_receive_time, &hf_smc_receive_time_att, decode_time_attribute },
326 {SMC_STAT_TIME_ATTRIBUTE, /* 661 */
327 "SMC stat time attribute", &ett_opsi_smc_stat_time, &hf_smc_stat_time_att, decode_longint_attribute },
328 {OPSI_FLAGS_ATTRIBUTE, /* 674 */
329 "OPSI flags attribute", &ett_opsi_flags, &hf_opsi_flags_att, decode_longint_attribute },
330 {OPSI_APPLICATION_NAME_ATTRIBUTE,/* 675 */
331 "OPSI application name attribute", &ett_opsi_application_name, &hf_opsi_application_name_att, decode_string_attribute },
334 #define OPSI_ATTRIBUTES_COUNT (sizeof(opsi_attributes)/sizeof(opsi_attribute_handle_t))
336 /* Desegmentation of OPSI (over TCP) */
337 static gboolean opsi_desegment = TRUE;
338 /* To check if we must create or update the information column */
339 static gboolean opsi_first;
341 void decode_string_attribute(tvbuff_t *tvb, proto_tree *tree, int* hfValue, int offset, int length)
345 proto_tree_add_text(tree, tvb, offset, length, "Too short attribute!");
349 pbuffer=tvb_get_string(tvb, offset+4, length-4);
350 proto_tree_add_string(tree, *hfValue, tvb, offset+4, length-4, pbuffer);
355 void decode_ipv4_attribute(tvbuff_t *tvb, proto_tree *tree, int* hfValue, int offset, int length)
359 proto_tree_add_text(tree, tvb, offset, length, "Too short attribute!");
362 tvb_memcpy(tvb, (guint8 *)&ip_address, offset+4, 4);
363 proto_tree_add_ipv4(tree, *hfValue, tvb, offset+4, 4, ip_address);
366 void decode_longint_attribute(tvbuff_t *tvb, proto_tree *tree, int* hfValue, int offset, int length)
369 proto_tree_add_text(tree, tvb, offset, length, "Too short attribute!");
372 proto_tree_add_uint(tree, *hfValue, tvb, offset+4, 4, tvb_get_ntohl(tvb, offset+4));
375 void decode_value_string_attribute(tvbuff_t *tvb, proto_tree *tree, int* hfValue, int offset, int length)
378 proto_tree_add_text(tree, tvb, offset, length, "Too short attribute!");
381 proto_tree_add_item(tree, *hfValue, tvb, offset+4, 4, FALSE);
384 void decode_time_attribute(tvbuff_t *tvb, proto_tree *tree, int* hfValue, int offset, int length)
389 proto_tree_add_text(tree, tvb, offset, length, "Too short attribute!");
392 ns.secs = tvb_get_ntohl(tvb, offset+4);
394 proto_tree_add_time(tree, *hfValue, tvb, offset+4, 4, &ns);
397 /****************************************************************************/
398 /********** End of attribute decoding ***************************************/
399 /****************************************************************************/
401 /* To find the correct size of the PDU. Needed by the desegmentation feature*/
402 static guint get_opsi_pdu_len(tvbuff_t *tvb, int offset)
405 * Get the length of the OPSI packet.
406 * We are guaranteed there're enough chars in tvb in order to
407 * extract the length value. No exception thrown !!
409 return tvb_get_ntohs(tvb, offset + 4);
412 static int get_opsi_attribute_index(int min, int max, int attribute_type)
416 middle = (min+max)/2;
417 at = opsi_attributes[middle].attribute_type;
418 if (at == attribute_type) return middle;
419 if (attribute_type > at) {
420 return (middle == max) ? -1 : get_opsi_attribute_index(middle+1, max, attribute_type);
422 return (middle == min) ? -1 : get_opsi_attribute_index(min, middle-1, attribute_type);
427 dissect_attributes(tvbuff_t *tvb, proto_tree *opsi_tree, int offset, int length)
431 int attribute_length;
433 proto_tree *ntree = NULL;
435 while (length >= 4) {
436 attribute_type = tvb_get_ntohs(tvb, offset);
437 attribute_length = tvb_get_ntohs(tvb, offset+2);
438 if (attribute_length > length) break;
439 /* We perform a standard log(n) lookup */
440 i = get_opsi_attribute_index(0, OPSI_ATTRIBUTES_COUNT-1, attribute_type);
442 proto_tree_add_text(opsi_tree, tvb, offset, attribute_length, "Unknown attribute (%d)", attribute_type);
445 ti = proto_tree_add_text(opsi_tree, tvb, offset, attribute_length, "%s (%d)", opsi_attributes[i].tree_text, attribute_type);
446 ntree = proto_item_add_subtree(ti, *opsi_attributes[i].tree_id);
447 proto_tree_add_text(ntree, tvb, offset+2, 2, "Length (%d)", attribute_length);
448 opsi_attributes[i].dissect(tvb, ntree, opsi_attributes[i].hf_type_attribute, offset, attribute_length);
450 if (attribute_length < 4) {
451 /* Length must be at least 4, for the type and length. */
454 offset += attribute_length;
455 length -= attribute_length;
458 proto_tree_add_text(opsi_tree, tvb, offset, -1, "Short frame");
463 dissect_opsi_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
466 proto_tree *opsi_tree;
468 if (opsi_first == TRUE) {
471 if (check_col(pinfo->cinfo, COL_PROTOCOL))
472 col_set_str(pinfo->cinfo, COL_PROTOCOL, "OPSI");
474 if (check_col(pinfo->cinfo, COL_INFO)) {
475 col_clear(pinfo->cinfo, COL_INFO);
476 if (tvb_length(tvb) < CODE_OFFSET+1) {
477 col_set_str(pinfo->cinfo, COL_INFO, "Open Policy Service Interface");
480 col_add_fstr(pinfo->cinfo, COL_INFO, "Open Policy Service Interface, %s",
481 val_to_str(tvb_get_guint8(tvb, CODE_OFFSET), opsi_opcode,
482 "<Unknown opcode %d>"));
486 else if (check_col(pinfo->cinfo, COL_INFO) && (tvb_length(tvb) > CODE_OFFSET)) {
487 col_append_fstr(pinfo->cinfo, COL_INFO, ", %s",
488 val_to_str(tvb_get_guint8(tvb, CODE_OFFSET), opsi_opcode,
489 "<Unknown opcode %d>"));
493 ti = proto_tree_add_item(tree, proto_opsi, tvb, 0, -1, FALSE);
494 opsi_tree = proto_item_add_subtree(ti, ett_opsi);
495 if (tvb_length(tvb) < 8 ) {
496 proto_tree_add_text(opsi_tree, tvb, 0, -1, "Too short OPSI packet!");
500 proto_tree_add_item(opsi_tree, hf_opsi_major_version, tvb, MAJOR_VERSION_OFFSET, 1, FALSE);
501 proto_tree_add_item(opsi_tree, hf_opsi_minor_version, tvb, MINOR_VERSION_OFFSET, 1, FALSE);
502 proto_tree_add_item(opsi_tree, hf_opsi_opcode, tvb, CODE_OFFSET, 1, FALSE);
503 proto_tree_add_item(opsi_tree, hf_opsi_hook_id, tvb, HOOK_ID_OFFSET, 1, FALSE);
504 proto_tree_add_item(opsi_tree, hf_opsi_length, tvb, PACKET_LENGTH_OFFSET, 2, FALSE);
505 proto_tree_add_item(opsi_tree, hf_opsi_session_id, tvb, SESSION_OFFSET, 2, FALSE);
507 dissect_attributes(tvb, opsi_tree, HEADER_LENGTH, MIN(((int)tvb_length(tvb)-HEADER_LENGTH), (tvb_get_ntohs(tvb, PACKET_LENGTH_OFFSET)-HEADER_LENGTH)));
513 dissect_opsi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
516 /* we need at least 6 bytes to get the payload size ! */
517 tcp_dissect_pdus(tvb, pinfo, tree, opsi_desegment, 6, get_opsi_pdu_len,
523 proto_register_opsi(void)
526 /* Setup list of header fields See Section 1.6.1 for details*/
527 static hf_register_info hf[] = {
528 { &hf_opsi_major_version,
529 { "Major version", "opsi.major",
530 FT_UINT8, BASE_DEC, NULL, 0x0,
533 { &hf_opsi_minor_version,
534 { "Minor version", "opsi.minor",
535 FT_UINT8, BASE_DEC, NULL, 0x0,
539 { "Operation code", "opsi.opcode",
540 FT_UINT8, BASE_DEC, VALS(opsi_opcode), 0x0,
544 { "Hook ID", "opsi.hook",
545 FT_UINT8, BASE_DEC, NULL, 0x0,
549 { "Message length", "opsi.length",
550 FT_UINT16, BASE_DEC, NULL, 0x0,
553 { &hf_opsi_session_id,
554 { "Session ID", "opsi.session_id",
555 FT_UINT16, BASE_DEC, NULL, 0x0,
559 { "User name", "opsi.attr.user_name",
560 FT_STRING, BASE_NONE, NULL, 0x00,
564 { "User password", "opsi.attr.password",
565 FT_STRING, BASE_NONE, NULL, 0x00,
568 { &hf_chap_password_att,
569 { "CHAP password attribute", "opsi.attr.chap_password",
570 FT_STRING, BASE_NONE, NULL, 0x00,
573 { &hf_nas_ip_add_att,
574 { "NAS IP address", "opsi.attr.nas_ip_addr",
575 FT_IPv4, BASE_DEC, NULL, 0x00,
579 { "NAS port", "opsi.attr.nas_port",
580 FT_UINT32, BASE_HEX, NULL, 0x00,
583 { &hf_service_type_att,
584 { "Service type", "opsi.attr.service_type",
585 FT_UINT32, BASE_DEC, VALS(opsi_service_type_code), 0x0,
588 { &hf_framed_protocol_att,
589 { "Framed protocol", "opsi.attr.framed_protocol",
590 FT_UINT32, BASE_DEC, VALS(opsi_framed_protocol_code), 0x0,
593 { &hf_framed_address_att,
594 { "Framed address", "opsi.attr.framed_address",
595 FT_IPv4, BASE_DEC, NULL, 0x00,
598 { &hf_framed_netmask_att,
599 { "Framed netmask", "opsi.attr.framed_netmask",
600 FT_IPv4, BASE_DEC, NULL, 0x00,
603 { &hf_framed_routing_att,
604 { "Framed routing", "opsi.attr.framed_routing",
605 FT_UINT32, BASE_DEC, VALS(opsi_framed_routing_code), 0x0,
608 { &hf_framed_filter_att,
609 { "Framed filter", "opsi.attr.framed_filter",
610 FT_STRING, BASE_NONE, NULL, 0x00,
613 { &hf_framed_mtu_att,
614 { "Framed MTU", "opsi.attr.framed_mtu",
615 FT_UINT32, BASE_DEC, NULL, 0x00,
618 { &hf_framed_compression_att,
619 { "Framed compression", "opsi.attr.framed_compression",
620 FT_UINT32, BASE_DEC, VALS(opsi_framed_compression_code), 0x0,
623 { &hf_called_station_att,
624 { "Called station ID", "opsi.attr.called_station_id",
625 FT_STRING, BASE_NONE, NULL, 0x00,
628 { &hf_calling_station_att,
629 { "Calling station ID", "opsi.attr.calling_station_id",
630 FT_STRING, BASE_NONE, NULL, 0x00,
633 { &hf_nas_identifier_att,
634 { "NAS ID", "opsi.attr.nas_id",
635 FT_STRING, BASE_NONE, NULL, 0x00,
638 { &hf_accounting_att,
639 { "Accounting", "opsi.attr.accounting",
640 FT_STRING, BASE_NONE, NULL, 0x00,
643 { &hf_acct_session_id_att,
644 { "Accounting session ID", "opsi.attr.acct.session_id",
645 FT_STRING, BASE_NONE, NULL, 0x00,
648 { &hf_chap_challenge_att,
649 { "CHAP challenge", "opsi.attr.chap_challenge",
650 FT_STRING, BASE_NONE, NULL, 0x00,
653 { &hf_nas_port_type_att,
654 { "NAS port type", "opsi.attr.nas_port_type",
655 FT_UINT32, BASE_DEC, VALS(opsi_nas_port_type_code), 0x0,
658 { &hf_designation_num_att,
659 { "Designation number", "opsi.attr.designation_number",
660 FT_STRING, BASE_NONE, NULL, 0x00,
663 { &hf_nas_port_id_att,
664 { "NAS port ID", "opsi.attr.nas_port_id",
665 FT_STRING, BASE_NONE, NULL, 0x00,
668 { &hf_smc_aaa_id_att,
669 { "SMC AAA ID", "opsi.attr.smc_aaa_id",
670 FT_UINT32, BASE_DEC, NULL, 0x00,
673 { &hf_smc_vpn_id_att,
674 { "SMC VPN ID", "opsi.attr.smc_vpn_id",
675 FT_UINT32, BASE_DEC, NULL, 0x00,
678 { &hf_smc_vpn_name_att,
679 { "SMC VPN name", "opsi.attr.smc_vpn_name",
680 FT_STRING, BASE_NONE, NULL, 0x00,
683 { &hf_smc_ran_id_att,
684 { "SMC RAN ID", "opsi.attr.smc_ran_id",
685 FT_UINT32, BASE_DEC, NULL, 0x00,
688 { &hf_smc_ran_ip_att,
689 { "SMC RAN IP address", "opsi.attr.smc_ran_ip",
690 FT_IPv4, BASE_DEC, NULL, 0x00,
693 { &hf_smc_ran_name_att,
694 { "SMC RAN name", "opsi.attr.smc_ran_name",
695 FT_STRING, BASE_NONE, NULL, 0x00,
698 { &hf_smc_pop_id_att,
699 { "SMC POP id", "opsi.attr.smc_pop_id",
700 FT_UINT32, BASE_DEC, NULL, 0x00,
703 { &hf_smc_pop_name_att,
704 { "SMC POP name", "opsi.attr.smc_pop_name",
705 FT_STRING, BASE_NONE, NULL, 0x00,
709 { "SMC ID", "opsi.attr.smc_id",
710 FT_UINT32, BASE_DEC, NULL, 0x00,
713 { &hf_smc_receive_time_att,
714 { "SMC receive time", "opsi.attr.smc_receive_time",
715 FT_ABSOLUTE_TIME, BASE_NONE, NULL, 0x00,
718 { &hf_smc_stat_time_att,
719 { "SMC stat time", "opsi.attr.smc_stat_time",
720 FT_UINT32, BASE_DEC, NULL, 0x00,
723 { &hf_opsi_flags_att,
724 { "OPSI flags", "opsi.attr.flags",
725 FT_UINT32, BASE_DEC, NULL, 0x00,
728 { &hf_opsi_application_name_att,
729 { "OPSI application name", "opsi.attr.application_name",
730 FT_STRING, BASE_NONE, NULL, 0x00,
735 /* Setup protocol subtree array */
736 static gint *ett[] = {
739 &ett_opsi_user_password,
740 &ett_opsi_chap_password,
741 &ett_opsi_nas_ip_address,
743 &ett_opsi_service_type,
744 &ett_opsi_framed_protocol,
745 &ett_opsi_framed_address,
746 &ett_opsi_framed_netmask,
747 &ett_opsi_framed_routing,
748 &ett_opsi_framed_filter,
749 &ett_opsi_framed_mtu,
750 &ett_opsi_framed_compression,
751 &ett_opsi_called_station_id,
752 &ett_opsi_calling_station_id,
753 &ett_opsi_nas_identifier,
754 &ett_opsi_accounting,
755 &ett_opsi_acct_session_id,
756 &ett_opsi_chap_challenge,
757 &ett_opsi_nas_port_type,
758 &ett_opsi_designation_number,
759 &ett_opsi_nas_port_id,
760 &ett_opsi_smc_aaa_id,
761 &ett_opsi_smc_vpn_id,
762 &ett_opsi_smc_vpn_name,
763 &ett_opsi_smc_ran_id,
764 &ett_opsi_smc_ran_ip,
765 &ett_opsi_smc_ran_name,
766 &ett_opsi_smc_pop_id,
767 &ett_opsi_smc_pop_name,
769 &ett_opsi_smc_receive_time,
770 &ett_opsi_smc_stat_time,
772 &ett_opsi_application_name,
775 /* For desegmentation / reassembly */
776 module_t *opsi_module;
778 /* Register the protocol name and description */
779 proto_opsi = proto_register_protocol("Open Policy Service Interface",
782 /* Required function calls to register the header fields and subtrees used */
783 proto_register_field_array(proto_opsi, hf, array_length(hf));
784 proto_register_subtree_array(ett, array_length(ett));
786 /* We activate the desegmentation / reassembly feature */
787 opsi_module = prefs_register_protocol(proto_opsi, NULL);
788 prefs_register_bool_preference(opsi_module, "desegment_opsi_messages",
789 "Desegment all OPSI messages spanning multiple TCP segments",
790 "Whether the OPSI dissector should desegment all messages spanning multiple TCP segments",
796 proto_reg_handoff_opsi(void)
798 dissector_handle_t opsi_handle;
799 opsi_handle = create_dissector_handle(dissect_opsi, proto_opsi);
800 dissector_add("tcp.port", TCP_PORT_OPSI, opsi_handle);
803 #ifndef ENABLE_STATIC
805 plugin_register(void)
807 /* register the new protocol, protocol fields, and subtrees */
808 if (proto_opsi == -1) { /* execute protocol initialization only once */
809 proto_register_opsi();
815 #ifndef ENABLE_STATIC
817 plugin_reg_handoff(void)
819 proto_reg_handoff_opsi();