2 * Copyright (C) James R. Leu 2003
5 * This software is covered under the LGPL, for more
6 * info check out http://www.gnu.org/copyleft/lgpl.html
9 #include "rsvpte_struct.h"
10 #include "rsvpte_if.h"
12 #include "mpls_assert.h"
13 #include "mpls_mm_impl.h"
14 #include "mpls_socket_impl.h"
15 #include "mpls_timer_impl.h"
16 #include "mpls_ifmgr_impl.h"
17 #include "mpls_trace_impl.h"
19 uint32_t _rsvpte_if_next_index
= 1;
21 rsvpte_if
*rsvpte_if_create()
23 rsvpte_if
*i
= (rsvpte_if
*) mpls_malloc(sizeof(rsvpte_if
));
26 memset(i
, 0, sizeof(rsvpte_if
));
27 MPLS_REFCNT_INIT(i
, 0);
28 MPLS_LIST_ELEM_INIT(i
, _global
);
30 i
->index
= _rsvpte_if_get_next_index();
31 i
->oper_state
= MPLS_OPER_DOWN
;
32 i
->admin_state
= MPLS_ADMIN_DISABLE
;
37 void rsvpte_if_delete(rsvpte_if
* i
)
39 LDP_PRINT(g
->user_data
,"if delete\n");
40 MPLS_REFCNT_ASSERT(i
, 0);
44 mpls_return_enum
rsvpte_if_startup(rsvpte_global
* g
, rsvpte_if
* i
)
46 LDP_ENTER(g
->user_data
, "rsvpte_if_startup");
48 MPLS_ASSERT(i
!= NULL
);
50 if (mpls_ifmgr_get_address(g
->ifmgr_handle
, i
->handle
,
51 &i
->local_source_address
, NULL
, NULL
) == MPLS_FAILURE
) {
52 goto rsvpte_if_startup_delay
;
55 i
->oper_state
= MPLS_OPER_UP
;
56 i
->admin_state
= MPLS_ADMIN_ENABLE
;
58 LDP_EXIT(g
->user_data
, "rsvpte_if_startup");
62 rsvpte_if_startup_delay
:
65 * when a interface update comes in, it will search the global
66 * list of interfaces, and start up the interface then
68 i
->oper_state
= MPLS_OPER_DOWN
;
70 LDP_EXIT(g
->user_data
, "rsvpte_if_startup-delayed");
75 mpls_return_enum
rsvpte_if_shutdown(rsvpte_global
* g
, rsvpte_if
* i
)
77 MPLS_ASSERT(i
!= NULL
);
79 LDP_ENTER(g
->user_data
, "rsvpte_if_shutdown");
81 i
->oper_state
= MPLS_OPER_DOWN
;
82 i
->admin_state
= MPLS_ADMIN_DISABLE
;
84 LDP_EXIT(g
->user_data
, "rsvpte_if_shutdown");
89 uint32_t _rsvpte_if_get_next_index()
91 uint32_t retval
= _rsvpte_if_next_index
;
93 _rsvpte_if_next_index
++;
94 if (retval
> _rsvpte_if_next_index
) {
95 _rsvpte_if_next_index
= 1;
100 mpls_bool
rsvpte_if_is_active(rsvpte_if
* i
)
103 if (i
->oper_state
== MPLS_OPER_UP
)
104 return MPLS_BOOL_TRUE
;
106 return MPLS_BOOL_FALSE
;