state_machine.h
Go to the documentation of this file.
00001 /*
00002  * wpa_supplicant/hostapd - State machine definitions
00003  * Copyright (c) 2002-2005, Jouni Malinen <j@w1.fi>
00004  *
00005  * This program is free software; you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License version 2 as
00007  * published by the Free Software Foundation.
00008  *
00009  * Alternatively, this software may be distributed under the terms of BSD
00010  * license.
00011  *
00012  * See README and COPYING for more details.
00013  *
00014  * This file includes a set of pre-processor macros that can be used to
00015  * implement a state machine. In addition to including this header file, each
00016  * file implementing a state machine must define STATE_MACHINE_DATA to be the
00017  * data structure including state variables (enum machine_state,
00018  * Boolean changed), and STATE_MACHINE_DEBUG_PREFIX to be a string that is used
00019  * as a prefix for all debug messages. If SM_ENTRY_MA macro is used to define
00020  * a group of state machines with shared data structure, STATE_MACHINE_ADDR
00021  * needs to be defined to point to the MAC address used in debug output.
00022  * SM_ENTRY_M macro can be used to define similar group of state machines
00023  * without this additional debug info.
00024  */
00025 
00026 #ifndef STATE_MACHINE_H
00027 #define STATE_MACHINE_H
00028 
00038 #define SM_STATE(machine, state) \
00039 static void sm_ ## machine ## _ ## state ## _Enter(STATE_MACHINE_DATA *sm, \
00040         int global)
00041 
00052 #define SM_ENTRY(machine, state) \
00053 if (!global || sm->machine ## _state != machine ## _ ## state) { \
00054         sm->changed = TRUE; \
00055         wpa_printf(MSG_DEBUG, STATE_MACHINE_DEBUG_PREFIX ": " #machine \
00056                    " entering state " #state); \
00057 } \
00058 sm->machine ## _state = machine ## _ ## state;
00059 
00071 #define SM_ENTRY_M(machine, _state, data) \
00072 if (!global || sm->data ## _ ## state != machine ## _ ## _state) { \
00073         sm->changed = TRUE; \
00074         wpa_printf(MSG_DEBUG, STATE_MACHINE_DEBUG_PREFIX ": " \
00075                    #machine " entering state " #_state); \
00076 } \
00077 sm->data ## _ ## state = machine ## _ ## _state;
00078 
00089 #define SM_ENTRY_MA(machine, _state, data) \
00090 if (!global || sm->data ## _ ## state != machine ## _ ## _state) { \
00091         sm->changed = TRUE; \
00092         wpa_printf(MSG_DEBUG, STATE_MACHINE_DEBUG_PREFIX ": " MACSTR " " \
00093                    #machine " entering state " #_state, \
00094                    MAC2STR(STATE_MACHINE_ADDR)); \
00095 } \
00096 sm->data ## _ ## state = machine ## _ ## _state;
00097 
00107 #define SM_ENTER(machine, state) \
00108 sm_ ## machine ## _ ## state ## _Enter(sm, 0)
00109 
00120 #define SM_ENTER_GLOBAL(machine, state) \
00121 sm_ ## machine ## _ ## state ## _Enter(sm, 1)
00122 
00132 #define SM_STEP(machine) \
00133 static void sm_ ## machine ## _Step(STATE_MACHINE_DATA *sm)
00134 
00142 #define SM_STEP_RUN(machine) sm_ ## machine ## _Step(sm)
00143 
00144 #endif /* STATE_MACHINE_H */


wpa_supplicant_node
Author(s): Package maintained by Blaise Gassend
autogenerated on Thu Apr 24 2014 15:33:21