3 * Copyright (C) James R. Leu 2000
6 * This software is covered under the LGPL, for more
7 * info check out http://www.gnu.org/copyleft/lgpl.html
10 #ifndef _LDP_STRUCT_H_
11 #define _LDP_STRUCT_H_
13 #include "mpls_struct.h"
14 #include "mpls_list.h"
15 #include "mpls_refcnt.h"
17 MPLS_LIST_ROOT(ldp_outlabel_list
, ldp_outlabel
);
18 MPLS_LIST_ROOT(ldp_resource_list
, ldp_resource
);
19 MPLS_LIST_ROOT(ldp_hop_list_list
, ldp_hop_list
);
20 MPLS_LIST_ROOT(ldp_inlabel_list
, ldp_inlabel
);
21 MPLS_LIST_ROOT(ldp_session_list
, ldp_session
);
22 MPLS_LIST_ROOT(ldp_entity_list
, ldp_entity
);
23 MPLS_LIST_ROOT(ldp_tunnel_list
, ldp_tunnel
);
24 MPLS_LIST_ROOT(ldp_addr_list
, ldp_addr
);
25 MPLS_LIST_ROOT(ldp_attr_list
, ldp_attr
);
26 MPLS_LIST_ROOT(ldp_peer_list
, ldp_peer
);
27 MPLS_LIST_ROOT(ldp_l2cc_list
, ldp_l2cc
);
28 MPLS_LIST_ROOT(_ldp_hop_list
, ldp_hop
);
29 MPLS_LIST_ROOT(ldp_adj_list
, ldp_adj
);
30 MPLS_LIST_ROOT(ldp_fec_list
, ldp_fec
);
31 MPLS_LIST_ROOT(ldp_fs_list
, ldp_fs
);
32 MPLS_LIST_ROOT(ldp_if_list
, ldp_if
);
34 typedef struct ldp_attr_list ldp_attr_list
;
40 } ldp_entity_type_enum
;
43 LDP_CONTROL_INDEPENDENT
= 1,
48 LDP_RETENTION_LIBERAL
= 1,
49 LDP_RETENTION_CONSERVATIVE
61 LDP_LOOP_HOPCOUNT_PATHVECTOR
,
63 } ldp_loop_detection_mode
;
66 LDP_TRANS_ADDR_NONE
= 0,
67 LDP_TRANS_ADDR_INTERFACE
,
69 } ldp_trans_addr_mode
;
72 LDP_DISTRIBUTION_UNSOLICITED
= 0,
73 LDP_DISTRIBUTION_ONDEMAND
= 1,
74 } ldp_distribution_mode
;
98 LDP_EVENT_TCP_CONNECT
,
106 LDP_STATE_INITIALIZED
,
109 LDP_STATE_OPERATIONAL
113 LDP_KEEPALIVE_RECV
= 1,
115 } ldp_keepalive_type
;
118 LDP_LSP_STATE_REQ_RECV
,
119 LDP_LSP_STATE_REQ_SENT
,
120 LDP_LSP_STATE_MAP_RECV
,
121 LDP_LSP_STATE_MAP_SENT
,
122 LDP_LSP_STATE_WITH_SENT
,
123 LDP_LSP_STATE_WITH_RECV
,
124 LDP_LSP_STATE_NO_LABEL_RESOURCE_SENT
,
125 LDP_LSP_STATE_NO_LABEL_RESOURCE_RECV
,
126 LDP_LSP_STATE_ABORT_SENT
,
127 LDP_LSP_STATE_ABORT_RECV
,
128 LDP_LSP_STATE_NOTIF_SENT
,
129 LDP_LSP_STATE_NOTIF_RECV
133 LDP_TRACE_FLAG_ADDRESS
= 0x00000001,
134 LDP_TRACE_FLAG_BINDING
= 0x00000002,
135 LDP_TRACE_FLAG_DEBUG
= 0x00000004,
136 LDP_TRACE_FLAG_ERROR
= 0x00000008,
137 LDP_TRACE_FLAG_EVENT
= 0x00000010,
138 LDP_TRACE_FLAG_GENERAL
= 0x00000020,
139 LDP_TRACE_FLAG_INIT
= 0x00000040,
140 LDP_TRACE_FLAG_LABEL
= 0x00000080,
141 LDP_TRACE_FLAG_NORMAL
= 0x00000100,
142 LDP_TRACE_FLAG_NOTIF
= 0x00000200,
143 LDP_TRACE_FLAG_PACKET_DUMP
= 0x00000400,
144 LDP_TRACE_FLAG_PACKET
= 0x00000800,
145 LDP_TRACE_FLAG_PATH
= 0x00001000,
146 LDP_TRACE_FLAG_PERIODIC
= 0x00002000,
147 LDP_TRACE_FLAG_POLICY
= 0x00004000,
148 LDP_TRACE_FLAG_ROUTE
= 0x00008000,
149 LDP_TRACE_FLAG_STATE
= 0x00010000,
150 LDP_TRACE_FLAG_TASK
= 0x00020000,
151 LDP_TRACE_FLAG_TIMER
= 0x00040000,
152 LDP_TRACE_FLAG_ALL
= 0xFFFFFFFF
158 LDP_NOTIF_BAD_LDP_ID
,
160 LDP_NOTIF_BAD_PDU_LEN
,
161 LDP_NOTIF_UNKNOWN_MESG
,
162 LDP_NOTIF_BAD_MESG_LEN
,
163 LDP_NOTIF_UNKNOWN_TVL
,
164 LDP_NOTIF_BAD_TLV_LEN
,
165 LDP_NOTIF_MALFORMED_TLV
,
166 LDP_NOTIF_HOLD_TIMER_EXPIRED
,
168 LDP_NOTIF_LOOP_DETECTED
,
169 LDP_NOTIF_UNKNOWN_FEC
,
171 LDP_NOTIF_NO_LABEL_RESOURCES_AVAILABLE
,
172 LDP_NOTIF_LABEL_RESOURCES_AVAILABLE
,
173 LDP_NOTIF_SESSION_REJECTED_NO_HELLO
,
174 LDP_NOTIF_SESSION_REJECTED_PARAMETERS_ADVERTISEMENT_MODE
,
175 LDP_NOTIF_SESSION_REJECTED_PARAMETERS_MAX_PDU_LEN
,
176 LDP_NOTIF_SESSION_REJECTED_PARAMETERS_LABEL_RANGE
,
177 LDP_NOTIF_KEEPALIVE_TIMER_EXPIRED
,
178 LDP_NOTIF_LABEL_ABORT
,
179 LDP_NOTIF_MISSING_MSG_PARAMS
,
180 LDP_NOTIF_UNSUPORTED_AF
,
181 LDP_NOTIF_SESSION_REJECTED_BAD_KEEPALIVE_TIME
,
182 LDP_NOTIF_INTERNAL_ERROR
185 #define LDP_STATE_NUM 6
186 #define LDP_EVENT_NUM 10
187 #define LDP_FUNC_NUM 10
189 #include "ldp_defaults.h"
190 #include "mpls_handle_type.h"
191 #include "ldp_nortel.h"
193 typedef struct ldp_mesg
{
194 mplsLdpHeader_t header
;
196 mplsLdpMsg_t generic
;
197 mplsLdpInitMsg_t init
;
198 mplsLdpNotifMsg_t notif
;
199 mplsLdpHelloMsg_t hello
;
200 mplsLdpKeepAlMsg_t keep
;
201 mplsLdpAdrMsg_t addr
;
202 mplsLdpLblMapMsg_t map
;
203 mplsLdpLblReqMsg_t request
;
204 mplsLdpLbl_W_R_Msg_t release
;
205 mplsLdpLblAbortMsg_t abort
;
209 typedef struct ldp_buf
{
218 typedef struct ldp_global
{
219 struct ldp_outlabel_list outlabel
;
220 struct ldp_resource_list resource
;
221 struct ldp_hop_list_list hop_list
;
222 struct ldp_inlabel_list inlabel
;
223 struct ldp_session_list session
;
224 struct ldp_tunnel_list tunnel
;
225 struct ldp_entity_list entity
;
226 struct ldp_peer_list peer
;
227 struct ldp_attr_list attr
;
228 struct ldp_l2cc_list l2cc
;
229 struct ldp_adj_list adj
;
230 struct ldp_if_list iff
;
232 mpls_lock_handle global_lock
;
233 mpls_instance_handle user_data
;
235 mpls_tree_handle addr_tree
;
236 mpls_tree_handle fec_tree
;
237 mpls_tree_handle nh_tree
;
239 mpls_socket_handle hello_socket
;
240 mpls_socket_handle listen_socket
;
242 mpls_timer_mgr_handle timer_handle
;
243 mpls_socket_mgr_handle socket_handle
;
244 mpls_fib_handle fib_handle
;
245 mpls_ifmgr_handle ifmgr_handle
;
248 mpls_cfg_handle lsr_handle
;
250 mpls_mpls_handle mpls_handle
;
254 * CSN changes with every MIB set, BUT only when a entity goes through
255 * shutdown/startup cycle will it grab the new CSN and use it in hellos
257 uint32_t configuration_sequence_number
;
260 * Message ID increaments with EVERY message, this means it will roll over
262 uint32_t message_identifier
;
264 struct mpls_inet_addr lsr_identifier
;
265 mpls_bool send_address_messages
;
266 mpls_bool send_lsrid_mapping
;
267 ldp_control_mode lsp_control_mode
;
268 ldp_retention_mode label_retention_mode
;
269 ldp_repaire_mode lsp_repair_mode
;
270 mpls_bool propagate_release
;
271 mpls_bool label_merge
;
272 ldp_loop_detection_mode loop_detection_mode
;
273 mpls_bool ttl_less_domain
;
274 uint16_t local_tcp_port
;
275 uint16_t local_udp_port
;
276 uint16_t backoff_step
;
277 int no_route_to_peer_time
;
280 * some global defaults, entities will inherit these values unless
281 * instructed otherwise
283 struct mpls_inet_addr transport_address
;
284 uint16_t keepalive_timer
;
285 uint16_t keepalive_interval
;
286 uint16_t hellotime_timer
;
287 uint16_t hellotime_interval
;
289 mpls_admin_state_enum admin_state
;
292 typedef struct ldp_entity
{
294 MPLS_LIST_ELEM(ldp_entity
) _global
;
295 struct ldp_adj_list adj_root
;
297 ldp_entity_type_enum entity_type
;
299 struct ldp_peer
*peer
;
303 ldp_state_enum state
;
304 uint32_t inherit_flag
;
307 struct mpls_inet_addr transport_address
;
308 uint8_t protocol_version
;
309 uint16_t remote_tcp_port
;
310 uint16_t remote_udp_port
;
312 uint16_t keepalive_timer
;
313 uint16_t keepalive_interval
;
314 uint16_t hellotime_timer
;
315 uint16_t hellotime_interval
;
316 uint16_t session_setup_count
;
317 uint16_t session_backoff_timer
;
318 ldp_distribution_mode label_distribution_mode
;
319 uint8_t path_vector_limit
;
320 uint8_t hop_count_limit
;
321 uint8_t label_request_count
;
322 uint16_t label_request_timer
;
323 ldp_loop_detection_mode loop_detection_mode
;
324 mpls_admin_state_enum admin_state
;
325 mpls_bool remote_in_ttl_less_domain
;
326 mpls_bool request_retry
;
332 /* only used for cfg gets */
337 typedef struct ldp_if
{
339 MPLS_LIST_ELEM(ldp_if
) _global
;
340 struct ldp_entity
*entity
;
341 mpls_timer_handle hellotime_send_timer
;
342 int hellotime_send_timer_duration
;
345 struct mpls_inet_addr local_source_address
;
346 mpls_if_handle handle
;
348 struct ldp_mesg
*tx_message
;
349 struct ldp_buf
*tx_buffer
;
350 struct ldp_mesg
*hello
;
352 /* YES this is a dest, it is what we use for sendto */
353 struct mpls_dest dest
;
355 char name
[MPLS_MAX_IF_NAME
];
356 mpls_oper_state_enum oper_state
;
358 /* only used for cfg gets */
359 uint32_t entity_index
;
362 typedef struct ldp_peer
{
364 MPLS_LIST_ELEM(ldp_peer
) _global
;
365 struct ldp_entity
*entity
;
366 mpls_timer_handle no_route_to_peer_timer
;
367 mpls_timer_handle hellotime_send_timer
;
368 int hellotime_send_timer_duration
;
371 struct mpls_inet_addr local_source_address
;
373 struct ldp_mesg
*tx_message
;
374 struct ldp_buf
*tx_buffer
;
375 struct ldp_mesg
*hello
;
377 /* YES this is a dest, it is what we use for sendto */
378 struct mpls_dest dest
;
379 ldp_role_enum target_role
;
381 char peer_name
[MPLS_MAX_IF_NAME
];
382 mpls_oper_state_enum oper_state
;
384 /* only used for cfg gets */
385 uint32_t entity_index
;
388 typedef struct ldp_session
{
390 MPLS_LIST_ELEM(ldp_session
) _global
;
391 struct ldp_outlabel_list outlabel_root
;
392 struct mpls_link_list inlabel_root
;
393 struct mpls_link_list addr_root
;
394 struct ldp_attr_list attr_root
;
395 struct ldp_adj_list adj_root
;
396 mpls_timer_handle initial_distribution_timer
;
397 mpls_timer_handle keepalive_recv_timer
;
398 mpls_timer_handle keepalive_send_timer
;
400 ldp_state_enum state
;
402 ldp_notif_status shutdown_notif
;
403 mpls_bool shutdown_fatal
;
404 mpls_socket_handle socket
;
405 mpls_timer_handle backoff_timer
;
408 /* operational values learned from initialization */
411 int oper_keepalive_interval
;
412 int oper_path_vector_limit
;
413 ldp_distribution_mode oper_distribution_mode
;
414 ldp_loop_detection_mode oper_loop_detection
;
416 /* these values are learned form the remote peer */
417 ldp_distribution_mode remote_distribution_mode
;
418 mpls_bool remote_loop_detection
;
419 int remote_path_vector_limit
;
420 int remote_keepalive
;
422 mpls_dest remote_dest
;
426 uint8_t session_name
[20]; /* xxx.xxx.xxx.xxx:yyy\0 */
428 mpls_bool no_label_resource_sent
;
429 mpls_bool no_label_resource_recv
;
432 /* various message and buffers used for tx and rx */
433 struct ldp_mesg
*keepalive
;
434 struct ldp_mesg
*tx_message
;
435 struct ldp_buf
*tx_buffer
;
437 /* cached from adj's */
438 ldp_role_enum oper_role
;
440 /* these are config values come from entity */
441 ldp_loop_detection_mode cfg_loop_detection_mode
;
442 ldp_distribution_mode cfg_distribution_mode
;
443 mpls_bool cfg_remote_in_ttl_less_domain
;
444 int cfg_label_request_count
;
445 int cfg_label_request_timer
;
446 uint16_t cfg_peer_tcp_port
;
447 int cfg_path_vector_limit
;
448 int cfg_hop_count_limit
;
457 /* only used by cfg gets */
461 typedef struct ldp_adj
{
463 MPLS_LIST_ELEM(ldp_adj
) _global
;
464 MPLS_LIST_ELEM(ldp_adj
) _session
;
465 MPLS_LIST_ELEM(ldp_adj
) _entity
;
466 struct ldp_session
*session
;
467 struct ldp_entity
*entity
;
468 mpls_timer_handle hellotime_recv_timer
;
469 mpls_oper_state_enum state
;
473 /* these values are learned form the remote peer */
474 struct mpls_inet_addr remote_transport_address
;
475 struct mpls_inet_addr remote_source_address
;
476 struct mpls_inet_addr remote_lsr_address
;
477 int remote_label_space
;
478 int remote_hellotime
;
481 /* only used by cfg gets */
482 uint32_t session_index
;
483 uint32_t entity_index
;
486 typedef struct ldp_addr
{
488 MPLS_LIST_ELEM(ldp_addr
) _addr
;
489 struct ldp_l2cc_list l2cc_root
;
490 struct mpls_link_list session_root
;
491 struct ldp_fec_list fec_root
;
492 struct mpls_inet_addr address
;
496 typedef struct ldp_outlabel
{
498 struct ldp_inlabel_list inlabel_root
;
499 struct ldp_tunnel_list tunnel_root
;
500 MPLS_LIST_ELEM(ldp_outlabel
) _global
;
501 MPLS_LIST_ELEM(ldp_outlabel
) _session
;
502 struct ldp_attr
*attr
;
503 uint32_t merge_count
;
505 struct ldp_session
*session
;
506 struct ldp_addr
*addr
;
507 struct mpls_outsegment info
;
510 /* only used by get() */
511 uint32_t session_index
;
515 typedef struct ldp_inlabel
{
517 MPLS_LIST_ELEM(ldp_inlabel
) _global
;
518 MPLS_LIST_ELEM(ldp_inlabel
) _outlabel
;
519 struct mpls_link_list session_root
;
520 struct mpls_link_list attr_root
;
521 struct ldp_outlabel
*outlabel
;
522 uint32_t reuse_count
;
524 struct mpls_insegment info
;
526 /* only used by get() */
527 uint32_t outlabel_index
;
530 typedef struct ldp_fec
{
532 MPLS_LIST_ELEM(ldp_fec
) _global
;
533 MPLS_LIST_ELEM(ldp_fec
) _inlabel
;
534 MPLS_LIST_ELEM(ldp_fec
) _outlabel
;
535 MPLS_LIST_ELEM(ldp_fec
) _tree
;
536 MPLS_LIST_ELEM(ldp_fec
) _addr
;
537 MPLS_LIST_ELEM(ldp_fec
) _fec
;
538 MPLS_LIST_ELEM(ldp_fec
) _nh
;
539 struct ldp_fs_list fs_root_us
;
540 struct ldp_fs_list fs_root_ds
;
541 struct mpls_fec info
;
544 typedef struct ldp_l2cc
{
547 MPLS_LIST_ELEM(ldp_l2cc
) _global
;
548 MPLS_LIST_ELEM(ldp_l2cc
) _addr
;
549 struct ldp_outlabel
*outlabel
;
550 struct mpls_fec info
;
551 struct mpls_inet_addr peer_addr
;
552 mpls_if_handle interface
;
553 mpls_admin_state_enum admin_state
;
555 /* only used during a get */
556 uint32_t outlabel_index
;
559 typedef struct ldp_fs
{
560 struct ldp_attr_list attr_root
;
561 MPLS_LIST_ELEM(ldp_fs
) _fec
;
562 struct ldp_session
*session
;
565 typedef struct ldp_attr
{
569 struct ldp_attr_list us_attr_root
;
570 struct ldp_attr
*ds_attr
;
575 struct ldp_session
*session
;
576 uint32_t attempt_count
;
577 mpls_timer_handle action_timer
;
578 ldp_lsp_state action
;
580 MPLS_LIST_ELEM(ldp_attr
) _session
;
581 MPLS_LIST_ELEM(ldp_attr
) _global
;
582 MPLS_LIST_ELEM(ldp_attr
) _ds_attr
;
583 MPLS_LIST_ELEM(ldp_attr
) _fs
;
585 mplsLdpFecTlv_t fecTlv
;
586 mplsLdpGenLblTlv_t genLblTlv
;
587 mplsLdpAtmLblTlv_t atmLblTlv
;
588 mplsLdpFrLblTlv_t frLblTlv
;
589 mplsLdpHopTlv_t hopCountTlv
;
590 mplsLdpPathTlv_t pathVecTlv
;
591 mplsLdpLblMsgIdTlv_t lblMsgIdTlv
;
592 mplsLdpLspIdTlv_t lspidTlv
;
593 mplsLdpTrafficTlv_t trafficTlv
;
594 mplsLdpStatusTlv_t statusTlv
;
595 mplsLdpRetMsgTlv_t retMsgTlv
;
597 uint8_t fecTlvExists
:1;
598 uint8_t genLblTlvExists
:1;
599 uint8_t atmLblTlvExists
:1;
600 uint8_t frLblTlvExists
:1;
601 uint8_t hopCountTlvExists
:1;
602 uint8_t pathVecTlvExists
:1;
603 uint8_t lblMsgIdTlvExists
:1;
604 uint8_t lspidTlvExists
:1;
605 uint8_t trafficTlvExists
:1;
606 uint8_t statusTlvExists
:1;
607 uint8_t retMsgTlvExists
:1;
609 struct ldp_outlabel
*outlabel
;
610 struct ldp_inlabel
*inlabel
;
612 /* only used for get() */
613 uint32_t inlabel_index
;
614 uint32_t outlabel_index
;
615 uint32_t session_index
;
618 typedef struct ldp_resource
{
620 MPLS_LIST_ELEM(ldp_resource
) _global
;
621 struct ldp_tunnel
*tunnel
;
628 typedef struct ldp_hop
{
630 MPLS_LIST_ELEM(ldp_hop
) _hop_list
;
631 struct ldp_hop_list
*hop_list
;
633 uint32_t hop_list_index
;
634 uint32_t path_option
;
639 typedef struct ldp_hop_list
{
641 MPLS_LIST_ELEM(ldp_hop_list
) _global
;
642 struct _ldp_hop_list hop
;
643 struct ldp_tunnel
*tunnel
;
647 typedef struct ldp_tunnel
{
649 MPLS_LIST_ELEM(ldp_tunnel
) _global
;
650 MPLS_LIST_ELEM(ldp_tunnel
) _outlabel
;
652 ldp_addr ingress_lsrid
;
653 ldp_addr egress_lsrid
;
654 char name
[MPLS_MAX_IF_NAME
];
655 mpls_bool is_interface
;
656 uint32_t outlabel_index
;
657 struct ldp_outlabel
*outlabel
;
660 uint32_t instance_prio
;
661 uint32_t resource_index
;
662 struct ldp_resource
*resource
;
663 uint32_t hop_list_index
;
664 struct ldp_hop_list
*hop_list
;
666 mpls_admin_state_enum admin_state
;
668 uint32_t primary_instance
;
669 uint32_t any_affinity
;
670 uint32_t all_affinity
;
671 uint32_t no_all_affinity
;
672 uint32_t path_in_use
;
674 mpls_bool local_protect
;
675 uint32_t session_attr
;
679 typedef void (*ldp_fib_callback
) (mpls_cfg_handle cfg
, mpls_update_enum type
,
681 typedef void (*ldp_ifmgr_callback
) (mpls_cfg_handle cfg
, mpls_update_enum type
,
682 mpls_inet_addr
*addr
);
683 typedef void (*ldp_tree_callback
) (void *);