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_if_next_index
= 1;
20 lsr_if
*lsr_if_create()
22 lsr_if
*i
= (lsr_if
*) mpls_malloc(sizeof(lsr_if
));
25 memset(i
, 0, sizeof(lsr_if
));
26 MPLS_REFCNT_INIT(i
, 0);
27 MPLS_LIST_ELEM_INIT(i
, _global
);
28 MPLS_LIST_INIT(&i
->outsegment_root
,lsr_outsegment
);
29 i
->index
= _lsr_if_get_next_index();
30 i
->oper_state
= MPLS_OPER_DOWN
;
35 void lsr_if_delete(lsr_if
* i
)
37 // LSR_PRINT(g->user_data,"if delete\n");
38 MPLS_REFCNT_ASSERT(i
, 0);
42 uint32_t _lsr_if_get_next_index()
44 uint32_t retval
= _lsr_if_next_index
;
47 if (retval
> _lsr_if_next_index
) {
48 _lsr_if_next_index
= 1;
53 mpls_return_enum
lsr_if_add_outsegment(lsr_if
*iff
, lsr_outsegment
*o
) {
56 MPLS_LIST_ADD_HEAD(&iff
->outsegment_root
, o
, _if
, lsr_outsegment
);
57 _lsr_outsegment_add_if(o
, iff
);
63 mpls_return_enum
lsr_if_del_outsegment(lsr_if
*iff
, lsr_outsegment
*o
) {
65 MPLS_LIST_REMOVE(&iff
->outsegment_root
, o
, _if
);
66 _lsr_outsegment_del_if(o
);
67 MPLS_REFCNT_RELEASE(o
, lsr_outsegment_delete
);