2 * Routines for ldp packet disassembly
4 * $Id: packet-ldp.c,v 1.14 2001/01/25 06:14:14 guy Exp $
6 * Copyright (c) November 2000 by Richard Sharpe <rsharpe@ns.aus.com>
8 * Ethereal - Network traffic analyzer
10 * Copyright 1999 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 #ifdef HAVE_SYS_TYPES_H
31 # include <sys/types.h>
34 #ifdef HAVE_NETINET_IN_H
35 #include <netinet/in.h>
48 #define TCP_PORT_LDP 646
49 #define UDP_PORT_LDP 646
51 void proto_reg_handoff_ldp(void);
53 static int proto_ldp = -1;
55 /* Delete the following if you do not use it, or add to it if you need */
56 static int hf_ldp_req = -1;
57 static int hf_ldp_rsp = -1;
58 static int hf_ldp_version = -1;
59 static int hf_ldp_pdu_len = -1;
60 static int hf_ldp_lsr = -1;
61 static int hf_ldp_ls_id = -1;
62 static int hf_ldp_msg_type = -1;
63 static int hf_ldp_msg_len = -1;
64 static int hf_ldp_msg_id = -1;
65 static int hf_ldp_tlv_value = -1;
66 static int hf_ldp_tlv_type = -1;
67 static int hf_ldp_tlv_len = -1;
68 static int hf_ldp_tlv_val_hold = -1;
69 static int hf_ldp_tlv_val_target = -1;
70 static int hf_ldp_tlv_val_request = -1;
71 static int hf_ldp_tlv_val_res = -1;
72 static int hf_ldp_tlv_config_seqno = -1;
73 static int hf_ldp_tlv_fec_wc = -1;
74 static int hf_ldp_tlv_fec_af = -1;
75 static int hf_ldp_tlv_fec_len = -1;
76 static int hf_ldp_tlv_fec_pfval = -1;
77 static int hf_ldp_tlv_generic_label = -1;
79 static int ett_ldp = -1;
80 static int ett_ldp_header = -1;
81 static int ett_ldp_ldpid = -1;
82 static int ett_ldp_message = -1;
83 static int ett_ldp_tlv = -1;
84 static int ett_ldp_tlv_val = -1;
85 static int ett_ldp_fec = -1;
87 static int tcp_port = 0;
88 static int udp_port = 0;
90 /* Add your functions here */
92 static int global_ldp_tcp_port = TCP_PORT_LDP;
93 static int global_ldp_udp_port = UDP_PORT_LDP;
96 * The following define all the TLV types I know about
99 #define TLV_FEC 0x0100
100 #define TLV_ADDRESS_LIST 0x0101
101 #define TLV_HOP_COUNT 0x0103
102 #define TLV_PATH_VECTOR 0x0104
103 #define TLV_GENERIC_LABEL 0x0200
104 #define TLV_ATM_LABEL 0x0201
105 #define TLV_FRAME_LABEL 0x0202
106 #define TLV_STATUS 0x0300
107 #define TLV_EXTENDED_STATUS 0x0301
108 #define TLV_RETURNED_PDU 0x0302
109 #define TLV_RETURNED_MESSAGE 0x0303
110 #define TLV_COMMON_HELLO_PARMS 0x0400
111 #define TLV_IPV4_TRANSPORT_ADDRESS 0x0401
112 #define TLV_CONFIGURATION_SEQNO 0x0402
113 #define TLV_IPV6_TRANSPORT_ADDRESS 0x0403
114 #define TLV_COMMON_SESSION_PARMS 0x0500
115 #define TLV_ATM_SESSION_PARMS 0x0501
116 #define TLV_FRAME_RELAY_SESSION_PARMS 0x0502
117 #define TLV_LABEL_REQUEST_MESSAGE_ID 0x0600
119 #define TLV_VENDOR_PRIVATE_START 0x3E00
120 #define TLV_VENDOR_PROVATE_END 0x3EFF
121 #define TLV_EXPERIMENTAL_START 0x3F00
122 #define TLV_EXPERIMENTAL_END 0x3FFF
124 static const value_string tlv_type_names[] = {
125 { TLV_FEC, "Forwarding Equivalence Classes" },
126 { TLV_ADDRESS_LIST, "Address List"},
127 { TLV_HOP_COUNT, "Hop Count"},
128 { TLV_PATH_VECTOR, "Path Vector"},
129 { TLV_GENERIC_LABEL, "Generic Label"},
130 { TLV_ATM_LABEL, "Frame Label"},
131 { TLV_STATUS, "Status"},
132 { TLV_EXTENDED_STATUS, "Extended Status"},
133 { TLV_RETURNED_PDU, "Returned PDU"},
134 { TLV_RETURNED_MESSAGE, "Returned Message"},
135 { TLV_COMMON_HELLO_PARMS, "Common Hello Parameters"},
136 { TLV_IPV4_TRANSPORT_ADDRESS, "IPv4 Transport Address"},
137 { TLV_CONFIGURATION_SEQNO, "Configuration Sequence Number"},
138 { TLV_IPV6_TRANSPORT_ADDRESS, "IPv6 Transport Address"},
139 { TLV_COMMON_SESSION_PARMS, "Common Session Parameters"},
140 { TLV_ATM_SESSION_PARMS, "ATM Session Parameters"},
141 { TLV_FRAME_RELAY_SESSION_PARMS, "Frame Relay Session Parameters"},
142 { TLV_LABEL_REQUEST_MESSAGE_ID, "Label Request Message ID"},
147 * The following define all the message types I know about
150 #define LDP_NOTIFICATION 0x0001
151 #define LDP_HELLO 0x0100
152 #define LDP_INITIALIZATION 0x0200
153 #define LDP_KEEPALIVE 0x0201
154 #define LDP_ADDRESS 0x0300
155 #define LDP_ADDRESS_WITHDRAWAL 0x0301
156 #define LDP_LABEL_MAPPING 0x0400
157 #define LDP_LABEL_REQUEST 0x0401
158 #define LDP_LABEL_WITHDRAWAL 0x0402
159 #define LDP_LABEL_RELEASE 0x0403
160 #define LDP_LABEL_ABORT_REQUEST 0x0404
161 #define LDP_VENDOR_PRIVATE_START 0x3E00
162 #define LDP_VENDOR_PRIVATE_END 0x3EFF
163 #define LDP_EXPERIMENTAL_MESSAGE_START 0x3F00
164 #define LDP_EXPERIMENTAL_MESSAGE_END 0x3FFF
166 static const value_string ldp_message_types[] = {
167 {LDP_NOTIFICATION, "Notification"},
168 {LDP_HELLO, "Hello"},
169 {LDP_INITIALIZATION, "Initialization"},
170 {LDP_KEEPALIVE, "Keep Alive"},
171 {LDP_ADDRESS, "Address"},
172 {LDP_ADDRESS_WITHDRAWAL, "Address Withdrawal"},
173 {LDP_LABEL_MAPPING, "Label Mapping"},
174 {LDP_LABEL_REQUEST, "Label Request"},
175 {LDP_LABEL_WITHDRAWAL, "Label Withdrawal"},
176 {LDP_LABEL_RELEASE, "Label Release"},
177 {LDP_LABEL_ABORT_REQUEST, "Label Abort Request"},
181 static const true_false_string hello_targeted_vals = {
186 static const value_string fec_types[] = {
189 {3, "Host Address FEC"},
193 static const value_string fec_af_types[] = {
198 {4, "HDLC (8-bit multidrop)"},
201 {10, "X.121 (X.25, Frame Relay)"},
207 static const true_false_string hello_requested_vals = {
208 "Source requests periodic hellos",
209 "Source does not request periodic hellos"
212 /* Dissect the common hello params */
214 void dissect_tlv_common_hello_parms(tvbuff_t *tvb, guint offset, proto_tree *tree, int rem)
216 proto_tree *ti = NULL, *val_tree = NULL;
220 ti = proto_tree_add_bytes(tree, hf_ldp_tlv_value, tvb, offset, rem,
221 tvb_get_ptr(tvb, offset, rem));
223 val_tree = proto_item_add_subtree(ti, ett_ldp_tlv_val);
225 proto_tree_add_item(val_tree, hf_ldp_tlv_val_hold, tvb, offset, 2, FALSE);
227 proto_tree_add_boolean(val_tree, hf_ldp_tlv_val_target, tvb, offset + 2, 2, FALSE);
228 proto_tree_add_boolean(val_tree, hf_ldp_tlv_val_request, tvb, offset + 2, 2, FALSE);
229 proto_tree_add_item(val_tree, hf_ldp_tlv_val_res, tvb, offset + 2, 2, FALSE);
234 /* Dissect a TLV and return the number of bytes consumed ... */
236 int dissect_tlv(tvbuff_t *tvb, guint offset, proto_tree *tree, int rem)
238 guint16 message = tvb_get_ntohs(tvb, offset),
239 length = tvb_get_ntohs(tvb, offset + 2),
240 pad = 0, fec_len = 0;
241 proto_tree *ti = NULL, *tlv_tree = NULL;
243 /* Hmmm, check for illegal alignment padding */
245 if (message == 0x00) {
247 proto_tree_add_text(tree, tvb, offset, 2, "Illegal Padding: %04X", message);
248 offset += 2; pad = 2;
249 message = tvb_get_ntohs(tvb, offset);
250 length = tvb_get_ntohs(tvb, offset + 2);
254 length = MIN(length, rem); /* Don't go haywire if a problem ... */
258 /* FIXME: Account for vendor and special messages */
260 ti = proto_tree_add_text(tree, tvb, offset, length + 4, "%s",
261 val_to_str(message, tlv_type_names, "Unknown TLV type (0x%04X)"));
263 tlv_tree = proto_item_add_subtree(ti, ett_ldp_tlv);
265 proto_tree_add_item(tlv_tree, hf_ldp_tlv_type, tvb, offset, 2, FALSE);
267 proto_tree_add_item(tlv_tree, hf_ldp_tlv_len, tvb, offset + 2, 2, FALSE);
271 case TLV_FEC: /* Process an FEC */
273 offset += 4; /* Skip the TLV header */
277 while (fec_len > 0) {
278 proto_tree *fec_tree = NULL;
281 switch (tvb_get_guint8(tvb, offset)) {
282 case 1: /* Wild Card */
284 proto_tree_add_item(tlv_tree, hf_ldp_tlv_fec_wc, tvb, offset, 4, FALSE);
293 /* Add a subtree for this ... */
295 ti = proto_tree_add_text(tlv_tree, tvb, offset, 8, "Prefix FEC Element");
297 fec_tree = proto_item_add_subtree(ti, ett_ldp_fec);
299 proto_tree_add_item(fec_tree, hf_ldp_tlv_fec_wc, tvb, offset, 1, FALSE);
303 /* XXX - the address family length should be extracted and used to
304 dissect the prefix field. */
305 proto_tree_add_item(fec_tree, hf_ldp_tlv_fec_af, tvb, offset, 2, FALSE);
309 proto_tree_add_item(fec_tree, hf_ldp_tlv_fec_len, tvb, offset, 1, FALSE);
313 proto_tree_add_item(fec_tree, hf_ldp_tlv_fec_pfval, tvb, offset, 4, FALSE);
319 case 3: /* Host address */
321 /* XXX - write me. */
329 default: /* Unknown */
331 /* XXX - do all FEC's have a length that's a multiple of 4? */
332 /* Hmmm, don't think so. Will check. RJS. */
346 case TLV_GENERIC_LABEL:
348 proto_tree_add_item(tlv_tree, hf_ldp_tlv_generic_label, tvb, offset + 4, 4, FALSE);
352 case TLV_COMMON_HELLO_PARMS:
354 dissect_tlv_common_hello_parms(tvb, offset + 4, tlv_tree, length);
357 case TLV_CONFIGURATION_SEQNO:
359 proto_tree_add_item(tlv_tree, hf_ldp_tlv_config_seqno, tvb, offset + 4, 4, FALSE);
363 proto_tree_add_bytes(tlv_tree, hf_ldp_tlv_value, tvb, offset + 4,
364 length, tvb_get_ptr(tvb, offset + 4, length));
371 return length + pad + 4; /* Length of the value field + header */
376 * Each of these routines dissect the relevant messages, but the msg header
377 * has already been dissected.
381 dissect_ldp_notification(tvbuff_t *tvb, guint offset, packet_info *pinfo, proto_tree *tree, guint length)
383 guint rem = length, cc = 0;
387 rem -= (cc = dissect_tlv(tvb, offset, tree, rem));
394 /* Dissect a Hello Message ... */
396 dissect_ldp_hello(tvbuff_t *tvb, guint offset, packet_info *pinfo, proto_tree *tree, guint length)
398 guint rem = length, cc = 0;
402 rem -= (cc = dissect_tlv(tvb, offset, tree, rem));
410 dissect_ldp_initialization(tvbuff_t *tvb, guint offset, packet_info *pinfo, proto_tree *tree, guint length)
412 guint rem = length, cc = 0;
416 rem -= (cc = dissect_tlv(tvb, offset, tree, rem));
424 dissect_ldp_keepalive(tvbuff_t *tvb, guint offset, packet_info *pinfo, proto_tree *tree, guint length)
426 guint rem = length, cc = 0;
430 rem -= (cc = dissect_tlv(tvb, offset, tree, rem));
438 dissect_ldp_address(tvbuff_t *tvb, guint offset, packet_info *pinfo, proto_tree *tree, guint length)
440 guint rem = length, cc = 0;
444 rem -= (cc = dissect_tlv(tvb, offset, tree, rem));
452 dissect_ldp_address_withdrawal(tvbuff_t *tvb, guint offset, packet_info *pinfo, proto_tree *tree, guint length)
454 guint rem = length, cc = 0;
458 rem -= (cc = dissect_tlv(tvb, offset, tree, rem));
466 dissect_ldp_label_mapping(tvbuff_t *tvb, guint offset, packet_info *pinfo, proto_tree *tree, guint length)
468 guint rem = length, cc = 0;
472 rem -= (cc = dissect_tlv(tvb, offset, tree, rem));
480 dissect_ldp_label_request(tvbuff_t *tvb, guint offset, packet_info *pinfo, proto_tree *tree, guint length)
482 guint rem = length, cc = 0;
486 rem -= (cc = dissect_tlv(tvb, offset, tree, rem));
494 dissect_ldp_label_withdrawal(tvbuff_t *tvb, guint offset, packet_info *pinfo, proto_tree *tree, guint length)
496 guint rem = length, cc = 0;
500 rem -= (cc = dissect_tlv(tvb, offset, tree, rem));
508 dissect_ldp_label_release(tvbuff_t *tvb, guint offset, packet_info *pinfo, proto_tree *tree, guint length)
510 guint rem = length, cc = 0;
514 rem -= (cc = dissect_tlv(tvb, offset, tree, rem));
522 dissect_ldp_label_abort_request(tvbuff_t *tvb, guint offset, packet_info *pinfo, proto_tree *tree, guint length)
524 guint rem = length, cc = 0;
528 rem -= (cc = dissect_tlv(tvb, offset, tree, rem));
536 dissect_ldp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
538 proto_tree *ldp_tree = NULL,
540 *hdr_tree = NULL, *ldpid_tree = NULL;
541 int offset = 0, msg_cnt = 0;
542 guint16 ldp_message = 0;
544 if (check_col(pinfo->fd, COL_PROTOCOL))
545 col_add_str(pinfo->fd, COL_PROTOCOL, "LDP");
546 if (check_col(pinfo->fd, COL_INFO))
547 col_clear(pinfo->fd, COL_INFO);
549 if (tree) { /* Build the tree info ..., this is wrong! FIXME */
551 ti = proto_tree_add_item(tree, proto_ldp, tvb, offset,
552 tvb_length_remaining(tvb, offset), FALSE);
553 ldp_tree = proto_item_add_subtree(ti, ett_ldp);
555 ti = proto_tree_add_text(ldp_tree, tvb, 0, 10, "Header");
557 hdr_tree = proto_item_add_subtree(ti, ett_ldp_header);
559 proto_tree_add_item(hdr_tree, hf_ldp_version, tvb, offset, 2, FALSE);
563 proto_tree_add_item(hdr_tree, hf_ldp_pdu_len, tvb, offset, 2, FALSE);
567 ti = proto_tree_add_text(hdr_tree, tvb, offset, 6, "LDP Identifier");
569 ldpid_tree = proto_item_add_subtree(ti, ett_ldp_ldpid);
571 proto_tree_add_item(ldpid_tree, hf_ldp_lsr, tvb, offset, 4, FALSE);
575 proto_tree_add_item(ldpid_tree, hf_ldp_ls_id, tvb, offset, 2, FALSE);
583 while (tvb_length_remaining(tvb, offset) > 0) { /* Dissect a message */
587 ldp_message = tvb_get_ntohs(tvb, offset) & 0x7FFF; /* Get the message type */
589 msg_len = tvb_get_ntohs(tvb, offset + 2);
591 if (check_col(pinfo->fd, COL_INFO)) { /* Check the type ... */
594 col_append_fstr(pinfo->fd, COL_INFO, ", %s",
595 val_to_str(ldp_message, ldp_message_types, "Unknown Message (0x%04X)"));
597 col_add_fstr(pinfo->fd, COL_INFO, "%s",
598 val_to_str(ldp_message, ldp_message_types, "Unknown Message (0x%04X)"));
606 proto_tree *ti = NULL, *msg_tree = NULL;
608 /* FIXME: Account for vendor and experimental messages */
610 ti = proto_tree_add_text(ldp_tree, tvb, offset, msg_len + 4, "%s",
611 val_to_str(ldp_message, ldp_message_types, "Unknown Message (0x%04X)"));
613 msg_tree = proto_item_add_subtree(ti, ett_ldp_message);
615 proto_tree_add_item(msg_tree, hf_ldp_msg_type, tvb, offset, 2, FALSE);
617 proto_tree_add_item(msg_tree, hf_ldp_msg_len, tvb, offset + 2, 2, FALSE);
619 proto_tree_add_item(msg_tree, hf_ldp_msg_id, tvb, offset + 4, 4, FALSE);
621 switch (ldp_message) {
623 case LDP_NOTIFICATION:
625 dissect_ldp_notification(tvb, offset + 8, pinfo, msg_tree, msg_len - 4);
631 dissect_ldp_hello(tvb, offset + 8, pinfo, msg_tree, msg_len - 4);
635 case LDP_INITIALIZATION:
637 dissect_ldp_initialization(tvb, offset + 8, pinfo, msg_tree, msg_len - 4);
643 dissect_ldp_keepalive(tvb, offset + 8, pinfo, msg_tree, msg_len - 4);
649 dissect_ldp_address(tvb, offset + 8, pinfo, msg_tree, msg_len - 4);
653 case LDP_ADDRESS_WITHDRAWAL:
655 dissect_ldp_address_withdrawal(tvb, offset + 8, pinfo, msg_tree, msg_len - 4);
659 case LDP_LABEL_MAPPING:
661 dissect_ldp_label_mapping(tvb, offset + 8, pinfo, msg_tree, msg_len - 4);
665 case LDP_LABEL_REQUEST:
667 dissect_ldp_label_request(tvb, offset + 8, pinfo, msg_tree, msg_len - 4);
671 case LDP_LABEL_WITHDRAWAL:
673 dissect_ldp_label_withdrawal(tvb, offset + 8, pinfo, msg_tree, msg_len - 4);
677 case LDP_LABEL_RELEASE:
679 dissect_ldp_label_release(tvb, offset + 8, pinfo, msg_tree, msg_len - 4);
683 case LDP_LABEL_ABORT_REQUEST:
685 dissect_ldp_label_abort_request(tvb, offset + 8, pinfo, msg_tree, msg_len - 4);
691 /* Some sort of unknown message, treat as undissected data */
699 offset += msg_len + 4;
704 /* Register all the bits needed with the filtering engine */
707 proto_register_ldp(void)
709 static hf_register_info hf[] = {
711 /* Change the following to the type you need */
712 { "Request", "ldp.req", FT_BOOLEAN, BASE_NONE, NULL, 0x0, "" }},
715 { "Response", "ldp.rsp", FT_BOOLEAN, BASE_NONE, NULL, 0x0, "" }},
718 { "Version", "ldp.hdr.version", FT_UINT16, BASE_DEC, NULL, 0x0, "LDP Version Number" }},
721 { "PDU Length", "ldp.hdr.pdu_len", FT_UINT16, BASE_DEC, NULL, 0x0, "LDP PDU Length"}},
724 { "LSR ID", "ldp.hdr.ldpid.lsr", FT_UINT32, BASE_HEX, NULL, 0x0, "LDP Label Space Router ID"}},
727 { "Label Space ID", "ldp.hdr.ldpid.lsid", FT_UINT16, BASE_HEX, NULL, 0x0, "LDP Label Space ID"}},
730 { "Message Type", "ldp.msg.type", FT_UINT16, BASE_HEX, VALS(ldp_message_types), 0x0, "LDP message type"}},
733 { "Message Length", "ldp.msg.len", FT_UINT16, BASE_DEC, NULL, 0x0, "LDP Message Length (excluding message type and len)"}},
736 { "Message ID", "ldp.msg.id", FT_UINT32, BASE_HEX, NULL, 0x0, "LDP Message ID"}},
739 { "TLV Type", "ldp.msg.tlv.type", FT_UINT16, BASE_HEX, VALS(tlv_type_names), 0x0, "TLV Type Field"}},
742 {"TLV Length", "ldp.msg.tlv.len", FT_UINT16, BASE_DEC, NULL, 0x0, "TLV Length Field"}},
745 { "TLV Value", "ldp.msg.tlv.value", FT_BYTES, BASE_NONE, NULL, 0x0, "TLV Value Bytes"}},
747 { &hf_ldp_tlv_val_hold,
748 { "Hold Time", "ldp.msg.tlv.hello.hold", FT_UINT16, BASE_DEC, NULL, 0x0, "Hello Common Parameters Hold Time"}},
750 { &hf_ldp_tlv_val_target,
751 { "Targeted Hello", "ldp.msg.tlv.hello.targeted", FT_BOOLEAN, 8, TFS(&hello_targeted_vals), 0x80, "Hello Common Parameters Targeted Bit"}},
753 { &hf_ldp_tlv_val_request,
754 { "Hello Requested", "ldp,msg.tlv.hello.requested", FT_BOOLEAN, 8, TFS(&hello_requested_vals), 0x40, "Hello Common Parameters Hello Requested Bit" }},
756 { &hf_ldp_tlv_val_res,
757 { "Reserved", "ldp.msg.tlv.hello.res", FT_UINT16, BASE_HEX, NULL, 0x3FFF, "Hello Common Parameters Reserved Field"}},
759 { &hf_ldp_tlv_config_seqno,
760 { "Configuration Sequence Number", "ldp.msg.tlv.hello.cnf_seqno", FT_UINT32, BASE_HEX, NULL, 0x0, "Hello COnfiguration Sequence Number"}},
762 { &hf_ldp_tlv_fec_wc,
763 { "FEC Element Type", "ldp.msg.tlv.fec.type", FT_UINT8, BASE_DEC, VALS(fec_types), 0x0, "Forwarding Equivalence Class Element Types"}},
765 { &hf_ldp_tlv_fec_af,
766 { "FEC Element Address Type", "ldp.msg.tlv.fec.af", FT_UINT16, BASE_DEC, VALS(fec_af_types), 0x0, "Forwarding Equivalence Class Element Address Family"}},
768 { &hf_ldp_tlv_fec_len,
769 { "FEC Element Length", "ldp.msg.tlv.fec.len", FT_UINT8, BASE_DEC, NULL, 0x0, "Forwarding Equivalence Class Element Length"}},
771 { &hf_ldp_tlv_fec_pfval,
772 { "FEC Element Prefix Value", "ldp.msg.tlv.fec.pfval", FT_UINT32, BASE_HEX, NULL, 0x0, "Forwarding Equivalence Class Element Prefix"}},
774 { &hf_ldp_tlv_generic_label,
775 { "Generic Label", "ldp.msg.tlv.label", FT_UINT32, BASE_HEX, NULL, 0x0, "Label Mapping Generic Label"}},
778 static gint *ett[] = {
787 module_t *ldp_module;
789 proto_ldp = proto_register_protocol("Label Distribution Protocol",
792 proto_register_field_array(proto_ldp, hf, array_length(hf));
793 proto_register_subtree_array(ett, array_length(ett));
795 /* Register our configuration options for , particularly our port */
797 ldp_module = prefs_register_protocol(proto_ldp, proto_reg_handoff_ldp);
799 prefs_register_uint_preference(ldp_module, "tcp.port", "LDP TCP Port",
800 "Set the port for messages (if other"
801 " than the default of 646)",
802 10, &global_ldp_tcp_port);
804 prefs_register_uint_preference(ldp_module, "udp.port", "LDP UDP Port",
805 "Set the port for messages (if other"
806 " than the default of 646)",
807 10, &global_ldp_udp_port);
811 /* The registration hand-off routine */
813 proto_reg_handoff_ldp(void)
815 static int ldp_prefs_initialized = FALSE;
817 if (ldp_prefs_initialized) {
819 dissector_delete("tcp.port", tcp_port, dissect_ldp);
820 dissector_delete("udp.port", udp_port, dissect_ldp);
825 ldp_prefs_initialized = TRUE;
829 /* Set our port number for future use */
831 tcp_port = global_ldp_tcp_port;
832 udp_port = global_ldp_udp_port;
834 dissector_add("tcp.port", global_ldp_tcp_port, dissect_ldp, proto_ldp);
835 dissector_add("udp.port", global_ldp_udp_port, dissect_ldp, proto_ldp);