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_nexthop_list
, ldp_nexthop
);
23 MPLS_LIST_ROOT(ldp_entity_list
, ldp_entity
);
24 MPLS_LIST_ROOT(ldp_tunnel_list
, ldp_tunnel
);
25 MPLS_LIST_ROOT(ldp_addr_list
, ldp_addr
);
26 MPLS_LIST_ROOT(ldp_attr_list
, ldp_attr
);
27 MPLS_LIST_ROOT(ldp_peer_list
, ldp_peer
);
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_DISTRIBUTION_UNSOLICITED
= 0,
67 LDP_DISTRIBUTION_ONDEMAND
= 1,
68 } ldp_distribution_mode
;
92 LDP_EVENT_TCP_CONNECT
,
100 LDP_STATE_INITIALIZED
,
103 LDP_STATE_OPERATIONAL
107 LDP_KEEPALIVE_RECV
= 1,
109 } ldp_keepalive_type
;
112 LDP_LSP_STATE_REQ_RECV
,
113 LDP_LSP_STATE_REQ_SENT
,
114 LDP_LSP_STATE_MAP_RECV
,
115 LDP_LSP_STATE_MAP_SENT
,
116 LDP_LSP_STATE_WITH_SENT
,
117 LDP_LSP_STATE_WITH_RECV
,
118 LDP_LSP_STATE_NO_LABEL_RESOURCE_SENT
,
119 LDP_LSP_STATE_NO_LABEL_RESOURCE_RECV
,
120 LDP_LSP_STATE_ABORT_SENT
,
121 LDP_LSP_STATE_ABORT_RECV
,
122 LDP_LSP_STATE_NOTIF_SENT
,
123 LDP_LSP_STATE_NOTIF_RECV
127 LDP_TRACE_FLAG_ADDRESS
= 0x00000001,
128 LDP_TRACE_FLAG_BINDING
= 0x00000002,
129 LDP_TRACE_FLAG_DEBUG
= 0x00000004,
130 LDP_TRACE_FLAG_ERROR
= 0x00000008,
131 LDP_TRACE_FLAG_EVENT
= 0x00000010,
132 LDP_TRACE_FLAG_GENERAL
= 0x00000020,
133 LDP_TRACE_FLAG_INIT
= 0x00000040,
134 LDP_TRACE_FLAG_LABEL
= 0x00000080,
135 LDP_TRACE_FLAG_NORMAL
= 0x00000100,
136 LDP_TRACE_FLAG_NOTIF
= 0x00000200,
137 LDP_TRACE_FLAG_PACKET_DUMP
= 0x00000400,
138 LDP_TRACE_FLAG_PACKET
= 0x00000800,
139 LDP_TRACE_FLAG_PATH
= 0x00001000,
140 LDP_TRACE_FLAG_PERIODIC
= 0x00002000,
141 LDP_TRACE_FLAG_POLICY
= 0x00004000,
142 LDP_TRACE_FLAG_ROUTE
= 0x00008000,
143 LDP_TRACE_FLAG_STATE
= 0x00010000,
144 LDP_TRACE_FLAG_TASK
= 0x00020000,
145 LDP_TRACE_FLAG_TIMER
= 0x00040000,
146 LDP_TRACE_FLAG_ALL
= 0xFFFFFFFF
152 LDP_NOTIF_BAD_LDP_ID
,
154 LDP_NOTIF_BAD_PDU_LEN
,
155 LDP_NOTIF_UNKNOWN_MESG
,
156 LDP_NOTIF_BAD_MESG_LEN
,
157 LDP_NOTIF_UNKNOWN_TVL
,
158 LDP_NOTIF_BAD_TLV_LEN
,
159 LDP_NOTIF_MALFORMED_TLV
,
160 LDP_NOTIF_HOLD_TIMER_EXPIRED
,
162 LDP_NOTIF_LOOP_DETECTED
,
163 LDP_NOTIF_UNKNOWN_FEC
,
165 LDP_NOTIF_NO_LABEL_RESOURCES_AVAILABLE
,
166 LDP_NOTIF_LABEL_RESOURCES_AVAILABLE
,
167 LDP_NOTIF_SESSION_REJECTED_NO_HELLO
,
168 LDP_NOTIF_SESSION_REJECTED_PARAMETERS_ADVERTISEMENT_MODE
,
169 LDP_NOTIF_SESSION_REJECTED_PARAMETERS_MAX_PDU_LEN
,
170 LDP_NOTIF_SESSION_REJECTED_PARAMETERS_LABEL_RANGE
,
171 LDP_NOTIF_KEEPALIVE_TIMER_EXPIRED
,
172 LDP_NOTIF_LABEL_ABORT
,
173 LDP_NOTIF_MISSING_MSG_PARAMS
,
174 LDP_NOTIF_UNSUPORTED_AF
,
175 LDP_NOTIF_SESSION_REJECTED_BAD_KEEPALIVE_TIME
,
176 LDP_NOTIF_INTERNAL_ERROR
179 #define LDP_STATE_NUM 6
180 #define LDP_EVENT_NUM 10
181 #define LDP_FUNC_NUM 10
183 #include "ldp_defaults.h"
184 #include "mpls_handle_type.h"
185 #include "ldp_nortel.h"
187 typedef struct ldp_mesg
{
188 mplsLdpHeader_t header
;
190 mplsLdpMsg_t generic
;
191 mplsLdpInitMsg_t init
;
192 mplsLdpNotifMsg_t notif
;
193 mplsLdpHelloMsg_t hello
;
194 mplsLdpKeepAlMsg_t keep
;
195 mplsLdpAdrMsg_t addr
;
196 mplsLdpLblMapMsg_t map
;
197 mplsLdpLblReqMsg_t request
;
198 mplsLdpLbl_W_R_Msg_t release
;
199 mplsLdpLblAbortMsg_t abort
;
203 typedef struct ldp_buf
{
212 typedef struct ldp_global
{
213 struct ldp_outlabel_list outlabel
;
214 struct ldp_resource_list resource
;
215 struct ldp_hop_list_list hop_list
;
216 struct ldp_inlabel_list inlabel
;
217 struct ldp_nexthop_list nexthop
;
218 struct ldp_session_list session
;
219 struct ldp_tunnel_list tunnel
;
220 struct ldp_entity_list entity
;
221 struct ldp_peer_list peer
;
222 struct ldp_attr_list attr
;
223 struct ldp_addr_list addr
;
224 struct ldp_adj_list adj
;
225 struct ldp_if_list iff
;
226 struct ldp_fec_list fec
;
228 mpls_lock_handle global_lock
;
229 mpls_instance_handle user_data
;
231 mpls_tree_handle addr_tree
;
232 mpls_tree_handle fec_tree
;
234 mpls_socket_handle hello_socket
;
235 mpls_socket_handle listen_socket
;
237 mpls_timer_mgr_handle timer_handle
;
238 mpls_socket_mgr_handle socket_handle
;
239 mpls_fib_handle fib_handle
;
240 mpls_ifmgr_handle ifmgr_handle
;
243 mpls_cfg_handle lsr_handle
;
245 mpls_mpls_handle mpls_handle
;
249 * CSN changes with every MIB set, BUT only when a entity goes through
250 * shutdown/startup cycle will it grab the new CSN and use it in hellos
252 uint32_t configuration_sequence_number
;
255 * Message ID increaments with EVERY message, this means it will roll over
257 uint32_t message_identifier
;
259 struct mpls_inet_addr lsr_identifier
;
260 mpls_bool send_address_messages
;
261 mpls_bool send_lsrid_mapping
;
262 ldp_control_mode lsp_control_mode
;
263 ldp_retention_mode label_retention_mode
;
264 ldp_repaire_mode lsp_repair_mode
;
265 mpls_bool propagate_release
;
266 mpls_bool label_merge
;
267 ldp_loop_detection_mode loop_detection_mode
;
268 mpls_bool ttl_less_domain
;
269 uint16_t local_tcp_port
;
270 uint16_t local_udp_port
;
271 uint16_t backoff_step
;
272 int no_route_to_peer_time
;
275 * some global defaults, entities will inherit these values unless
276 * instructed otherwise
278 struct mpls_inet_addr transport_address
;
279 uint16_t keepalive_timer
;
280 uint16_t keepalive_interval
;
281 uint16_t hellotime_timer
;
282 uint16_t hellotime_interval
;
284 mpls_admin_state_enum admin_state
;
287 typedef struct ldp_entity
{
289 MPLS_LIST_ELEM(ldp_entity
) _global
;
290 struct ldp_adj_list adj_root
;
292 ldp_entity_type_enum entity_type
;
294 struct ldp_peer
*peer
;
298 ldp_state_enum state
;
299 uint32_t inherit_flag
;
302 struct mpls_inet_addr transport_address
;
303 uint8_t protocol_version
;
304 uint16_t remote_tcp_port
;
305 uint16_t remote_udp_port
;
307 uint16_t keepalive_timer
;
308 uint16_t keepalive_interval
;
309 uint16_t hellotime_timer
;
310 uint16_t hellotime_interval
;
311 uint16_t session_setup_count
;
312 uint16_t session_backoff_timer
;
313 ldp_distribution_mode label_distribution_mode
;
314 uint8_t path_vector_limit
;
315 uint8_t hop_count_limit
;
316 uint8_t label_request_count
;
317 uint16_t label_request_timer
;
318 ldp_loop_detection_mode loop_detection_mode
;
319 mpls_admin_state_enum admin_state
;
320 mpls_bool remote_in_ttl_less_domain
;
321 mpls_bool request_retry
;
327 /* only used for cfg gets */
332 typedef struct ldp_if
{
334 MPLS_LIST_ELEM(ldp_if
) _global
;
335 struct mpls_link_list session_root
;
336 struct ldp_nexthop_list nh_root
;
337 struct ldp_addr_list addr_root
;
338 struct ldp_entity
*entity
;
339 mpls_timer_handle hellotime_send_timer
;
340 int hellotime_send_timer_duration
;
343 mpls_if_handle handle
;
345 struct ldp_mesg
*tx_message
;
346 struct ldp_buf
*tx_buffer
;
347 struct ldp_mesg
*hello
;
349 /* YES this is a dest, it is what we use for sendto */
350 struct mpls_dest dest
;
352 mpls_oper_state_enum oper_state
;
355 /* only used for cfg gets */
356 uint32_t entity_index
;
359 typedef struct ldp_peer
{
361 MPLS_LIST_ELEM(ldp_peer
) _global
;
362 struct ldp_entity
*entity
;
363 mpls_timer_handle no_route_to_peer_timer
;
364 mpls_timer_handle hellotime_send_timer
;
365 int hellotime_send_timer_duration
;
369 struct ldp_mesg
*tx_message
;
370 struct ldp_buf
*tx_buffer
;
371 struct ldp_mesg
*hello
;
373 /* YES this is a dest, it is what we use for sendto */
374 struct mpls_dest dest
;
375 ldp_role_enum target_role
;
377 char peer_name
[MPLS_MAX_IF_NAME
];
378 mpls_oper_state_enum oper_state
;
380 /* only used for cfg gets */
381 uint32_t entity_index
;
384 typedef struct ldp_session
{
386 MPLS_LIST_ELEM(ldp_session
) _global
;
387 struct ldp_outlabel_list outlabel_root
;
388 struct mpls_link_list inlabel_root
;
389 struct mpls_link_list addr_root
;
390 struct ldp_attr_list attr_root
;
391 struct ldp_adj_list adj_root
;
392 mpls_timer_handle initial_distribution_timer
;
393 mpls_timer_handle keepalive_recv_timer
;
394 mpls_timer_handle keepalive_send_timer
;
396 ldp_state_enum state
;
398 ldp_notif_status shutdown_notif
;
399 mpls_bool shutdown_fatal
;
400 mpls_socket_handle socket
;
401 mpls_timer_handle backoff_timer
;
404 /* operational values learned from initialization */
407 int oper_keepalive_interval
;
408 int oper_path_vector_limit
;
409 ldp_distribution_mode oper_distribution_mode
;
410 ldp_loop_detection_mode oper_loop_detection
;
412 /* these values are learned form the remote peer */
413 ldp_distribution_mode remote_distribution_mode
;
414 mpls_bool remote_loop_detection
;
415 int remote_path_vector_limit
;
416 int remote_keepalive
;
418 mpls_dest remote_dest
;
419 uint8_t session_name
[20]; /* xxx.xxx.xxx.xxx:yyy\0 */
421 mpls_bool no_label_resource_sent
;
422 mpls_bool no_label_resource_recv
;
425 /* various message and buffers used for tx and rx */
426 struct ldp_mesg
*keepalive
;
427 struct ldp_mesg
*tx_message
;
428 struct ldp_buf
*tx_buffer
;
430 /* cached from adj's */
431 ldp_role_enum oper_role
;
433 /* these are config values come from entity */
434 ldp_loop_detection_mode cfg_loop_detection_mode
;
435 ldp_distribution_mode cfg_distribution_mode
;
436 mpls_bool cfg_remote_in_ttl_less_domain
;
437 int cfg_label_request_count
;
438 int cfg_label_request_timer
;
439 uint16_t cfg_peer_tcp_port
;
440 int cfg_path_vector_limit
;
441 int cfg_hop_count_limit
;
450 /* only used by cfg gets */
454 typedef struct ldp_adj
{
456 MPLS_LIST_ELEM(ldp_adj
) _global
;
457 MPLS_LIST_ELEM(ldp_adj
) _session
;
458 MPLS_LIST_ELEM(ldp_adj
) _entity
;
459 struct ldp_session
*session
;
460 struct ldp_entity
*entity
;
461 mpls_timer_handle hellotime_recv_timer
;
462 mpls_oper_state_enum state
;
466 /* these values are learned form the remote peer */
467 struct mpls_inet_addr remote_transport_address
;
468 struct mpls_inet_addr remote_source_address
;
469 struct mpls_inet_addr remote_lsr_address
;
470 int remote_label_space
;
471 int remote_hellotime
;
474 /* only used by cfg gets */
475 uint32_t session_index
;
476 uint32_t entity_index
;
479 typedef struct ldp_addr
{
481 MPLS_LIST_ELEM(ldp_addr
) _global
;
482 MPLS_LIST_ELEM(ldp_addr
) _if
;
483 struct ldp_session
*session
;
484 struct ldp_nexthop_list nh_root
;
485 struct mpls_inet_addr address
;
489 * if an address has a if_handle it is locally attached
491 mpls_if_handle if_handle
;
495 * only used durring gets
497 uint32_t session_index
;
498 uint32_t nexthop_index
;
504 typedef struct ldp_nexthop
{
506 MPLS_LIST_ELEM(ldp_nexthop
) _global
;
507 MPLS_LIST_ELEM(ldp_nexthop
) _fec
;
508 MPLS_LIST_ELEM(ldp_nexthop
) _addr
;
509 MPLS_LIST_ELEM(ldp_nexthop
) _if
;
510 MPLS_LIST_ELEM(ldp_nexthop
) _outlabel
;
511 struct ldp_outlabel_list outlabel_root
;
513 struct ldp_addr
*addr
;
515 struct ldp_outlabel
*outlabel
;
516 struct mpls_nexthop info
;
521 typedef struct ldp_outlabel
{
523 MPLS_LIST_ELEM(ldp_outlabel
) _global
;
524 MPLS_LIST_ELEM(ldp_outlabel
) _session
;
525 MPLS_LIST_ELEM(ldp_outlabel
) _nexthop
;
526 struct ldp_inlabel_list inlabel_root
;
527 struct ldp_tunnel_list tunnel_root
;
528 struct ldp_nexthop_list nh_root
;
529 uint32_t merge_count
;
530 struct ldp_attr
*attr
;
531 struct ldp_session
*session
;
532 struct ldp_nexthop
*nh
;
533 struct mpls_outsegment info
;
537 /* only used by get() */
538 uint32_t session_index
;
543 typedef struct ldp_inlabel
{
545 MPLS_LIST_ELEM(ldp_inlabel
) _global
;
546 MPLS_LIST_ELEM(ldp_inlabel
) _outlabel
;
547 struct mpls_link_list session_root
;
548 struct mpls_link_list attr_root
;
549 struct ldp_outlabel
*outlabel
;
550 uint32_t reuse_count
;
552 struct mpls_insegment info
;
554 /* only used by get() */
555 uint32_t outlabel_index
;
558 typedef struct ldp_fec
{
560 MPLS_LIST_ELEM(ldp_fec
) _global
;
561 MPLS_LIST_ELEM(ldp_fec
) _inlabel
;
562 MPLS_LIST_ELEM(ldp_fec
) _outlabel
;
563 MPLS_LIST_ELEM(ldp_fec
) _tree
;
564 MPLS_LIST_ELEM(ldp_fec
) _addr
;
565 MPLS_LIST_ELEM(ldp_fec
) _fec
;
566 MPLS_LIST_ELEM(ldp_fec
) _if
;
567 struct ldp_fs_list fs_root_us
;
568 struct ldp_fs_list fs_root_ds
;
570 struct ldp_nexthop_list nh_root
;
571 struct mpls_fec info
;
575 typedef struct ldp_fs
{
576 struct ldp_attr_list attr_root
;
577 MPLS_LIST_ELEM(ldp_fs
) _fec
;
578 struct ldp_session
*session
;
581 typedef struct ldp_attr
{
585 struct ldp_attr_list us_attr_root
;
586 struct ldp_attr
*ds_attr
;
591 struct ldp_session
*session
;
592 uint32_t attempt_count
;
593 mpls_timer_handle action_timer
;
594 ldp_lsp_state action
;
597 MPLS_LIST_ELEM(ldp_attr
) _session
;
598 MPLS_LIST_ELEM(ldp_attr
) _global
;
599 MPLS_LIST_ELEM(ldp_attr
) _ds_attr
;
600 MPLS_LIST_ELEM(ldp_attr
) _fs
;
602 mplsLdpFecTlv_t fecTlv
;
603 mplsLdpGenLblTlv_t genLblTlv
;
604 mplsLdpAtmLblTlv_t atmLblTlv
;
605 mplsLdpFrLblTlv_t frLblTlv
;
606 mplsLdpHopTlv_t hopCountTlv
;
607 mplsLdpPathTlv_t pathVecTlv
;
608 mplsLdpLblMsgIdTlv_t lblMsgIdTlv
;
609 mplsLdpLspIdTlv_t lspidTlv
;
610 mplsLdpTrafficTlv_t trafficTlv
;
611 mplsLdpStatusTlv_t statusTlv
;
612 mplsLdpRetMsgTlv_t retMsgTlv
;
614 uint8_t fecTlvExists
:1;
615 uint8_t genLblTlvExists
:1;
616 uint8_t atmLblTlvExists
:1;
617 uint8_t frLblTlvExists
:1;
618 uint8_t hopCountTlvExists
:1;
619 uint8_t pathVecTlvExists
:1;
620 uint8_t lblMsgIdTlvExists
:1;
621 uint8_t lspidTlvExists
:1;
622 uint8_t trafficTlvExists
:1;
623 uint8_t statusTlvExists
:1;
624 uint8_t retMsgTlvExists
:1;
626 struct ldp_outlabel
*outlabel
;
627 struct ldp_inlabel
*inlabel
;
629 /* only used for get() */
630 uint32_t inlabel_index
;
631 uint32_t outlabel_index
;
632 uint32_t session_index
;
635 typedef struct ldp_resource
{
637 MPLS_LIST_ELEM(ldp_resource
) _global
;
638 struct ldp_tunnel
*tunnel
;
645 typedef struct ldp_hop
{
647 MPLS_LIST_ELEM(ldp_hop
) _hop_list
;
648 struct ldp_hop_list
*hop_list
;
650 uint32_t hop_list_index
;
651 uint32_t path_option
;
656 typedef struct ldp_hop_list
{
658 MPLS_LIST_ELEM(ldp_hop_list
) _global
;
659 struct _ldp_hop_list hop
;
660 struct ldp_tunnel
*tunnel
;
664 typedef struct ldp_tunnel
{
666 MPLS_LIST_ELEM(ldp_tunnel
) _global
;
667 MPLS_LIST_ELEM(ldp_tunnel
) _outlabel
;
669 mpls_inet_addr ingress_lsrid
;
670 ldp_addr egress_lsrid
;
671 char name
[MPLS_MAX_IF_NAME
];
672 mpls_bool is_interface
;
673 uint32_t outlabel_index
;
674 struct ldp_outlabel
*outlabel
;
677 uint32_t instance_prio
;
678 uint32_t resource_index
;
679 struct ldp_resource
*resource
;
680 uint32_t hop_list_index
;
681 struct ldp_hop_list
*hop_list
;
683 mpls_admin_state_enum admin_state
;
685 uint32_t primary_instance
;
686 uint32_t any_affinity
;
687 uint32_t all_affinity
;
688 uint32_t no_all_affinity
;
689 uint32_t path_in_use
;
691 mpls_bool local_protect
;
692 uint32_t session_attr
;
696 typedef void (*ldp_tree_callback
) (void *);