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 #include "ldp_struct.h"
12 #include "ldp_global.h"
13 #include "ldp_entity.h"
19 #include "ldp_nexthop.h"
20 #include "ldp_tunnel.h"
21 #include "ldp_resource.h"
22 #include "mpls_ifmgr_impl.h"
23 #include "ldp_label_mapping.h"
25 #include "ldp_hop_list.h"
26 #include "mpls_lock_impl.h"
27 #include "mpls_trace_impl.h"
28 #include "mpls_tree_impl.h"
30 mpls_cfg_handle
ldp_cfg_open(mpls_instance_handle data
)
32 ldp_global
*g
= ldp_global_create(data
);
34 LDP_ENTER(data
, "ldp_cfg_open");
35 LDP_EXIT(data
, "ldp_cfg_open");
37 return (mpls_cfg_handle
) g
;
40 void ldp_cfg_close(mpls_cfg_handle g
)
42 LDP_ENTER((mpls_instance_handle
) g
->user_data
, "ldp_cfg_close");
44 LDP_EXIT((mpls_instance_handle
) g
->user_data
, "ldp_cfg_close");
47 /******************* GLOBAL **********************/
49 mpls_return_enum
ldp_cfg_global_get(mpls_cfg_handle handle
, ldp_global
* g
,
52 ldp_global
*global
= (ldp_global
*) handle
;
54 MPLS_ASSERT(global
!=NULL
);
56 LDP_ENTER(global
->user_data
, "ldp_cfg_global_get");
58 mpls_lock_get(global
->global_lock
); /* LOCK */
60 if (flag
& LDP_GLOBAL_CFG_LSR_IDENTIFIER
) {
61 memcpy(&(g
->lsr_identifier
), &(global
->lsr_identifier
),
62 sizeof(mpls_inet_addr
));
64 if (flag
& LDP_GLOBAL_CFG_ADMIN_STATE
) {
65 g
->admin_state
= global
->admin_state
;
67 if (flag
& LDP_GLOBAL_CFG_CONTROL_MODE
) {
68 g
->lsp_control_mode
= global
->lsp_control_mode
;
70 if (flag
& LDP_GLOBAL_CFG_RETENTION_MODE
) {
71 g
->label_retention_mode
= global
->label_retention_mode
;
73 if (flag
& LDP_GLOBAL_CFG_REPAIR_MODE
) {
74 g
->lsp_repair_mode
= global
->lsp_repair_mode
;
76 if (flag
& LDP_GLOBAL_CFG_PROPOGATE_RELEASE
) {
77 g
->propagate_release
= global
->propagate_release
;
79 if (flag
& LDP_GLOBAL_CFG_LABEL_MERGE
) {
80 g
->label_merge
= global
->label_merge
;
82 if (flag
& LDP_GLOBAL_CFG_LOOP_DETECTION_MODE
) {
83 g
->loop_detection_mode
= global
->loop_detection_mode
;
85 if (flag
& LDP_GLOBAL_CFG_TTLLESS_DOMAIN
) {
86 g
->ttl_less_domain
= global
->ttl_less_domain
;
88 if (flag
& LDP_GLOBAL_CFG_LOCAL_TCP_PORT
) {
89 g
->local_tcp_port
= global
->local_tcp_port
;
91 if (flag
& LDP_GLOBAL_CFG_LOCAL_UDP_PORT
) {
92 g
->local_udp_port
= global
->local_udp_port
;
94 if (flag
& LDP_GLOBAL_CFG_TRANS_ADDR
) {
95 memcpy(&(g
->transport_address
), &(global
->transport_address
),
96 sizeof(mpls_inet_addr
));
98 if (flag
& LDP_GLOBAL_CFG_KEEPALIVE_TIMER
) {
99 g
->keepalive_timer
= global
->keepalive_timer
;
101 if (flag
& LDP_GLOBAL_CFG_KEEPALIVE_INTERVAL
) {
102 g
->keepalive_interval
= global
->keepalive_interval
;
104 if (flag
& LDP_GLOBAL_CFG_HELLOTIME_TIMER
) {
105 g
->hellotime_timer
= global
->hellotime_timer
;
107 if (flag
& LDP_GLOBAL_CFG_HELLOTIME_INTERVAL
) {
108 g
->hellotime_interval
= global
->hellotime_interval
;
111 if (flag
& LDP_GLOBAL_CFG_LSR_HANDLE
) {
112 g
->lsr_handle
= global
->lsr_handle
;
116 mpls_lock_release(global
->global_lock
); /* UNLOCK */
118 LDP_EXIT(global
->user_data
, "ldp_cfg_global_get");
123 mpls_return_enum
ldp_cfg_global_test(mpls_cfg_handle handle
, ldp_global
* g
,
126 ldp_global
*global
= (ldp_global
*) handle
;
127 mpls_return_enum retval
= MPLS_SUCCESS
;
129 MPLS_ASSERT(global
!=NULL
);
131 LDP_ENTER(global
->user_data
, "ldp_cfg_global_test");
133 mpls_lock_get(global
->global_lock
); /* LOCK */
135 if (global
->admin_state
== MPLS_ADMIN_ENABLE
&& (flag
& LDP_GLOBAL_CFG_WHEN_DOWN
))
136 retval
= MPLS_FAILURE
;
138 mpls_lock_release(global
->global_lock
); /* UNLOCK */
140 LDP_EXIT(global
->user_data
, "ldp_cfg_global_test");
145 mpls_return_enum
ldp_cfg_global_set(mpls_cfg_handle handle
, ldp_global
* g
,
148 ldp_global
*global
= (ldp_global
*) handle
;
149 mpls_return_enum retval
= MPLS_FAILURE
;
151 MPLS_ASSERT(global
!=NULL
);
153 LDP_ENTER(global
->user_data
, "ldp_cfg_global_set");
155 mpls_lock_get(global
->global_lock
); /* LOCK */
157 if ((global
->admin_state
== MPLS_ADMIN_ENABLE
&& (flag
& LDP_GLOBAL_CFG_WHEN_DOWN
)))
158 goto ldp_cfg_global_set_end
;
160 if (flag
& LDP_GLOBAL_CFG_CONTROL_MODE
) {
161 global
->lsp_control_mode
= g
->lsp_control_mode
;
163 if (flag
& LDP_GLOBAL_CFG_RETENTION_MODE
) {
164 global
->label_retention_mode
= g
->label_retention_mode
;
166 if (flag
& LDP_GLOBAL_CFG_REPAIR_MODE
) {
167 global
->lsp_repair_mode
= g
->lsp_repair_mode
;
169 if (flag
& LDP_GLOBAL_CFG_PROPOGATE_RELEASE
) {
170 global
->propagate_release
= g
->propagate_release
;
172 if (flag
& LDP_GLOBAL_CFG_LABEL_MERGE
) {
173 global
->label_merge
= g
->label_merge
;
175 if (flag
& LDP_GLOBAL_CFG_LOOP_DETECTION_MODE
) {
176 global
->loop_detection_mode
= g
->loop_detection_mode
;
178 if (flag
& LDP_GLOBAL_CFG_TTLLESS_DOMAIN
) {
179 global
->ttl_less_domain
= g
->ttl_less_domain
;
181 if (flag
& LDP_GLOBAL_CFG_LOCAL_TCP_PORT
) {
182 global
->local_tcp_port
= g
->local_tcp_port
;
184 if (flag
& LDP_GLOBAL_CFG_LOCAL_UDP_PORT
) {
185 global
->local_udp_port
= g
->local_udp_port
;
187 if (flag
& LDP_GLOBAL_CFG_LSR_IDENTIFIER
) {
188 memcpy(&(global
->lsr_identifier
), &(g
->lsr_identifier
),
189 sizeof(mpls_inet_addr
));
192 if (flag
& LDP_GLOBAL_CFG_LSR_HANDLE
) {
193 global
->lsr_handle
= g
->lsr_handle
;
196 if (flag
& LDP_GLOBAL_CFG_ADMIN_STATE
) {
197 if (global
->admin_state
== MPLS_ADMIN_ENABLE
&& g
->admin_state
== MPLS_ADMIN_DISABLE
) {
198 ldp_global_shutdown(global
);
199 } else if (global
->admin_state
== MPLS_ADMIN_DISABLE
&& g
->admin_state
==
201 ldp_global_startup(global
);
204 if (flag
& LDP_GLOBAL_CFG_TRANS_ADDR
) {
205 memcpy(&(global
->transport_address
), &(g
->transport_address
),
206 sizeof(mpls_inet_addr
));
208 if (flag
& LDP_GLOBAL_CFG_KEEPALIVE_TIMER
) {
209 if (g
->keepalive_timer
== 0) {
210 global
->keepalive_timer
= LDP_ENTITY_DEF_KEEPALIVE_TIMER
;
212 global
->keepalive_timer
= g
->keepalive_timer
;
215 if (flag
& LDP_GLOBAL_CFG_KEEPALIVE_INTERVAL
) {
216 if (g
->keepalive_interval
== 0) {
217 global
->keepalive_interval
= LDP_ENTITY_DEF_KEEPALIVE_INTERVAL
;
219 global
->keepalive_interval
= g
->keepalive_interval
;
222 if (flag
& LDP_GLOBAL_CFG_HELLOTIME_TIMER
) {
223 if (g
->hellotime_timer
== 0) {
224 global
->hellotime_timer
= LDP_ENTITY_DEF_HELLOTIME_TIMER
;
226 global
->hellotime_timer
= g
->hellotime_timer
;
229 if (flag
& LDP_GLOBAL_CFG_HELLOTIME_INTERVAL
) {
230 if (g
->hellotime_interval
== 0) {
231 global
->hellotime_interval
= LDP_ENTITY_DEF_HELLOTIME_INTERVAL
;
233 global
->hellotime_interval
= g
->hellotime_interval
;
237 if (flag
& LDP_GLOBAL_CFG_LSR_HANDLE
) {
238 global
->lsr_handle
= g
->lsr_handle
;
241 global
->configuration_sequence_number
++;
243 retval
= MPLS_SUCCESS
;
245 ldp_cfg_global_set_end
:
247 mpls_lock_release(global
->global_lock
); /* UNLOCK */
249 LDP_EXIT(global
->user_data
, "ldp_cfg_global_set");
254 /******************* ENTITY **********************/
256 /* must set ldp_entity->index */
257 mpls_return_enum
ldp_cfg_entity_get(mpls_cfg_handle handle
, ldp_entity
* e
,
260 ldp_global
*global
= (ldp_global
*) handle
;
261 ldp_entity
*entity
= NULL
;
262 mpls_return_enum retval
= MPLS_FAILURE
;
264 MPLS_ASSERT(global
!=NULL
&& e
!= NULL
);
266 LDP_ENTER(global
->user_data
, "ldp_cfg_entity_get");
268 mpls_lock_get(global
->global_lock
); /* LOCK */
270 if (ldp_global_find_entity_index(global
, e
->index
, &entity
) != MPLS_SUCCESS
)
271 goto ldp_cfg_entity_get_end
;
273 if (flag
& LDP_ENTITY_CFG_ADMIN_STATE
) {
274 e
->admin_state
= entity
->admin_state
;
276 if (flag
& LDP_ENTITY_CFG_TRANS_ADDR
) {
277 e
->transport_address
= entity
->transport_address
;
279 if (flag
& LDP_ENTITY_CFG_PROTO_VER
) {
280 e
->protocol_version
= entity
->protocol_version
;
282 if (flag
& LDP_ENTITY_CFG_REMOTE_TCP
) {
283 e
->remote_tcp_port
= entity
->remote_tcp_port
;
285 if (flag
& LDP_ENTITY_CFG_REMOTE_UDP
) {
286 e
->remote_udp_port
= entity
->remote_udp_port
;
288 if (flag
& LDP_ENTITY_CFG_MAX_PDU
) {
289 e
->max_pdu
= entity
->max_pdu
;
291 if (flag
& LDP_ENTITY_CFG_KEEPALIVE_TIMER
) {
292 e
->keepalive_timer
= entity
->keepalive_timer
;
294 if (flag
& LDP_ENTITY_CFG_KEEPALIVE_INTERVAL
) {
295 e
->keepalive_interval
= entity
->keepalive_interval
;
297 if (flag
& LDP_ENTITY_CFG_HELLOTIME_TIMER
) {
298 e
->hellotime_timer
= entity
->hellotime_timer
;
300 if (flag
& LDP_ENTITY_CFG_HELLOTIME_INTERVAL
) {
301 e
->hellotime_interval
= entity
->hellotime_interval
;
303 if (flag
& LDP_ENTITY_CFG_SESSION_SETUP_COUNT
) {
304 e
->session_setup_count
= entity
->session_setup_count
;
306 if (flag
& LDP_ENTITY_CFG_SESSION_BACKOFF_TIMER
) {
307 e
->session_backoff_timer
= entity
->session_backoff_timer
;
309 if (flag
& LDP_ENTITY_CFG_DISTRIBUTION_MODE
) {
310 e
->label_distribution_mode
= entity
->label_distribution_mode
;
312 if (flag
& LDP_ENTITY_CFG_PATHVECTOR_LIMIT
) {
313 e
->path_vector_limit
= entity
->path_vector_limit
;
315 if (flag
& LDP_ENTITY_CFG_HOPCOUNT_LIMIT
) {
316 e
->hop_count_limit
= entity
->hop_count_limit
;
318 if (flag
& LDP_ENTITY_CFG_REQUEST_COUNT
) {
319 e
->label_request_count
= entity
->label_request_count
;
321 if (flag
& LDP_ENTITY_CFG_REQUEST_TIMER
) {
322 e
->label_request_timer
= entity
->label_request_timer
;
324 if (flag
& LDP_ENTITY_CFG_TYPE
) {
325 e
->entity_type
= entity
->entity_type
;
327 if (flag
& LDP_ENTITY_CFG_SUB_INDEX
) {
328 e
->sub_index
= entity
->sub_index
;
330 if (flag
& LDP_ENTITY_CFG_MESG_TX
) {
331 e
->mesg_tx
= entity
->mesg_tx
;
333 if (flag
& LDP_ENTITY_CFG_MESG_RX
) {
334 e
->mesg_rx
= entity
->mesg_rx
;
336 if (flag
& LDP_ENTITY_CFG_ADJ_COUNT
) {
337 e
->adj_count
= e
->adj_root
.count
;
339 if (flag
& LDP_ENTITY_CFG_ADJ_INDEX
) {
340 ldp_adj
*a
= MPLS_LIST_HEAD(&e
->adj_root
);
341 e
->adj_index
= a
? a
->index
: 0;
343 if (flag
& LDP_ENTITY_CFG_INHERIT_FLAG
) {
344 e
->inherit_flag
= entity
->inherit_flag
;
346 retval
= MPLS_SUCCESS
;
348 ldp_cfg_entity_get_end
:
350 mpls_lock_release(global
->global_lock
); /* UNLOCK */
352 LDP_EXIT(global
->user_data
, "ldp_cfg_entity_get");
357 mpls_return_enum
ldp_cfg_entity_getnext(mpls_cfg_handle handle
, ldp_entity
* e
,
360 ldp_global
*g
= (ldp_global
*) handle
;
361 ldp_entity
*entity
= NULL
;
362 mpls_return_enum r
= MPLS_FAILURE
;
363 mpls_bool done
= MPLS_BOOL_FALSE
;
366 LDP_ENTER(g
->user_data
, "ldp_cfg_entity_getnext");
371 index
= e
->index
+ 1;
374 mpls_lock_get(g
->global_lock
); /* LOCK */
375 while (done
== MPLS_BOOL_FALSE
) {
376 switch ((r
= ldp_global_find_entity_index(g
, index
, &entity
))) {
378 case MPLS_END_OF_LIST
:
379 done
= MPLS_BOOL_TRUE
;
388 mpls_lock_release(g
->global_lock
); /* UNLOCK */
390 if (r
== MPLS_SUCCESS
) {
391 e
->index
= entity
->index
;
392 LDP_EXIT(g
->user_data
, "ldp_cfg_entity_getnext");
393 return ldp_cfg_entity_get(g
, e
, flag
);
395 LDP_EXIT(g
->user_data
, "ldp_cfg_entity_getnext");
399 mpls_return_enum
ldp_cfg_entity_test(mpls_cfg_handle handle
, ldp_entity
* e
,
402 ldp_global
*global
= (ldp_global
*) handle
;
403 ldp_entity
*entity
= NULL
;
404 mpls_return_enum retval
= MPLS_FAILURE
;
406 MPLS_ASSERT(global
!=NULL
);
408 LDP_ENTER(global
->user_data
, "ldp_cfg_entity_test");
410 mpls_lock_get(global
->global_lock
); /* LOCK */
412 if (!(flag
& LDP_CFG_ADD
)) {
414 goto ldp_cfg_entity_test_end
;
416 ldp_global_find_entity_index(global
, e
->index
, &entity
);
418 retval
= MPLS_SUCCESS
;
419 goto ldp_cfg_entity_test_end
;
422 if (entity
== NULL
) {
423 goto ldp_cfg_entity_test_end
;
426 if ((ldp_entity_is_active(entity
) == MPLS_BOOL_TRUE
) &&
427 (flag
& LDP_ENTITY_CFG_WHEN_DOWN
)) {
428 goto ldp_cfg_entity_test_end
;
431 retval
= MPLS_SUCCESS
;
433 ldp_cfg_entity_test_end
:
434 mpls_lock_release(global
->global_lock
); /* UNLOCK */
436 LDP_EXIT(global
->user_data
, "ldp_cfg_entity_test");
441 /* must set ldp_entity->index if not an add */
442 mpls_return_enum
ldp_cfg_entity_set(mpls_cfg_handle handle
, ldp_entity
* e
,
445 ldp_global
*global
= (ldp_global
*) handle
;
446 ldp_entity
*entity
= NULL
;
447 mpls_return_enum retval
= MPLS_FAILURE
;
449 MPLS_ASSERT(global
!=NULL
&& e
!= NULL
);
451 LDP_ENTER(global
->user_data
, "ldp_cfg_entity_set");
453 mpls_lock_get(global
->global_lock
); /* LOCK */
455 if (flag
& LDP_CFG_ADD
) {
456 entity
= ldp_entity_create();
457 _ldp_global_add_entity(global
, entity
);
459 e
->index
= entity
->index
;
461 ldp_global_find_entity_index(global
, e
->index
, &entity
);
464 if (entity
== NULL
) {
465 LDP_PRINT(global
->user_data
, "ldp_cfg_entity_set: can't find entity\n");
466 goto ldp_cfg_entity_set_end
;
469 if ((ldp_entity_is_active(entity
) == MPLS_BOOL_TRUE
) &&
470 (flag
& LDP_ENTITY_CFG_WHEN_DOWN
)) {
471 LDP_PRINT(global
->user_data
, "ldp_cfg_entity_set: entity is active\n");
472 goto ldp_cfg_entity_set_end
;
475 if (flag
& LDP_CFG_DEL
) {
476 switch (entity
->entity_type
) {
478 ldp_entity_del_if(global
, entity
);
481 ldp_entity_del_peer(entity
);
486 _ldp_global_del_entity(global
, entity
);
488 retval
= MPLS_SUCCESS
;
489 goto ldp_cfg_entity_set_end
;
492 if (flag
& LDP_ENTITY_CFG_SUB_INDEX
) {
493 if (entity
->sub_index
!= 0) {
494 /* unlink the old sub object */
495 switch (entity
->entity_type
) {
497 ldp_entity_del_if(global
, entity
);
500 ldp_entity_del_peer(entity
);
507 /* link the new sub object */
508 switch (e
->entity_type
) {
512 if (ldp_global_find_if_index(global
, e
->sub_index
,
513 &iff
) != MPLS_SUCCESS
) {
514 LDP_PRINT(global
->user_data
,
515 "ldp_cfg_entity_set: no such interface\n");
517 if (flag
& LDP_CFG_ADD
) {
518 _ldp_global_del_entity(global
, entity
);
520 goto ldp_cfg_entity_set_end
;
522 ldp_entity_add_if(entity
, iff
);
527 ldp_peer
*peer
= NULL
;
529 if (ldp_global_find_peer_index(global
, e
->sub_index
, &peer
) !=
531 LDP_PRINT(global
->user_data
, "ldp_cfg_entity_set: no such peer\n");
533 if (flag
& LDP_CFG_ADD
) {
534 _ldp_global_del_entity(global
, entity
);
536 goto ldp_cfg_entity_set_end
;
538 ldp_entity_add_peer(entity
, peer
);
546 if (flag
& LDP_ENTITY_CFG_TRANS_ADDR
) {
547 if (e
->transport_address
.type
== MPLS_FAMILY_NONE
) {
548 entity
->inherit_flag
|= LDP_ENTITY_CFG_TRANS_ADDR
;
550 entity
->inherit_flag
&= ~LDP_ENTITY_CFG_TRANS_ADDR
;
552 memcpy(&entity
->transport_address
, &e
->transport_address
,
553 sizeof(mpls_inet_addr
));;
555 if (flag
& LDP_ENTITY_CFG_PROTO_VER
) {
556 entity
->protocol_version
= e
->protocol_version
;
558 if (flag
& LDP_ENTITY_CFG_REMOTE_TCP
) {
559 entity
->remote_tcp_port
= e
->remote_tcp_port
;
561 if (flag
& LDP_ENTITY_CFG_REMOTE_UDP
) {
562 entity
->remote_udp_port
= e
->remote_udp_port
;
564 if (flag
& LDP_ENTITY_CFG_MAX_PDU
) {
565 entity
->max_pdu
= e
->max_pdu
;
567 if (flag
& LDP_ENTITY_CFG_KEEPALIVE_TIMER
) {
568 if (e
->transport_address
.type
== MPLS_FAMILY_NONE
) {
569 entity
->inherit_flag
|= LDP_ENTITY_CFG_KEEPALIVE_TIMER
;
571 entity
->inherit_flag
&= ~LDP_ENTITY_CFG_KEEPALIVE_TIMER
;
573 entity
->keepalive_timer
= e
->keepalive_timer
;
575 if (flag
& LDP_ENTITY_CFG_KEEPALIVE_INTERVAL
) {
576 if (e
->transport_address
.type
== MPLS_FAMILY_NONE
) {
577 entity
->inherit_flag
|= LDP_ENTITY_CFG_KEEPALIVE_INTERVAL
;
579 entity
->inherit_flag
&= ~LDP_ENTITY_CFG_KEEPALIVE_INTERVAL
;
581 entity
->keepalive_interval
= e
->keepalive_interval
;
583 if (flag
& LDP_ENTITY_CFG_HELLOTIME_TIMER
) {
584 if (e
->transport_address
.type
== MPLS_FAMILY_NONE
) {
585 entity
->inherit_flag
|= LDP_ENTITY_CFG_HELLOTIME_TIMER
;
587 entity
->inherit_flag
&= ~LDP_ENTITY_CFG_HELLOTIME_TIMER
;
589 entity
->hellotime_timer
= e
->hellotime_timer
;
591 if (flag
& LDP_ENTITY_CFG_HELLOTIME_INTERVAL
) {
592 if (e
->transport_address
.type
== MPLS_FAMILY_NONE
) {
593 entity
->inherit_flag
|= LDP_ENTITY_CFG_HELLOTIME_INTERVAL
;
595 entity
->inherit_flag
&= ~LDP_ENTITY_CFG_HELLOTIME_INTERVAL
;
597 entity
->hellotime_interval
= e
->hellotime_interval
;
599 if (flag
& LDP_ENTITY_CFG_SESSION_SETUP_COUNT
) {
600 entity
->session_setup_count
= e
->session_setup_count
;
602 if (flag
& LDP_ENTITY_CFG_SESSION_BACKOFF_TIMER
) {
603 entity
->session_backoff_timer
= e
->session_backoff_timer
;
605 if (flag
& LDP_ENTITY_CFG_DISTRIBUTION_MODE
) {
606 entity
->label_distribution_mode
= e
->label_distribution_mode
;
608 if (flag
& LDP_ENTITY_CFG_PATHVECTOR_LIMIT
) {
609 entity
->path_vector_limit
= e
->path_vector_limit
;
611 if (flag
& LDP_ENTITY_CFG_HOPCOUNT_LIMIT
) {
612 entity
->hop_count_limit
= e
->hop_count_limit
;
614 if (flag
& LDP_ENTITY_CFG_REQUEST_COUNT
) {
615 entity
->label_request_count
= e
->label_request_count
;
617 if (flag
& LDP_ENTITY_CFG_REQUEST_TIMER
) {
618 entity
->label_request_timer
= e
->label_request_timer
;
620 if (flag
& LDP_ENTITY_CFG_TYPE
) {
621 entity
->entity_type
= e
->entity_type
;
623 if (flag
& LDP_ENTITY_CFG_ADMIN_STATE
) {
624 if (ldp_entity_is_active(entity
) == MPLS_BOOL_TRUE
&&
625 e
->admin_state
== MPLS_ADMIN_DISABLE
) {
626 if (ldp_entity_shutdown(global
, entity
, 0) == MPLS_FAILURE
) {
627 goto ldp_cfg_entity_set_end
;
629 } else if (ldp_entity_is_active(entity
) == MPLS_BOOL_FALSE
&&
630 e
->admin_state
== MPLS_ADMIN_ENABLE
&& ldp_entity_is_ready(entity
) == MPLS_BOOL_TRUE
) {
631 if (ldp_entity_startup(global
, entity
) == MPLS_FAILURE
) {
632 goto ldp_cfg_entity_set_end
;
635 LDP_PRINT(global
->user_data
, "ldp_cfg_entity_set: entity not ready\n");
637 goto ldp_cfg_entity_set_end
;
640 if (flag
& LDP_ENTITY_CFG_INHERIT_FLAG
) {
641 entity
->inherit_flag
= e
->inherit_flag
;
643 global
->configuration_sequence_number
++;
645 retval
= MPLS_SUCCESS
;
647 ldp_cfg_entity_set_end
:
648 mpls_lock_release(global
->global_lock
); /* UNLOCK */
650 LDP_EXIT(global
->user_data
, "ldp_cfg_entity_set");
655 mpls_return_enum
ldp_cfg_entity_adj_getnext(mpls_cfg_handle handle
,
658 ldp_global
*g
= (ldp_global
*) handle
;
659 mpls_bool this_one
= MPLS_BOOL_FALSE
;
660 mpls_return_enum r
= MPLS_FAILURE
;
661 ldp_adj
*adj_next
= NULL
;
663 ldp_entity
*entity
= NULL
;
665 LDP_ENTER(g
->user_data
, "ldp_cfg_entity_adj_getnext");
667 /* if an adj_index of zero is sent, get the index of
668 * the first adj in the list
671 this_one
= MPLS_BOOL_TRUE
;
674 mpls_lock_get(g
->global_lock
); /* LOCK */
676 if (ldp_global_find_entity_index(g
, e
->index
, &entity
) == MPLS_SUCCESS
) {
677 adj
= MPLS_LIST_HEAD(&entity
->adj_root
);
679 if (this_one
== MPLS_BOOL_TRUE
) {
684 /* since the entities are sort in the list ... */
685 if (adj
->index
> e
->adj_index
) {
687 } else if (adj
->index
== e
->adj_index
) {
688 this_one
= MPLS_BOOL_TRUE
;
690 adj
= MPLS_LIST_NEXT(&entity
->adj_root
, adj
, _entity
);
693 mpls_lock_release(g
->global_lock
); /* UNLOCK */
696 e
->adj_index
= adj_next
->index
;
700 LDP_EXIT(g
->user_data
, "ldp_cfg_entity_adj_getnext");
704 /******************* INTERFACE **********************/
706 mpls_return_enum
ldp_cfg_if_get(mpls_cfg_handle handle
, ldp_if
* i
, uint32_t flag
)
708 ldp_global
*global
= (ldp_global
*) handle
;
710 mpls_return_enum retval
= MPLS_FAILURE
;
712 MPLS_ASSERT(global
!=NULL
&& i
!= NULL
);
714 LDP_ENTER(global
->user_data
, "ldp_cfg_if_get");
716 mpls_lock_get(global
->global_lock
); /* LOCK */
718 if (ldp_global_find_if_index(global
, i
->index
, &iff
) != MPLS_SUCCESS
)
719 goto ldp_cfg_if_get_end
;
721 if (flag
& LDP_IF_CFG_NAME
) {
722 strncpy(i
->name
, iff
->name
, MPLS_MAX_IF_NAME
);
724 if (flag
& LDP_IF_CFG_LABEL_SPACE
) {
725 i
->label_space
= iff
->label_space
;
727 if (flag
& LDP_IF_CFG_ENTITY_INDEX
) {
728 i
->entity_index
= iff
->entity
? iff
->entity
->index
: 0;
730 if (flag
& LDP_IF_CFG_OPER_STATE
) {
731 i
->oper_state
= iff
->oper_state
;
733 if (flag
& LDP_IF_CFG_LOCAL_SOURCE_ADDR
) {
734 memcpy(&i
->local_source_address
, &iff
->local_source_address
,
735 sizeof(mpls_inet_addr
));
737 retval
= MPLS_SUCCESS
;
740 mpls_lock_release(global
->global_lock
); /* UNLOCK */
742 LDP_EXIT(global
->user_data
, "ldp_cfg_if_get");
747 mpls_return_enum
ldp_cfg_if_getnext(mpls_cfg_handle handle
, ldp_if
* i
,
750 ldp_global
*g
= (ldp_global
*) handle
;
752 mpls_return_enum r
= MPLS_FAILURE
;
753 mpls_bool done
= MPLS_BOOL_FALSE
;
756 LDP_ENTER(g
->user_data
, "ldp_cfg_if_getnext");
761 index
= i
->index
+ 1;
764 mpls_lock_get(g
->global_lock
); /* LOCK */
765 while (done
== MPLS_BOOL_FALSE
) {
766 switch ((r
= ldp_global_find_if_index(g
, index
, &iff
))) {
768 case MPLS_END_OF_LIST
:
769 done
= MPLS_BOOL_TRUE
;
778 mpls_lock_release(g
->global_lock
); /* UNLOCK */
780 if (r
== MPLS_SUCCESS
) {
781 i
->index
= iff
->index
;
782 LDP_EXIT(g
->user_data
, "ldp_cfg_if_getnext");
783 return ldp_cfg_if_get(g
, i
, flag
);
785 LDP_EXIT(g
->user_data
, "ldp_cfg_if_getnext");
789 mpls_return_enum
ldp_cfg_if_test(mpls_cfg_handle handle
, ldp_if
* i
,
792 ldp_global
*global
= (ldp_global
*) handle
;
794 mpls_return_enum retval
= MPLS_FAILURE
;
796 MPLS_ASSERT(global
!=NULL
&& i
!= NULL
);
798 LDP_ENTER(global
->user_data
, "ldp_cfg_if_test");
800 mpls_lock_get(global
->global_lock
); /* LOCK */
802 if (!(flag
& LDP_CFG_ADD
)) {
803 ldp_global_find_if_index(global
, i
->index
, &iff
);
805 retval
= MPLS_SUCCESS
;
806 goto ldp_cfg_if_test_end
;
810 ((ldp_if_is_active(iff
) == MPLS_BOOL_TRUE
) &&
811 (flag
& LDP_IF_CFG_WHEN_DOWN
))) goto ldp_cfg_if_test_end
;
813 if (flag
& LDP_CFG_DEL
) {
814 if (iff
->entity
!= NULL
)
815 goto ldp_cfg_if_test_end
;
817 retval
= MPLS_SUCCESS
;
820 mpls_lock_release(global
->global_lock
); /* UNLOCK */
822 LDP_EXIT(global
->user_data
, "ldp_cfg_if_test");
827 mpls_return_enum
ldp_cfg_if_set(mpls_cfg_handle handle
, ldp_if
* i
, uint32_t flag
)
829 ldp_global
*global
= (ldp_global
*)handle
;
831 mpls_return_enum retval
= MPLS_FAILURE
;
833 MPLS_ASSERT(global
!=NULL
&& i
!= NULL
);
835 LDP_ENTER(global
->user_data
, "ldp_cfg_if_set");
837 mpls_lock_get(global
->global_lock
); /* LOCK */
839 if (flag
& LDP_CFG_ADD
) {
840 if ((iff
= ldp_global_find_if_handle(global
, i
->handle
)) == NULL
) {
841 if ((iff
= ldp_if_create(global
)) == NULL
) {
842 goto ldp_cfg_if_set_end
;
844 if (mpls_if_handle_verify(global
->ifmgr_handle
, i
->handle
) ==
846 i
->handle
= mpls_ifmgr_open_if(global
->ifmgr_handle
, i
->name
);
848 iff
->handle
= i
->handle
;
850 i
->index
= iff
->index
;
851 strncpy(iff
->name
, i
->name
, MPLS_MAX_IF_NAME
);
852 iff
->used_by_ldp
= MPLS_BOOL_TRUE
;
854 ldp_global_find_if_index(global
, i
->index
, &iff
);
858 ((ldp_if_is_active(iff
) == MPLS_BOOL_TRUE
) &&
859 (flag
& LDP_IF_CFG_WHEN_DOWN
))) goto ldp_cfg_if_set_end
;
861 if (flag
& LDP_CFG_DEL
) {
862 if (iff
->entity
!= NULL
) {
863 goto ldp_cfg_if_set_end
;
866 iff
->used_by_ldp
= MPLS_BOOL_FALSE
;
867 MPLS_REFCNT_RELEASE2(global
, iff
, ldp_if_delete
);
869 retval
= MPLS_SUCCESS
;
870 goto ldp_cfg_if_set_end
;
872 if (flag
& LDP_IF_CFG_INDEX
) {
873 iff
->index
= i
->index
;
875 if (flag
& LDP_IF_CFG_LABEL_SPACE
) {
876 iff
->label_space
= i
->label_space
;
878 global
->configuration_sequence_number
++;
880 retval
= MPLS_SUCCESS
;
883 mpls_lock_release(global
->global_lock
); /* UNLOCK */
885 LDP_EXIT(global
->user_data
, "ldp_cfg_if_set");
890 /******************* ATTR **********************/
892 mpls_return_enum
ldp_cfg_attr_get(mpls_cfg_handle handle
, ldp_attr
* a
,
895 ldp_global
*global
= (ldp_global
*) handle
;
896 ldp_attr
*attr
= NULL
;
897 mpls_return_enum retval
= MPLS_FAILURE
;
899 MPLS_ASSERT(global
!=NULL
&& a
!= NULL
);
901 LDP_ENTER(global
->user_data
, "ldp_cfg_attr_get");
903 mpls_lock_get(global
->global_lock
); /* LOCK */
905 if (ldp_global_find_attr_index(global
, a
->index
, &attr
) != MPLS_SUCCESS
)
906 goto ldp_cfg_attr_get_end
;
908 if (flag
& LDP_ATTR_CFG_STATE
) {
909 a
->state
= attr
->state
;
911 if (flag
& LDP_ATTR_CFG_FEC
) {
912 ldp_attr2ldp_attr(attr
, a
, LDP_ATTR_FEC
);
914 if (flag
& LDP_ATTR_CFG_LABEL
) {
915 ldp_attr2ldp_attr(attr
, a
, LDP_ATTR_LABEL
);
917 if (flag
& LDP_ATTR_CFG_HOP_COUNT
) {
918 ldp_attr2ldp_attr(attr
, a
, LDP_ATTR_HOPCOUNT
);
920 if (flag
& LDP_ATTR_CFG_PATH
) {
921 ldp_attr2ldp_attr(attr
, a
, LDP_ATTR_PATH
);
923 if (flag
& LDP_ATTR_CFG_SESSION_INDEX
) {
924 a
->session_index
= (attr
->session
) ? (attr
->session
->index
) : 0;
926 if (flag
& LDP_ATTR_CFG_INLABEL_INDEX
) {
927 a
->inlabel_index
= (attr
->inlabel
) ? (attr
->inlabel
->index
) : 0;
929 if (flag
& LDP_ATTR_CFG_OUTLABEL_INDEX
) {
930 a
->outlabel_index
= (attr
->outlabel
) ? (attr
->outlabel
->index
) : 0;
932 if (flag
& LDP_ATTR_CFG_INGRESS
) {
933 a
->ingress
= attr
->ingress
;
935 retval
= MPLS_SUCCESS
;
937 ldp_cfg_attr_get_end
:
938 mpls_lock_release(global
->global_lock
); /* UNLOCK */
940 LDP_EXIT(global
->user_data
, "ldp_cfg_attr_get");
945 mpls_return_enum
ldp_cfg_attr_getnext(mpls_cfg_handle handle
, ldp_attr
* a
,
948 ldp_global
*g
= (ldp_global
*) handle
;
949 ldp_attr
*attr
= NULL
;
950 mpls_return_enum r
= MPLS_FAILURE
;
951 mpls_bool done
= MPLS_BOOL_FALSE
;
954 LDP_ENTER(g
->user_data
, "ldp_cfg_attr_getnext");
959 index
= a
->index
+ 1;
962 mpls_lock_get(g
->global_lock
); /* LOCK */
963 while (done
== MPLS_BOOL_FALSE
) {
964 switch ((r
= ldp_global_find_attr_index(g
, index
, &attr
))) {
966 case MPLS_END_OF_LIST
:
967 done
= MPLS_BOOL_TRUE
;
976 mpls_lock_release(g
->global_lock
); /* UNLOCK */
978 if (r
== MPLS_SUCCESS
) {
979 a
->index
= attr
->index
;
980 LDP_EXIT(g
->user_data
, "ldp_cfg_attr_getnext");
981 return ldp_cfg_attr_get(g
, a
, flag
);
983 LDP_EXIT(g
->user_data
, "ldp_cfg_attr_getnext");
987 /******************* PEER **********************/
989 mpls_return_enum
ldp_cfg_peer_get(mpls_cfg_handle handle
, ldp_peer
* p
,
992 ldp_global
*global
= (ldp_global
*) handle
;
993 ldp_peer
*peer
= NULL
;
994 mpls_return_enum retval
= MPLS_FAILURE
;
996 MPLS_ASSERT(global
!=NULL
&& p
!= NULL
);
998 LDP_ENTER(global
->user_data
, "ldp_cfg_peer_get");
1000 mpls_lock_get(global
->global_lock
); /* LOCK */
1002 if (ldp_global_find_peer_index(global
, p
->index
, &peer
) != MPLS_SUCCESS
)
1003 goto ldp_cfg_peer_get_end
;
1005 if (flag
& LDP_PEER_CFG_LABEL_SPACE
) {
1006 p
->label_space
= peer
->label_space
;
1008 if (flag
& LDP_PEER_CFG_TARGET_ROLE
) {
1009 p
->target_role
= peer
->target_role
;
1011 if (flag
& LDP_PEER_CFG_DEST_ADDR
) {
1012 memcpy(&p
->dest
.addr
, &peer
->dest
.addr
, sizeof(mpls_inet_addr
));
1014 if (flag
& LDP_PEER_CFG_ENTITY_INDEX
) {
1015 p
->entity_index
= peer
->entity
->index
;
1017 if (flag
& LDP_PEER_CFG_OPER_STATE
) {
1018 p
->oper_state
= peer
->oper_state
;
1020 if (flag
& LDP_PEER_CFG_PEER_NAME
) {
1021 strncpy(p
->peer_name
, peer
->peer_name
, MPLS_MAX_IF_NAME
);
1023 if (flag
& LDP_PEER_CFG_LOCAL_SOURCE_ADDR
) {
1024 memcpy(&p
->local_source_address
, &peer
->local_source_address
,
1025 sizeof(mpls_inet_addr
));
1027 retval
= MPLS_SUCCESS
;
1029 ldp_cfg_peer_get_end
:
1030 mpls_lock_release(global
->global_lock
); /* UNLOCK */
1032 LDP_EXIT(global
->user_data
, "ldp_cfg_peer_get");
1037 mpls_return_enum
ldp_cfg_peer_getnext(mpls_cfg_handle handle
, ldp_peer
* p
,
1040 ldp_global
*g
= (ldp_global
*) handle
;
1041 ldp_peer
*peer
= NULL
;
1042 mpls_return_enum r
= MPLS_FAILURE
;
1043 mpls_bool done
= MPLS_BOOL_FALSE
;
1046 LDP_ENTER(g
->user_data
, "ldp_cfg_peer_getnext");
1048 if (p
->index
== 0) {
1051 index
= p
->index
+ 1;
1054 mpls_lock_get(g
->global_lock
); /* LOCK */
1055 while (done
== MPLS_BOOL_FALSE
) {
1056 switch ((r
= ldp_global_find_peer_index(g
, index
, &peer
))) {
1058 case MPLS_END_OF_LIST
:
1059 done
= MPLS_BOOL_TRUE
;
1068 mpls_lock_release(g
->global_lock
); /* UNLOCK */
1070 if (r
== MPLS_SUCCESS
) {
1071 p
->index
= peer
->index
;
1072 LDP_EXIT(g
->user_data
, "ldp_cfg_peer_getnext");
1073 return ldp_cfg_peer_get(g
, p
, flag
);
1075 LDP_EXIT(g
->user_data
, "ldp_cfg_peer_getnext");
1079 mpls_return_enum
ldp_cfg_peer_test(mpls_cfg_handle handle
, ldp_peer
* p
,
1082 // ldp_global* g = (ldp_global*)handle;
1083 return MPLS_SUCCESS
;
1086 mpls_return_enum
ldp_cfg_peer_set(mpls_cfg_handle handle
, ldp_peer
* p
,
1089 ldp_global
*global
= (ldp_global
*) handle
;
1090 ldp_peer
*peer
= NULL
;
1091 mpls_return_enum retval
= MPLS_FAILURE
;
1093 MPLS_ASSERT(global
!=NULL
&& p
!= NULL
);
1095 LDP_ENTER(global
->user_data
, "ldp_cfg_peer_set");
1097 mpls_lock_get(global
->global_lock
); /* LOCK */
1099 if (flag
& LDP_CFG_ADD
) {
1100 if ((peer
= ldp_peer_create()) == NULL
) {
1101 goto ldp_cfg_peer_set_end
;
1103 p
->index
= peer
->index
;
1104 _ldp_global_add_peer(global
, peer
);
1106 ldp_global_find_peer_index(global
, p
->index
, &peer
);
1110 LDP_PRINT(global
->user_data
, "ldp_cfg_peer_set: no such peer\n");
1112 goto ldp_cfg_peer_set_end
;
1114 if ((ldp_peer_is_active(peer
) == MPLS_BOOL_TRUE
) && (flag
& LDP_PEER_CFG_WHEN_DOWN
)) {
1115 LDP_PRINT(global
->user_data
, "ldp_cfg_peer_set: peer is activer\n");
1117 goto ldp_cfg_peer_set_end
;
1120 if (flag
& LDP_CFG_DEL
) {
1121 if (peer
->entity
!= NULL
) {
1122 LDP_PRINT(global
->user_data
,
1123 "ldp_cfg_peer_set: not cleanup correctly is activer\n");
1125 goto ldp_cfg_peer_set_end
;
1128 _ldp_global_del_peer(global
, peer
);
1130 retval
= MPLS_SUCCESS
;
1131 goto ldp_cfg_peer_set_end
;
1133 if (flag
& LDP_PEER_CFG_LABEL_SPACE
) {
1134 peer
->label_space
= p
->label_space
;
1136 if (flag
& LDP_PEER_CFG_TARGET_ROLE
) {
1137 peer
->target_role
= p
->target_role
;
1139 if (flag
& LDP_PEER_CFG_DEST_ADDR
) {
1140 memcpy(&peer
->dest
.addr
, &p
->dest
.addr
, sizeof(mpls_inet_addr
));
1142 if (flag
& LDP_PEER_CFG_PEER_NAME
) {
1143 LDP_PRINT(global
->user_data
, "ldp_cfg_peer_set: peer_name = %s\n",
1146 strncpy(peer
->peer_name
, p
->peer_name
, MPLS_MAX_IF_NAME
);
1148 global
->configuration_sequence_number
++;
1150 retval
= MPLS_SUCCESS
;
1152 ldp_cfg_peer_set_end
:
1153 mpls_lock_release(global
->global_lock
); /* UNLOCK */
1155 LDP_EXIT(global
->user_data
, "ldp_cfg_peer_set");
1159 /******************* FEC **********************/
1161 mpls_return_enum
ldp_cfg_fec_get(mpls_cfg_handle handle
, mpls_fec
* f
,
1164 ldp_global
*global
= (ldp_global
*) handle
;
1165 ldp_fec
*fec
= NULL
;
1166 mpls_return_enum retval
= MPLS_FAILURE
;
1168 MPLS_ASSERT(global
!=NULL
&& f
!= NULL
);
1170 LDP_ENTER(global
->user_data
, "ldp_cfg_fec_get");
1172 mpls_lock_get(global
->global_lock
); /* LOCK */
1174 if (flag
& LDP_FEC_CFG_BY_INDEX
) {
1175 ldp_global_find_fec_index(global
, f
->index
, &fec
);
1177 fec
= ldp_fec_find(global
, f
);
1180 goto ldp_cfg_fec_get_end
;
1182 memcpy(f
, &fec
->info
, sizeof(mpls_fec
));
1183 retval
= MPLS_SUCCESS
;
1185 ldp_cfg_fec_get_end
:
1186 mpls_lock_release(global
->global_lock
); /* UNLOCK */
1188 LDP_EXIT(global
->user_data
, "ldp_cfg_fec_get");
1193 mpls_return_enum
ldp_cfg_fec_getnext(mpls_cfg_handle handle
, mpls_fec
* f
,
1196 ldp_global
*g
= (ldp_global
*) handle
;
1197 ldp_fec
*fec
= NULL
;
1198 mpls_return_enum r
= MPLS_FAILURE
;
1199 mpls_bool done
= MPLS_BOOL_FALSE
;
1202 LDP_ENTER(g
->user_data
, "ldp_cfg_fec_getnext");
1204 if (f
->index
== 0) {
1207 index
= f
->index
+ 1;
1210 mpls_lock_get(g
->global_lock
); /* LOCK */
1211 while (done
== MPLS_BOOL_FALSE
) {
1212 switch ((r
= ldp_global_find_fec_index(g
, index
, &fec
))) {
1214 case MPLS_END_OF_LIST
:
1215 done
= MPLS_BOOL_TRUE
;
1224 mpls_lock_release(g
->global_lock
); /* UNLOCK */
1226 if (r
== MPLS_SUCCESS
) {
1227 f
->index
= fec
->index
;
1228 LDP_EXIT(g
->user_data
, "ldp_cfg_fec_getnext");
1229 return ldp_cfg_fec_get(g
, f
, flag
);
1231 LDP_EXIT(g
->user_data
, "ldp_cfg_fec_getnext");
1235 mpls_return_enum
ldp_cfg_fec_test(mpls_cfg_handle handle
, mpls_fec
* f
,
1238 // ldp_global* g = (ldp_global*)handle;
1239 return MPLS_SUCCESS
;
1242 mpls_return_enum
ldp_cfg_fec_set(mpls_cfg_handle handle
, mpls_fec
* f
,
1245 ldp_global
*global
= (ldp_global
*) handle
;
1246 ldp_fec
*fec
= NULL
;
1247 mpls_return_enum retval
= MPLS_FAILURE
;
1249 MPLS_ASSERT(global
!=NULL
&& f
!= NULL
);
1251 LDP_ENTER(global
->user_data
, "ldp_cfg_fec_set");
1253 mpls_lock_get(global
->global_lock
); /* LOCK */
1255 if (flag
& LDP_CFG_ADD
) {
1256 if (ldp_fec_find(global
, f
) || (fec
= ldp_fec_create()) == NULL
) {
1257 goto ldp_cfg_fec_set_end
;
1259 f
->index
= fec
->index
;
1260 mpls_fec2ldp_fec(f
, fec
);
1261 _ldp_global_add_fec(global
, fec
);
1262 ldp_fec_insert2(global
, fec
);
1264 if (flag
& LDP_FEC_CFG_BY_INDEX
) {
1265 ldp_global_find_fec_index(global
, f
->index
, &fec
);
1267 fec
= ldp_fec_find(global
, f
);
1272 LDP_PRINT(global
->user_data
, "ldp_cfg_fec_set: no such fec\n");
1273 goto ldp_cfg_fec_set_end
;
1276 if (flag
& LDP_CFG_DEL
) {
1277 ldp_fec_remove(global
,&fec
->info
);
1278 _ldp_global_del_fec(global
, fec
);
1281 retval
= MPLS_SUCCESS
;
1283 ldp_cfg_fec_set_end
:
1284 mpls_lock_release(global
->global_lock
); /* UNLOCK */
1286 LDP_EXIT(global
->user_data
, "ldp_cfg_fec_set");
1291 mpls_return_enum
ldp_cfg_fec_nexthop_get(mpls_cfg_handle handle
, mpls_fec
* f
,
1292 mpls_nexthop
*n
, uint32_t flag
)
1294 ldp_global
*global
= (ldp_global
*) handle
;
1295 ldp_fec
*fec
= NULL
;
1296 ldp_nexthop
*nh
= NULL
;
1297 mpls_return_enum retval
= MPLS_FAILURE
;
1299 MPLS_ASSERT(global
!=NULL
&& f
!= NULL
);
1301 LDP_ENTER(global
->user_data
, "ldp_cfg_fec_nexthop_get");
1303 mpls_lock_get(global
->global_lock
); /* LOCK */
1305 if (flag
& LDP_FEC_CFG_BY_INDEX
) {
1306 ldp_global_find_fec_index(global
, f
->index
, &fec
);
1308 fec
= ldp_fec_find(global
, f
);
1311 goto ldp_cfg_fec_nexthop_get_end
;
1313 if (flag
& LDP_FEC_NEXTHOP_CFG_BY_INDEX
) {
1314 ldp_fec_find_nexthop_index(fec
, n
->index
, &nh
);
1316 nh
= ldp_fec_nexthop_find(fec
, n
);
1319 goto ldp_cfg_fec_nexthop_get_end
;
1321 memcpy(n
, nh
, sizeof(mpls_nexthop
));
1322 retval
= MPLS_SUCCESS
;
1324 ldp_cfg_fec_nexthop_get_end
:
1325 mpls_lock_release(global
->global_lock
); /* UNLOCK */
1327 LDP_EXIT(global
->user_data
, "ldp_cfg_fec_nexthop_get");
1332 mpls_return_enum
ldp_cfg_fec_nexthop_getnext(mpls_cfg_handle handle
,
1333 mpls_fec
* f
, mpls_nexthop
*n
, uint32_t flag
)
1335 ldp_global
*global
= (ldp_global
*) handle
;
1336 ldp_fec
*fec
= NULL
;
1337 ldp_nexthop
*nh
= NULL
;
1338 mpls_return_enum r
= MPLS_FAILURE
;
1339 mpls_bool done
= MPLS_BOOL_FALSE
;
1342 LDP_ENTER(global
->user_data
, "ldp_cfg_fec_nexthop_getnext");
1344 if (n
->index
== 0) {
1347 index
= n
->index
+ 1;
1350 mpls_lock_get(global
->global_lock
); /* LOCK */
1352 if (flag
& LDP_FEC_CFG_BY_INDEX
) {
1353 ldp_global_find_fec_index(global
, f
->index
, &fec
);
1355 fec
= ldp_fec_find(global
, f
);
1358 goto ldp_cfg_fec_nexthop_getnext_end
;
1360 while (done
== MPLS_BOOL_FALSE
) {
1361 switch ((r
= ldp_fec_find_nexthop_index(fec
, index
, &nh
))) {
1363 case MPLS_END_OF_LIST
:
1364 done
= MPLS_BOOL_TRUE
;
1373 mpls_lock_release(global
->global_lock
); /* UNLOCK */
1375 if (r
== MPLS_SUCCESS
) {
1376 n
->index
= nh
->index
;
1377 LDP_EXIT(global
->user_data
, "ldp_cfg_fec_getnext");
1378 return ldp_cfg_fec_nexthop_get(global
, f
, n
,
1379 flag
& ~LDP_FEC_NEXTHOP_CFG_BY_INDEX
);
1382 ldp_cfg_fec_nexthop_getnext_end
:
1384 LDP_EXIT(global
->user_data
, "ldp_cfg_fec_getnext");
1388 mpls_return_enum
ldp_cfg_fec_nexthop_test(mpls_cfg_handle handle
, mpls_fec
* f
,
1389 mpls_nexthop
*n
, uint32_t flag
)
1391 // ldp_global* g = (ldp_global*)handle;
1392 return MPLS_SUCCESS
;
1395 mpls_return_enum
ldp_cfg_fec_nexthop_set(mpls_cfg_handle handle
, mpls_fec
* f
,
1396 mpls_nexthop
*n
, uint32_t flag
)
1398 ldp_global
*global
= (ldp_global
*) handle
;
1399 ldp_fec
*fec
= NULL
;
1400 ldp_nexthop
*nh
= NULL
;
1401 mpls_return_enum retval
= MPLS_FAILURE
;
1403 MPLS_ASSERT(global
!=NULL
&& f
!= NULL
&& n
!= NULL
);
1405 LDP_ENTER(global
->user_data
, "ldp_cfg_fec_nexthop_set");
1407 mpls_lock_get(global
->global_lock
); /* LOCK */
1409 if (flag
& LDP_FEC_CFG_BY_INDEX
) {
1410 ldp_global_find_fec_index(global
, f
->index
, &fec
);
1412 fec
= ldp_fec_find(global
, f
);
1415 goto ldp_cfg_fec_nexthop_set_end
;
1417 if (flag
& LDP_CFG_ADD
) {
1418 if (ldp_fec_nexthop_find(fec
, n
) || (nh
= ldp_nexthop_create()) == NULL
) {
1419 goto ldp_cfg_fec_nexthop_set_end
;
1421 n
->index
= nh
->index
;
1422 mpls_nexthop2ldp_nexthop(n
, nh
);
1423 _ldp_global_add_nexthop(global
, nh
);
1424 ldp_fec_add_nexthop(global
, fec
, nh
);
1426 if (flag
& LDP_FEC_NEXTHOP_CFG_BY_INDEX
) {
1427 ldp_fec_find_nexthop_index(fec
, n
->index
, &nh
);
1429 nh
= ldp_fec_nexthop_find(fec
, n
);
1434 LDP_PRINT(global
->user_data
, "ldp_cfg_fec_nexthop_set: no such nh\n");
1435 goto ldp_cfg_fec_nexthop_set_end
;
1438 if (flag
& LDP_CFG_DEL
) {
1439 ldp_fec_del_nexthop(global
, fec
,nh
);
1440 _ldp_global_del_nexthop(global
, nh
);
1443 retval
= MPLS_SUCCESS
;
1445 ldp_cfg_fec_nexthop_set_end
:
1446 mpls_lock_release(global
->global_lock
); /* UNLOCK */
1448 LDP_EXIT(global
->user_data
, "ldp_cfg_fec_nexthop_set");
1453 /******************* ADDR **********************/
1455 mpls_return_enum
ldp_cfg_if_addr_get(mpls_cfg_handle handle
, ldp_if
* i
,
1456 mpls_inet_addr
* a
, uint32_t flag
)
1458 ldp_global
*global
= (ldp_global
*) handle
;
1459 ldp_addr
*addr
= NULL
;
1461 mpls_return_enum retval
= MPLS_FAILURE
;
1463 MPLS_ASSERT(global
!=NULL
&& i
!= NULL
&& a
!= NULL
);
1465 LDP_ENTER(global
->user_data
, "ldp_cfg_if_addr_get");
1467 mpls_lock_get(global
->global_lock
); /* LOCK */
1469 if ((iff
= ldp_global_find_if_handle(global
, i
->handle
)) == NULL
)
1470 goto ldp_cfg_if_addr_get_end
;
1472 if (!(addr
= ldp_if_addr_find(iff
, a
)))
1473 goto ldp_cfg_if_addr_get_end
;
1475 retval
= MPLS_SUCCESS
;
1477 ldp_cfg_if_addr_get_end
:
1478 mpls_lock_release(global
->global_lock
); /* UNLOCK */
1480 LDP_EXIT(global
->user_data
, "ldp_cfg_if_addr_get");
1485 mpls_return_enum
ldp_cfg_if_addr_set(mpls_cfg_handle handle
, ldp_if
* i
,
1486 mpls_inet_addr
* a
, uint32_t flag
)
1488 ldp_global
*global
= (ldp_global
*) handle
;
1489 ldp_addr
*addr
= NULL
;
1491 mpls_return_enum retval
= MPLS_FAILURE
;
1493 MPLS_ASSERT(global
!=NULL
&& i
!= NULL
&& a
!= NULL
);
1495 LDP_ENTER(global
->user_data
, "ldp_if_cfg_addr_set");
1497 mpls_lock_get(global
->global_lock
); /* LOCK */
1499 if ((iff
= ldp_global_find_if_handle(global
, i
->handle
)) == NULL
)
1500 goto ldp_cfg_if_addr_set_end
;
1502 addr
= ldp_if_addr_find(iff
, a
);
1503 if (flag
& LDP_CFG_ADD
) {
1504 if ((addr
) || ((addr
= ldp_addr_create(global
, a
)) == NULL
)) {
1505 goto ldp_cfg_if_addr_set_end
;
1507 ldp_addr_insert2(global
, addr
);
1508 ldp_if_add_addr(iff
, addr
);
1512 LDP_PRINT(global
->user_data
, "ldp_if_cfg_addr_set: no such addr\n");
1513 goto ldp_cfg_if_addr_set_end
;
1516 if (flag
& LDP_CFG_DEL
) {
1517 ldp_if_del_addr(global
, iff
, addr
);
1518 if (ldp_addr_is_empty(addr
)) {
1519 ldp_addr_remove(global
, &addr
->address
);
1523 retval
= MPLS_SUCCESS
;
1525 ldp_cfg_if_addr_set_end
:
1526 mpls_lock_release(global
->global_lock
); /* UNLOCK */
1528 LDP_EXIT(global
->user_data
, "ldp_cfg_if_addr_set");
1532 /******************* ADJACENCY **********************/
1534 mpls_return_enum
ldp_cfg_adj_get(mpls_cfg_handle handle
, ldp_adj
* a
,
1537 ldp_global
*global
= (ldp_global
*) handle
;
1538 ldp_adj
*adj
= NULL
;
1539 mpls_return_enum retval
= MPLS_FAILURE
;
1541 MPLS_ASSERT(global
!=NULL
&& a
!= NULL
);
1543 LDP_ENTER(global
->user_data
, "ldp_cfg_adj_get");
1545 mpls_lock_get(global
->global_lock
); /* LOCK */
1547 if (ldp_global_find_adj_index(global
, a
->index
, &adj
) != MPLS_SUCCESS
)
1548 goto ldp_cfg_adj_get_end
;
1550 if (flag
& LDP_ADJ_CFG_REMOTE_TRADDR
) {
1551 memcpy(&a
->remote_transport_address
, &adj
->remote_transport_address
,
1552 sizeof(mpls_inet_addr
));
1554 if (flag
& LDP_ADJ_CFG_REMOTE_SRCADDR
) {
1555 memcpy(&a
->remote_source_address
, &adj
->remote_source_address
,
1556 sizeof(mpls_inet_addr
));
1558 if (flag
& LDP_ADJ_CFG_REMOTE_LSRADDR
) {
1559 memcpy(&a
->remote_lsr_address
, &adj
->remote_lsr_address
,
1560 sizeof(mpls_inet_addr
));
1562 if (flag
& LDP_ADJ_CFG_REMOTE_CSN
) {
1563 a
->remote_csn
= adj
->remote_csn
;
1565 if (flag
& LDP_ADJ_CFG_REMOTE_LABELSPACE
) {
1566 a
->remote_label_space
= adj
->remote_label_space
;
1568 if (flag
& LDP_ADJ_CFG_REMOTE_HELLOTIME
) {
1569 a
->remote_hellotime
= adj
->remote_hellotime
;
1571 if (flag
& LDP_ADJ_CFG_ENTITY_INDEX
) {
1572 a
->entity_index
= adj
->entity
? adj
->entity
->index
: 0;
1574 if (flag
& LDP_ADJ_CFG_REMOTE_SESSION_INDEX
) {
1575 a
->session_index
= (adj
->session
) ? (adj
->session
->index
) : 0;
1577 if (flag
& LDP_ADJ_CFG_ROLE
) {
1578 a
->role
= adj
->role
;
1580 retval
= MPLS_SUCCESS
;
1582 ldp_cfg_adj_get_end
:
1584 mpls_lock_release(global
->global_lock
); /* UNLOCK */
1586 LDP_EXIT(global
->user_data
, "ldp_cfg_adj_get");
1591 mpls_return_enum
ldp_cfg_adj_getnext(mpls_cfg_handle handle
, ldp_adj
* a
,
1594 ldp_global
*g
= (ldp_global
*) handle
;
1595 ldp_adj
*adj
= NULL
;
1596 mpls_return_enum r
= MPLS_FAILURE
;
1597 mpls_bool done
= MPLS_BOOL_FALSE
;
1600 LDP_ENTER(g
->user_data
, "ldp_cfg_adj_getnext");
1602 if (a
->index
== 0) {
1605 index
= a
->index
+ 1;
1608 mpls_lock_get(g
->global_lock
); /* LOCK */
1609 while (done
== MPLS_BOOL_FALSE
) {
1610 switch ((r
= ldp_global_find_adj_index(g
, index
, &adj
))) {
1612 case MPLS_END_OF_LIST
:
1613 done
= MPLS_BOOL_TRUE
;
1622 mpls_lock_release(g
->global_lock
); /* UNLOCK */
1624 if (r
== MPLS_SUCCESS
) {
1625 a
->index
= adj
->index
;
1626 LDP_EXIT(g
->user_data
, "ldp_cfg_adj_getnext");
1627 return ldp_cfg_adj_get(g
, a
, flag
);
1629 LDP_EXIT(g
->user_data
, "ldp_cfg_adj_getnext");
1633 /******************* SESSION **********************/
1635 mpls_return_enum
ldp_cfg_session_get(mpls_cfg_handle handle
, ldp_session
* s
,
1638 ldp_global
*global
= (ldp_global
*) handle
;
1639 ldp_session
*session
= NULL
;
1640 mpls_return_enum retval
= MPLS_FAILURE
;
1642 MPLS_ASSERT(global
!=NULL
&& s
!= NULL
);
1644 LDP_ENTER(global
->user_data
, "ldp_cfg_session_get");
1646 mpls_lock_get(global
->global_lock
); /* LOCK */
1648 if (ldp_global_find_session_index(global
, s
->index
, &session
) != MPLS_SUCCESS
)
1649 goto ldp_cfg_session_get_end
;
1651 if (flag
& LDP_SESSION_CFG_STATE
) {
1652 s
->state
= session
->state
;
1654 if (flag
& LDP_SESSION_CFG_OPER_UP
) {
1655 s
->oper_up
= session
->oper_up
;
1657 if (flag
& LDP_SESSION_CFG_MAX_PDU
) {
1658 s
->oper_max_pdu
= session
->oper_max_pdu
;
1660 if (flag
& LDP_SESSION_CFG_KEEPALIVE
) {
1661 s
->oper_keepalive
= session
->oper_keepalive
;
1663 if (flag
& LDP_SESSION_CFG_PATH_LIMIT
) {
1664 s
->oper_path_vector_limit
= session
->oper_path_vector_limit
;
1666 if (flag
& LDP_SESSION_CFG_DIST_MODE
) {
1667 s
->oper_distribution_mode
= session
->oper_distribution_mode
;
1669 if (flag
& LDP_SESSION_CFG_LOOP_DETECTION
) {
1670 s
->oper_loop_detection
= session
->oper_loop_detection
;
1672 if (flag
& LDP_SESSION_CFG_REMOTE_MAX_PDU
) {
1673 s
->remote_max_pdu
= session
->remote_max_pdu
;
1675 if (flag
& LDP_SESSION_CFG_REMOTE_KEEPALIVE
) {
1676 s
->remote_keepalive
= session
->remote_keepalive
;
1678 if (flag
& LDP_SESSION_CFG_REMOTE_PATH_LIMIT
) {
1679 s
->remote_path_vector_limit
= session
->remote_path_vector_limit
;
1681 if (flag
& LDP_SESSION_CFG_REMOTE_DIST_MODE
) {
1682 s
->remote_distribution_mode
= session
->remote_distribution_mode
;
1684 if (flag
& LDP_SESSION_CFG_REMOTE_LOOP_DETECTION
) {
1685 s
->remote_loop_detection
= session
->remote_loop_detection
;
1687 if (flag
& LDP_SESSION_CFG_REMOTE_ADDR
) {
1688 s
->remote_dest
.addr
.type
= session
->remote_dest
.addr
.type
;
1689 s
->remote_dest
.addr
.u
.ipv4
= session
->remote_dest
.addr
.u
.ipv4
;
1691 if (flag
& LDP_SESSION_CFG_REMOTE_PORT
) {
1692 s
->remote_dest
.port
= session
->remote_dest
.port
;
1694 if (flag
& LDP_SESSION_CFG_LABEL_RESOURCE_STATE_LOCAL
) {
1695 s
->no_label_resource_sent
= session
->no_label_resource_sent
;
1697 if (flag
& LDP_SESSION_CFG_LABEL_RESOURCE_STATE_REMOTE
) {
1698 s
->no_label_resource_recv
= session
->no_label_resource_recv
;
1700 if (flag
& LDP_SESSION_CFG_ADJ_INDEX
) {
1701 ldp_adj
*a
= MPLS_LIST_HEAD(&session
->adj_root
);
1702 s
->adj_index
= a
? a
->index
: 0;
1704 if (flag
& LDP_SESSION_CFG_MESG_TX
) {
1705 s
->mesg_tx
= session
->mesg_tx
;
1707 if (flag
& LDP_SESSION_CFG_MESG_RX
) {
1708 s
->mesg_rx
= session
->mesg_rx
;
1710 retval
= MPLS_SUCCESS
;
1712 ldp_cfg_session_get_end
:
1713 mpls_lock_release(global
->global_lock
); /* UNLOCK */
1715 LDP_EXIT(global
->user_data
, "ldp_cfg_session_get");
1720 mpls_return_enum
ldp_cfg_session_getnext(mpls_cfg_handle handle
, ldp_session
* s
,
1723 ldp_global
*g
= (ldp_global
*) handle
;
1724 ldp_session
*ses
= NULL
;
1725 mpls_return_enum r
= MPLS_FAILURE
;
1726 mpls_bool done
= MPLS_BOOL_FALSE
;
1729 LDP_ENTER(g
->user_data
, "ldp_cfg_session_getnext");
1731 if (s
->index
== 0) {
1734 index
= s
->index
+ 1;
1737 mpls_lock_get(g
->global_lock
); /* LOCK */
1738 while (done
== MPLS_BOOL_FALSE
) {
1739 switch ((r
= ldp_global_find_session_index(g
, index
, &ses
))) {
1741 case MPLS_END_OF_LIST
:
1742 done
= MPLS_BOOL_TRUE
;
1751 mpls_lock_release(g
->global_lock
); /* UNLOCK */
1753 if (r
== MPLS_SUCCESS
) {
1754 s
->index
= ses
->index
;
1756 LDP_EXIT(g
->user_data
, "ldp_cfg_session_getnext");
1757 return ldp_cfg_session_get(g
, s
, flag
);
1760 LDP_EXIT(g
->user_data
, "ldp_cfg_session_getnext");
1765 mpls_return_enum
ldp_cfg_session_adj_getnext(mpls_cfg_handle handle
,
1768 ldp_global
*g
= (ldp_global
*) handle
;
1769 mpls_bool this_one
= MPLS_BOOL_FALSE
;
1770 mpls_return_enum r
= MPLS_FAILURE
;
1771 ldp_adj
*adj_next
= NULL
;
1772 ldp_adj
*adj
= NULL
;
1773 ldp_session
*session
= NULL
;
1775 LDP_ENTER(g
->user_data
, "ldp_cfg_session_adj_getnext");
1777 /* if an adj_index of zero is sent, get the index of
1778 * the first adj in the list
1780 if (!s
->adj_index
) {
1781 this_one
= MPLS_BOOL_TRUE
;
1784 mpls_lock_get(g
->global_lock
); /* LOCK */
1786 if (ldp_global_find_session_index(g
, s
->index
, &session
) == MPLS_SUCCESS
) {
1787 adj
= MPLS_LIST_HEAD(&session
->adj_root
);
1789 if (this_one
== MPLS_BOOL_TRUE
) {
1794 /* since the entities are sort in the list ... */
1795 if (adj
->index
> s
->adj_index
) {
1797 } else if (adj
->index
== s
->adj_index
) {
1798 this_one
= MPLS_BOOL_TRUE
;
1800 adj
= MPLS_LIST_NEXT(&session
->adj_root
, adj
, _session
);
1803 mpls_lock_release(g
->global_lock
); /* UNLOCK */
1806 s
->adj_index
= adj_next
->index
;
1810 LDP_EXIT(g
->user_data
, "ldp_cfg_session_adj_getnext");
1814 mpls_return_enum
ldp_cfg_session_raddr_get(mpls_cfg_handle handle
,
1815 ldp_session
* s
, ldp_addr
* a
, uint32_t flag
)
1817 ldp_global
*global
= (ldp_global
*) handle
;
1818 ldp_session
*session
= NULL
;
1819 ldp_addr
*addr
= NULL
;
1820 mpls_return_enum retval
= MPLS_FAILURE
;
1822 MPLS_ASSERT(global
!=NULL
&& s
!= NULL
&& a
!= NULL
);
1824 LDP_ENTER(global
->user_data
, "ldp_cfg_session_raddr_get");
1826 mpls_lock_get(global
->global_lock
); /* LOCK */
1828 if (ldp_global_find_session_index(global
, s
->index
, &session
) != MPLS_SUCCESS
)
1829 goto ldp_cfg_session_raddr_get_end
;
1831 if (ldp_session_find_raddr_index(session
, a
->index
, &addr
) != MPLS_SUCCESS
)
1832 goto ldp_cfg_session_raddr_get_end
;
1834 if (flag
& LDP_SESSION_RADDR_CFG_ADDR
) {
1835 memcpy(&a
->address
,&addr
->address
,sizeof(struct mpls_inet_addr
));
1837 if (flag
& LDP_SESSION_RADDR_CFG_INDEX
) {
1838 a
->index
= addr
->index
;
1840 retval
= MPLS_SUCCESS
;
1842 ldp_cfg_session_raddr_get_end
:
1843 mpls_lock_release(global
->global_lock
); /* UNLOCK */
1845 LDP_EXIT(global
->user_data
, "ldp_cfg_session_raddr_get");
1850 mpls_return_enum
ldp_cfg_session_raddr_getnext(mpls_cfg_handle handle
,
1851 ldp_session
* s
, ldp_addr
* a
, uint32_t flag
)
1853 ldp_global
*g
= (ldp_global
*) handle
;
1854 ldp_addr
*addr
= NULL
;
1855 mpls_return_enum r
= MPLS_FAILURE
;
1856 mpls_bool done
= MPLS_BOOL_FALSE
;
1857 ldp_session
*sp
= NULL
;
1860 LDP_ENTER(g
->user_data
, "ldp_cfg_session_raddr_getnext");
1862 if (a
->index
== 0) {
1865 index
= a
->index
+ 1;
1868 r
= ldp_global_find_session_index(g
, s
->index
, &sp
);
1869 if (r
!= MPLS_SUCCESS
) {
1873 mpls_lock_get(g
->global_lock
); /* LOCK */
1874 while (done
== MPLS_BOOL_FALSE
) {
1875 switch ((r
= ldp_session_find_raddr_index(sp
, index
, &addr
))) {
1877 case MPLS_END_OF_LIST
:
1878 done
= MPLS_BOOL_TRUE
;
1887 mpls_lock_release(g
->global_lock
); /* UNLOCK */
1889 if (r
== MPLS_SUCCESS
) {
1890 a
->index
= addr
->index
;
1891 r
= ldp_cfg_session_raddr_get(handle
, sp
, a
, flag
);
1894 LDP_EXIT(g
->user_data
, "ldp_cfg_session_getnext");
1898 /******************* IN LABEL **********************/
1900 mpls_return_enum
ldp_cfg_inlabel_get(mpls_cfg_handle handle
, ldp_inlabel
* i
,
1903 ldp_global
*global
= (ldp_global
*) handle
;
1904 ldp_inlabel
*inlabel
= NULL
;
1905 mpls_return_enum retval
= MPLS_FAILURE
;
1907 MPLS_ASSERT(global
!=NULL
&& i
!= NULL
);
1909 LDP_ENTER(global
->user_data
, "ldp_cfg_inlabel_get");
1911 mpls_lock_get(global
->global_lock
); /* LOCK */
1913 if (ldp_global_find_inlabel_index(global
, i
->index
, &inlabel
) != MPLS_SUCCESS
)
1914 goto ldp_cfg_inlabel_get_end
;
1916 if (flag
& LDP_INLABEL_CFG_LABELSPACE
) {
1917 i
->info
.labelspace
= inlabel
->info
.labelspace
;
1919 if (flag
& LDP_INLABEL_CFG_LABEL
) {
1920 memcpy(&i
->info
.label
, &inlabel
->info
.label
, sizeof(mpls_label_struct
));
1922 if (flag
& LDP_INLABEL_CFG_OUTLABEL_INDEX
) {
1923 i
->outlabel_index
= (inlabel
->outlabel
) ? (inlabel
->outlabel
->index
) : 0;
1926 retval
= MPLS_SUCCESS
;
1928 ldp_cfg_inlabel_get_end
:
1929 mpls_lock_release(global
->global_lock
); /* UNLOCK */
1931 LDP_EXIT(global
->user_data
, "ldp_cfg_inlabel_get");
1936 mpls_return_enum
ldp_cfg_inlabel_getnext(mpls_cfg_handle handle
, ldp_inlabel
* i
,
1939 ldp_global
*g
= (ldp_global
*) handle
;
1940 ldp_inlabel
*inlabel
= NULL
;
1941 mpls_return_enum r
= MPLS_FAILURE
;
1942 mpls_bool done
= MPLS_BOOL_FALSE
;
1945 LDP_ENTER(g
->user_data
, "ldp_cfg_inlabel_getnext");
1947 if (i
->index
== 0) {
1950 index
= i
->index
+ 1;
1953 mpls_lock_get(g
->global_lock
); /* LOCK */
1954 while (done
== MPLS_BOOL_FALSE
) {
1955 switch ((r
= ldp_global_find_inlabel_index(g
, index
, &inlabel
))) {
1957 case MPLS_END_OF_LIST
:
1958 done
= MPLS_BOOL_TRUE
;
1967 mpls_lock_release(g
->global_lock
); /* UNLOCK */
1969 if (r
== MPLS_SUCCESS
) {
1970 i
->index
= inlabel
->index
;
1972 LDP_EXIT(g
->user_data
, "ldp_cfg_inlabel_getnext");
1973 return ldp_cfg_inlabel_get(g
, i
, flag
);
1976 LDP_EXIT(g
->user_data
, "ldp_cfg_inlabel_getnext");
1981 /******************* OUT LABEL **********************/
1983 mpls_return_enum
ldp_cfg_outlabel_get(mpls_cfg_handle handle
, ldp_outlabel
* o
,
1986 ldp_global
*global
= (ldp_global
*) handle
;
1987 ldp_outlabel
*outlabel
= NULL
;
1988 mpls_return_enum retval
= MPLS_FAILURE
;
1990 MPLS_ASSERT(global
!=NULL
&& o
!= NULL
);
1992 LDP_ENTER(global
->user_data
, "ldp_cfg_outlabel_get");
1994 mpls_lock_get(global
->global_lock
); /* LOCK */
1996 if (ldp_global_find_outlabel_index(global
, o
->index
,
1997 &outlabel
) != MPLS_SUCCESS
) goto ldp_cfg_outlabel_get_end
;
1999 if (flag
& LDP_OUTLABEL_CFG_NH_INDEX
) {
2001 o
->nh_index
= outlabel
->nh
->index
;
2006 if (flag
& LDP_OUTLABEL_CFG_SESSION_INDEX
) {
2007 o
->session_index
= (outlabel
->session
) ? (outlabel
->session
->index
) : 0;
2009 if (flag
& LDP_OUTLABEL_CFG_LABEL
) {
2010 memcpy(&o
->info
.label
, &outlabel
->info
.label
, sizeof(mpls_label_struct
));
2012 if (flag
& LDP_OUTLABEL_CFG_MERGE_COUNT
) {
2013 o
->merge_count
= outlabel
->merge_count
;
2016 retval
= MPLS_SUCCESS
;
2018 ldp_cfg_outlabel_get_end
:
2019 mpls_lock_release(global
->global_lock
); /* UNLOCK */
2021 LDP_EXIT(global
->user_data
, "ldp_cfg_outlabel_get");
2026 mpls_return_enum
ldp_cfg_outlabel_getnext(mpls_cfg_handle handle
,
2027 ldp_outlabel
* o
, uint32_t flag
)
2029 ldp_global
*g
= (ldp_global
*) handle
;
2030 ldp_outlabel
*outlabel
= NULL
;
2031 mpls_return_enum r
= MPLS_FAILURE
;
2032 mpls_bool done
= MPLS_BOOL_FALSE
;
2035 LDP_ENTER(g
->user_data
, "ldp_cfg_outlabel_getnext");
2037 if (o
->index
== 0) {
2040 index
= o
->index
+ 1;
2043 mpls_lock_get(g
->global_lock
); /* LOCK */
2044 while (done
== MPLS_BOOL_FALSE
) {
2045 switch ((r
= ldp_global_find_outlabel_index(g
, index
, &outlabel
))) {
2047 case MPLS_END_OF_LIST
:
2048 done
= MPLS_BOOL_TRUE
;
2057 mpls_lock_release(g
->global_lock
); /* UNLOCK */
2059 if (r
== MPLS_SUCCESS
) {
2060 o
->index
= outlabel
->index
;
2062 LDP_EXIT(g
->user_data
, "ldp_cfg_outlabel_getnext");
2063 return ldp_cfg_outlabel_get(g
, o
, flag
);
2066 LDP_EXIT(g
->user_data
, "ldp_cfg_outlabel_getnext");
2071 /******************* TUNNEL **********************/
2073 mpls_return_enum
ldp_cfg_tunnel_set(mpls_cfg_handle handle
, ldp_tunnel
* t
,
2076 ldp_global
*global
= (ldp_global
*) handle
;
2077 mpls_return_enum retval
= MPLS_FAILURE
;
2078 ldp_tunnel
*tunnel
= NULL
;
2080 MPLS_ASSERT(global
!=NULL
);
2082 LDP_ENTER(global
->user_data
, "ldp_cfg_tunnel_set");
2084 mpls_lock_get(global
->global_lock
); /* LOCK */
2086 if (flag
& LDP_CFG_ADD
) {
2087 if (!(tunnel
= ldp_tunnel_create())) {
2088 goto ldp_cfg_tunnel_set_end
;
2090 _ldp_global_add_tunnel(global
, tunnel
);
2092 t
->index
= tunnel
->index
;
2094 ldp_global_find_tunnel_index(global
, t
->index
, &tunnel
);
2098 LDP_PRINT(global
->user_data
,
2100 "ldp_cfg_tunnel_set:could not create tunnel\n");
2101 goto ldp_cfg_tunnel_set_end
;
2104 if ((ldp_tunnel_is_active(tunnel
) == MPLS_BOOL_TRUE
) &&
2105 (flag
& LDP_TUNNEL_CFG_WHEN_DOWN
)) {
2106 LDP_PRINT(global
->user_data
, "ldp_cfg_tunnel_set: tunnel is active\n");
2108 goto ldp_cfg_tunnel_set_end
;
2111 if (flag
& LDP_CFG_DEL
) {
2112 if (tunnel
->outlabel
)
2113 ldp_tunnel_del_outlabel(tunnel
);
2114 if (tunnel
->resource
)
2115 ldp_tunnel_del_resource(tunnel
);
2116 if (tunnel
->hop_list
)
2117 ldp_tunnel_del_hop_list(tunnel
);
2118 _ldp_global_del_tunnel(global
, tunnel
);
2120 retval
= MPLS_SUCCESS
;
2121 goto ldp_cfg_tunnel_set_end
;
2124 if (flag
& LDP_TUNNEL_CFG_INGRESS
) {
2125 memcpy(&tunnel
->ingress_lsrid
, &t
->ingress_lsrid
, sizeof(ldp_addr
));
2127 if (flag
& LDP_TUNNEL_CFG_EGRESS
) {
2128 memcpy(&tunnel
->egress_lsrid
, &t
->egress_lsrid
, sizeof(ldp_addr
));
2130 if (flag
& LDP_TUNNEL_CFG_NAME
) {
2131 memcpy(&tunnel
->name
, &t
->name
, MPLS_MAX_IF_NAME
);
2133 if (flag
& LDP_TUNNEL_CFG_IS_IF
) {
2134 tunnel
->is_interface
= t
->is_interface
;
2136 if (flag
& LDP_TUNNEL_CFG_OUTLABEL
) {
2137 ldp_outlabel
*outlabel
= NULL
;
2139 if (t
->outlabel_index
) {
2140 ldp_global_find_outlabel_index(global
, t
->outlabel_index
, &outlabel
);
2143 goto ldp_cfg_tunnel_set_end
;
2145 ldp_tunnel_add_outlabel(tunnel
, outlabel
);
2147 ldp_tunnel_del_outlabel(tunnel
);
2150 if (flag
& LDP_TUNNEL_CFG_SETUP_PRIO
) {
2151 tunnel
->setup_prio
= t
->setup_prio
;
2153 if (flag
& LDP_TUNNEL_CFG_HOLD_PRIO
) {
2154 tunnel
->hold_prio
= t
->hold_prio
;
2156 if (flag
& LDP_TUNNEL_CFG_INSTANCE_PRIO
) {
2157 tunnel
->instance_prio
= t
->instance_prio
;
2159 if (flag
& LDP_TUNNEL_CFG_LOCAL_PROTECT
) {
2160 tunnel
->local_protect
= t
->local_protect
;
2162 if (flag
& LDP_TUNNEL_CFG_RESOURCE_INDEX
) {
2163 ldp_resource
*resource
= NULL
;
2165 if (t
->resource_index
) {
2166 ldp_global_find_resource_index(global
, t
->resource_index
, &resource
);
2169 goto ldp_cfg_tunnel_set_end
;
2171 ldp_tunnel_add_resource(tunnel
, resource
);
2173 ldp_tunnel_del_resource(tunnel
);
2176 if (flag
& LDP_TUNNEL_CFG_HOP_LIST_INDEX
) {
2177 ldp_hop_list
*hop_list
= NULL
;
2179 if (t
->hop_list_index
) {
2180 ldp_global_find_hop_list_index(global
, t
->hop_list_index
, &hop_list
);
2183 goto ldp_cfg_tunnel_set_end
;
2185 ldp_tunnel_add_hop_list(tunnel
, hop_list
);
2187 ldp_tunnel_del_hop_list(tunnel
);
2190 if (flag
& LDP_TUNNEL_CFG_FEC
) {
2191 memcpy(&tunnel
->fec
, &t
->fec
, sizeof(ldp_fec
));
2193 if (flag
& LDP_TUNNEL_CFG_ADMIN_STATE
) {
2194 if (ldp_tunnel_is_active(tunnel
) == MPLS_BOOL_TRUE
) {
2195 if (t
->admin_state
== MPLS_ADMIN_DISABLE
) {
2196 if (ldp_tunnel_shutdown(global
, tunnel
, 0) == MPLS_FAILURE
) {
2197 goto ldp_cfg_tunnel_set_end
;
2201 if (t
->admin_state
== MPLS_ADMIN_ENABLE
) {
2202 if (ldp_tunnel_is_ready(tunnel
) == MPLS_BOOL_TRUE
) {
2203 if (ldp_tunnel_startup(global
, tunnel
) == MPLS_FAILURE
) {
2204 goto ldp_cfg_tunnel_set_end
;
2207 LDP_PRINT(global
->user_data
,
2209 "ldp_cfg_tunnel_set: tunnel not ready\n");
2210 goto ldp_cfg_tunnel_set_end
;
2215 retval
= MPLS_SUCCESS
;
2217 ldp_cfg_tunnel_set_end
:
2219 mpls_lock_release(global
->global_lock
); /* UNLOCK */
2221 LDP_EXIT(global
->user_data
, "ldp_cfg_tunnel_set");
2226 mpls_return_enum
ldp_cfg_tunnel_test(mpls_cfg_handle handle
, ldp_tunnel
* t
,
2229 ldp_global
*global
= (ldp_global
*) handle
;
2230 mpls_return_enum retval
= MPLS_FAILURE
;
2231 ldp_tunnel
*tunnel
= NULL
;
2233 MPLS_ASSERT(global
!=NULL
);
2235 LDP_ENTER(global
->user_data
, "ldp_cfg_tunnel_test");
2237 mpls_lock_get(global
->global_lock
); /* LOCK */
2239 if (flag
& LDP_CFG_ADD
) {
2240 retval
= MPLS_SUCCESS
;
2241 goto ldp_cfg_tunnel_test_end
;
2244 ldp_global_find_tunnel_index(global
, t
->index
, &tunnel
);
2247 goto ldp_cfg_tunnel_test_end
;
2250 if (flag
& LDP_TUNNEL_CFG_RESOURCE_INDEX
) {
2251 ldp_resource
*resource
= NULL
;
2253 if (t
->resource_index
) {
2254 ldp_global_find_resource_index(global
, t
->resource_index
, &resource
);
2257 goto ldp_cfg_tunnel_test_end
;
2261 if (flag
& LDP_TUNNEL_CFG_HOP_LIST_INDEX
) {
2262 ldp_hop_list
*hop_list
= NULL
;
2264 if (t
->hop_list_index
) {
2265 ldp_global_find_hop_list_index(global
, t
->hop_list_index
, &hop_list
);
2268 goto ldp_cfg_tunnel_test_end
;
2272 if (flag
& LDP_TUNNEL_CFG_OUTLABEL
) {
2273 ldp_outlabel
*outlabel
= NULL
;
2275 if (t
->outlabel_index
) {
2276 ldp_global_find_outlabel_index(global
, t
->outlabel_index
, &outlabel
);
2279 goto ldp_cfg_tunnel_test_end
;
2283 if ((flag
& LDP_TUNNEL_CFG_ADMIN_STATE
) &&
2284 (ldp_tunnel_is_active(tunnel
) == MPLS_BOOL_FALSE
) &&
2285 (t
->admin_state
== MPLS_ADMIN_ENABLE
) && (ldp_tunnel_is_ready(tunnel
) != MPLS_BOOL_TRUE
)) {
2286 goto ldp_cfg_tunnel_test_end
;
2288 retval
= MPLS_SUCCESS
;
2290 ldp_cfg_tunnel_test_end
:
2292 mpls_lock_release(global
->global_lock
); /* UNLOCK */
2294 LDP_EXIT(global
->user_data
, "ldp_cfg_tunnel_test");
2299 mpls_return_enum
ldp_cfg_tunnel_get(mpls_cfg_handle handle
, ldp_tunnel
* t
,
2302 ldp_global
*global
= (ldp_global
*) handle
;
2303 mpls_return_enum retval
= MPLS_FAILURE
;
2304 ldp_tunnel
*tunnel
= NULL
;
2306 MPLS_ASSERT(global
!=NULL
);
2308 LDP_ENTER(global
->user_data
, "ldp_cfg_tunnel_get");
2310 mpls_lock_get(global
->global_lock
); /* LOCK */
2312 ldp_global_find_tunnel_index(global
, t
->index
, &tunnel
);
2315 goto ldp_cfg_tunnel_get_end
;
2317 if (flag
& LDP_TUNNEL_CFG_INGRESS
) {
2318 memcpy(&t
->ingress_lsrid
, &tunnel
->ingress_lsrid
, sizeof(ldp_addr
));
2320 if (flag
& LDP_TUNNEL_CFG_EGRESS
) {
2321 memcpy(&t
->egress_lsrid
, &tunnel
->egress_lsrid
, sizeof(ldp_addr
));
2323 if (flag
& LDP_TUNNEL_CFG_NAME
) {
2324 memcpy(&t
->name
, &tunnel
->name
, MPLS_MAX_IF_NAME
);
2326 if (flag
& LDP_TUNNEL_CFG_IS_IF
) {
2327 t
->is_interface
= tunnel
->is_interface
;
2329 if (flag
& LDP_TUNNEL_CFG_OUTLABEL
) {
2330 if (tunnel
->outlabel
) {
2331 t
->outlabel_index
= tunnel
->outlabel
->index
;
2333 t
->outlabel_index
= 0;
2336 if (flag
& LDP_TUNNEL_CFG_SETUP_PRIO
) {
2337 t
->setup_prio
= tunnel
->setup_prio
;
2339 if (flag
& LDP_TUNNEL_CFG_HOLD_PRIO
) {
2340 t
->hold_prio
= tunnel
->hold_prio
;
2342 if (flag
& LDP_TUNNEL_CFG_INSTANCE_PRIO
) {
2343 tunnel
->instance_prio
= t
->instance_prio
;
2345 if (flag
& LDP_TUNNEL_CFG_LOCAL_PROTECT
) {
2346 tunnel
->local_protect
= t
->local_protect
;
2348 if (flag
& LDP_TUNNEL_CFG_RESOURCE_INDEX
) {
2349 if (tunnel
->resource
) {
2350 t
->resource_index
= tunnel
->resource
->index
;
2352 t
->resource_index
= 0;
2355 if (flag
& LDP_TUNNEL_CFG_HOP_LIST_INDEX
) {
2356 if (tunnel
->hop_list
) {
2357 t
->hop_list_index
= tunnel
->hop_list
->index
;
2359 t
->hop_list_index
= 0;
2362 if (flag
& LDP_TUNNEL_CFG_FEC
) {
2363 memcpy(&t
->fec
, &tunnel
->fec
, sizeof(ldp_fec
));
2365 if (flag
& LDP_TUNNEL_CFG_ADMIN_STATE
) {
2366 t
->admin_state
= tunnel
->admin_state
;
2368 retval
= MPLS_SUCCESS
;
2370 ldp_cfg_tunnel_get_end
:
2372 mpls_lock_release(global
->global_lock
); /* UNLOCK */
2374 LDP_EXIT(global
->user_data
, "ldp_cfg_tunnel_get");
2379 /******************* RESOURCE **********************/
2381 mpls_return_enum
ldp_cfg_resource_set(mpls_cfg_handle handle
, ldp_resource
* r
,
2384 ldp_global
*global
= (ldp_global
*) handle
;
2385 mpls_return_enum retval
= MPLS_FAILURE
;
2386 ldp_resource
*resource
= NULL
;
2388 MPLS_ASSERT(global
!=NULL
);
2390 LDP_ENTER(global
->user_data
, "ldp_cfg_resource_set");
2392 mpls_lock_get(global
->global_lock
); /* LOCK */
2394 if (flag
& LDP_CFG_ADD
) {
2395 resource
= ldp_resource_create();
2396 _ldp_global_add_resource(global
, resource
);
2398 r
->index
= resource
->index
;
2400 ldp_global_find_resource_index(global
, r
->index
, &resource
);
2404 goto ldp_cfg_resource_set_end
;
2407 if (flag
& LDP_RESOURCE_CFG_MAXBPS
) {
2408 resource
->max_rate
= r
->max_rate
;
2410 if (flag
& LDP_RESOURCE_CFG_MEANBPS
) {
2411 resource
->mean_rate
= r
->mean_rate
;
2413 if (flag
& LDP_RESOURCE_CFG_BURSTSIZE
) {
2414 resource
->burst_size
= r
->burst_size
;
2416 retval
= MPLS_SUCCESS
;
2418 ldp_cfg_resource_set_end
:
2420 mpls_lock_release(global
->global_lock
); /* UNLOCK */
2422 LDP_EXIT(global
->user_data
, "ldp_cfg_resource_set");
2427 mpls_return_enum
ldp_cfg_resource_test(mpls_cfg_handle handle
, ldp_resource
* r
,
2430 ldp_global
*global
= (ldp_global
*) handle
;
2431 mpls_return_enum retval
= MPLS_FAILURE
;
2432 ldp_resource
*resource
= NULL
;
2434 MPLS_ASSERT(global
!=NULL
);
2436 LDP_ENTER(global
->user_data
, "ldp_cfg_resource_test");
2438 mpls_lock_get(global
->global_lock
); /* LOCK */
2440 if (flag
& LDP_CFG_ADD
) {
2441 retval
= MPLS_SUCCESS
;
2442 goto ldp_cfg_resource_test_end
;
2445 ldp_global_find_resource_index(global
, r
->index
, &resource
);
2448 goto ldp_cfg_resource_test_end
;
2451 if (ldp_resource_in_use(resource
) == MPLS_BOOL_TRUE
) {
2452 goto ldp_cfg_resource_test_end
;
2454 retval
= MPLS_SUCCESS
;
2456 ldp_cfg_resource_test_end
:
2458 mpls_lock_release(global
->global_lock
); /* UNLOCK */
2460 LDP_EXIT(global
->user_data
, "ldp_cfg_resource_test");
2465 mpls_return_enum
ldp_cfg_resource_get(mpls_cfg_handle handle
, ldp_resource
* r
,
2468 ldp_global
*global
= (ldp_global
*) handle
;
2469 mpls_return_enum retval
= MPLS_FAILURE
;
2470 ldp_resource
*resource
= NULL
;
2472 MPLS_ASSERT(global
!=NULL
);
2474 LDP_ENTER(global
->user_data
, "ldp_cfg_resource_get");
2476 mpls_lock_get(global
->global_lock
); /* LOCK */
2478 ldp_global_find_resource_index(global
, r
->index
, &resource
);
2481 goto ldp_cfg_resource_get_end
;
2484 if (flag
& LDP_RESOURCE_CFG_MAXBPS
) {
2485 r
->max_rate
= resource
->max_rate
;
2487 if (flag
& LDP_RESOURCE_CFG_MEANBPS
) {
2488 r
->mean_rate
= resource
->mean_rate
;
2490 if (flag
& LDP_RESOURCE_CFG_BURSTSIZE
) {
2491 r
->burst_size
= resource
->burst_size
;
2493 retval
= MPLS_SUCCESS
;
2495 ldp_cfg_resource_get_end
:
2497 mpls_lock_release(global
->global_lock
); /* UNLOCK */
2499 LDP_EXIT(global
->user_data
, "ldp_cfg_resource_get");
2504 /******************* HOP **********************/
2506 mpls_return_enum
ldp_cfg_hop_set(mpls_cfg_handle handle
, ldp_hop
* h
,
2509 ldp_global
*global
= (ldp_global
*) handle
;
2510 mpls_return_enum retval
= MPLS_FAILURE
;
2511 ldp_hop_list
*hop_list
= NULL
;
2512 ldp_hop
*hop
= NULL
;
2514 MPLS_ASSERT(global
!=NULL
);
2516 LDP_ENTER(global
->user_data
, "ldp_cfg_hop_set");
2518 if (!h
->hop_list_index
&& !h
->index
) {
2522 mpls_lock_get(global
->global_lock
); /* LOCK */
2524 ldp_global_find_hop_list_index(global
, h
->hop_list_index
, &hop_list
);
2527 if (flag
& LDP_CFG_ADD
) {
2528 if (!(hop_list
= ldp_hop_list_create())) {
2529 goto ldp_cfg_hop_set_end
;
2531 _ldp_global_add_hop_list(global
, hop_list
);
2533 h
->hop_list_index
= hop_list
->index
;
2535 goto ldp_cfg_hop_set_end
;
2539 ldp_hop_list_find_hop_index(hop_list
, h
->index
, &hop
);
2541 if (h
->index
&& (flag
& LDP_CFG_ADD
)) {
2542 if (!(hop
= ldp_hop_create())) {
2543 goto ldp_cfg_hop_set_end
;
2545 hop
->index
= h
->index
;
2546 ldp_hop_list_add_hop(hop_list
, hop
);
2548 goto ldp_cfg_hop_set_end
;
2552 if (flag
& LDP_HOP_CFG_PATH_OPTION
) {
2553 hop
->path_option
= h
->path_option
;
2555 if (flag
& LDP_HOP_CFG_ADDR
) {
2556 memcpy(&hop
->addr
, &h
->addr
, sizeof(ldp_addr
));
2558 if (flag
& LDP_HOP_CFG_TYPE
) {
2559 hop
->type
= h
->type
;
2561 retval
= MPLS_SUCCESS
;
2563 ldp_cfg_hop_set_end
:
2565 mpls_lock_release(global
->global_lock
); /* UNLOCK */
2567 LDP_EXIT(global
->user_data
, "ldp_cfg_hop_set");
2572 mpls_return_enum
ldp_cfg_hop_test(mpls_cfg_handle handle
, ldp_hop
* h
,
2575 ldp_global
*global
= (ldp_global
*) handle
;
2576 mpls_return_enum retval
= MPLS_FAILURE
;
2577 ldp_hop_list
*hop_list
= NULL
;
2578 ldp_hop
*hop
= NULL
;
2580 MPLS_ASSERT(global
!=NULL
);
2582 LDP_ENTER(global
->user_data
, "ldp_cfg_hop_test");
2584 mpls_lock_get(global
->global_lock
); /* LOCK */
2586 if (flag
& LDP_CFG_ADD
) {
2587 retval
= MPLS_SUCCESS
;
2588 goto ldp_cfg_hop_test_end
;
2591 ldp_global_find_hop_list_index(global
, h
->hop_list_index
, &hop_list
);
2594 goto ldp_cfg_hop_test_end
;
2597 ldp_hop_list_find_hop_index(hop_list
, h
->index
, &hop
);
2599 goto ldp_cfg_hop_test_end
;
2602 if (ldp_hop_in_use(hop
) == MPLS_BOOL_TRUE
) {
2603 goto ldp_cfg_hop_test_end
;
2605 retval
= MPLS_SUCCESS
;
2607 ldp_cfg_hop_test_end
:
2609 mpls_lock_release(global
->global_lock
); /* UNLOCK */
2611 LDP_EXIT(global
->user_data
, "ldp_cfg_hop_test");
2616 mpls_return_enum
ldp_cfg_hop_get(mpls_cfg_handle handle
, ldp_hop
* h
,
2619 ldp_global
*global
= (ldp_global
*) handle
;
2620 mpls_return_enum retval
= MPLS_FAILURE
;
2621 ldp_hop_list
*hop_list
= NULL
;
2622 ldp_hop
*hop
= NULL
;
2624 MPLS_ASSERT(global
!=NULL
);
2626 LDP_ENTER(global
->user_data
, "ldp_cfg_hop_get");
2628 mpls_lock_get(global
->global_lock
); /* LOCK */
2630 ldp_global_find_hop_list_index(global
, h
->hop_list_index
, &hop_list
);
2633 goto ldp_cfg_hop_get_end
;
2636 ldp_hop_list_find_hop_index(hop_list
, h
->index
, &hop
);
2638 goto ldp_cfg_hop_get_end
;
2641 if (flag
& LDP_HOP_CFG_PATH_OPTION
) {
2642 h
->path_option
= hop
->path_option
;
2644 if (flag
& LDP_HOP_CFG_ADDR
) {
2645 memcpy(&h
->addr
, &hop
->addr
, sizeof(ldp_addr
));
2647 if (flag
& LDP_HOP_CFG_TYPE
) {
2648 h
->type
= hop
->type
;
2650 retval
= MPLS_SUCCESS
;
2652 ldp_cfg_hop_get_end
:
2654 mpls_lock_release(global
->global_lock
); /* UNLOCK */
2656 LDP_EXIT(global
->user_data
, "ldp_cfg_hop_get");