/*
 * IS-IS Rout(e)ing protocol - isis_csm.c
 *                             IS-IS circuit state machine
 * Copyright (C) 2001,2002    Sampo Saaristo
 *                            Tampere University of Technology      
 *                            Institute of Communications Engineering
 *
 * This program is free software; you can redistribute it and/or modify it 
 * under the terms of the GNU General Public Licenseas published by the Free 
 * Software Foundation; either version 2 of the License, or (at your option) 
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,but WITHOUT 
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for 
 * more details.
 *
 * You should have received a copy of the GNU General Public License along 
 * with this program; if not, write to the Free Software Foundation, Inc., 
 * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */

#include <zebra.h>

#include "log.h"
#include "memory.h"
#include "if.h"
#include "linklist.h"
#include "command.h"
#include "thread.h"
#include "hash.h"
#include "prefix.h"
#include "stream.h"

#include "isisd/dict.h"
#include "isisd/include-netbsd/iso.h"
#include "isisd/isis_constants.h"
#include "isisd/isis_common.h"
#include "isisd/isis_circuit.h"
#include "isisd/isis_tlv.h"
#include "isisd/isis_lsp.h"
#include "isisd/isis_pdu.h"
#include "isisd/isis_network.h"
#include "isisd/isis_misc.h"
#include "isisd/isis_constants.h"
#include "isisd/isis_adjacency.h"
#include "isisd/isis_dr.h"
#include "isisd/isis_flags.h"
#include "isisd/isisd.h"
#include "isisd/isis_csm.h"
#include "isisd/isis_events.h"

extern struct isis *isis;

static char *csm_statestr[] = {
  "C_STATE_NA",
  "C_STATE_INIT",
  "C_STATE_CONF",
  "C_STATE_UP"
};

#define STATE2STR(S) csm_statestr[S]

static char *csm_eventstr[] = {
  "NO_STATE",
  "ISIS_ENABLE",
  "IF_UP_FROM_Z",
  "ISIS_DISABLE",
  "IF_DOWN_FROM_Z",
};

#define EVENT2STR(E) csm_eventstr[E]

struct isis_circuit *
isis_csm_state_change (int event, struct isis_circuit *circuit, void *arg)
{
  int old_state;

  old_state = circuit ? circuit->state : C_STATE_NA;

  zlog_info ("CSM_EVENT: %s", EVENT2STR (event));

  switch (old_state)
    {
    case C_STATE_NA:
      if (circuit)
	zlog_warn ("Non-null circuit while state C_STATE_NA");
      switch (event)
	{
	case ISIS_ENABLE:
	  circuit = isis_circuit_new ();
	  isis_circuit_configure (circuit, (struct isis_area *) arg);
	  circuit->state = C_STATE_CONF;
	  break;
	case IF_UP_FROM_Z:
	  circuit = isis_circuit_new ();
	  isis_circuit_if_add (circuit, (struct interface *) arg);
	  listnode_add (isis->init_circ_list, circuit);
	  circuit->state = C_STATE_INIT;
	  break;
	case ISIS_DISABLE:
	  zlog_warn ("circuit already disabled");
	case IF_DOWN_FROM_Z:
	  zlog_warn ("circuit already disconnected");
	  break;
	}
      break;
    case C_STATE_INIT:
      switch (event)
	{
	case ISIS_ENABLE:
	  isis_circuit_configure (circuit, (struct isis_area *) arg);
	  isis_circuit_up (circuit);
	  circuit->state = C_STATE_UP;
	  isis_event_circuit_state_change (circuit, 1);
	  listnode_delete (isis->init_circ_list, circuit);
	  break;
	case IF_UP_FROM_Z:
	  zlog_warn ("circuit already connected");
	  break;
	case ISIS_DISABLE:
	  zlog_warn ("circuit already disabled");
	  break;
	case IF_DOWN_FROM_Z:
	  isis_circuit_if_del (circuit);
	  listnode_delete (isis->init_circ_list, circuit);
	  isis_circuit_del (circuit);
	  break;
	}
      break;
    case C_STATE_CONF:
      switch (event)
	{
	case ISIS_ENABLE:
	  zlog_warn ("circuit already enabled");
	  break;
	case IF_UP_FROM_Z:
	  isis_circuit_if_add (circuit, (struct interface *) arg);
	  isis_circuit_up (circuit);
	  circuit->state = C_STATE_UP;
	  isis_event_circuit_state_change (circuit, 1);
	  break;
	case ISIS_DISABLE:
	  isis_circuit_deconfigure (circuit, (struct isis_area *) arg);
	  isis_circuit_del (circuit);
	  break;
	case IF_DOWN_FROM_Z:
	  zlog_warn ("circuit already disconnected");
	  break;
	}
      break;
    case C_STATE_UP:
      switch (event)
	{
	case ISIS_ENABLE:
	  zlog_warn ("circuit already configured");
	  break;
	case IF_UP_FROM_Z:
	  zlog_warn ("circuit already connected");
	  break;
	case ISIS_DISABLE:
	  isis_circuit_deconfigure (circuit, (struct isis_area *) arg);
	  listnode_add (isis->init_circ_list, circuit);
	  circuit->state = C_STATE_INIT;
	  isis_event_circuit_state_change (circuit, 0);
	  break;
	case IF_DOWN_FROM_Z:
	  isis_circuit_if_del (circuit);
	  circuit->state = C_STATE_CONF;
	  isis_event_circuit_state_change (circuit, 0);
	  break;
	}
      break;

    default:
      zlog_warn ("Invalid circuit state %d", old_state);
    }

  zlog_info ("CSM_STATE_CHANGE: %s -> %s ", STATE2STR (old_state),
	     circuit ? STATE2STR (circuit->state) : STATE2STR (C_STATE_NA));

  return circuit;
}
