This file should have been deleted what ldp-portable was
[mpls-ldp-portable.git] / lsr / lsr_ftn.c
blob69e974b70adf501d7f9a4da73c3669e942b2717a
2 /*
3 * Copyright (C) James R. Leu 2002
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 "lsr_struct.h"
11 #include "lsr_ftn.h"
12 #include "lsr_outsegment.h"
14 #include "mpls_assert.h"
15 #include "mpls_mm_impl.h"
16 #include "mpls_trace_impl.h"
18 uint32_t _lsr_ftn_next_index = 1;
20 lsr_ftn *lsr_ftn_create()
22 lsr_ftn *i = (lsr_ftn *) mpls_malloc(sizeof(lsr_ftn));
24 if (i) {
25 memset(i, 0, sizeof(lsr_ftn));
26 MPLS_REFCNT_INIT(i, 0);
27 MPLS_LIST_ELEM_INIT(i, _outsegment);
28 MPLS_LIST_ELEM_INIT(i, _global);
29 i->index = _lsr_ftn_get_next_index();
31 return i;
34 void lsr_ftn_delete(lsr_ftn * i)
36 // LSR_PRINT(g->user_data,"if delete\n");
37 MPLS_REFCNT_ASSERT(i, 0);
38 mpls_free(i);
41 uint32_t _lsr_ftn_get_next_index()
43 uint32_t retval = _lsr_ftn_next_index;
45 _lsr_ftn_next_index++;
46 if (retval > _lsr_ftn_next_index) {
47 _lsr_ftn_next_index = 1;
49 return retval;
52 mpls_return_enum _lsr_ftn_add_outsegment(lsr_ftn * x, lsr_outsegment * o)
54 if (x && o) {
55 MPLS_REFCNT_HOLD(o);
56 x->outsegment = o;
57 return MPLS_SUCCESS;
59 return MPLS_FAILURE;
62 mpls_return_enum _lsr_ftn_del_outsegment(lsr_ftn * x)
64 if (x && x->outsegment) {
65 MPLS_REFCNT_RELEASE(x->outsegment, lsr_outsegment_delete);
66 x->outsegment = NULL;
67 return MPLS_SUCCESS;
69 return MPLS_FAILURE;