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_hop_list
, ldp_hop
);
28 MPLS_LIST_ROOT(ldp_adj_list
, ldp_adj
);
29 MPLS_LIST_ROOT(ldp_fec_list
, ldp_fec
);
30 MPLS_LIST_ROOT(ldp_fs_list
, ldp_fs
);
31 MPLS_LIST_ROOT(ldp_if_list
, ldp_if
);
33 typedef struct ldp_attr_list ldp_attr_list
;
39 } ldp_entity_type_enum
;
42 LDP_CONTROL_INDEPENDENT
= 1,
47 LDP_RETENTION_LIBERAL
= 1,
48 LDP_RETENTION_CONSERVATIVE
60 LDP_LOOP_HOPCOUNT_PATHVECTOR
,
62 } ldp_loop_detection_mode
;
65 LDP_TRANS_ADDR_NONE
= 0,
66 LDP_TRANS_ADDR_INTERFACE
,
68 } ldp_trans_addr_mode
;
71 LDP_DISTRIBUTION_UNSOLICITED
= 0,
72 LDP_DISTRIBUTION_ONDEMAND
= 1,
73 } ldp_distribution_mode
;
97 LDP_EVENT_TCP_CONNECT
,
105 LDP_STATE_INITIALIZED
,
108 LDP_STATE_OPERATIONAL
112 LDP_KEEPALIVE_RECV
= 1,
114 } ldp_keepalive_type
;
117 LDP_LSP_STATE_REQ_RECV
,
118 LDP_LSP_STATE_REQ_SENT
,
119 LDP_LSP_STATE_MAP_RECV
,
120 LDP_LSP_STATE_MAP_SENT
,
121 LDP_LSP_STATE_WITH_SENT
,
122 LDP_LSP_STATE_WITH_RECV
,
123 LDP_LSP_STATE_NO_LABEL_RESOURCE_SENT
,
124 LDP_LSP_STATE_NO_LABEL_RESOURCE_RECV
,
125 LDP_LSP_STATE_ABORT_SENT
,
126 LDP_LSP_STATE_ABORT_RECV
,
127 LDP_LSP_STATE_NOTIF_SENT
,
128 LDP_LSP_STATE_NOTIF_RECV
132 LDP_TRACE_FLAG_ADDRESS
= 0x00000001,
133 LDP_TRACE_FLAG_BINDING
= 0x00000002,
134 LDP_TRACE_FLAG_DEBUG
= 0x00000004,
135 LDP_TRACE_FLAG_ERROR
= 0x00000008,
136 LDP_TRACE_FLAG_EVENT
= 0x00000010,
137 LDP_TRACE_FLAG_GENERAL
= 0x00000020,
138 LDP_TRACE_FLAG_INIT
= 0x00000040,
139 LDP_TRACE_FLAG_LABEL
= 0x00000080,
140 LDP_TRACE_FLAG_NORMAL
= 0x00000100,
141 LDP_TRACE_FLAG_NOTIF
= 0x00000200,
142 LDP_TRACE_FLAG_PACKET_DUMP
= 0x00000400,
143 LDP_TRACE_FLAG_PACKET
= 0x00000800,
144 LDP_TRACE_FLAG_PATH
= 0x00001000,
145 LDP_TRACE_FLAG_PERIODIC
= 0x00002000,
146 LDP_TRACE_FLAG_POLICY
= 0x00004000,
147 LDP_TRACE_FLAG_ROUTE
= 0x00008000,
148 LDP_TRACE_FLAG_STATE
= 0x00010000,
149 LDP_TRACE_FLAG_TASK
= 0x00020000,
150 LDP_TRACE_FLAG_TIMER
= 0x00040000,
151 LDP_TRACE_FLAG_ALL
= 0xFFFFFFFF
157 LDP_NOTIF_BAD_LDP_ID
,
159 LDP_NOTIF_BAD_PDU_LEN
,
160 LDP_NOTIF_UNKNOWN_MESG
,
161 LDP_NOTIF_BAD_MESG_LEN
,
162 LDP_NOTIF_UNKNOWN_TVL
,
163 LDP_NOTIF_BAD_TLV_LEN
,
164 LDP_NOTIF_MALFORMED_TLV
,
165 LDP_NOTIF_HOLD_TIMER_EXPIRED
,
167 LDP_NOTIF_LOOP_DETECTED
,
168 LDP_NOTIF_UNKNOWN_FEC
,
170 LDP_NOTIF_NO_LABEL_RESOURCES_AVAILABLE
,
171 LDP_NOTIF_LABEL_RESOURCES_AVAILABLE
,
172 LDP_NOTIF_SESSION_REJECTED_NO_HELLO
,
173 LDP_NOTIF_SESSION_REJECTED_PARAMETERS_ADVERTISEMENT_MODE
,
174 LDP_NOTIF_SESSION_REJECTED_PARAMETERS_MAX_PDU_LEN
,
175 LDP_NOTIF_SESSION_REJECTED_PARAMETERS_LABEL_RANGE
,
176 LDP_NOTIF_KEEPALIVE_TIMER_EXPIRED
,
177 LDP_NOTIF_LABEL_ABORT
,
178 LDP_NOTIF_MISSING_MSG_PARAMS
,
179 LDP_NOTIF_UNSUPORTED_AF
,
180 LDP_NOTIF_SESSION_REJECTED_BAD_KEEPALIVE_TIME
,
181 LDP_NOTIF_INTERNAL_ERROR
184 #define LDP_STATE_NUM 6
185 #define LDP_EVENT_NUM 10
186 #define LDP_FUNC_NUM 10
188 #include "ldp_defaults.h"
189 #include "mpls_handle_type.h"
190 #include "ldp_nortel.h"
192 typedef struct ldp_mesg
{
193 mplsLdpHeader_t header
;
195 mplsLdpMsg_t generic
;
196 mplsLdpInitMsg_t init
;
197 mplsLdpNotifMsg_t notif
;
198 mplsLdpHelloMsg_t hello
;
199 mplsLdpKeepAlMsg_t keep
;
200 mplsLdpAdrMsg_t addr
;
201 mplsLdpLblMapMsg_t map
;
202 mplsLdpLblReqMsg_t request
;
203 mplsLdpLbl_W_R_Msg_t release
;
204 mplsLdpLblAbortMsg_t abort
;
208 typedef struct ldp_buf
{
217 typedef struct ldp_global
{
218 struct ldp_outlabel_list outlabel
;
219 struct ldp_resource_list resource
;
220 struct ldp_hop_list_list hop_list
;
221 struct ldp_inlabel_list inlabel
;
222 struct ldp_session_list session
;
223 struct ldp_tunnel_list tunnel
;
224 struct ldp_entity_list entity
;
225 struct ldp_peer_list peer
;
226 struct ldp_attr_list attr
;
227 struct ldp_adj_list adj
;
228 struct ldp_if_list iff
;
230 mpls_lock_handle global_lock
;
231 mpls_instance_handle user_data
;
233 mpls_tree_handle addr_tree
;
234 mpls_tree_handle fec_tree
;
235 mpls_tree_handle nh_tree
;
237 mpls_socket_handle hello_socket
;
238 mpls_socket_handle listen_socket
;
240 mpls_timer_mgr_handle timer_handle
;
241 mpls_socket_mgr_handle socket_handle
;
242 mpls_fib_handle fib_handle
;
243 mpls_ifmgr_handle ifmgr_handle
;
246 mpls_cfg_handle lsr_handle
;
248 mpls_mpls_handle mpls_handle
;
252 * CSN changes with every MIB set, BUT only when a entity goes through
253 * shutdown/startup cycle will it grab the new CSN and use it in hellos
255 uint32_t configuration_sequence_number
;
258 * Message ID increaments with EVERY message, this means it will roll over
260 uint32_t message_identifier
;
262 struct mpls_inet_addr lsr_identifier
;
263 mpls_bool send_address_messages
;
264 mpls_bool send_lsrid_mapping
;
265 ldp_control_mode lsp_control_mode
;
266 ldp_retention_mode label_retention_mode
;
267 ldp_repaire_mode lsp_repair_mode
;
268 mpls_bool propagate_release
;
269 mpls_bool label_merge
;
270 ldp_loop_detection_mode loop_detection_mode
;
271 mpls_bool ttl_less_domain
;
272 uint16_t local_tcp_port
;
273 uint16_t local_udp_port
;
274 uint16_t backoff_step
;
275 int no_route_to_peer_time
;
278 * some global defaults, entities will inherit these values unless
279 * instructed otherwise
281 struct mpls_inet_addr transport_address
;
282 uint16_t keepalive_timer
;
283 uint16_t keepalive_interval
;
284 uint16_t hellotime_timer
;
285 uint16_t hellotime_interval
;
287 mpls_admin_state_enum admin_state
;
290 typedef struct ldp_entity
{
292 MPLS_LIST_ELEM(ldp_entity
) _global
;
293 struct ldp_adj_list adj_root
;
295 ldp_entity_type_enum entity_type
;
297 struct ldp_peer
*peer
;
301 ldp_state_enum state
;
302 uint32_t inherit_flag
;
305 struct mpls_inet_addr transport_address
;
306 uint8_t protocol_version
;
307 uint16_t remote_tcp_port
;
308 uint16_t remote_udp_port
;
310 uint16_t keepalive_timer
;
311 uint16_t keepalive_interval
;
312 uint16_t hellotime_timer
;
313 uint16_t hellotime_interval
;
314 uint16_t session_setup_count
;
315 uint16_t session_backoff_timer
;
316 ldp_distribution_mode label_distribution_mode
;
317 uint8_t path_vector_limit
;
318 uint8_t hop_count_limit
;
319 uint8_t label_request_count
;
320 uint16_t label_request_timer
;
321 ldp_loop_detection_mode loop_detection_mode
;
322 mpls_admin_state_enum admin_state
;
323 mpls_bool remote_in_ttl_less_domain
;
324 mpls_bool request_retry
;
330 /* only used for cfg gets */
335 typedef struct ldp_if
{
337 MPLS_LIST_ELEM(ldp_if
) _global
;
338 struct ldp_entity
*entity
;
339 mpls_timer_handle hellotime_send_timer
;
340 int hellotime_send_timer_duration
;
343 struct mpls_inet_addr local_source_address
;
344 mpls_if_handle handle
;
346 struct ldp_mesg
*tx_message
;
347 struct ldp_buf
*tx_buffer
;
348 struct ldp_mesg
*hello
;
350 /* YES this is a dest, it is what we use for sendto */
351 struct mpls_dest dest
;
353 char name
[MPLS_MAX_IF_NAME
];
354 mpls_oper_state_enum oper_state
;
356 /* only used for cfg gets */
357 uint32_t entity_index
;
360 typedef struct ldp_peer
{
362 MPLS_LIST_ELEM(ldp_peer
) _global
;
363 struct ldp_entity
*entity
;
364 mpls_timer_handle no_route_to_peer_timer
;
365 mpls_timer_handle hellotime_send_timer
;
366 int hellotime_send_timer_duration
;
369 struct mpls_inet_addr local_source_address
;
371 struct ldp_mesg
*tx_message
;
372 struct ldp_buf
*tx_buffer
;
373 struct ldp_mesg
*hello
;
375 /* YES this is a dest, it is what we use for sendto */
376 struct mpls_dest dest
;
377 ldp_role_enum target_role
;
379 char peer_name
[MPLS_MAX_IF_NAME
];
380 mpls_oper_state_enum oper_state
;
382 /* only used for cfg gets */
383 uint32_t entity_index
;
386 typedef struct ldp_session
{
388 MPLS_LIST_ELEM(ldp_session
) _global
;
389 struct ldp_outlabel_list outlabel_root
;
390 struct mpls_link_list inlabel_root
;
391 struct mpls_link_list addr_root
;
392 struct ldp_attr_list attr_root
;
393 struct ldp_adj_list adj_root
;
394 mpls_timer_handle initial_distribution_timer
;
395 mpls_timer_handle keepalive_recv_timer
;
396 mpls_timer_handle keepalive_send_timer
;
398 ldp_state_enum state
;
400 ldp_notif_status shutdown_notif
;
401 mpls_bool shutdown_fatal
;
402 mpls_socket_handle socket
;
403 mpls_timer_handle backoff_timer
;
406 /* operational values learned from initialization */
409 int oper_keepalive_interval
;
410 int oper_path_vector_limit
;
411 ldp_distribution_mode oper_distribution_mode
;
412 ldp_loop_detection_mode oper_loop_detection
;
414 /* these values are learned form the remote peer */
415 ldp_distribution_mode remote_distribution_mode
;
416 mpls_bool remote_loop_detection
;
417 int remote_path_vector_limit
;
418 int remote_keepalive
;
420 mpls_dest remote_dest
;
424 uint8_t session_name
[20]; /* xxx.xxx.xxx.xxx:yyy\0 */
426 mpls_bool no_label_resource_sent
;
427 mpls_bool no_label_resource_recv
;
430 /* various message and buffers used for tx and rx */
431 struct ldp_mesg
*keepalive
;
432 struct ldp_mesg
*tx_message
;
433 struct ldp_buf
*tx_buffer
;
435 /* cached from adj's */
436 ldp_role_enum oper_role
;
438 /* these are config values come from entity */
439 ldp_loop_detection_mode cfg_loop_detection_mode
;
440 ldp_distribution_mode cfg_distribution_mode
;
441 mpls_bool cfg_remote_in_ttl_less_domain
;
442 int cfg_label_request_count
;
443 int cfg_label_request_timer
;
444 uint16_t cfg_peer_tcp_port
;
445 int cfg_path_vector_limit
;
446 int cfg_hop_count_limit
;
455 /* only used by cfg gets */
459 typedef struct ldp_adj
{
461 MPLS_LIST_ELEM(ldp_adj
) _global
;
462 MPLS_LIST_ELEM(ldp_adj
) _session
;
463 MPLS_LIST_ELEM(ldp_adj
) _entity
;
464 struct ldp_session
*session
;
465 struct ldp_entity
*entity
;
466 mpls_timer_handle hellotime_recv_timer
;
467 mpls_oper_state_enum state
;
471 /* these values are learned form the remote peer */
472 struct mpls_inet_addr remote_transport_address
;
473 struct mpls_inet_addr remote_source_address
;
474 struct mpls_inet_addr remote_lsr_address
;
475 int remote_label_space
;
476 int remote_hellotime
;
479 /* only used by cfg gets */
480 uint32_t session_index
;
481 uint32_t entity_index
;
484 typedef struct ldp_addr
{
486 MPLS_LIST_ELEM(ldp_addr
) _addr
;
487 struct mpls_link_list session_root
;
488 struct ldp_fec_list fec_root
;
489 struct mpls_inet_addr address
;
493 typedef struct ldp_outlabel
{
495 struct ldp_inlabel_list inlabel_root
;
496 struct ldp_tunnel_list tunnel_root
;
497 MPLS_LIST_ELEM(ldp_outlabel
) _global
;
498 MPLS_LIST_ELEM(ldp_outlabel
) _session
;
499 struct ldp_attr
*attr
;
500 uint32_t merge_count
;
502 struct ldp_session
*session
;
503 struct ldp_addr
*addr
;
504 struct mpls_outsegment info
;
507 /* only used by get() */
508 uint32_t session_index
;
512 typedef struct ldp_inlabel
{
514 MPLS_LIST_ELEM(ldp_inlabel
) _global
;
515 MPLS_LIST_ELEM(ldp_inlabel
) _outlabel
;
516 struct mpls_link_list session_root
;
517 struct mpls_link_list attr_root
;
518 struct ldp_outlabel
*outlabel
;
519 uint32_t reuse_count
;
521 struct mpls_insegment info
;
523 /* only used by get() */
524 uint32_t outlabel_index
;
527 typedef struct ldp_fec
{
529 MPLS_LIST_ELEM(ldp_fec
) _global
;
530 MPLS_LIST_ELEM(ldp_fec
) _inlabel
;
531 MPLS_LIST_ELEM(ldp_fec
) _outlabel
;
532 MPLS_LIST_ELEM(ldp_fec
) _tree
;
533 MPLS_LIST_ELEM(ldp_fec
) _addr
;
534 MPLS_LIST_ELEM(ldp_fec
) _fec
;
535 MPLS_LIST_ELEM(ldp_fec
) _nh
;
536 struct ldp_fs_list fs_root_us
;
537 struct ldp_fs_list fs_root_ds
;
538 struct mpls_fec info
;
541 typedef struct ldp_fs
{
542 struct ldp_attr_list attr_root
;
543 MPLS_LIST_ELEM(ldp_fs
) _fec
;
544 struct ldp_session
*session
;
547 typedef struct ldp_attr
{
551 struct ldp_attr_list us_attr_root
;
552 struct ldp_attr
*ds_attr
;
557 struct ldp_session
*session
;
558 uint32_t attempt_count
;
559 mpls_timer_handle action_timer
;
560 ldp_lsp_state action
;
562 MPLS_LIST_ELEM(ldp_attr
) _session
;
563 MPLS_LIST_ELEM(ldp_attr
) _global
;
564 MPLS_LIST_ELEM(ldp_attr
) _ds_attr
;
565 MPLS_LIST_ELEM(ldp_attr
) _fs
;
567 mplsLdpFecTlv_t fecTlv
;
568 mplsLdpGenLblTlv_t genLblTlv
;
569 mplsLdpAtmLblTlv_t atmLblTlv
;
570 mplsLdpFrLblTlv_t frLblTlv
;
571 mplsLdpHopTlv_t hopCountTlv
;
572 mplsLdpPathTlv_t pathVecTlv
;
573 mplsLdpLblMsgIdTlv_t lblMsgIdTlv
;
574 mplsLdpLspIdTlv_t lspidTlv
;
575 mplsLdpTrafficTlv_t trafficTlv
;
576 mplsLdpStatusTlv_t statusTlv
;
577 mplsLdpRetMsgTlv_t retMsgTlv
;
579 uint8_t fecTlvExists
:1;
580 uint8_t genLblTlvExists
:1;
581 uint8_t atmLblTlvExists
:1;
582 uint8_t frLblTlvExists
:1;
583 uint8_t hopCountTlvExists
:1;
584 uint8_t pathVecTlvExists
:1;
585 uint8_t lblMsgIdTlvExists
:1;
586 uint8_t lspidTlvExists
:1;
587 uint8_t trafficTlvExists
:1;
588 uint8_t statusTlvExists
:1;
589 uint8_t retMsgTlvExists
:1;
591 struct ldp_outlabel
*outlabel
;
592 struct ldp_inlabel
*inlabel
;
594 /* only used for get() */
595 uint32_t inlabel_index
;
596 uint32_t outlabel_index
;
597 uint32_t session_index
;
600 typedef struct ldp_resource
{
602 MPLS_LIST_ELEM(ldp_resource
) _global
;
603 struct ldp_tunnel
*tunnel
;
610 typedef struct ldp_hop
{
612 MPLS_LIST_ELEM(ldp_hop
) _hop_list
;
613 struct ldp_hop_list
*hop_list
;
615 uint32_t hop_list_index
;
616 uint32_t path_option
;
621 typedef struct ldp_hop_list
{
623 MPLS_LIST_ELEM(ldp_hop_list
) _global
;
624 struct _ldp_hop_list hop
;
625 struct ldp_tunnel
*tunnel
;
629 typedef struct ldp_tunnel
{
631 MPLS_LIST_ELEM(ldp_tunnel
) _global
;
632 MPLS_LIST_ELEM(ldp_tunnel
) _outlabel
;
634 ldp_addr ingress_lsrid
;
635 ldp_addr egress_lsrid
;
636 char name
[MPLS_MAX_IF_NAME
];
637 mpls_bool is_interface
;
638 uint32_t outlabel_index
;
639 struct ldp_outlabel
*outlabel
;
642 uint32_t instance_prio
;
643 uint32_t resource_index
;
644 struct ldp_resource
*resource
;
645 uint32_t hop_list_index
;
646 struct ldp_hop_list
*hop_list
;
648 mpls_admin_state_enum admin_state
;
650 uint32_t primary_instance
;
651 uint32_t any_affinity
;
652 uint32_t all_affinity
;
653 uint32_t no_all_affinity
;
654 uint32_t path_in_use
;
656 mpls_bool local_protect
;
657 uint32_t session_attr
;
661 typedef void (*ldp_fib_callback
) (mpls_cfg_handle cfg
, mpls_update_enum type
,
663 typedef void (*ldp_ifmgr_callback
) (mpls_cfg_handle cfg
, mpls_update_enum type
,
664 mpls_inet_addr
*addr
);
665 typedef void (*ldp_tree_callback
) (void *);