3 * Copyright (C) James R. Leu 2002
6 * This software is covered under the LGPL, for more
7 * info check out http://www.gnu.org/copyleft/lgpl.html
10 #include "lsr_struct.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
));
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();
34 void lsr_ftn_delete(lsr_ftn
* i
)
36 // LSR_PRINT(g->user_data,"if delete\n");
37 MPLS_REFCNT_ASSERT(i
, 0);
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;
52 mpls_return_enum
_lsr_ftn_add_outsegment(lsr_ftn
* x
, lsr_outsegment
* o
)
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
);