]>
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 extern struct isis
*isis
;
53 static const char *const csm_statestr
[] = {"C_STATE_NA", "C_STATE_INIT",
54 "C_STATE_CONF", "C_STATE_UP"};
56 #define STATE2STR(S) csm_statestr[S]
58 static const char *const csm_eventstr
[] = {
59 "NO_STATE", "ISIS_ENABLE", "IF_UP_FROM_Z",
60 "ISIS_DISABLE", "IF_DOWN_FROM_Z",
63 #define EVENT2STR(E) csm_eventstr[E]
66 isis_csm_state_change(int event
, struct isis_circuit
*circuit
, void *arg
)
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
);
81 circuit
= isis_circuit_new();
82 isis_circuit_configure(circuit
,
83 (struct isis_area
*)arg
);
84 circuit
->state
= C_STATE_CONF
;
87 circuit
= isis_circuit_new();
88 isis_circuit_if_add(circuit
, (struct interface
*)arg
);
89 listnode_add(isis
->init_circ_list
, circuit
);
90 circuit
->state
= C_STATE_INIT
;
93 zlog_warn("circuit already disabled");
96 zlog_warn("circuit already disconnected");
104 isis_circuit_configure(circuit
,
105 (struct isis_area
*)arg
);
106 if (isis_circuit_up(circuit
) != ISIS_OK
) {
107 isis_circuit_deconfigure(
108 circuit
, (struct isis_area
*)arg
);
111 circuit
->state
= C_STATE_UP
;
112 isis_event_circuit_state_change(circuit
, circuit
->area
,
114 listnode_delete(isis
->init_circ_list
, circuit
);
118 zlog_warn("circuit already connected");
121 zlog_warn("circuit already disabled");
124 isis_circuit_if_del(circuit
, (struct interface
*)arg
);
125 listnode_delete(isis
->init_circ_list
, circuit
);
126 isis_circuit_del(circuit
);
135 zlog_warn("circuit already enabled");
138 isis_circuit_if_add(circuit
, (struct interface
*)arg
);
139 if (isis_circuit_up(circuit
) != ISIS_OK
) {
142 "Could not bring up %s because of invalid config.",
143 circuit
->interface
->name
);
146 circuit
->state
= C_STATE_UP
;
147 isis_event_circuit_state_change(circuit
, circuit
->area
,
151 isis_circuit_deconfigure(circuit
,
152 (struct isis_area
*)arg
);
153 isis_circuit_del(circuit
);
157 zlog_warn("circuit already disconnected");
165 zlog_warn("circuit already configured");
168 zlog_warn("circuit already connected");
171 isis_circuit_down(circuit
);
172 isis_circuit_deconfigure(circuit
,
173 (struct isis_area
*)arg
);
174 circuit
->state
= C_STATE_INIT
;
175 isis_event_circuit_state_change(
176 circuit
, (struct isis_area
*)arg
, 0);
177 listnode_add(isis
->init_circ_list
, circuit
);
180 isis_circuit_down(circuit
);
181 isis_circuit_if_del(circuit
, (struct interface
*)arg
);
182 circuit
->state
= C_STATE_CONF
;
183 isis_event_circuit_state_change(circuit
, circuit
->area
,
190 zlog_warn("Invalid circuit state %d", old_state
);
194 zlog_debug("CSM_STATE_CHANGE: %s -> %s ", STATE2STR(old_state
),
195 circuit
? STATE2STR(circuit
->state
)
196 : STATE2STR(C_STATE_NA
));