3 * Dissector for ANCP - Access Node Control Protocol
5 * More info on the protocol can be found on IETF:
6 * https://tools.ietf.org/wg/ancp/
7 * https://tools.ietf.org/html/draft-ietf-ancp-protocol-09
8 * https://tools.ietf.org/html/rfc6320
9 * https://tools.ietf.org/html/rfc7256
10 * https://www.iana.org/assignments/ancp/ancp.xhtml
12 * Copyright 2010, Aniruddha.A (anira@cisco.com)
13 * Uli Heilmeier, 2017; Update to RFC6320; current IANA registry types
15 * Wireshark - Network traffic analyzer
16 * By Gerald Combs <gerald@wireshark.org>
17 * Copyright 1998 Gerald Combs
19 * SPDX-License-Identifier: GPL-2.0-or-later
24 #include <epan/packet.h>
25 #include <epan/stats_tree.h>
27 #include <epan/unit_strings.h>
28 #include <wsutil/ws_roundup.h>
29 #include "packet-tcp.h"
31 #define ANCP_PORT 6068 /* The ANCP TCP port */
33 #define ANCP_MIN_HDR 4
34 #define ANCP_GSMP_ETHER_TYPE 0x880C
35 #define TECH_TYPE_DSL 0x5
36 #define TECH_TYPE_PON 0x1
38 #define ANCP_RESULT_MASK 0xF0
39 #define ANCP_CODE_MASK 0x0FFF
40 #define ANCP_I_FLAG_MASK 0x80
41 #define ANCP_SUBMSG_MASK 0x7FFF
42 #define ADJ_CODE_MASK 0x7F /* excluding MSB M-Flag */
44 #define ANCP_MTYPE_ADJ 10
45 #define ANCP_MTYPE_PORT_MGMT 32
46 #define ANCP_MTYPE_PORT_UP 80
47 #define ANCP_MTYPE_PORT_DN 81
48 #define ANCP_MTYPE_ADJ_UPD 85
49 #define ANCP_MTYPE_GEN_RSP 91
50 #define ANCP_MTYPE_PROV 93
52 /* Topology Discovery Extensions */
53 #define TLV_DSL_LINE_ATTRIBUTES 0x04
54 #define TLV_DSL_LINE_STATE 0x8F
55 #define TLV_DSL_TYPE 0x91
57 /* Port Management Extensions */
58 #define TLV_PING_PARAMS 0x07
59 #define TLV_PING_OPAQUE_DATA 0x08
60 #define TLV_PING_RES_STR 0x09
62 void proto_register_ancp(void);
63 void proto_reg_handoff_ancp(void);
65 static dissector_handle_t ancp_handle
;
67 static int hf_ancp_len
;
68 static int hf_ancp_len2
;
69 static int hf_ancp_ver
;
70 static int hf_ancp_mtype
;
71 static int hf_ancp_timer
;
72 static int hf_ancp_adj_code
;
73 static int hf_ancp_sender_name
;
74 static int hf_ancp_receiver_name
;
75 static int hf_ancp_sender_port
;
76 static int hf_ancp_receiver_port
;
77 static int hf_ancp_p_info
;
78 static int hf_ancp_sender_instance
;
79 static int hf_ancp_p_id
;
80 static int hf_ancp_receiver_instance
;
81 static int hf_ancp_tech_type
;
82 static int hf_ancp_num_tlvs
;
83 static int hf_ancp_tot_len
;
84 static int hf_ancp_cap
;
85 static int hf_ancp_result
;
86 static int hf_ancp_code
;
87 static int hf_ancp_trans_id
;
88 static int hf_ancp_i_flag
;
89 static int hf_ancp_submsg_num
;
90 static int hf_ancp_pudm_unused
;
91 static int hf_ancp_function
;
92 static int hf_ancp_x_function
;
93 static int hf_ancp_ext_flags_res
;
94 static int hf_ancp_reserved
;
95 static int hf_ancp_blk_len
;
96 static int hf_ancp_num_ext_tlvs
;
97 static int hf_ancp_ext_tlv_type
;
98 static int hf_ancp_ext_tlv_len
;
99 static int hf_ancp_dsl_line_stlv_type
;
100 static int hf_ancp_dsl_line_stlv_len
;
101 static int hf_ancp_dsl_line_stlv_value
;
102 static int hf_ancp_ext_tlv_value_str
;
103 static int hf_ancp_oam_opaque
;
104 static int hf_ancp_oam_loopb_cnt
;
105 static int hf_ancp_oam_timeout
;
107 static int ett_ancp_len
;
108 static int ett_ancp_ver
;
109 static int ett_ancp_mtype
;
110 static int ett_ancp_timer
;
111 static int ett_ancp_adj_code
;
112 static int ett_ancp_sender_name
;
113 static int ett_ancp_receiver_name
;
114 static int ett_ancp_sender_port
;
115 static int ett_ancp_receiver_port
;
116 static int ett_ancp_p_info
;
117 static int ett_ancp_sender_instance
;
118 static int ett_ancp_p_id
;
119 static int ett_ancp_receiver_instance
;
120 static int ett_ancp_tech_type
;
121 static int ett_ancp_num_tlvs
;
122 static int ett_ancp_tot_len
;
123 static int ett_ancp_cap
;
124 static int ett_ancp_result
;
125 static int ett_ancp_code
;
126 static int ett_ancp_trans_id
;
127 static int ett_ancp_i_flag
;
128 static int ett_ancp_submsg_num
;
129 static int ett_ancp_port
;
130 static int ett_ancp_port_sess_num
;
131 static int ett_ancp_evt_seq_num
;
132 static int ett_ancp_label
;
133 static int ett_ancp_reserved
;
134 static int ett_ancp_blk_len
;
135 static int ett_ancp_num_ext_tlvs
;
136 static int ett_ancp_ext_tlv_type
;
137 static int ett_ancp_dsl_line_stlv_type
;
138 static int ett_ancp_dsl_line_stlv_val
;
139 static int ett_ancp_ext_tlv_value_str
;
140 static int ett_ancp_oam_opaque
;
141 static int ett_ancp_oam_loopb_cnt
;
142 static int ett_ancp_oam_timeout
;
144 static int proto_ancp
;
146 /* ANCP stats - Tap interface */
147 static const uint8_t *st_str_packets
= "Total Packets";
148 static const uint8_t *st_str_packet_types
= "ANCP Packet Types";
149 static const uint8_t *st_str_adj_pack_types
= "ANCP Adjacency Packet Types";
151 static int st_node_packets
= -1;
152 static int st_node_packet_types
= -1;
153 static int st_node_adj_pack_types
= -1;
158 int ancp_adjcode
; /* valid for ancp adjacency message only */
162 static const value_string mtype_names
[] = {
164 { 32, "Port-Management" },
167 { 85, "Adjacency Update" },
168 { 91, "Generic Response" },
169 { 93, "Provisioning" },
170 { 144, "Multicast Replication Control" },
171 { 145, "Multicast Admission Control" },
172 { 146, "Bandwidth Reallocation Request" },
173 { 147, "Bandwidth Transfer" },
174 { 148, "Delegated Bandwidth Query" },
175 { 149, "Mulicast Flow Query" },
176 { 150, "Committed Bandwidth Report" },
180 static const value_string adj_code_names
[] = {
188 static const value_string captype_names
[] = {
189 { 1, "Dynamic-Topology-Discovery" },
190 { 2, "Line-Configuration" },
191 { 3, "Transactional-Multicast" },
196 static const value_string resulttype_names
[] = {
205 static const value_string codetype_names
[] = {
206 { 0x000, "No result" },
207 { 0x002, "Invalid request message" },
208 { 0x006, "One or more of the specified ports are down" },
209 { 0x013, "Out of resources" },
210 { 0x051, "Request message type not implemented" },
211 { 0x053, "Malformed message" },
212 { 0x054, "Mandatory TLV missing" },
213 { 0x055, "Invalid TLV contents" },
214 { 0x064, "Command error" },
215 { 0x065, "Invalid flow address" },
216 { 0x066, "Mulicast flow does not exist" },
217 { 0x067, "Invalid preferred bandwith amount" },
218 { 0x068, "Inconsistent views of delegated bandwidth amount" },
219 { 0x069, "Bandwidth request conflict" },
220 { 0x500, "One or more of the specified ports do not exist" },
221 { 0x501, "Loopback test timed out" },
222 { 0x502, "Reserved" },
223 { 0x503, "DSL access line status showtime" },
224 { 0x504, "DSL access line status idle" },
225 { 0x505, "DSL access line status silent" },
226 { 0x506, "DSL access line status training" },
227 { 0x507, "DSL access line integrity error" },
228 { 0x508, "DSLAM resource not available" },
229 { 0x509, "Invalid test parameter" },
233 static const value_string techtype_str
[] = {
234 { 0x00, "Not technology dependent" },
237 { 0xFF, "Reserved" },
241 static const value_string dsl_line_attrs
[] = {
242 { 0x91, "DSL-Type" },
243 { 0x81, "Actual-Net-Data-Rate-Upstream" },
244 { 0x82, "Actual-Net-Data-Rate-Downstream" },
245 { 0x83, "Minimum-Net-Data-Rate-Upstream" },
246 { 0x84, "Minimum-Net-Data-Rate-Downstream" },
247 { 0x85, "Attainable-Net-Data-Rate-Upstream" },
248 { 0x86, "Attainable-Net-Data-Rate-Downstream" },
249 { 0x87, "Maximum-Net-Data-Rate-Upstream" },
250 { 0x88, "Maximum-Net-Data-Rate-Downstream" },
251 { 0x89, "Minimum-Net-Low-Power-Data-Rate-Upstream" },
252 { 0x8A, "Minimum-Net-Low-Power-Data-Rate-Downstream" },
253 { 0x8B, "Maximum-Interleaving-Delay-Upstream" },
254 { 0x8C, "Actual-Interleaving-Delay-Upstream" },
255 { 0x8D, "Maximum-Interleaving-Delay-Downstream" },
256 { 0x8E, "Actual-Interleaving-Delay-Downstream" },
257 { 0x8F, "DSL line state" },
258 { 0x90, "Access Loop Encapsulation" },
262 static const value_string dsl_line_attr_units
[] = {
283 static const value_string dsl_line_type_names
[] = {
293 static const value_string dsl_line_state_names
[] = {
300 static const value_string function_names
[] = {
302 { 8, "Configure Connection Service Data" },
303 { 9, "Remote Loopback" },
307 static const value_string ext_tlv_types
[] = {
308 { 0x0000, "Reserved" },
309 { 0x0001, "Access-Loop-Circuit-ID" },
310 { 0x0002, "Access-Loop-Remote-ID" },
311 { 0x0003, "Access-Aggregation-Circuit-ID-ASCII" },
312 { 0x0004, "DSL Line Attributes" },
313 { 0x0005, "Service-Profile-Name" },
314 { 0x0006, "Access-Aggregation-Circuit-ID-Binary" },
315 { 0x0007, "OAM-Loopback-Test-Parameters" },
316 { 0x0008, "Opaque-Data" },
317 { 0x0009, "OAM-Loopback-Test-Response-String" },
318 { 0x0011, "Command" },
319 { 0x0013, "Multicast-Service-Profile" },
320 { 0x0015, "Bandwidth-Allocation" },
321 { 0x0016, "Bandwidth-Request" },
322 { 0x0018, "Multicast-Service-Profile-Name" },
323 { 0x0019, "Multicast-Flow" },
324 { 0x0021, "List-Action" },
325 { 0x0022, "Sequence-Number" },
326 { 0x0024, "White-List-CAC" },
327 { 0x0025, "MRepCtl-CAC" },
328 { 0x0081, "Actual-Net-Data-Rate-Upstream" },
329 { 0x0082, "Actual-Net-Data-Rate-Downstream" },
330 { 0x0083, "Minimum-Net-Data-Rate-Upstream" },
331 { 0x0084, "Minimum-Net-Data-Rate-Downstream" },
332 { 0x0085, "Attainable-Net-Data-Rate-Upstream" },
333 { 0x0086, "Attainable-Net-Data-Rate-Downstream" },
334 { 0x0087, "Maximum-Net-Data-Rate-Upstream" },
335 { 0x0088, "Maximum-Net-Data-Rate-Downstream" },
336 { 0x0089, "Minimum-Net-Low-Power-Data-Rate-Upstream" },
337 { 0x008A, "Minimum-Net-Low-Power-Data-Rate-Downstream" },
338 { 0x008B, "Maximum-Interleaving-Delay-Upstream" },
339 { 0x008C, "Actual-Interleaving-Delay-Upstream" },
340 { 0x008D, "Maximum-Interleaving-Delay-Downstream" },
341 { 0x008E, "Actual-Interleaving-Delay-Downstream" },
342 { 0x008F, "DSL-Line-State" },
343 { 0x0090, "Access-Loop-Encapsulation" },
344 { 0x0091, "DSL-Type" },
345 { 0x0092, "Request-Source-IP" },
346 { 0x0093, "Request-Source-MAC" },
347 { 0x0094, "Report-Buffering-Time" },
348 { 0x0095, "Committed-Bandwidth" },
349 { 0x0096, "Request-Source-Device-Id" },
350 { 0x0106, "Status-Info" },
351 { 0x1000, "Target (single access line variant)" },
354 static value_string_ext ext_tlv_types_ext
= VALUE_STRING_EXT_INIT(ext_tlv_types
);
357 dissect_ancp_tlv(tvbuff_t
*tvb
, proto_tree
*tlv_tree
, int offset
)
359 uint16_t tlen
, ttype
;
363 proto_tree_add_item(tlv_tree
, hf_ancp_ext_tlv_type
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
364 ttype
= tvb_get_ntohs(tvb
, offset
);
367 tti
= proto_tree_add_item(tlv_tree
, hf_ancp_ext_tlv_len
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
368 tlen
= tvb_get_ntohs(tvb
, offset
);
372 * Extension Block is common for event message and port
373 * management message, but the TLVs that can appear
377 case TLV_DSL_LINE_ATTRIBUTES
:
379 proto_tree
*dsl_tree
;
380 uint16_t stlvtype
, stlvlen
;
383 /* Create a DSL Attribute SubTree */
384 dsl_tree
= proto_item_add_subtree(tti
, ett_ancp_ext_tlv_type
);
385 num_stlvs
= tlen
/ 8; /* TODO - better way? */
386 for ( ;num_stlvs
; num_stlvs
--) {
387 proto_tree_add_item(dsl_tree
,
388 hf_ancp_dsl_line_stlv_type
, tvb
, offset
,
390 stlvtype
= tvb_get_ntohs(tvb
, offset
);
392 proto_tree_add_item(dsl_tree
,
393 hf_ancp_dsl_line_stlv_len
, tvb
, offset
,
395 stlvlen
= tvb_get_ntohs(tvb
, offset
);
396 offset
+= 2; /* Sub TLV Length */
398 tti
= proto_tree_add_item(dsl_tree
,
399 hf_ancp_dsl_line_stlv_value
, tvb
, offset
,
400 stlvlen
, ENC_BIG_ENDIAN
);
401 val
= tvb_get_ntohl(tvb
, offset
);
404 case TLV_DSL_LINE_STATE
:
405 proto_item_append_text(tti
, " (%s)",
406 val_to_str(val
, dsl_line_state_names
,
407 "Unknown (0x%02x)"));
410 proto_item_append_text(tti
, " (%s)",
411 val_to_str(val
, dsl_line_type_names
,
412 "Unknown (0x%02x)"));
417 proto_item_append_text(tti
, " %s",
420 "Unknown (0x%02x)"));
423 offset
+= WS_ROUNDUP_4(stlvlen
); /* Except loop-encap, rest are 4B */
427 case TLV_PING_OPAQUE_DATA
:
429 proto_tree_add_item(tlv_tree
, hf_ancp_oam_opaque
,
430 tvb
, offset
, 4, ENC_BIG_ENDIAN
);
432 proto_tree_add_item(tlv_tree
, hf_ancp_oam_opaque
,
433 tvb
, offset
, 4, ENC_BIG_ENDIAN
);
436 case TLV_PING_PARAMS
:
437 /* Count (1B) Timeout (1B), 2B empty */
438 proto_tree_add_item(tlv_tree
,
439 hf_ancp_oam_loopb_cnt
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
441 proto_tree_add_item(tlv_tree
,
442 hf_ancp_oam_timeout
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
444 /* Lets not bother about 2B until IETF WG figures out */
448 /* Assume TLV value is string - covers ALCID, OAM resp */
449 proto_tree_add_item(tlv_tree
, hf_ancp_ext_tlv_value_str
,
450 tvb
, offset
, tlen
, ENC_ASCII
);
451 offset
+= WS_ROUNDUP_4(tlen
);
453 } /* end switch {ttype} */
458 dissect_ancp_port_up_dn_mgmt(tvbuff_t
*tvb
, proto_tree
*ancp_tree
, int offset
, uint8_t mtype
)
464 if (mtype
== ANCP_MTYPE_PORT_MGMT
) {
465 proto_tree_add_item(ancp_tree
, hf_ancp_pudm_unused
, tvb
, offset
, 14, ENC_NA
);
468 proto_tree_add_item(ancp_tree
, hf_ancp_function
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
471 proto_tree_add_item(ancp_tree
, hf_ancp_x_function
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
474 proto_tree_add_item(ancp_tree
, hf_ancp_pudm_unused
, tvb
, offset
, 4, ENC_NA
);
477 proto_tree_add_item(ancp_tree
, hf_ancp_pudm_unused
, tvb
, offset
, 20, ENC_NA
);
481 proto_tree_add_item(ancp_tree
, hf_ancp_ext_flags_res
, tvb
, offset
, 1, ENC_NA
);
484 proto_tree_add_item(ancp_tree
, hf_ancp_mtype
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
487 if (mtype
== ANCP_MTYPE_PORT_MGMT
) {
488 proto_tree_add_item(ancp_tree
, hf_ancp_reserved
, tvb
, offset
, 2, ENC_NA
);
492 proto_tree_add_item(ancp_tree
, hf_ancp_tech_type
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
493 tech_type
= tvb_get_uint8(tvb
, offset
);
496 proto_tree_add_item(ancp_tree
, hf_ancp_reserved
, tvb
, offset
, 1, ENC_NA
);
500 proto_tree_add_item(ancp_tree
, hf_ancp_num_ext_tlvs
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
501 num_tlvs
= tvb_get_ntohs(tvb
, offset
);
504 sti
= proto_tree_add_item(ancp_tree
, hf_ancp_blk_len
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
507 if (tech_type
== TECH_TYPE_DSL
|| tech_type
== TECH_TYPE_PON
) {
508 proto_tree
*tlv_tree
;
510 /* Create a TLV sub tree */
511 tlv_tree
= proto_item_add_subtree(sti
, ett_ancp_len
);
513 for( ;num_tlvs
; num_tlvs
--) {
514 offset
= dissect_ancp_tlv(tvb
, tlv_tree
, offset
);
515 } /* end for {numtlvs} */
520 dissect_ancp_adj_msg(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*ancp_tree
,
521 int offset
, struct ancp_tap_t
*ancp_info
525 proto_tree
*ancp_cap_tree
;
526 uint8_t byte
, numcaps
, adjcode
;
529 sti
= proto_tree_add_item(ancp_tree
, hf_ancp_timer
, tvb
, offset
, 1,
532 proto_item_append_text(sti
, " msec");
534 sti
= proto_tree_add_item(ancp_tree
, hf_ancp_adj_code
, tvb
, offset
, 1,
536 byte
= tvb_get_uint8(tvb
, offset
);
538 adjcode
= byte
& ADJ_CODE_MASK
;
539 ancp_info
->ancp_adjcode
= adjcode
; /* stats */
540 proto_item_append_text(sti
, " (%s, M Flag %s)",
541 val_to_str(adjcode
, adj_code_names
, "Unknown (0x%02x)"),
542 (byte
>> 7) ? "Set" : "Unset");
543 col_append_fstr(pinfo
->cinfo
, COL_INFO
, " (%s)",
544 val_to_str(adjcode
, adj_code_names
, "Unknown (0x%02x)"));
546 proto_tree_add_item(ancp_tree
, hf_ancp_sender_name
, tvb
, offset
, 6, ENC_NA
);
549 proto_tree_add_item(ancp_tree
, hf_ancp_receiver_name
, tvb
,offset
, 6, ENC_NA
);
552 proto_tree_add_item(ancp_tree
, hf_ancp_sender_port
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
555 proto_tree_add_item(ancp_tree
, hf_ancp_receiver_port
, tvb
,offset
, 4, ENC_BIG_ENDIAN
);
558 sti
= proto_tree_add_item(ancp_tree
, hf_ancp_p_info
, tvb
,
559 offset
, 1, ENC_BIG_ENDIAN
);
560 byte
= tvb_get_uint8(tvb
, offset
);
562 proto_item_append_text(sti
, " (Type = %d, Flag = %d)",
563 byte
>> 4, byte
& 0x0F);
565 proto_tree_add_item(ancp_tree
, hf_ancp_sender_instance
, tvb
, offset
, 3, ENC_BIG_ENDIAN
);
568 proto_tree_add_item(ancp_tree
, hf_ancp_p_id
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
571 proto_tree_add_item(ancp_tree
, hf_ancp_receiver_instance
, tvb
, offset
, 3, ENC_BIG_ENDIAN
);
574 proto_tree_add_item(ancp_tree
, hf_ancp_reserved
, tvb
, offset
, 1, ENC_NA
);
577 sti
= proto_tree_add_item(ancp_tree
, hf_ancp_num_tlvs
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
578 numcaps
= tvb_get_uint8(tvb
, offset
);
581 /* Start the capability subtree */
582 ancp_cap_tree
= proto_item_add_subtree(sti
, ett_ancp_tot_len
);
584 proto_tree_add_item(ancp_cap_tree
, hf_ancp_tot_len
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
587 for ( ;numcaps
; numcaps
--) {
588 sti
= proto_tree_add_item(ancp_cap_tree
, hf_ancp_cap
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
591 tlv_len
= tvb_get_ntohs(tvb
, offset
);
593 proto_item_append_text(sti
, " (%d bytes)", tlv_len
);
594 /* TODO - if there are non boolean caps, validate before use */
599 ancp_stats_tree_init(stats_tree
*st
)
601 st_node_packets
= stats_tree_create_node(st
, st_str_packets
, 0, STAT_DT_INT
, true);
602 st_node_packet_types
= stats_tree_create_pivot(st
, st_str_packet_types
,
604 st_node_adj_pack_types
= stats_tree_create_node(st
, st_str_adj_pack_types
,
605 st_node_packets
, STAT_DT_INT
, true);
608 static tap_packet_status
609 ancp_stats_tree_packet(stats_tree
* st
, packet_info
* pinfo _U_
,
610 epan_dissect_t
* edt _U_
, const void* p
, tap_flags_t flags _U_
)
612 const struct ancp_tap_t
*pi
= (const struct ancp_tap_t
*) p
;
614 tick_stat_node(st
, st_str_packets
, 0, false);
615 stats_tree_tick_pivot(st
, st_node_packet_types
,
616 val_to_str(pi
->ancp_mtype
, mtype_names
,
617 "Unknown packet type (%d)"));
618 if (pi
->ancp_mtype
== ANCP_MTYPE_ADJ
)
619 stats_tree_tick_pivot(st
, st_node_adj_pack_types
,
620 val_to_str(pi
->ancp_adjcode
, adj_code_names
,
621 "Unknown Adjacency packet (%d)"));
622 return TAP_PACKET_REDRAW
;
626 dissect_ancp_message(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void* data _U_
)
630 struct ancp_tap_t
*ancp_info
;
633 proto_item
*tti
= NULL
;
634 proto_tree
*ancp_tree
;
635 proto_tree
*tlv_tree
;
640 if (tvb_get_ntohs(tvb
, offset
) != ANCP_GSMP_ETHER_TYPE
)
641 return 0; /* XXX: this dissector is not a heuristic dissector */
642 /* Should do "expert" & dissect rest as "data" */
643 /* (after setting COL_PROTOCOL & etc) ? */
645 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "ANCP");
646 col_clear(pinfo
->cinfo
, COL_INFO
);
648 ancp_info
= wmem_new(pinfo
->pool
, struct ancp_tap_t
);
649 ancp_info
->ancp_mtype
= 0;
650 ancp_info
->ancp_adjcode
= 0;
652 ti
= proto_tree_add_item(tree
, proto_ancp
, tvb
, 0, -1, ENC_NA
);
654 ancp_tree
= proto_item_add_subtree(ti
, ett_ancp_len
);
656 offset
= 2; /* skip ether type */
658 proto_tree_add_item(ancp_tree
, hf_ancp_len
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
659 len
= tvb_get_ntohs(tvb
, offset
);
662 sti
= proto_tree_add_item(ancp_tree
, hf_ancp_ver
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
663 byte
= tvb_get_uint8(tvb
, offset
);
665 proto_item_append_text(sti
, " (%d.%d)", byte
>> 4, byte
& 0x0F);
667 sti
= proto_tree_add_item(ancp_tree
, hf_ancp_mtype
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
668 mtype
= tvb_get_uint8(tvb
, offset
); /* ANCP message type */
669 ancp_info
->ancp_mtype
= mtype
; /* stats */
672 col_add_fstr(pinfo
->cinfo
, COL_INFO
, "%s Message",
673 val_to_str(mtype
, mtype_names
, "Unknown (0x%02x)"));
675 if (mtype
!= ANCP_MTYPE_ADJ
) {
676 /* Dissect common header */
677 proto_tree_add_item(ancp_tree
, hf_ancp_result
, tvb
, offset
, 1,
678 ENC_BIG_ENDIAN
); /* treat as 1B, but don't change offset */
680 proto_tree_add_item(ancp_tree
, hf_ancp_code
, tvb
, offset
, 2,
684 proto_tree_add_item(ancp_tree
, hf_ancp_p_id
, tvb
, offset
,
688 proto_tree_add_item(ancp_tree
, hf_ancp_trans_id
, tvb
,
689 offset
, 3, ENC_BIG_ENDIAN
);
692 proto_tree_add_item(ancp_tree
, hf_ancp_i_flag
, tvb
, offset
, 1,
693 ENC_BIG_ENDIAN
); /* treat as 1B, but don't change offset */
695 proto_tree_add_item(ancp_tree
, hf_ancp_submsg_num
, tvb
,
696 offset
, 2, ENC_BIG_ENDIAN
);
699 tti
= proto_tree_add_item(ancp_tree
, hf_ancp_len2
, tvb
, offset
,
701 offset
+= 2; /* Length */
706 dissect_ancp_adj_msg(tvb
, pinfo
, ancp_tree
, offset
, ancp_info
);
708 case ANCP_MTYPE_PORT_DN
:
710 case ANCP_MTYPE_PORT_MGMT
:
712 case ANCP_MTYPE_PORT_UP
:
713 dissect_ancp_port_up_dn_mgmt(tvb
, ancp_tree
, offset
, mtype
);
715 case ANCP_MTYPE_PROV
:
717 case ANCP_MTYPE_GEN_RSP
:
718 tlv_tree
= proto_item_add_subtree(tti
, ett_ancp_len
);
720 while( offset
< len
+ 4) {
721 offset
= dissect_ancp_tlv(tvb
, tlv_tree
, offset
);
724 case ANCP_MTYPE_ADJ_UPD
:
727 proto_item_append_text(sti
, " (Unknown Message %d)", mtype
);
730 tap_queue_packet(ancp_tap
, pinfo
, ancp_info
);
732 return tvb_reported_length(tvb
);
736 get_ancp_msg_len(packet_info
*pinfo _U_
, tvbuff_t
*tvb
, int offset
, void *data _U_
)
738 return (unsigned)tvb_get_ntohs(tvb
, offset
+ 2) + 4; /* 2B len + 4B hdr */
742 dissect_ancp(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void* data
)
744 tcp_dissect_pdus(tvb
, pinfo
, tree
, true, ANCP_MIN_HDR
,
745 get_ancp_msg_len
, dissect_ancp_message
, data
);
747 return tvb_reported_length(tvb
);
751 proto_register_ancp(void)
753 static hf_register_info hf
[] = {
755 { "Length", "ancp.len",
761 { "Length", "ancp.len2",
767 { "Version", "ancp.ver",
773 { "Message Type", "ancp.mtype",
775 VALS(mtype_names
), 0x0,
779 { "Timer", "ancp.timer",
780 FT_UINT8
, BASE_DEC
|BASE_UNIT_STRING
,
781 UNS(&units_milliseconds
), 0x0,
785 { "Code", "ancp.adjcode", /* this is diff from code */
786 FT_UINT8
, BASE_DEC
, /* for Adjacency msg only */
790 { &hf_ancp_sender_name
,
791 { "Sender Name", "ancp.sender_name",
796 { &hf_ancp_receiver_name
,
797 { "Receiver Name", "ancp.receiver_name",
802 { &hf_ancp_sender_port
,
803 { "Sender Port", "ancp.sender_port",
808 { &hf_ancp_receiver_port
,
809 { "Receiver Port", "ancp.receiver_port",
815 { "Partition Info", "ancp.partition_info",
820 { &hf_ancp_sender_instance
,
821 { "Sender Instance", "ancp.sender_instance",
827 { "Partition ID", "ancp.partition_id",
832 { &hf_ancp_receiver_instance
,
833 { "Receiver Instance", "ancp.receiver_instance",
838 { &hf_ancp_tech_type
,
839 { "Tech Type", "ancp.tech_type",
841 VALS(techtype_str
), 0x0,
845 { "Num TLVs", "ancp.num_tlvs",
851 { "Length", "ancp.tot_len", /* name just Len to reuse*/
857 { "Capability", "ancp.capability",
859 VALS(captype_names
), 0x0,
863 { "Result", "ancp.result",
865 VALS(resulttype_names
), ANCP_RESULT_MASK
,
869 { "Code", "ancp.code",
871 VALS(codetype_names
), ANCP_CODE_MASK
,
875 { "Transaction ID", "ancp.transaction_id",
881 { "I Flag", "ancp.i_flag",
883 TFS(&tfs_set_notset
), ANCP_I_FLAG_MASK
,
886 { &hf_ancp_submsg_num
,
887 { "SubMessage Number", "ancp.submessage_number",
889 NULL
, ANCP_SUBMSG_MASK
,
892 { &hf_ancp_pudm_unused
,
893 { "Unused Bytes", "ancp.unused",
899 { "Function", "ancp.function",
901 VALS(function_names
), 0x0,
904 { &hf_ancp_x_function
,
905 { "X-Function", "ancp.x_function",
910 { &hf_ancp_ext_flags_res
,
911 { "Extension Flags Reserved", "ancp.ext_flags",
917 { "Reserved", "ancp.reserved",
923 { "Block Length", "ancp.blk_len",
928 { &hf_ancp_num_ext_tlvs
,
929 { "Num TLVs", "ancp.ext_tlvs.count",
934 { &hf_ancp_ext_tlv_type
,
935 { "TLV Type", "ancp.ext_tlv.type",
936 FT_UINT16
, BASE_DEC
|BASE_EXT_STRING
,
937 &ext_tlv_types_ext
, 0x0,
940 { &hf_ancp_ext_tlv_len
,
941 { "TLV Length", "ancp.ext_tlv.len",
946 { &hf_ancp_dsl_line_stlv_type
,
947 { "Sub-TLV", "ancp.sub_tlv_type",
949 VALS(dsl_line_attrs
), 0x0,
952 { &hf_ancp_dsl_line_stlv_len
,
953 { "Sub-TLV Length", "ancp.sub_tlv_len",
958 { &hf_ancp_dsl_line_stlv_value
,
959 { "Value", "ancp.dsl_line_param",
964 { &hf_ancp_ext_tlv_value_str
,
965 { "Value", "ancp.ext_tlv.value",
966 FT_STRING
, BASE_NONE
,
970 { &hf_ancp_oam_opaque
,
971 { "Opaque", "ancp.oam.opaque", /* There will be 2 such 32b vals */
976 { &hf_ancp_oam_loopb_cnt
,
977 { "OAM Loopback Count", "ancp.oam.loopback_count",
982 { &hf_ancp_oam_timeout
,
983 { "OAM Timeout", "ancp.oam.timeout",
990 /* Setup protocol subtree array */
991 static int *ett
[] = {
997 &ett_ancp_sender_name
,
998 &ett_ancp_receiver_name
,
999 &ett_ancp_sender_port
,
1000 &ett_ancp_receiver_port
,
1002 &ett_ancp_sender_instance
,
1004 &ett_ancp_receiver_instance
,
1005 &ett_ancp_tech_type
,
1013 &ett_ancp_submsg_num
,
1015 &ett_ancp_port_sess_num
,
1016 &ett_ancp_evt_seq_num
,
1020 &ett_ancp_num_ext_tlvs
,
1021 &ett_ancp_ext_tlv_type
,
1022 &ett_ancp_dsl_line_stlv_type
,
1023 &ett_ancp_dsl_line_stlv_val
,
1024 &ett_ancp_ext_tlv_value_str
,
1025 &ett_ancp_oam_opaque
,
1026 &ett_ancp_oam_loopb_cnt
,
1027 &ett_ancp_oam_timeout
,
1030 proto_ancp
= proto_register_protocol (
1031 "Access Node Control Protocol",
1036 proto_register_field_array(proto_ancp
, hf
, array_length(hf
));
1037 proto_register_subtree_array(ett
, array_length(ett
));
1038 ancp_tap
= register_tap("ancp");
1040 ancp_handle
= register_dissector("ancp", dissect_ancp
, proto_ancp
);
1044 proto_reg_handoff_ancp(void)
1046 dissector_add_uint_with_preference("tcp.port", ANCP_PORT
, ancp_handle
);
1047 stats_tree_register("ancp", "ancp", "ANCP", 0,
1048 ancp_stats_tree_packet
, ancp_stats_tree_init
, NULL
);
1052 * Editor modelines - https://www.wireshark.org/tools/modelines.html
1057 * indent-tabs-mode: nil
1060 * vi: set shiftwidth=4 tabstop=8 expandtab:
1061 * :indentSize=4:tabSize=8:noTabs=true: