Remove address callback. Locally attached address are now
[mpls-ldp-portable.git] / ldp / ldp_cfg.c
blob1c36969cc3b2bcf70b8482d47a9af2669f479545
2 /*
3 * Copyright (C) James R. Leu 2000
4 * jleu@mindspring.com
6 * This software is covered under the LGPL, for more
7 * info check out http://www.gnu.org/copyleft/lgpl.html
8 */
10 #include "ldp_struct.h"
11 #include "ldp_cfg.h"
12 #include "ldp_global.h"
13 #include "ldp_entity.h"
14 #include "ldp_attr.h"
15 #include "ldp_if.h"
16 #include "ldp_peer.h"
17 #include "ldp_fec.h"
18 #include "ldp_addr.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"
24 #include "ldp_hop.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");
43 ldp_global_delete(g);
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,
50 uint32_t flag)
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;
110 #if MPLS_USE_LSR
111 if (flag & LDP_GLOBAL_CFG_LSR_HANDLE) {
112 g->lsr_handle = global->lsr_handle;
114 #endif
116 mpls_lock_release(global->global_lock); /* UNLOCK */
118 LDP_EXIT(global->user_data, "ldp_cfg_global_get");
120 return MPLS_SUCCESS;
123 mpls_return_enum ldp_cfg_global_test(mpls_cfg_handle handle, ldp_global * g,
124 uint32_t flag)
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");
142 return retval;
145 mpls_return_enum ldp_cfg_global_set(mpls_cfg_handle handle, ldp_global * g,
146 uint32_t flag)
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));
191 #if MPLS_USE_LSR
192 if (flag & LDP_GLOBAL_CFG_LSR_HANDLE) {
193 global->lsr_handle = g->lsr_handle;
195 #endif
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 ==
200 MPLS_ADMIN_ENABLE) {
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;
211 } else {
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;
218 } else {
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;
225 } else {
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;
232 } else {
233 global->hellotime_interval = g->hellotime_interval;
236 #if MPLS_USE_LSR
237 if (flag & LDP_GLOBAL_CFG_LSR_HANDLE) {
238 global->lsr_handle = g->lsr_handle ;
240 #endif
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");
251 return retval;
254 /******************* ENTITY **********************/
256 /* must set ldp_entity->index */
257 mpls_return_enum ldp_cfg_entity_get(mpls_cfg_handle handle, ldp_entity * e,
258 uint32_t flag)
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");
354 return retval;
357 mpls_return_enum ldp_cfg_entity_getnext(mpls_cfg_handle handle, ldp_entity * e,
358 uint32_t flag)
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;
364 int index;
366 LDP_ENTER(g->user_data, "ldp_cfg_entity_getnext");
368 if (e->index == 0) {
369 index = 1;
370 } else {
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))) {
377 case MPLS_SUCCESS:
378 case MPLS_END_OF_LIST:
379 done = MPLS_BOOL_TRUE;
380 break;
381 case MPLS_FAILURE:
382 break;
383 default:
384 MPLS_ASSERT(0);
386 index++;
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");
396 return r;
399 mpls_return_enum ldp_cfg_entity_test(mpls_cfg_handle handle, ldp_entity * e,
400 uint32_t flag)
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)) {
413 if (e == NULL)
414 goto ldp_cfg_entity_test_end;
416 ldp_global_find_entity_index(global, e->index, &entity);
417 } else {
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");
438 return retval;
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,
443 uint32_t flag)
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;
460 } else {
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) {
477 case LDP_DIRECT:
478 ldp_entity_del_if(global, entity);
479 break;
480 case LDP_INDIRECT:
481 ldp_entity_del_peer(entity);
482 break;
483 default:
484 MPLS_ASSERT(0);
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) {
496 case LDP_DIRECT:
497 ldp_entity_del_if(global, entity);
498 break;
499 case LDP_INDIRECT:
500 ldp_entity_del_peer(entity);
501 break;
502 default:
503 MPLS_ASSERT(0);
507 /* link the new sub object */
508 switch (e->entity_type) {
509 case LDP_DIRECT:
511 ldp_if *iff = NULL;
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);
523 break;
525 case LDP_INDIRECT:
527 ldp_peer *peer = NULL;
529 if (ldp_global_find_peer_index(global, e->sub_index, &peer) !=
530 MPLS_SUCCESS) {
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);
539 break;
541 default:
542 MPLS_ASSERT(0);
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;
549 } else {
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;
570 } else {
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;
578 } else {
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;
586 } else {
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;
594 } else {
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;
634 } else {
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");
652 return retval;
655 mpls_return_enum ldp_cfg_entity_adj_getnext(mpls_cfg_handle handle,
656 ldp_entity * e)
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;
662 ldp_adj *adj = 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
670 if (!e->adj_index) {
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);
678 while (adj) {
679 if (this_one == MPLS_BOOL_TRUE) {
680 adj_next = adj;
681 break;
684 /* since the entities are sort in the list ... */
685 if (adj->index > e->adj_index) {
686 break;
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 */
695 if (adj_next) {
696 e->adj_index = adj_next->index;
697 r = MPLS_SUCCESS;
700 LDP_EXIT(g->user_data, "ldp_cfg_entity_adj_getnext");
701 return r;
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;
709 ldp_if *iff = NULL;
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;
739 ldp_cfg_if_get_end:
740 mpls_lock_release(global->global_lock); /* UNLOCK */
742 LDP_EXIT(global->user_data, "ldp_cfg_if_get");
744 return retval;
747 mpls_return_enum ldp_cfg_if_getnext(mpls_cfg_handle handle, ldp_if * i,
748 uint32_t flag)
750 ldp_global *g = (ldp_global *) handle;
751 ldp_if *iff = NULL;
752 mpls_return_enum r = MPLS_FAILURE;
753 mpls_bool done = MPLS_BOOL_FALSE;
754 int index;
756 LDP_ENTER(g->user_data, "ldp_cfg_if_getnext");
758 if (i->index == 0) {
759 index = 1;
760 } else {
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))) {
767 case MPLS_SUCCESS:
768 case MPLS_END_OF_LIST:
769 done = MPLS_BOOL_TRUE;
770 break;
771 case MPLS_FAILURE:
772 break;
773 default:
774 MPLS_ASSERT(0);
776 index++;
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");
786 return r;
789 mpls_return_enum ldp_cfg_if_test(mpls_cfg_handle handle, ldp_if * i,
790 uint32_t flag)
792 ldp_global *global = (ldp_global *) handle;
793 ldp_if *iff = NULL;
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);
804 } else {
805 retval = MPLS_SUCCESS;
806 goto ldp_cfg_if_test_end;
809 if ((iff == NULL) ||
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;
819 ldp_cfg_if_test_end:
820 mpls_lock_release(global->global_lock); /* UNLOCK */
822 LDP_EXIT(global->user_data, "ldp_cfg_if_test");
824 return retval;
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;
830 ldp_if *iff = NULL;
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) ==
845 MPLS_BOOL_FALSE) {
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;
853 } else {
854 ldp_global_find_if_index(global, i->index, &iff);
857 if ((iff == NULL) ||
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;
882 ldp_cfg_if_set_end:
883 mpls_lock_release(global->global_lock); /* UNLOCK */
885 LDP_EXIT(global->user_data, "ldp_cfg_if_set");
887 return retval;
890 /******************* ATTR **********************/
892 mpls_return_enum ldp_cfg_attr_get(mpls_cfg_handle handle, ldp_attr * a,
893 uint32_t flag)
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");
942 return retval;
945 mpls_return_enum ldp_cfg_attr_getnext(mpls_cfg_handle handle, ldp_attr * a,
946 uint32_t flag)
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;
952 int index;
954 LDP_ENTER(g->user_data, "ldp_cfg_attr_getnext");
956 if (a->index == 0) {
957 index = 1;
958 } else {
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))) {
965 case MPLS_SUCCESS:
966 case MPLS_END_OF_LIST:
967 done = MPLS_BOOL_TRUE;
968 break;
969 case MPLS_FAILURE:
970 break;
971 default:
972 MPLS_ASSERT(0);
974 index++;
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");
984 return r;
987 /******************* PEER **********************/
989 mpls_return_enum ldp_cfg_peer_get(mpls_cfg_handle handle, ldp_peer * p,
990 uint32_t flag)
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");
1034 return retval;
1037 mpls_return_enum ldp_cfg_peer_getnext(mpls_cfg_handle handle, ldp_peer * p,
1038 uint32_t flag)
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;
1044 int index;
1046 LDP_ENTER(g->user_data, "ldp_cfg_peer_getnext");
1048 if (p->index == 0) {
1049 index = 1;
1050 } else {
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))) {
1057 case MPLS_SUCCESS:
1058 case MPLS_END_OF_LIST:
1059 done = MPLS_BOOL_TRUE;
1060 break;
1061 case MPLS_FAILURE:
1062 break;
1063 default:
1064 MPLS_ASSERT(0);
1066 index++;
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");
1076 return r;
1079 mpls_return_enum ldp_cfg_peer_test(mpls_cfg_handle handle, ldp_peer * p,
1080 uint32_t flag)
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,
1087 uint32_t flag)
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);
1105 } else {
1106 ldp_global_find_peer_index(global, p->index, &peer);
1109 if (peer == NULL) {
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",
1145 p->peer_name);
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");
1157 return retval;
1159 /******************* FEC **********************/
1161 mpls_return_enum ldp_cfg_fec_get(mpls_cfg_handle handle, mpls_fec * f,
1162 uint32_t flag)
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);
1176 } else {
1177 fec = ldp_fec_find(global, f);
1179 if (!fec)
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");
1190 return retval;
1193 mpls_return_enum ldp_cfg_fec_getnext(mpls_cfg_handle handle, mpls_fec * f,
1194 uint32_t flag)
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;
1200 int index;
1202 LDP_ENTER(g->user_data, "ldp_cfg_fec_getnext");
1204 if (f->index == 0) {
1205 index = 1;
1206 } else {
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))) {
1213 case MPLS_SUCCESS:
1214 case MPLS_END_OF_LIST:
1215 done = MPLS_BOOL_TRUE;
1216 break;
1217 case MPLS_FAILURE:
1218 break;
1219 default:
1220 MPLS_ASSERT(0);
1222 index++;
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");
1232 return r;
1235 mpls_return_enum ldp_cfg_fec_test(mpls_cfg_handle handle, mpls_fec * f,
1236 uint32_t flag)
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,
1243 uint32_t flag)
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);
1263 } else {
1264 if (flag & LDP_FEC_CFG_BY_INDEX) {
1265 ldp_global_find_fec_index(global, f->index, &fec);
1266 } else {
1267 fec = ldp_fec_find(global, f);
1271 if (fec == NULL) {
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");
1288 return retval;
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);
1307 } else {
1308 fec = ldp_fec_find(global, f);
1310 if (!fec)
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);
1315 } else {
1316 nh = ldp_fec_nexthop_find(fec, n);
1318 if (!nh)
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");
1329 return retval;
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;
1340 int index;
1342 LDP_ENTER(global->user_data, "ldp_cfg_fec_nexthop_getnext");
1344 if (n->index == 0) {
1345 index = 1;
1346 } else {
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);
1354 } else {
1355 fec = ldp_fec_find(global, f);
1357 if (!fec)
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))) {
1362 case MPLS_SUCCESS:
1363 case MPLS_END_OF_LIST:
1364 done = MPLS_BOOL_TRUE;
1365 break;
1366 case MPLS_FAILURE:
1367 break;
1368 default:
1369 MPLS_ASSERT(0);
1371 index++;
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");
1385 return r;
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);
1411 } else {
1412 fec = ldp_fec_find(global, f);
1414 if (!fec)
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);
1425 } else {
1426 if (flag & LDP_FEC_NEXTHOP_CFG_BY_INDEX) {
1427 ldp_fec_find_nexthop_index(fec, n->index, &nh);
1428 } else {
1429 nh = ldp_fec_nexthop_find(fec, n);
1433 if (nh == NULL) {
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");
1450 return retval;
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;
1460 ldp_if *iff = 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");
1482 return retval;
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;
1490 ldp_if *iff = 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);
1511 if (addr == NULL) {
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");
1530 return retval;
1532 /******************* ADJACENCY **********************/
1534 mpls_return_enum ldp_cfg_adj_get(mpls_cfg_handle handle, ldp_adj * a,
1535 uint32_t flag)
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");
1588 return retval;
1591 mpls_return_enum ldp_cfg_adj_getnext(mpls_cfg_handle handle, ldp_adj * a,
1592 uint32_t flag)
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;
1598 int index;
1600 LDP_ENTER(g->user_data, "ldp_cfg_adj_getnext");
1602 if (a->index == 0) {
1603 index = 1;
1604 } else {
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))) {
1611 case MPLS_SUCCESS:
1612 case MPLS_END_OF_LIST:
1613 done = MPLS_BOOL_TRUE;
1614 break;
1615 case MPLS_FAILURE:
1616 break;
1617 default:
1618 MPLS_ASSERT(0);
1620 index++;
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");
1630 return r;
1633 /******************* SESSION **********************/
1635 mpls_return_enum ldp_cfg_session_get(mpls_cfg_handle handle, ldp_session * s,
1636 uint32_t flag)
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");
1717 return retval;
1720 mpls_return_enum ldp_cfg_session_getnext(mpls_cfg_handle handle, ldp_session * s,
1721 uint32_t flag)
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;
1727 int index;
1729 LDP_ENTER(g->user_data, "ldp_cfg_session_getnext");
1731 if (s->index == 0) {
1732 index = 1;
1733 } else {
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))) {
1740 case MPLS_SUCCESS:
1741 case MPLS_END_OF_LIST:
1742 done = MPLS_BOOL_TRUE;
1743 break;
1744 case MPLS_FAILURE:
1745 break;
1746 default:
1747 MPLS_ASSERT(0);
1749 index++;
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");
1762 return r;
1765 mpls_return_enum ldp_cfg_session_adj_getnext(mpls_cfg_handle handle,
1766 ldp_session * s)
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);
1788 while (adj) {
1789 if (this_one == MPLS_BOOL_TRUE) {
1790 adj_next = adj;
1791 break;
1794 /* since the entities are sort in the list ... */
1795 if (adj->index > s->adj_index) {
1796 break;
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 */
1805 if (adj_next) {
1806 s->adj_index = adj_next->index;
1807 r = MPLS_SUCCESS;
1810 LDP_EXIT(g->user_data, "ldp_cfg_session_adj_getnext");
1811 return r;
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");
1847 return retval;
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;
1858 int index;
1860 LDP_ENTER(g->user_data, "ldp_cfg_session_raddr_getnext");
1862 if (a->index == 0) {
1863 index = 1;
1864 } else {
1865 index = a->index + 1;
1868 r = ldp_global_find_session_index(g, s->index, &sp);
1869 if (r != MPLS_SUCCESS) {
1870 return r;
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))) {
1876 case MPLS_SUCCESS:
1877 case MPLS_END_OF_LIST:
1878 done = MPLS_BOOL_TRUE;
1879 break;
1880 case MPLS_FAILURE:
1881 break;
1882 default:
1883 MPLS_ASSERT(0);
1885 index++;
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");
1895 return r;
1898 /******************* IN LABEL **********************/
1900 mpls_return_enum ldp_cfg_inlabel_get(mpls_cfg_handle handle, ldp_inlabel * i,
1901 uint32_t flag)
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");
1933 return retval;
1936 mpls_return_enum ldp_cfg_inlabel_getnext(mpls_cfg_handle handle, ldp_inlabel * i,
1937 uint32_t flag)
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;
1943 int index;
1945 LDP_ENTER(g->user_data, "ldp_cfg_inlabel_getnext");
1947 if (i->index == 0) {
1948 index = 1;
1949 } else {
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))) {
1956 case MPLS_SUCCESS:
1957 case MPLS_END_OF_LIST:
1958 done = MPLS_BOOL_TRUE;
1959 break;
1960 case MPLS_FAILURE:
1961 break;
1962 default:
1963 MPLS_ASSERT(0);
1965 index++;
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");
1978 return r;
1981 /******************* OUT LABEL **********************/
1983 mpls_return_enum ldp_cfg_outlabel_get(mpls_cfg_handle handle, ldp_outlabel * o,
1984 uint32_t flag)
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) {
2000 if (outlabel->nh) {
2001 o->nh_index = outlabel->nh->index;
2002 } else {
2003 o->nh_index = 0;
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");
2023 return retval;
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;
2033 int index;
2035 LDP_ENTER(g->user_data, "ldp_cfg_outlabel_getnext");
2037 if (o->index == 0) {
2038 index = 1;
2039 } else {
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))) {
2046 case MPLS_SUCCESS:
2047 case MPLS_END_OF_LIST:
2048 done = MPLS_BOOL_TRUE;
2049 break;
2050 case MPLS_FAILURE:
2051 break;
2052 default:
2053 MPLS_ASSERT(0);
2055 index++;
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");
2068 return r;
2071 /******************* TUNNEL **********************/
2073 mpls_return_enum ldp_cfg_tunnel_set(mpls_cfg_handle handle, ldp_tunnel * t,
2074 uint32_t flag)
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;
2093 } else {
2094 ldp_global_find_tunnel_index(global, t->index, &tunnel);
2097 if (!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);
2142 if (!outlabel) {
2143 goto ldp_cfg_tunnel_set_end;
2145 ldp_tunnel_add_outlabel(tunnel, outlabel);
2146 } else {
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);
2168 if (!resource) {
2169 goto ldp_cfg_tunnel_set_end;
2171 ldp_tunnel_add_resource(tunnel, resource);
2172 } else {
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);
2182 if (!hop_list) {
2183 goto ldp_cfg_tunnel_set_end;
2185 ldp_tunnel_add_hop_list(tunnel, hop_list);
2186 } else {
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;
2200 } else {
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;
2206 } else {
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");
2223 return retval;
2226 mpls_return_enum ldp_cfg_tunnel_test(mpls_cfg_handle handle, ldp_tunnel * t,
2227 uint32_t flag)
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);
2246 if (!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);
2256 if (!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);
2267 if (!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);
2278 if (!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");
2296 return retval;
2299 mpls_return_enum ldp_cfg_tunnel_get(mpls_cfg_handle handle, ldp_tunnel * t,
2300 uint32_t flag)
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);
2314 if (!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;
2332 } else {
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;
2351 } else {
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;
2358 } else {
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");
2376 return retval;
2379 /******************* RESOURCE **********************/
2381 mpls_return_enum ldp_cfg_resource_set(mpls_cfg_handle handle, ldp_resource * r,
2382 uint32_t flag)
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;
2399 } else {
2400 ldp_global_find_resource_index(global, r->index, &resource);
2403 if (!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");
2424 return retval;
2427 mpls_return_enum ldp_cfg_resource_test(mpls_cfg_handle handle, ldp_resource * r,
2428 uint32_t flag)
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);
2447 if (!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");
2462 return retval;
2465 mpls_return_enum ldp_cfg_resource_get(mpls_cfg_handle handle, ldp_resource * r,
2466 uint32_t flag)
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);
2480 if (!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");
2501 return retval;
2504 /******************* HOP **********************/
2506 mpls_return_enum ldp_cfg_hop_set(mpls_cfg_handle handle, ldp_hop * h,
2507 uint32_t flag)
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) {
2519 return retval;
2522 mpls_lock_get(global->global_lock); /* LOCK */
2524 ldp_global_find_hop_list_index(global, h->hop_list_index, &hop_list);
2526 if (!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;
2534 } else {
2535 goto ldp_cfg_hop_set_end;
2539 ldp_hop_list_find_hop_index(hop_list, h->index, &hop);
2540 if (!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);
2547 } else {
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");
2569 return retval;
2572 mpls_return_enum ldp_cfg_hop_test(mpls_cfg_handle handle, ldp_hop * h,
2573 uint32_t flag)
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);
2593 if (!hop_list) {
2594 goto ldp_cfg_hop_test_end;
2597 ldp_hop_list_find_hop_index(hop_list, h->index, &hop);
2598 if (!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");
2613 return retval;
2616 mpls_return_enum ldp_cfg_hop_get(mpls_cfg_handle handle, ldp_hop * h,
2617 uint32_t flag)
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);
2632 if (!hop_list) {
2633 goto ldp_cfg_hop_get_end;
2636 ldp_hop_list_find_hop_index(hop_list, h->index, &hop);
2637 if (!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");
2658 return retval;