]>
git.proxmox.com Git - mirror_frr.git/blob - isisd/isis_csm.c
2 * IS-IS Rout(e)ing protocol - isis_csm.c
3 * IS-IS circuit state machine
4 * Copyright (C) 2001,2002 Sampo Saaristo
5 * Tampere University of Technology
6 * Institute of Communications Engineering
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public Licenseas published by the Free
10 * Software Foundation; either version 2 of the License, or (at your option)
13 * This program is distributed in the hope that it will be useful,but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
18 * You should have received a copy of the GNU General Public License along
19 * with this program; see the file COPYING; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
35 #include "isisd/isis_constants.h"
36 #include "isisd/isis_common.h"
37 #include "isisd/isis_flags.h"
38 #include "isisd/isis_circuit.h"
39 #include "isisd/isis_lsp.h"
40 #include "isisd/isis_pdu.h"
41 #include "isisd/isis_network.h"
42 #include "isisd/isis_misc.h"
43 #include "isisd/isis_constants.h"
44 #include "isisd/isis_adjacency.h"
45 #include "isisd/isis_dr.h"
46 #include "isisd/isisd.h"
47 #include "isisd/isis_csm.h"
48 #include "isisd/isis_events.h"
49 #include "isisd/isis_errors.h"
51 static const char *const csm_statestr
[] = {"C_STATE_NA", "C_STATE_INIT",
52 "C_STATE_CONF", "C_STATE_UP"};
54 #define STATE2STR(S) csm_statestr[S]
56 static const char *const csm_eventstr
[] = {
57 "NO_STATE", "ISIS_ENABLE", "IF_UP_FROM_Z",
58 "ISIS_DISABLE", "IF_DOWN_FROM_Z",
61 #define EVENT2STR(E) csm_eventstr[E]
64 isis_csm_state_change(int event
, struct isis_circuit
*circuit
, void *arg
)
67 struct isis
*isis
= NULL
;
68 struct isis_area
*area
= NULL
;
70 old_state
= circuit
? circuit
->state
: C_STATE_NA
;
72 zlog_debug("CSM_EVENT: %s", EVENT2STR(event
));
77 zlog_warn("Non-null circuit while state C_STATE_NA");
78 assert(circuit
== NULL
);
83 circuit
= isis_circuit_new(area
->isis
);
84 isis_circuit_configure(circuit
, area
);
85 circuit
->state
= C_STATE_CONF
;
88 isis
= isis_lookup_by_vrfid(((struct interface
*)arg
)->vrf_id
);
91 " %s : ISIS routing instance not found",
95 circuit
= isis_circuit_new(isis
);
96 isis_circuit_if_add(circuit
, (struct interface
*)arg
);
97 listnode_add(isis
->init_circ_list
, circuit
);
98 circuit
->state
= C_STATE_INIT
;
101 zlog_warn("circuit already disabled");
104 zlog_warn("circuit already disconnected");
112 isis_circuit_configure(circuit
,
113 (struct isis_area
*)arg
);
114 if (isis_circuit_up(circuit
) != ISIS_OK
) {
115 isis_circuit_deconfigure(
116 circuit
, (struct isis_area
*)arg
);
119 circuit
->state
= C_STATE_UP
;
120 isis_event_circuit_state_change(circuit
, circuit
->area
,
122 listnode_delete(circuit
->isis
->init_circ_list
,
127 zlog_warn("circuit already connected");
130 zlog_warn("circuit already disabled");
133 isis_circuit_if_del(circuit
, (struct interface
*)arg
);
134 listnode_delete(circuit
->isis
->init_circ_list
,
136 isis_circuit_del(circuit
);
145 zlog_warn("circuit already enabled");
148 isis_circuit_if_add(circuit
, (struct interface
*)arg
);
149 if (isis_circuit_up(circuit
) != ISIS_OK
) {
150 isis_circuit_if_del(circuit
, (struct interface
*)arg
);
153 "Could not bring up %s because of invalid config.",
154 circuit
->interface
->name
);
157 circuit
->state
= C_STATE_UP
;
158 isis_event_circuit_state_change(circuit
, circuit
->area
,
162 isis_circuit_deconfigure(circuit
,
163 (struct isis_area
*)arg
);
164 isis_circuit_del(circuit
);
168 zlog_warn("circuit already disconnected");
176 zlog_warn("circuit already configured");
179 zlog_warn("circuit already connected");
182 isis
= circuit
->isis
;
183 isis_circuit_down(circuit
);
184 isis_circuit_deconfigure(circuit
,
185 (struct isis_area
*)arg
);
186 circuit
->state
= C_STATE_INIT
;
187 isis_event_circuit_state_change(
188 circuit
, (struct isis_area
*)arg
, 0);
189 listnode_add(isis
->init_circ_list
, circuit
);
192 isis_circuit_down(circuit
);
193 isis_circuit_if_del(circuit
, (struct interface
*)arg
);
194 circuit
->state
= C_STATE_CONF
;
195 isis_event_circuit_state_change(circuit
, circuit
->area
,
202 zlog_warn("Invalid circuit state %d", old_state
);
206 zlog_debug("CSM_STATE_CHANGE: %s -> %s ", STATE2STR(old_state
),
207 circuit
? STATE2STR(circuit
->state
)
208 : STATE2STR(C_STATE_NA
));