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"
11 #include "lsr_xconnect.h"
12 #include "lsr_outsegment.h"
13 #include "lsr_insegment.h"
15 #include "mpls_assert.h"
16 #include "mpls_mm_impl.h"
17 #include "mpls_trace_impl.h"
19 uint32_t _lsr_xconnect_next_index
= 1;
21 lsr_xconnect
*lsr_xconnect_create()
23 lsr_xconnect
*i
= (lsr_xconnect
*) mpls_malloc(sizeof(lsr_xconnect
));
26 memset(i
, 0, sizeof(lsr_xconnect
));
27 MPLS_REFCNT_INIT(i
, 0);
28 MPLS_LIST_ELEM_INIT(i
, _outsegment
);
29 MPLS_LIST_ELEM_INIT(i
, _insegment
);
30 MPLS_LIST_ELEM_INIT(i
, _global
);
31 i
->index
= _lsr_xconnect_get_next_index();
36 void lsr_xconnect_delete(lsr_xconnect
* i
)
38 // LSR_PRINT(g->user_data,"if delete\n");
39 MPLS_REFCNT_ASSERT(i
, 0);
43 uint32_t _lsr_xconnect_get_next_index()
45 uint32_t retval
= _lsr_xconnect_next_index
;
47 _lsr_xconnect_next_index
++;
48 if (retval
> _lsr_xconnect_next_index
) {
49 _lsr_xconnect_next_index
= 1;
54 mpls_return_enum
_lsr_xconnect_add_outsegment(lsr_xconnect
* x
, lsr_outsegment
* o
)
64 mpls_return_enum
_lsr_xconnect_del_outsegment(lsr_xconnect
* x
)
66 if (x
&& x
->outsegment
) {
67 MPLS_REFCNT_RELEASE(x
->outsegment
, lsr_outsegment_delete
);
74 mpls_return_enum
_lsr_xconnect_add_insegment(lsr_xconnect
* x
, lsr_insegment
* i
)
84 mpls_return_enum
_lsr_xconnect_del_insegment(lsr_xconnect
* x
)
86 if (x
&& x
->insegment
) {
87 MPLS_REFCNT_RELEASE(x
->insegment
, lsr_insegment_delete
);