1 /* 2 * IEEE 802.1X-2004 Authenticator - State dump 3 * Copyright (c) 2002-2009, Jouni Malinen <j@w1.fi> 4 * 5 * This software may be distributed under the terms of the BSD license. 6 * See README for more details. 7 */ 8 9 #include "includes.h" 10 11 #include "common.h" 12 #include "eap_server/eap.h" 13 #include "eapol_auth_sm.h" 14 #include "eapol_auth_sm_i.h" 15 16 static inline const char * port_type_txt(PortTypes pt) 17 { 18 switch (pt) { 19 case ForceUnauthorized: return "ForceUnauthorized"; 20 case ForceAuthorized: return "ForceAuthorized"; 21 case Auto: return "Auto"; 22 default: return "Unknown"; 23 } 24 } 25 26 27 static inline const char * port_state_txt(PortState ps) 28 { 29 switch (ps) { 30 case Unauthorized: return "Unauthorized"; 31 case Authorized: return "Authorized"; 32 default: return "Unknown"; 33 } 34 } 35 36 37 static inline const char * ctrl_dir_txt(ControlledDirection dir) 38 { 39 switch (dir) { 40 case Both: return "Both"; 41 case In: return "In"; 42 default: return "Unknown"; 43 } 44 } 45 46 47 static inline const char * auth_pae_state_txt(int s) 48 { 49 switch (s) { 50 case AUTH_PAE_INITIALIZE: return "INITIALIZE"; 51 case AUTH_PAE_DISCONNECTED: return "DISCONNECTED"; 52 case AUTH_PAE_CONNECTING: return "CONNECTING"; 53 case AUTH_PAE_AUTHENTICATING: return "AUTHENTICATING"; 54 case AUTH_PAE_AUTHENTICATED: return "AUTHENTICATED"; 55 case AUTH_PAE_ABORTING: return "ABORTING"; 56 case AUTH_PAE_HELD: return "HELD"; 57 case AUTH_PAE_FORCE_AUTH: return "FORCE_AUTH"; 58 case AUTH_PAE_FORCE_UNAUTH: return "FORCE_UNAUTH"; 59 case AUTH_PAE_RESTART: return "RESTART"; 60 default: return "Unknown"; 61 } 62 } 63 64 65 static inline const char * be_auth_state_txt(int s) 66 { 67 switch (s) { 68 case BE_AUTH_REQUEST: return "REQUEST"; 69 case BE_AUTH_RESPONSE: return "RESPONSE"; 70 case BE_AUTH_SUCCESS: return "SUCCESS"; 71 case BE_AUTH_FAIL: return "FAIL"; 72 case BE_AUTH_TIMEOUT: return "TIMEOUT"; 73 case BE_AUTH_IDLE: return "IDLE"; 74 case BE_AUTH_INITIALIZE: return "INITIALIZE"; 75 case BE_AUTH_IGNORE: return "IGNORE"; 76 default: return "Unknown"; 77 } 78 } 79 80 81 static inline const char * reauth_timer_state_txt(int s) 82 { 83 switch (s) { 84 case REAUTH_TIMER_INITIALIZE: return "INITIALIZE"; 85 case REAUTH_TIMER_REAUTHENTICATE: return "REAUTHENTICATE"; 86 default: return "Unknown"; 87 } 88 } 89 90 91 static inline const char * auth_key_tx_state_txt(int s) 92 { 93 switch (s) { 94 case AUTH_KEY_TX_NO_KEY_TRANSMIT: return "NO_KEY_TRANSMIT"; 95 case AUTH_KEY_TX_KEY_TRANSMIT: return "KEY_TRANSMIT"; 96 default: return "Unknown"; 97 } 98 } 99 100 101 static inline const char * key_rx_state_txt(int s) 102 { 103 switch (s) { 104 case KEY_RX_NO_KEY_RECEIVE: return "NO_KEY_RECEIVE"; 105 case KEY_RX_KEY_RECEIVE: return "KEY_RECEIVE"; 106 default: return "Unknown"; 107 } 108 } 109 110 111 static inline const char * ctrl_dir_state_txt(int s) 112 { 113 switch (s) { 114 case CTRL_DIR_FORCE_BOTH: return "FORCE_BOTH"; 115 case CTRL_DIR_IN_OR_BOTH: return "IN_OR_BOTH"; 116 default: return "Unknown"; 117 } 118 } 119 120 121 void eapol_auth_dump_state(FILE *f, const char *prefix, 122 struct eapol_state_machine *sm) 123 { 124 fprintf(f, "%sEAPOL state machine:\n", prefix); 125 fprintf(f, "%s aWhile=%d quietWhile=%d reAuthWhen=%d\n", prefix, 126 sm->aWhile, sm->quietWhile, sm->reAuthWhen); 127 #define _SB(b) ((b) ? "TRUE" : "FALSE") 128 fprintf(f, 129 "%s authAbort=%s authFail=%s authPortStatus=%s authStart=%s\n" 130 "%s authTimeout=%s authSuccess=%s eapFail=%s eapolEap=%s\n" 131 "%s eapSuccess=%s eapTimeout=%s initialize=%s " 132 "keyAvailable=%s\n" 133 "%s keyDone=%s keyRun=%s keyTxEnabled=%s portControl=%s\n" 134 "%s portEnabled=%s portValid=%s reAuthenticate=%s\n", 135 prefix, _SB(sm->authAbort), _SB(sm->authFail), 136 port_state_txt(sm->authPortStatus), _SB(sm->authStart), 137 prefix, _SB(sm->authTimeout), _SB(sm->authSuccess), 138 _SB(sm->eap_if->eapFail), _SB(sm->eapolEap), 139 prefix, _SB(sm->eap_if->eapSuccess), 140 _SB(sm->eap_if->eapTimeout), 141 _SB(sm->initialize), _SB(sm->eap_if->eapKeyAvailable), 142 prefix, _SB(sm->keyDone), _SB(sm->keyRun), 143 _SB(sm->keyTxEnabled), port_type_txt(sm->portControl), 144 prefix, _SB(sm->eap_if->portEnabled), _SB(sm->portValid), 145 _SB(sm->reAuthenticate)); 146 147 fprintf(f, "%s Authenticator PAE:\n" 148 "%s state=%s\n" 149 "%s eapolLogoff=%s eapolStart=%s eapRestart=%s\n" 150 "%s portMode=%s reAuthCount=%d\n" 151 "%s quietPeriod=%d reAuthMax=%d\n" 152 "%s authEntersConnecting=%d\n" 153 "%s authEapLogoffsWhileConnecting=%d\n" 154 "%s authEntersAuthenticating=%d\n" 155 "%s authAuthSuccessesWhileAuthenticating=%d\n" 156 "%s authAuthTimeoutsWhileAuthenticating=%d\n" 157 "%s authAuthFailWhileAuthenticating=%d\n" 158 "%s authAuthEapStartsWhileAuthenticating=%d\n" 159 "%s authAuthEapLogoffWhileAuthenticating=%d\n" 160 "%s authAuthReauthsWhileAuthenticated=%d\n" 161 "%s authAuthEapStartsWhileAuthenticated=%d\n" 162 "%s authAuthEapLogoffWhileAuthenticated=%d\n", 163 prefix, prefix, auth_pae_state_txt(sm->auth_pae_state), prefix, 164 _SB(sm->eapolLogoff), _SB(sm->eapolStart), 165 _SB(sm->eap_if->eapRestart), 166 prefix, port_type_txt(sm->portMode), sm->reAuthCount, 167 prefix, sm->quietPeriod, sm->reAuthMax, 168 prefix, sm->authEntersConnecting, 169 prefix, sm->authEapLogoffsWhileConnecting, 170 prefix, sm->authEntersAuthenticating, 171 prefix, sm->authAuthSuccessesWhileAuthenticating, 172 prefix, sm->authAuthTimeoutsWhileAuthenticating, 173 prefix, sm->authAuthFailWhileAuthenticating, 174 prefix, sm->authAuthEapStartsWhileAuthenticating, 175 prefix, sm->authAuthEapLogoffWhileAuthenticating, 176 prefix, sm->authAuthReauthsWhileAuthenticated, 177 prefix, sm->authAuthEapStartsWhileAuthenticated, 178 prefix, sm->authAuthEapLogoffWhileAuthenticated); 179 180 fprintf(f, "%s Backend Authentication:\n" 181 "%s state=%s\n" 182 "%s eapNoReq=%s eapReq=%s eapResp=%s\n" 183 "%s serverTimeout=%d\n" 184 "%s backendResponses=%d\n" 185 "%s backendAccessChallenges=%d\n" 186 "%s backendOtherRequestsToSupplicant=%d\n" 187 "%s backendAuthSuccesses=%d\n" 188 "%s backendAuthFails=%d\n", 189 prefix, prefix, 190 be_auth_state_txt(sm->be_auth_state), 191 prefix, _SB(sm->eap_if->eapNoReq), _SB(sm->eap_if->eapReq), 192 _SB(sm->eap_if->eapResp), 193 prefix, sm->serverTimeout, 194 prefix, sm->backendResponses, 195 prefix, sm->backendAccessChallenges, 196 prefix, sm->backendOtherRequestsToSupplicant, 197 prefix, sm->backendAuthSuccesses, 198 prefix, sm->backendAuthFails); 199 200 fprintf(f, "%s Reauthentication Timer:\n" 201 "%s state=%s\n" 202 "%s reAuthPeriod=%d reAuthEnabled=%s\n", prefix, prefix, 203 reauth_timer_state_txt(sm->reauth_timer_state), prefix, 204 sm->reAuthPeriod, _SB(sm->reAuthEnabled)); 205 206 fprintf(f, "%s Authenticator Key Transmit:\n" 207 "%s state=%s\n", prefix, prefix, 208 auth_key_tx_state_txt(sm->auth_key_tx_state)); 209 210 fprintf(f, "%s Key Receive:\n" 211 "%s state=%s\n" 212 "%s rxKey=%s\n", prefix, prefix, 213 key_rx_state_txt(sm->key_rx_state), prefix, _SB(sm->rxKey)); 214 215 fprintf(f, "%s Controlled Directions:\n" 216 "%s state=%s\n" 217 "%s adminControlledDirections=%s " 218 "operControlledDirections=%s\n" 219 "%s operEdge=%s\n", prefix, prefix, 220 ctrl_dir_state_txt(sm->ctrl_dir_state), 221 prefix, ctrl_dir_txt(sm->adminControlledDirections), 222 ctrl_dir_txt(sm->operControlledDirections), 223 prefix, _SB(sm->operEdge)); 224 #undef _SB 225 } 226