Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-lon.c
blob4650a9b29075b482ebd265f51e2f0c55d0a49b02
1 /* packet-lon.c
2 * Traffic analyzer for Lontalk/EIA-709.1 networks
3 * Daniel Willmann <daniel@totalueberwachung.de>
4 * (c) 2011 Daniel Willmann
6 * Used some code by habibi_khalid <khalidhabibi@gmx.de> and
7 * Honorine_KEMGNE_NGUIFFO <honorinekemgne@yahoo.fr> from
8 * https://gitlab.com/wireshark/wireshark/-/issues/4704
10 * Wireshark - Network traffic analyzer
11 * By Gerald Combs <gerald@wireshark.org>
12 * Copyright 1998 Gerald Combs
14 * SPDX-License-Identifier: GPL-2.0-or-later
17 #include "config.h"
19 #include <epan/packet.h>
20 #include <epan/expert.h>
22 void proto_register_lon(void);
23 void proto_reg_handoff_lon(void);
25 static dissector_handle_t lon_handle;
27 static const value_string pdu_fmt_vs[]=
29 {0x00, "TPDU"},
30 {0x01, "SPDU"},
31 {0x02, "AuthPDU"},
32 {0x03, "APDU"},
33 {0, NULL}
36 static const value_string addr_fmt_vs[]=
38 {0x00, "Broadcast (0)"},
39 {0x01, "Multicast (1)"},
40 {0x02, "Unicast (2a)/Multicast (2b)"},
41 {0x03, "Unicast (3)"},
42 {0, NULL}
45 static const value_string domain_length_vs[]=
47 {0x00, "0 bit"},
48 {0x01, "8 bit"},
49 {0x02, "24 bit"},
50 {0x03, "48 bit"},
51 {0, NULL}
54 static const value_string tpdu_type_vs[]=
56 {0x00, "ACKD"},
57 {0x01, "UnACKD_RPT"},
58 {0x02, "ACK"},
59 {0x04, "REMINDER"},
60 {0x05, "REM/MSG"},
61 {0, NULL}
64 static const value_string spdu_type_vs[]=
66 {0x00, "REQUEST"},
67 {0x02, "RESPONSE"},
68 {0x04, "REMINDER"},
69 {0x05, "REM/MSG"},
70 {0, NULL}
73 static const value_string authpdu_type_vs[]=
75 {0x00, "CHALLENGE"},
76 {0x02, "REPLY"},
77 {0, NULL}
80 static const value_string nm_code_vs[]=
82 {0x61, "NM_QUERY_ID"},
83 {0x62, "NM_RESPOND_TO_QUERY"},
84 {0x63, "NM_UPDATE_DOMAIN"},
85 {0x64, "NM_LEAVE_DOMAIN"},
86 {0x65, "NM_UPDATE_KEY"},
87 {0x66, "NM_UPDATE_ADDR"},
88 {0x67, "NM_QUERY_ADDR"},
89 {0x68, "NM_QUERY_NV_CNFG"},
90 {0x69, "NM_UPDATE_GROUP_ADDR"},
91 {0x6A, "NM_QUERY_DOMAIN"},
92 {0x6B, "NM_UPDATE_NV_CNFG"},
93 {0x6C, "NM_SET_NODE_MODE"},
94 {0x6D, "NM_READ_MEMORY"},
95 {0x6E, "NM_WRITE_MEMORY"},
96 {0x6F, "NM_CHECKSUM_RECALC"},
97 {0x70, "NM_WINK"},
98 {0x71, "NM_MEMORY_REFRESH"},
99 {0x72, "NM_QUERY_SNVT"},
100 {0x73, "NM_NV_FETCH"},
101 {0x7F, "NM_MANUAL_SERVICE_REQUEST"},
102 { 0, NULL}
105 static const value_string nd_code_vs[]=
107 {0x51, "ND_QUERY_STATUS"},
108 {0x52, "ND_PROXY_COMMAND"},
109 {0x53, "ND_CLEAR_STATUS"},
110 {0x54, "ND_QUERY_XCVR"},
111 {0, NULL}
114 static int hf_lon_ppdu;
115 static int hf_lon_ppdu_prio;
116 static int hf_lon_ppdu_alt;
117 static int hf_lon_ppdu_deltabl;
118 static int hf_lon_npdu;
119 static int hf_lon_npdu_version;
120 static int hf_lon_npdu_pdu_fmt;
121 static int hf_lon_npdu_addr_fmt;
122 static int hf_lon_npdu_dom_len;
123 static int hf_lon_addr_srcsub;
124 static int hf_lon_addr_srcnode;
125 static int hf_lon_addr_dstsub;
126 static int hf_lon_addr_dstgrp;
127 static int hf_lon_addr_dstnode;
128 static int hf_lon_addr_grp;
129 static int hf_lon_addr_grpmem;
130 static int hf_lon_addr_uid;
131 static int hf_lon_name;
132 static int hf_lon_domain;
133 static int hf_lon_tpdu;
134 static int hf_lon_auth;
135 static int hf_lon_tpdu_tpdu_type;
136 static int hf_lon_trans_no;
137 static int hf_lon_spdu;
138 static int hf_lon_spdu_spdu_type;
139 static int hf_lon_mlen;
140 static int hf_lon_mlist;
141 static int hf_lon_authpdu;
142 static int hf_lon_authpdu_fmt;
143 static int hf_lon_authpdu_authpdu_type;
144 static int hf_lon_nv_dir;
145 static int hf_lon_nv_selector;
146 static int hf_lon_app_code;
147 static int hf_lon_nm_code;
148 static int hf_lon_nd_code;
149 static int hf_lon_ff_code;
150 static int hf_lon_nv;
151 static int hf_lon_app;
152 static int hf_lon_nm;
153 static int hf_lon_nd;
154 static int hf_lon_ff;
155 /* static int hf_lon_checksum; */
156 static int proto_lon;
159 static int ett_lon;
160 static int ett_ppdu;
161 static int ett_npdu;
162 static int ett_tpdu;
163 static int ett_spdu;
164 static int ett_authpdu;
165 static int ett_apdu;
166 static int ett_nv;
167 static int ett_app;
168 static int ett_nm;
169 static int ett_nd;
170 static int ett_ff;
172 static int ett_address;
174 static expert_field ei_lon_tpdu_tpdu_type_unknown;
175 static expert_field ei_lon_tpdu_spdu_type_unknown;
176 static expert_field ei_lon_tpdu_authpdu_type_unknown;
177 static expert_field ei_lon_tpdu_apdu_dest_type;
179 static int dissect_apdu(proto_tree *tree, packet_info *pinfo, tvbuff_t *tvb,
180 int offset);
182 static int
183 dissect_lon(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
185 int offset = 0;
187 int pdu_fmt, addr_fmt, dom_len, pdutype, length;
188 int addr_a;
190 proto_tree *ti;
191 proto_tree *lon_tree;
192 int npdu, type;
194 col_set_str(pinfo->cinfo, COL_PROTOCOL, "LON");
195 col_clear(pinfo->cinfo, COL_INFO);
197 npdu = tvb_get_uint8(tvb, 0);
198 type = tvb_get_uint8(tvb, 1);
199 type = (type&0x30)>>4;
200 col_add_fstr(pinfo->cinfo, COL_INFO,
201 "%sDelta_BL: %i Type: %s",
202 npdu&0x80?"Priority ":"",
203 npdu&0x3F,
204 val_to_str_const(type, pdu_fmt_vs, "Unknown"));
206 ti = proto_tree_add_item(tree, proto_lon, tvb, offset, -1, ENC_NA);
207 lon_tree = proto_item_add_subtree(ti, ett_lon);
210 static int * const ppdu_fields[] = {
211 &hf_lon_ppdu_prio,
212 &hf_lon_ppdu_alt,
213 &hf_lon_ppdu_deltabl,
214 NULL
216 proto_tree_add_bitmask(lon_tree, tvb, offset, hf_lon_ppdu,
217 ett_ppdu, ppdu_fields, ENC_BIG_ENDIAN);
218 offset++;
221 static int * const npdu_fields[] = {
222 &hf_lon_npdu_version,
223 &hf_lon_npdu_pdu_fmt,
224 &hf_lon_npdu_addr_fmt,
225 &hf_lon_npdu_dom_len,
226 NULL
228 proto_tree_add_bitmask(lon_tree, tvb, offset, hf_lon_npdu,
229 ett_npdu, npdu_fields, ENC_BIG_ENDIAN);
231 pdu_fmt = (tvb_get_uint8(tvb, offset) >> 4) & 0x03;
232 addr_fmt = (tvb_get_uint8(tvb, offset) >> 2) & 0x03;
233 dom_len = tvb_get_uint8(tvb, offset) & 0x03;
234 offset++;
236 /* Address part */
237 switch(addr_fmt)
239 case 0: /* Broadcast */
240 ti = proto_tree_add_subtree(lon_tree, tvb, offset, 3, ett_address, NULL, "Address type 0 (broadcast)");
241 proto_tree_add_item(ti, hf_lon_addr_srcsub, tvb, offset, 1, ENC_BIG_ENDIAN);
242 proto_tree_add_item(ti, hf_lon_addr_srcnode, tvb, offset+1, 1, ENC_BIG_ENDIAN);
243 proto_tree_add_item(ti, hf_lon_addr_dstsub, tvb, offset+2, 1, ENC_BIG_ENDIAN);
244 offset += 3;
245 break;
246 case 1: /* Multicast */
247 ti = proto_tree_add_subtree(lon_tree, tvb, offset, 3, ett_address, NULL, "Address type 1 (multicast)");
248 proto_tree_add_item(ti, hf_lon_addr_srcsub, tvb, offset, 1, ENC_BIG_ENDIAN);
249 proto_tree_add_item(ti, hf_lon_addr_srcnode, tvb, offset+1, 1, ENC_BIG_ENDIAN);
250 proto_tree_add_item(ti, hf_lon_addr_dstgrp, tvb, offset+2, 1, ENC_BIG_ENDIAN);
251 offset += 3;
252 break;
253 case 2: /* Unicast/Multicast */
254 addr_a = tvb_get_uint8(tvb, offset+1) >> 7;
255 if (addr_a) { /* Type 2a */
256 ti = proto_tree_add_subtree(lon_tree, tvb, offset, 4, ett_address, NULL, "Address type 2a (unicast)");
257 proto_tree_add_item(ti, hf_lon_addr_srcsub, tvb, offset, 1, ENC_BIG_ENDIAN);
258 proto_tree_add_item(ti, hf_lon_addr_srcnode, tvb, offset+1, 1, ENC_BIG_ENDIAN);
259 proto_tree_add_item(ti, hf_lon_addr_dstsub, tvb, offset+2, 1, ENC_BIG_ENDIAN);
260 proto_tree_add_item(ti, hf_lon_addr_dstnode, tvb, offset+3, 1, ENC_BIG_ENDIAN);
261 offset += 4;
262 } else { /* Type 2b */
263 ti = proto_tree_add_subtree(lon_tree, tvb, offset, 6, ett_address, NULL, "Address type 2b (multicast)");
264 proto_tree_add_item(ti, hf_lon_addr_srcsub, tvb, offset, 1, ENC_BIG_ENDIAN);
265 proto_tree_add_item(ti, hf_lon_addr_srcnode, tvb, offset+1, 1, ENC_BIG_ENDIAN);
266 proto_tree_add_item(ti, hf_lon_addr_dstgrp, tvb, offset+2, 1, ENC_BIG_ENDIAN);
267 proto_tree_add_item(ti, hf_lon_addr_dstnode, tvb, offset+3, 1, ENC_BIG_ENDIAN);
268 proto_tree_add_item(ti, hf_lon_addr_grp, tvb, offset+4, 1, ENC_BIG_ENDIAN);
269 proto_tree_add_item(ti, hf_lon_addr_grpmem, tvb, offset+5, 1, ENC_BIG_ENDIAN);
270 offset += 6;
272 break;
273 case 3: /* UID */
274 ti = proto_tree_add_subtree(lon_tree, tvb, offset, 9, ett_address, NULL, "Address type 3 (UID)");
275 proto_tree_add_item(ti, hf_lon_addr_srcsub, tvb, offset, 1, ENC_BIG_ENDIAN);
276 proto_tree_add_item(ti, hf_lon_addr_srcnode, tvb, offset+1, 1, ENC_BIG_ENDIAN);
277 proto_tree_add_item(ti, hf_lon_addr_dstsub, tvb, offset+2, 1, ENC_BIG_ENDIAN);
278 proto_tree_add_item(ti, hf_lon_addr_uid, tvb, offset+3, 6, ENC_NA);
279 offset += 9;
280 break;
282 /* END Address part */
283 /* Domain */
284 switch(dom_len)
286 case 0: /* Domain-wide */
287 proto_tree_add_bytes_format(lon_tree, hf_lon_domain, tvb, offset, 0, NULL, "Domain wide addressing");
288 break;
289 case 1:
290 proto_tree_add_item(lon_tree, hf_lon_domain, tvb, offset, 1, ENC_NA);
291 offset++;
292 break;
293 case 2:
294 proto_tree_add_item(lon_tree, hf_lon_domain, tvb, offset, 3, ENC_NA);
295 offset += 3;
296 break;
297 case 3:
298 proto_tree_add_item(lon_tree, hf_lon_domain, tvb, offset, 6, ENC_NA);
299 offset += 6;
300 break;
302 /* END Domain */
303 /* *PDU */
304 switch(pdu_fmt)
306 case 0: /* TPDU */
308 static int * const tpdu_fields[] = {
309 &hf_lon_auth,
310 &hf_lon_tpdu_tpdu_type,
311 &hf_lon_trans_no,
312 NULL
314 proto_tree_add_bitmask(lon_tree, tvb, offset, hf_lon_tpdu,
315 ett_tpdu, tpdu_fields, ENC_BIG_ENDIAN);
317 pdutype = (tvb_get_uint8(tvb, offset)>>4)& 0x07;
318 offset++;
319 switch(pdutype)
321 case 0:
322 case 1: /* ACKD and UnACKD_RPT */
323 offset += dissect_apdu(lon_tree, pinfo, tvb, offset);
324 break;
325 case 2: /* ACK */
326 break;
327 case 4: /* REMINDER */
328 length = tvb_get_uint8(tvb, offset);
329 proto_tree_add_item(lon_tree, hf_lon_mlen, tvb, offset, 1, ENC_BIG_ENDIAN);
330 offset++;
331 proto_tree_add_item(lon_tree, hf_lon_mlist, tvb, offset, length, ENC_BIG_ENDIAN);
332 offset += length;
333 break;
334 case 5: /* REM/MSG */
335 length = tvb_get_uint8(tvb, offset);
336 proto_tree_add_item(lon_tree, hf_lon_mlen, tvb, offset, 1, ENC_BIG_ENDIAN);
337 offset++;
338 if (length > 0)
339 proto_tree_add_item(lon_tree, hf_lon_mlist, tvb, offset, length, ENC_BIG_ENDIAN);
340 offset += length;
341 offset += dissect_apdu(lon_tree, pinfo, tvb, offset);
342 break;
343 default:
344 expert_add_info_format(pinfo, lon_tree, &ei_lon_tpdu_tpdu_type_unknown, "Unexpected TPDU type %i", pdutype);
345 break;
348 break;
349 case 1: /* SPDU */
351 static int * const spdu_fields[] = {
352 &hf_lon_auth,
353 &hf_lon_spdu_spdu_type,
354 &hf_lon_trans_no,
355 NULL
357 proto_tree_add_bitmask(lon_tree, tvb, offset, hf_lon_spdu,
358 ett_spdu, spdu_fields, ENC_BIG_ENDIAN);
359 pdutype = (tvb_get_uint8(tvb, offset)>>4)& 0x07;
360 offset++;
361 switch(pdutype)
363 case 0: /* REQUEST */
364 offset += dissect_apdu(lon_tree, pinfo, tvb, offset);
365 break;
366 case 2: /* RESPONSE */
367 offset += dissect_apdu(lon_tree, pinfo, tvb, offset);
368 break;
369 case 4: /* REMINDER */
370 length = tvb_get_uint8(tvb, offset);
371 proto_tree_add_item(lon_tree, hf_lon_mlen, tvb, offset, 1, ENC_BIG_ENDIAN);
372 offset++;
373 proto_tree_add_item(lon_tree, hf_lon_mlist, tvb, offset, length, ENC_BIG_ENDIAN);
374 offset += length;
375 break;
376 case 5: /* REM/MSG */
377 length = tvb_get_uint8(tvb, offset);
378 proto_tree_add_item(lon_tree, hf_lon_mlen, tvb, offset, 1, ENC_BIG_ENDIAN);
379 offset++;
380 if (length > 0)
381 proto_tree_add_item(lon_tree, hf_lon_mlist, tvb, offset, length, ENC_BIG_ENDIAN);
382 offset += length;
383 offset += dissect_apdu(lon_tree, pinfo, tvb, offset);
384 break;
385 default:
386 expert_add_info_format(pinfo, lon_tree, &ei_lon_tpdu_spdu_type_unknown, "Unexpected SPDU type %i", pdutype);
387 break;
390 break;
391 case 2: /* AuthPDU */
393 /* TODO: these masks are not correct - have { 0xc0, 0x02, 0x0f } */
394 static int * const authpdu_fields[] = {
395 &hf_lon_authpdu_fmt,
396 &hf_lon_authpdu_authpdu_type,
397 &hf_lon_trans_no,
398 NULL
400 proto_tree_add_bitmask(lon_tree, tvb, offset, hf_lon_authpdu,
401 ett_authpdu, authpdu_fields, ENC_BIG_ENDIAN);
403 pdutype = (tvb_get_uint8(tvb, offset)>>4)& 0x03;
404 offset++;
405 switch(pdutype)
407 case 0: /* CHALLENGE */
408 case 2: /* REPLY */
409 offset += 9;
410 break;
411 default:
412 expert_add_info_format(pinfo, lon_tree, &ei_lon_tpdu_authpdu_type_unknown, "Unexpected AuthPDU type %i", pdutype);
413 break;
416 break;
417 case 3: /* APDU */
418 offset += dissect_apdu(lon_tree, pinfo, tvb, offset);
419 break;
421 /* END *PDU */
423 return offset;
426 static int
427 dissect_apdu(proto_tree *tree, packet_info *pinfo, tvbuff_t *tvb,
428 int offset)
430 tvbuff_t *next_tvb;
431 int old_offset = offset, dest_type;
433 dest_type = tvb_get_uint8(tvb, offset);
435 if ((dest_type&0x80) == 0x80) { /* Network variable */
436 static int * const nv_fields[] = {
437 &hf_lon_nv_dir,
438 &hf_lon_nv_selector,
439 NULL
441 proto_tree_add_bitmask(tree, tvb, offset, hf_lon_nv,
442 ett_nv, nv_fields, ENC_BIG_ENDIAN);
443 offset += 2;
444 } else if ((dest_type&0xc0) == 0) { /* Application */
445 static int * const app_fields[] = {
446 &hf_lon_app_code,
447 NULL
449 proto_tree_add_bitmask(tree, tvb, offset, hf_lon_app,
450 ett_app, app_fields, ENC_BIG_ENDIAN);
451 offset++;
452 } else if ((dest_type&0xe0) == 0x60) { /* Network Management */
453 static int * const nm_fields[] = {
454 &hf_lon_nm_code,
455 NULL
457 proto_tree_add_bitmask(tree, tvb, offset, hf_lon_nm,
458 ett_nm, nm_fields, ENC_BIG_ENDIAN);
459 offset++;
461 if (dest_type == 0x7F) {
462 proto_tree_add_item(tree, hf_lon_addr_uid, tvb, offset, 6, ENC_NA);
463 offset += 6;
464 proto_tree_add_item(tree, hf_lon_name, tvb, offset, 8, ENC_NA);
465 offset += 8;
468 } else if ((dest_type&0xf0) == 0x50) { /* Network Diagnostic */
469 static int * const nd_fields[] = {
470 &hf_lon_nd_code,
471 NULL
473 proto_tree_add_bitmask(tree, tvb, offset, hf_lon_nd,
474 ett_nd, nd_fields, ENC_BIG_ENDIAN);
475 offset++;
476 } else if ((dest_type&0xf0) == 0x40) { /* Foreign Frame */
477 static int * const ff_fields[] = {
478 &hf_lon_ff_code,
479 NULL
481 proto_tree_add_bitmask(tree, tvb, offset, hf_lon_ff,
482 ett_ff, ff_fields, ENC_BIG_ENDIAN);
483 offset++;
484 } else { /* Shouldn't get here */
485 expert_add_info_format(pinfo, tree, &ei_lon_tpdu_apdu_dest_type, "Malformed APDU destin&type %i", dest_type);
488 next_tvb = tvb_new_subset_remaining(tvb, offset);
490 return offset - old_offset + call_data_dissector(next_tvb, pinfo, tree);
493 void
494 proto_register_lon(void)
496 static hf_register_info hf[] =
498 {&hf_lon_ppdu,
499 {"PPDU", "lon.ppdu",
500 FT_UINT8, BASE_HEX, NULL, 0,
501 NULL, HFILL }
503 {&hf_lon_ppdu_prio,
504 {"Priority", "lon.prio",
505 FT_UINT8, BASE_DEC, NULL, 0x80,
506 "Priority packet", HFILL }
508 {&hf_lon_ppdu_alt,
509 {"Alt path", "lon.alt_path",
510 FT_UINT8, BASE_DEC, NULL, 0x40,
511 "Alternate path", HFILL }
513 {&hf_lon_ppdu_deltabl,
514 {"Delta BL", "lon.delta_bl",
515 FT_UINT8, BASE_DEC, NULL, 0x3f,
516 "How many packets to expect from this one", HFILL }
518 {&hf_lon_npdu,
519 {"NPDU", "lon.npdu",
520 FT_UINT8, BASE_DEC, NULL, 0,
521 NULL, HFILL }
523 {&hf_lon_npdu_version,
524 {"version", "lon.vers",
525 FT_UINT8, BASE_HEX, NULL, 0xc0,
526 "LON protocol version", HFILL }
528 {&hf_lon_npdu_pdu_fmt,
529 {"PDU format", "lon.pdufmt",
530 FT_UINT8, BASE_HEX, VALS(pdu_fmt_vs), 0x30,
531 NULL, HFILL }
533 {&hf_lon_npdu_addr_fmt,
534 {"Address format", "lon.addrfmt",
535 FT_UINT8, BASE_HEX, VALS(addr_fmt_vs), 0x0c,
536 NULL, HFILL }
538 {&hf_lon_npdu_dom_len,
539 {"Domain length", "lon.domainlen",
540 FT_UINT8, BASE_HEX, VALS(domain_length_vs), 0x03,
541 NULL, HFILL }
543 {&hf_lon_addr_srcsub,
544 {"Source subnet", "lon.srcnet",
545 FT_UINT8, BASE_HEX, NULL, 0,
546 NULL, HFILL }
548 {&hf_lon_addr_srcnode,
549 {"Source node", "lon.srcnode",
550 FT_UINT8, BASE_HEX, NULL, 0x7f,
551 NULL, HFILL }
553 {&hf_lon_addr_dstsub,
554 {"Destination subnet", "lon.dstnet",
555 FT_UINT8, BASE_HEX, NULL, 0,
556 NULL, HFILL }
558 {&hf_lon_addr_dstgrp,
559 {"Destination group", "lon.dstgrp",
560 FT_UINT8, BASE_HEX, NULL, 0,
561 NULL, HFILL }
563 {&hf_lon_addr_dstnode,
564 {"Destination node", "lon.dstnode",
565 FT_UINT8, BASE_HEX, NULL, 0x7f,
566 NULL, HFILL }
568 {&hf_lon_addr_grp,
569 {"Group", "lon.grp",
570 FT_UINT8, BASE_HEX, NULL, 0,
571 NULL, HFILL }
573 {&hf_lon_addr_grpmem,
574 {"Group member", "lon.grpmem",
575 FT_UINT8, BASE_HEX, NULL, 0,
576 NULL, HFILL }
578 {&hf_lon_addr_uid,
579 {"Unique node ID", "lon.uid",
580 FT_BYTES, BASE_NONE, NULL, 0,
581 NULL, HFILL }
583 {&hf_lon_domain,
584 {"Domain", "lon.domain",
585 FT_BYTES, BASE_NONE, NULL , 0,
586 NULL, HFILL }
588 {&hf_lon_tpdu,
589 {"TPDU", "lon.tpdu",
590 FT_UINT8, BASE_HEX, NULL, 0,
591 NULL, HFILL }
593 {&hf_lon_auth,
594 {"Auth", "lon.auth",
595 FT_UINT8, BASE_HEX, NULL, 0x80,
596 NULL, HFILL }
598 {&hf_lon_tpdu_tpdu_type,
599 {"TPDU type", "lon.tpdu_type",
600 FT_UINT8, BASE_HEX, VALS(tpdu_type_vs), 0x70,
601 NULL, HFILL }
603 {&hf_lon_trans_no,
604 {"Transaction number", "lon.trans_no",
605 FT_UINT8, BASE_HEX, NULL, 0x0f,
606 NULL, HFILL }
608 {&hf_lon_spdu,
609 {"SPDU", "lon.spdu",
610 FT_UINT8, BASE_HEX, NULL, 0,
611 NULL, HFILL }
613 {&hf_lon_spdu_spdu_type,
614 {"SPDU type", "lon.spdu_type",
615 FT_UINT8, BASE_HEX, VALS(spdu_type_vs), 0x70,
616 NULL, HFILL }
618 {&hf_lon_mlen,
619 {"Length of M_List", "lon.spdu.mlen",
620 FT_UINT8, BASE_HEX, NULL, 0,
621 NULL, HFILL }
623 {&hf_lon_mlist,
624 {"M_List", "lon.spdu.mlist",
625 FT_UINT8, BASE_HEX, NULL, 0,
626 NULL, HFILL }
628 {&hf_lon_authpdu,
629 {"AuthPDU", "lon.authpdu",
630 FT_UINT8, BASE_HEX, NULL, 0,
631 NULL, HFILL }
633 {&hf_lon_authpdu_fmt,
634 {"FMT (same as AddrFmt)", "lon.authpdu_addrfmt",
635 FT_UINT8, BASE_HEX, NULL, 0xc,
636 NULL, HFILL }
638 {&hf_lon_authpdu_authpdu_type,
639 {"AuthPDU type", "lon.authpdu_type",
640 FT_UINT8, BASE_HEX, VALS(authpdu_type_vs), 0x02,
641 NULL, HFILL }
643 {&hf_lon_nv,
644 {"Network Variable", "lon.nv",
645 FT_UINT16, BASE_HEX, NULL, 0,
646 NULL, HFILL }
648 {&hf_lon_nv_dir,
649 {"NV direction", "lon.nv.dir",
650 FT_UINT16, BASE_HEX, NULL, 0x4000,
651 NULL, HFILL }
653 {&hf_lon_nv_selector,
654 {"NV selector", "lon.nv.selector",
655 FT_UINT16, BASE_HEX, NULL, 0x3fff,
656 NULL, HFILL }
658 {&hf_lon_app,
659 {"Application", "lon.application",
660 FT_UINT8, BASE_HEX, NULL, 0,
661 NULL, HFILL }
663 {&hf_lon_app_code,
664 {"Code", "lon.code",
665 FT_UINT8, BASE_HEX, NULL, 0x3f,
666 NULL, HFILL }
668 {&hf_lon_nm,
669 {"Network Management", "lon.nm",
670 FT_UINT8, BASE_HEX, NULL, 0,
671 NULL, HFILL }
673 {&hf_lon_nm_code,
674 {"Code", "lon.code",
675 FT_UINT8, BASE_HEX, VALS(nm_code_vs), 0xff,
676 NULL, HFILL }
678 {&hf_lon_nd,
679 {"Network Diagnostic", "lon.nd",
680 FT_UINT8, BASE_HEX, NULL, 0,
681 NULL, HFILL }
683 {&hf_lon_nd_code,
684 {"Code", "lon.code",
685 FT_UINT8, BASE_HEX, VALS(nd_code_vs), 0xff,
686 NULL, HFILL }
688 {&hf_lon_ff,
689 {"Foreign Frame", "lon.ff",
690 FT_UINT8, BASE_HEX, NULL, 0,
691 NULL, HFILL }
693 {&hf_lon_ff_code,
694 {"Code", "lon.code",
695 FT_UINT8, BASE_HEX, NULL, 0x0f,
696 NULL, HFILL }
698 {&hf_lon_name,
699 {"Node name", "lon.name",
700 FT_BYTES, BASE_NONE, NULL, 0,
701 NULL, HFILL }
703 #if 0
704 {&hf_lon_checksum,
705 {"Checksum", "lon.chksum",
706 FT_BYTES, BASE_NONE, NULL, 0,
707 NULL, HFILL }
709 #endif
712 static int *ett[] =
714 &ett_lon,
715 &ett_address,
716 &ett_ppdu,
717 &ett_npdu,
718 &ett_tpdu,
719 &ett_spdu,
720 &ett_authpdu,
721 &ett_apdu,
722 &ett_nv,
723 &ett_app,
724 &ett_nm,
725 &ett_nd,
726 &ett_ff
729 static ei_register_info ei[] = {
730 { &ei_lon_tpdu_tpdu_type_unknown, { "lon.tpdu_type.unknown", PI_PROTOCOL, PI_WARN, "Unexpected TPDU type", EXPFILL }},
731 { &ei_lon_tpdu_spdu_type_unknown, { "lon.spdu_type.unknown", PI_PROTOCOL, PI_WARN, "Unexpected SPDU type", EXPFILL }},
732 { &ei_lon_tpdu_authpdu_type_unknown, { "lon.authpdu_type.unknown", PI_PROTOCOL, PI_WARN, "Unexpected AuthPDU type", EXPFILL }},
733 { &ei_lon_tpdu_apdu_dest_type, { "lon.authpdu_dest_type.unknown", PI_PROTOCOL, PI_WARN, "Malformed APDU destin&type", EXPFILL }},
736 expert_module_t* expert_lon;
738 proto_lon = proto_register_protocol("Local Operating Network",
739 "LON", "lon");
741 proto_register_field_array (proto_lon, hf, array_length (hf));
742 proto_register_subtree_array (ett, array_length (ett));
743 expert_lon = expert_register_protocol(proto_lon);
744 expert_register_field_array(expert_lon, ei, array_length(ei));
746 lon_handle = register_dissector("lon", dissect_lon, proto_lon);
750 void
751 proto_reg_handoff_lon(void)
753 dissector_add_uint("cnip.protocol", 0, lon_handle);
757 * Editor modelines - https://www.wireshark.org/tools/modelines.html
759 * Local variables:
760 * c-basic-offset: 8
761 * tab-width: 8
762 * indent-tabs-mode: t
763 * End:
765 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
766 * :indentSize=8:tabSize=8:noTabs=false: