epan/dissectors/pidl/samr/samr.cnf cnf_dissect_lsa_BinaryString => lsarpc_dissect_str...
[wireshark-sm.git] / epan / dissectors / packet-shicp.c
blob88f6ab076a919ff48ff53003fbcf7487bf3bf6da
1 /* packet-shicp.c
2 * Routines for Secure Host IP Configuration Protocol dissection
3 * Copyright 2021, Filip Kågesson <exfik@hms.se>
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * SPDX-License-Identifier: GPL-2.0-or-later
12 #include <config.h>
14 #include <epan/packet.h>
15 #include <epan/expert.h>
16 #include <epan/addr_resolv.h>
17 #include <epan/tfs.h>
18 #include <wsutil/array.h>
19 #include "packet-udp.h"
21 void proto_reg_handoff_shicp(void);
22 void proto_register_shicp(void);
24 /* Protocols and header fields */
25 static int proto_shicp;
26 static int hf_shicp_header;
27 static int hf_shicp_protocol_version;
28 static int hf_shicp_dst;
29 static int hf_shicp_src;
30 static int hf_shicp_flags;
31 static int hf_shicp_msgclass_flag;
32 static int hf_shicp_error_flag;
33 static int hf_shicp_reserved_flag;
34 static int hf_shicp_msgtype;
35 static int hf_shicp_error;
36 static int hf_shicp_error_string;
37 static int hf_shicp_auth_req;
38 static int hf_shicp_module_version;
39 static int hf_shicp_module_desc;
40 static int hf_shicp_supported_msg;
41 static int hf_shicp_ip;
42 static int hf_shicp_sn;
43 static int hf_shicp_gw;
44 static int hf_shicp_dns1;
45 static int hf_shicp_dns2;
46 static int hf_shicp_dhcp;
47 static int hf_shicp_hn;
48 static int hf_shicp_hn_max_len;
49 static int hf_shicp_pswd_max_len;
50 static int hf_shicp_challenge;
51 static int hf_shicp_validity_period;
52 static int hf_shicp_token;
53 static int hf_shicp_pswd;
54 static int hf_shicp_wink_type;
55 static int hf_shicp_restart_mode;
57 static int ett_shicp;
58 static int ett_shicp_flags;
60 static expert_field ei_shicp_error;
61 static expert_field ei_shicp_malformed;
63 #define SHICP_UDP_PORT 3250
65 #define SHICP_MIN_LENGTH 2
66 #define SHICP_MAX_LENGTH 548
67 #define SHICP_HEADER_SIZE 2
68 #define SHICP_ADDRESS_SIZE 6
69 #define SHICP_FLAGS_SIZE 1
70 #define SHICP_MSG_TYPE_SIZE 1
71 #define SHICP_ERROR_SIZE 1
72 #define SHICP_CHALLENGE_SIZE 4
73 #define SHICP_VALIDITY_PERIOD_SIZE 1
74 #define SHICP_TOKEN_SIZE 36
75 #define SHICP_WINK_TYPE_SIZE 1
76 #define SHICP_RESTART_MODE_SIZE 1
77 #define SHICP_FIXED_LEN 18
78 #define SHICP_MSG_CLASS_FLAG 0x01
79 #define SHICP_ERROR_FLAG 0x02
80 #define SHICP_RESERVED_FLAG 0xFC
82 /* Values of the supported message types. */
83 #define SHICP_DISCOVER_MSG_TYPE 0x00
84 #define SHICP_AUTH_CHALLENGE_MSG_TYPE 0x01
85 #define SHICP_CONFIG_MSG_TYPE 0x02
86 #define SHICP_WINK_MSG_TYPE 0x03
87 #define SHICP_RESTART_MSG_TYPE 0x04
88 #define SHICP_MASS_RESTART_MSG_TYPE 0x05
90 /* Keys of the parameters associated with discover messages. */
91 #define SHICP_DISCOVER_AUTH_REQ_KEY 0x00
92 #define SHICP_DISCOVER_MODULE_VERSION_KEY 0x01
93 #define SHICP_DISCOVER_MODULE_DESC_KEY 0x02
94 #define SHICP_DISCOVER_SUPPORTED_MSG_KEY 0x03
95 #define SHICP_DISCOVER_IP_KEY 0x04
96 #define SHICP_DISCOVER_SN_KEY 0x05
97 #define SHICP_DISCOVER_GW_KEY 0x06
98 #define SHICP_DISCOVER_DNS1_KEY 0x07
99 #define SHICP_DISCOVER_DNS2_KEY 0x08
100 #define SHICP_DISCOVER_DHCP_KEY 0x09
101 #define SHICP_DISCOVER_HN_KEY 0x0A
102 #define SHICP_DISCOVER_HN_MAX_LEN_KEY 0x0B
103 #define SHICP_DISCOVER_PSWD_MAX_LEN_KEY 0x0C
105 /* Keys of the parameters associated with configuration messages. */
106 #define SHICP_CONFIG_IP_KEY 0x00
107 #define SHICP_CONFIG_SN_KEY 0x01
108 #define SHICP_CONFIG_GW_KEY 0x02
109 #define SHICP_CONFIG_DNS1_KEY 0x03
110 #define SHICP_CONFIG_DNS2_KEY 0x04
111 #define SHICP_CONFIG_DHCP_KEY 0x05
112 #define SHICP_CONFIG_HN_KEY 0x06
113 #define SHICP_CONFIG_PSWD_KEY 0x07
115 /* The types of messages supported. */
116 static const value_string message_types[] = {
117 {SHICP_DISCOVER_MSG_TYPE, "Discover"},
118 {SHICP_AUTH_CHALLENGE_MSG_TYPE, "Authentication challenge"},
119 {SHICP_CONFIG_MSG_TYPE, "Configuration"},
120 {SHICP_WINK_MSG_TYPE, "Wink"},
121 {SHICP_RESTART_MSG_TYPE, "Restart"},
122 {SHICP_MASS_RESTART_MSG_TYPE, "Mass-restart"},
123 {0, NULL}
125 /* The error codes that are supported. */
126 static const value_string error_types[] = {
127 {0x00, "Request was rejected"},
128 {0x01, "Authentication failed"},
129 {0x02, "Authentication required"},
130 {0x03, "Unsupported message type"},
131 {0x1F, "Hostname too long"},
132 {0x20, "Password too long"},
133 {0x21, "Bad config"},
134 {0, NULL}
136 /* The types of restart mode that are supported. */
137 static const value_string restart_mode_types[] = {
138 {0x00, "Immediate restart"},
139 {0x01, "Delayed restart"},
140 {0, NULL}
143 static bool
144 test_shicp(packet_info* pinfo, tvbuff_t* tvb, int offset, void* data _U_)
146 /* Check that the port matches the port used by SHICP. */
147 if (pinfo->destport != SHICP_UDP_PORT) {
148 return false;
151 /* Check that the length of the message is within allowed boundaries. */
152 if (tvb_reported_length(tvb) < SHICP_MIN_LENGTH || tvb_reported_length(tvb) > SHICP_MAX_LENGTH) {
153 return false;
156 /* Check that the header tag starts with 0xABC0. */
157 if ((tvb_get_uint16(tvb, offset, ENC_LITTLE_ENDIAN) & 0xFFF8) != 0xABC0) {
158 return false;
161 return true;
164 static int
165 dissect_shicp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
166 void *data _U_)
168 proto_item* ti;
169 proto_item* flags_pi;
170 proto_item* error_pi;
171 proto_tree* shicp_tree;
172 unsigned offset = 0;
173 unsigned payload_end;
174 unsigned keyvalue_key = 0;
175 unsigned keyvalue_length = 0;
176 unsigned keyvalue_offset = 0;
177 unsigned keyvalue_end = 0;
178 uint8_t supported_message_value = 0;
179 uint16_t payload_length = 0;
180 uint32_t version = 0;
181 uint32_t msgtype_value = 0;
182 uint32_t error_value = 0;
183 uint64_t flags_value = 0;
185 wmem_strbuf_t* supported_messages = wmem_strbuf_new(pinfo->pool, "");
186 wmem_strbuf_t* module_addr_strbuf = wmem_strbuf_new(pinfo->pool, "");
188 static int* flags[] = {
189 &hf_shicp_reserved_flag,
190 &hf_shicp_error_flag,
191 &hf_shicp_msgclass_flag,
192 NULL
195 col_set_str(pinfo->cinfo, COL_PROTOCOL, "SHICP");
196 col_clear(pinfo->cinfo, COL_INFO);
198 ti = proto_tree_add_item(tree, proto_shicp, tvb, offset, -1, ENC_NA);
200 shicp_tree = proto_item_add_subtree(ti, ett_shicp);
201 proto_item_append_text(ti,
202 ", Src:%s, Dst:%s",
203 address_with_resolution_to_str(pinfo->pool, &pinfo->dl_src),
204 address_with_resolution_to_str(pinfo->pool, &pinfo->dl_dst));
205 proto_tree_add_item_ret_uint(shicp_tree, hf_shicp_header, tvb, offset, SHICP_HEADER_SIZE, ENC_LITTLE_ENDIAN, &version);
206 proto_tree_add_uint(shicp_tree, hf_shicp_protocol_version, tvb, offset, SHICP_HEADER_SIZE, version & 0x07);
207 offset += SHICP_HEADER_SIZE;
208 proto_tree_add_item(shicp_tree, hf_shicp_dst, tvb, offset, SHICP_ADDRESS_SIZE, ENC_NA);
209 char* dst = tvb_address_to_str(pinfo->pool, tvb, AT_ETHER, offset);
210 offset += SHICP_ADDRESS_SIZE;
211 proto_tree_add_item(shicp_tree, hf_shicp_src, tvb, offset, SHICP_ADDRESS_SIZE, ENC_NA);
212 char* src = tvb_address_to_str(pinfo->pool, tvb, AT_ETHER, offset);
213 offset += SHICP_ADDRESS_SIZE;
214 flags_pi = proto_tree_add_bitmask_ret_uint64(shicp_tree, tvb, offset, hf_shicp_flags, ett_shicp_flags, flags, ENC_LITTLE_ENDIAN, &flags_value);
215 offset += SHICP_FLAGS_SIZE;
216 proto_tree_add_item_ret_uint(shicp_tree, hf_shicp_msgtype, tvb, offset, SHICP_MSG_TYPE_SIZE, ENC_LITTLE_ENDIAN, &msgtype_value);
217 offset += SHICP_MSG_TYPE_SIZE;
218 payload_length = tvb_get_uint16(tvb, offset, ENC_LITTLE_ENDIAN);
219 offset += 1;
220 if (flags_value & SHICP_ERROR_FLAG) {
221 proto_item_set_text(flags_pi,
222 "Message flags: 0x%02x (%s, %s)",
223 (unsigned)flags_value,
224 tfs_get_string(flags_value & SHICP_MSG_CLASS_FLAG, &tfs_response_request), "Error");
225 if (payload_length != 1) {
226 error_pi = proto_tree_add_string(shicp_tree, hf_shicp_error_string, tvb, offset, 0, "Malformed message");
227 expert_add_info(pinfo, error_pi, &ei_shicp_malformed);
228 col_append_str(pinfo->cinfo, COL_INFO, "Error: Malformed message");
230 else {
231 error_pi = proto_tree_add_item_ret_uint(shicp_tree, hf_shicp_error, tvb, offset, SHICP_ERROR_SIZE, ENC_LITTLE_ENDIAN, &error_value);
232 expert_add_info(pinfo, error_pi, &ei_shicp_error);
233 col_append_fstr(pinfo->cinfo, COL_INFO, "Error: %s", val_to_str(error_value, error_types, "%d"));
236 else {
237 proto_item_set_text(flags_pi,
238 "Message flags: 0x%02x (%s)",
239 (unsigned)flags_value,
240 tfs_get_string(flags_value & SHICP_MSG_CLASS_FLAG, &tfs_response_request));
241 col_append_fstr(pinfo->cinfo,
242 COL_INFO,
243 "%s, Type: %s",
244 tfs_get_string(flags_value & SHICP_MSG_CLASS_FLAG, &tfs_response_request),
245 val_to_str(msgtype_value, message_types, "%d"));
246 payload_end = offset + payload_length;
247 switch (msgtype_value)
249 case SHICP_DISCOVER_MSG_TYPE:
250 while (offset < payload_end) {
251 keyvalue_key = tvb_get_uint8(tvb, offset);
252 offset += 1;
253 keyvalue_length = tvb_get_uint8(tvb, offset);
254 offset += 1;
255 switch (keyvalue_key)
257 case SHICP_DISCOVER_AUTH_REQ_KEY:
258 proto_tree_add_item(shicp_tree, hf_shicp_auth_req, tvb, offset, keyvalue_length, ENC_LITTLE_ENDIAN);
259 break;
260 case SHICP_DISCOVER_MODULE_VERSION_KEY:
261 proto_tree_add_item(shicp_tree, hf_shicp_module_version, tvb, offset, keyvalue_length, ENC_ASCII | ENC_NA);
262 break;
263 case SHICP_DISCOVER_MODULE_DESC_KEY:
264 proto_tree_add_item(shicp_tree, hf_shicp_module_desc, tvb, offset, keyvalue_length, ENC_ASCII | ENC_NA);
265 break;
266 case SHICP_DISCOVER_SUPPORTED_MSG_KEY:
267 keyvalue_end = offset + keyvalue_length;
268 keyvalue_offset = offset;
269 supported_message_value = tvb_get_uint8(tvb, keyvalue_offset);
270 wmem_strbuf_append(supported_messages, val_to_str(supported_message_value, message_types, "%d"));
271 keyvalue_offset += 1;
272 while (keyvalue_offset < keyvalue_end) {
273 supported_message_value = tvb_get_uint8(tvb, keyvalue_offset);
274 wmem_strbuf_append_printf(supported_messages, ", %s", val_to_str(supported_message_value, message_types, "%d"));
275 keyvalue_offset += 1;
277 proto_tree_add_string(shicp_tree, hf_shicp_supported_msg, tvb, offset, keyvalue_length, wmem_strbuf_get_str(supported_messages));
278 break;
279 case SHICP_DISCOVER_IP_KEY:
280 proto_tree_add_item(shicp_tree, hf_shicp_ip, tvb, offset, keyvalue_length, ENC_LITTLE_ENDIAN);
281 break;
282 case SHICP_DISCOVER_SN_KEY:
283 proto_tree_add_item(shicp_tree, hf_shicp_sn, tvb, offset, keyvalue_length, ENC_LITTLE_ENDIAN);
284 break;
285 case SHICP_DISCOVER_GW_KEY:
286 proto_tree_add_item(shicp_tree, hf_shicp_gw, tvb, offset, keyvalue_length, ENC_LITTLE_ENDIAN);
287 break;
288 case SHICP_DISCOVER_DNS1_KEY:
289 proto_tree_add_item(shicp_tree, hf_shicp_dns1, tvb, offset, keyvalue_length, ENC_LITTLE_ENDIAN);
290 break;
291 case SHICP_DISCOVER_DNS2_KEY:
292 proto_tree_add_item(shicp_tree, hf_shicp_dns2, tvb, offset, keyvalue_length, ENC_LITTLE_ENDIAN);
293 break;
294 case SHICP_DISCOVER_DHCP_KEY:
295 proto_tree_add_item(shicp_tree, hf_shicp_dhcp, tvb, offset, keyvalue_length, ENC_LITTLE_ENDIAN);
296 break;
297 case SHICP_DISCOVER_HN_KEY:
298 proto_tree_add_item(shicp_tree, hf_shicp_hn, tvb, offset, keyvalue_length, ENC_ASCII | ENC_NA);
299 break;
300 case SHICP_DISCOVER_HN_MAX_LEN_KEY:
301 proto_tree_add_item(shicp_tree, hf_shicp_hn_max_len, tvb, offset, keyvalue_length, ENC_LITTLE_ENDIAN);
302 break;
303 case SHICP_DISCOVER_PSWD_MAX_LEN_KEY:
304 proto_tree_add_item(shicp_tree, hf_shicp_pswd_max_len, tvb, offset, keyvalue_length, ENC_LITTLE_ENDIAN);
305 break;
306 default:
307 break;
309 offset += keyvalue_length;
311 break;
312 case SHICP_AUTH_CHALLENGE_MSG_TYPE:
313 if (payload_length >= 5) {
314 proto_tree_add_item(shicp_tree, hf_shicp_challenge, tvb, offset, SHICP_CHALLENGE_SIZE, ENC_LITTLE_ENDIAN);
315 offset += SHICP_CHALLENGE_SIZE;
316 proto_tree_add_item(shicp_tree, hf_shicp_validity_period, tvb, offset, SHICP_VALIDITY_PERIOD_SIZE, ENC_LITTLE_ENDIAN);
318 break;
319 case SHICP_CONFIG_MSG_TYPE:
320 if (payload_length >= SHICP_TOKEN_SIZE) {
321 proto_tree_add_item(shicp_tree, hf_shicp_token, tvb, offset, SHICP_TOKEN_SIZE, ENC_NA);
322 offset += SHICP_TOKEN_SIZE;
324 else if (payload_length == SHICP_ERROR_SIZE) {
325 proto_tree_add_item(shicp_tree, hf_shicp_error, tvb, offset, SHICP_ERROR_SIZE, ENC_ASCII | ENC_NA);
326 break;
328 while (offset < payload_end) {
329 keyvalue_key = tvb_get_uint8(tvb, offset);
330 offset += 1;
331 keyvalue_length = tvb_get_uint8(tvb, offset);
332 offset += 1;
333 switch (keyvalue_key)
335 case SHICP_CONFIG_IP_KEY:
336 proto_tree_add_item(shicp_tree, hf_shicp_ip, tvb, offset, keyvalue_length, ENC_LITTLE_ENDIAN);
337 break;
338 case SHICP_CONFIG_SN_KEY:
339 proto_tree_add_item(shicp_tree, hf_shicp_sn, tvb, offset, keyvalue_length, ENC_LITTLE_ENDIAN);
340 break;
341 case SHICP_CONFIG_GW_KEY:
342 proto_tree_add_item(shicp_tree, hf_shicp_gw, tvb, offset, keyvalue_length, ENC_LITTLE_ENDIAN);
343 break;
344 case SHICP_CONFIG_DNS1_KEY:
345 proto_tree_add_item(shicp_tree, hf_shicp_dns1, tvb, offset, keyvalue_length, ENC_LITTLE_ENDIAN);
346 break;
347 case SHICP_CONFIG_DNS2_KEY:
348 proto_tree_add_item(shicp_tree, hf_shicp_dns2, tvb, offset, keyvalue_length, ENC_LITTLE_ENDIAN);
349 break;
350 case SHICP_CONFIG_DHCP_KEY:
351 proto_tree_add_item(shicp_tree, hf_shicp_dhcp, tvb, offset, keyvalue_length, ENC_LITTLE_ENDIAN);
352 break;
353 case SHICP_CONFIG_HN_KEY:
354 proto_tree_add_item(shicp_tree, hf_shicp_hn, tvb, offset, keyvalue_length, ENC_ASCII | ENC_NA);
355 break;
356 case SHICP_CONFIG_PSWD_KEY:
357 proto_tree_add_item(shicp_tree, hf_shicp_pswd, tvb, offset, keyvalue_length, ENC_ASCII | ENC_NA);
358 break;
359 default:
360 break;
362 offset += keyvalue_length;
364 break;
365 case SHICP_WINK_MSG_TYPE:
366 if (payload_length >= SHICP_TOKEN_SIZE + SHICP_WINK_TYPE_SIZE) {
367 proto_tree_add_item(shicp_tree, hf_shicp_token, tvb, offset, SHICP_TOKEN_SIZE, ENC_NA);
368 offset += SHICP_TOKEN_SIZE;
369 proto_tree_add_item(shicp_tree, hf_shicp_wink_type, tvb, offset, SHICP_WINK_TYPE_SIZE, ENC_LITTLE_ENDIAN);
371 break;
372 case SHICP_RESTART_MSG_TYPE:
373 if (payload_length >= SHICP_TOKEN_SIZE + SHICP_RESTART_MODE_SIZE) {
374 proto_tree_add_item(shicp_tree, hf_shicp_token, tvb, offset, SHICP_TOKEN_SIZE, ENC_NA);
375 offset += SHICP_TOKEN_SIZE;
376 proto_tree_add_item(shicp_tree, hf_shicp_restart_mode, tvb, offset, SHICP_RESTART_MODE_SIZE, ENC_LITTLE_ENDIAN);
378 break;
379 default:
380 break;
384 wmem_strbuf_append(module_addr_strbuf, (flags_value & SHICP_MSG_CLASS_FLAG) ? src : dst);
385 if (strcmp(wmem_strbuf_get_str(module_addr_strbuf), "ff:ff:ff:ff:ff:ff") != 0) {
386 col_append_fstr(pinfo->cinfo, COL_INFO, ", Module MAC address: %s", wmem_strbuf_get_str(module_addr_strbuf));
389 return tvb_captured_length(tvb);
392 static unsigned
393 get_shicp_len(packet_info* pinfo _U_, tvbuff_t* tvb, int offset _U_, void* data _U_)
395 return (unsigned)tvb_reported_length(tvb);
398 static bool
399 dissect_shicp_heur_udp(tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree, void* data)
401 return (udp_dissect_pdus(tvb, pinfo, tree, SHICP_FIXED_LEN, test_shicp,
402 get_shicp_len, dissect_shicp, data) != 0);
405 void
406 proto_register_shicp(void)
408 expert_module_t* expert_shicp;
410 static hf_register_info hf[] = {
411 { &hf_shicp_header,
412 { "Header", "shicp.header",
413 FT_UINT16, BASE_HEX,
414 NULL, 0x0,
415 NULL, HFILL }
417 { &hf_shicp_protocol_version,
418 { "Protocol version", "shicp.protocolversion",
419 FT_UINT8, BASE_DEC,
420 NULL, 0x0,
421 NULL, HFILL }
423 { &hf_shicp_dst,
424 { "Destination", "shicp.dst",
425 FT_ETHER, BASE_NONE,
426 NULL, 0x0,
427 NULL, HFILL }
429 { &hf_shicp_src,
430 { "Source", "shicp.src",
431 FT_ETHER, BASE_NONE,
432 NULL, 0x0,
433 NULL, HFILL }
435 { &hf_shicp_flags,
436 { "Message flags", "shicp.flags",
437 FT_UINT8, BASE_HEX,
438 NULL, 0x0,
439 NULL, HFILL }
441 { &hf_shicp_reserved_flag,
442 { "Reserved", "shicp.flags.reserved",
443 FT_BOOLEAN, 8,
444 TFS(&tfs_set_notset), 0xFC,
445 NULL, HFILL }
447 { &hf_shicp_error_flag,
448 { "Error", "shicp.flags.error",
449 FT_BOOLEAN, 8,
450 TFS(&tfs_set_notset), 0x02,
451 NULL, HFILL }
453 { &hf_shicp_msgclass_flag,
454 { "Class", "shicp.flags.msgclass",
455 FT_BOOLEAN, 8,
456 TFS(&tfs_response_request), 0x01,
457 NULL, HFILL }
459 { &hf_shicp_msgtype,
460 { "Message type", "shicp.msgtype",
461 FT_UINT8, BASE_HEX,
462 VALS(message_types), 0x0,
463 NULL, HFILL }
465 { &hf_shicp_error,
466 { "Error", "shicp.error",
467 FT_UINT8, BASE_HEX,
468 NULL, 0x0,
469 NULL, HFILL }
471 { &hf_shicp_error_string,
472 { "Error", "shicp.error.string",
473 FT_STRINGZ, BASE_NONE,
474 NULL, 0x0,
475 NULL, HFILL }
477 { &hf_shicp_auth_req,
478 { "Authentication required", "shicp.authreq",
479 FT_BOOLEAN, BASE_NONE,
480 NULL, 0x0,
481 NULL, HFILL }
483 { &hf_shicp_module_version,
484 { "Module version", "shicp.moduleversion",
485 FT_STRINGZ, BASE_NONE,
486 NULL, 0x0,
487 NULL, HFILL }
489 { &hf_shicp_module_desc,
490 { "Module description", "shicp.moduledesc",
491 FT_STRINGZ, BASE_NONE,
492 NULL, 0x0,
493 NULL, HFILL }
495 { &hf_shicp_supported_msg,
496 { "Supported messages", "shicp.supportedmsg",
497 FT_STRINGZ, BASE_NONE,
498 NULL, 0x0,
499 NULL, HFILL }
501 { &hf_shicp_ip,
502 { "IP address", "shicp.ip",
503 FT_IPv4, BASE_NONE,
504 NULL, 0x0,
505 NULL, HFILL }
507 { &hf_shicp_sn,
508 { "Subnet mask", "shicp.sn",
509 FT_IPv4, BASE_NONE,
510 NULL, 0x0,
511 NULL, HFILL }
513 { &hf_shicp_gw,
514 { "Gateway address", "shicp.gw",
515 FT_IPv4, BASE_NONE,
516 NULL, 0x0,
517 NULL, HFILL }
519 { &hf_shicp_dns1,
520 { "Primary DNS address", "shicp.dns1",
521 FT_IPv4, BASE_NONE,
522 NULL, 0x0,
523 NULL, HFILL }
525 { &hf_shicp_dns2,
526 { "Secondary DNS address", "shicp.dns2",
527 FT_IPv4, BASE_NONE,
528 NULL, 0x0,
529 NULL, HFILL }
531 { &hf_shicp_dhcp,
532 { "DHCP", "shicp.dhcp",
533 FT_BOOLEAN, BASE_NONE,
534 TFS(&tfs_enabled_disabled), 0x0,
535 NULL, HFILL }
537 { &hf_shicp_hn,
538 { "Hostname", "shicp.hn",
539 FT_STRINGZ, BASE_NONE,
540 NULL, 0x0,
541 NULL, HFILL }
543 { &hf_shicp_hn_max_len,
544 { "Hostname max length", "shicp.hnmaxlen",
545 FT_UINT8, BASE_DEC,
546 NULL, 0x0,
547 NULL, HFILL }
549 { &hf_shicp_pswd_max_len,
550 { "Password max length", "shicp.pswdmaxlen",
551 FT_UINT8, BASE_DEC,
552 NULL, 0x0,
553 NULL, HFILL }
555 { &hf_shicp_challenge,
556 { "Challenge", "shicp.challenge",
557 FT_UINT32, BASE_HEX,
558 NULL, 0x0,
559 NULL, HFILL }
561 { &hf_shicp_validity_period,
562 { "Validity period (seconds)", "shicp.validityperiod",
563 FT_UINT8, BASE_DEC,
564 NULL, 0x0,
565 NULL, HFILL }
567 { &hf_shicp_token,
568 { "Authentication token", "shicp.token",
569 FT_BYTES, BASE_NONE,
570 NULL, 0x0,
571 NULL, HFILL }
573 { &hf_shicp_pswd,
574 { "Password", "shicp.pswd",
575 FT_STRINGZ, BASE_NONE,
576 NULL, 0x0,
577 NULL, HFILL }
579 { &hf_shicp_wink_type,
580 { "Wink type", "shicp.winktype",
581 FT_UINT8, BASE_HEX,
582 NULL, 0x0,
583 NULL, HFILL }
585 { &hf_shicp_restart_mode,
586 { "Restart mode", "shicp.restartmode",
587 FT_UINT8, BASE_HEX,
588 VALS(restart_mode_types), 0x0,
589 NULL, HFILL }
593 static int *ett[] = {
594 &ett_shicp,
595 &ett_shicp_flags
598 /* Setup protocol expert items */
599 static ei_register_info ei[] = {
600 { &ei_shicp_error,
601 { "shicp.expert.error", PI_RESPONSE_CODE, PI_NOTE,
602 "Message contains an error code", EXPFILL }
604 { &ei_shicp_malformed,
605 { "shicp.malformed", PI_MALFORMED, PI_WARN,
606 "Malformed message", EXPFILL }
610 proto_shicp = proto_register_protocol("Secure Host IP Configuration Protocol", "SHICP", "shicp");
612 proto_register_field_array(proto_shicp, hf, array_length(hf));
613 proto_register_subtree_array(ett, array_length(ett));
615 expert_shicp = expert_register_protocol(proto_shicp);
616 expert_register_field_array(expert_shicp, ei, array_length(ei));
619 void
620 proto_reg_handoff_shicp(void)
622 heur_dissector_add("udp", dissect_shicp_heur_udp, "SHICP over UDP", "shicp_udp", proto_shicp, HEURISTIC_ENABLE);
626 * Editor modelines - https://www.wireshark.org/tools/modelines.html
628 * Local variables:
629 * c-basic-offset: 4
630 * tab-width: 8
631 * indent-tabs-mode: nil
632 * End:
634 * vi: set shiftwidth=4 tabstop=8 expandtab:
635 * :indentSize=4:tabSize=8:noTabs=true: