eapol_auth_sm_i.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. /*
  2. * IEEE 802.1X-2004 Authenticator - EAPOL state machine (internal definitions)
  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. #ifndef EAPOL_AUTH_SM_I_H
  9. #define EAPOL_AUTH_SM_I_H
  10. #include "common/defs.h"
  11. #include "radius/radius.h"
  12. /* IEEE Std 802.1X-2004, Ch. 8.2 */
  13. typedef enum { ForceUnauthorized = 1, ForceAuthorized = 3, Auto = 2 }
  14. PortTypes;
  15. typedef enum { Unauthorized = 2, Authorized = 1 } PortState;
  16. typedef enum { Both = 0, In = 1 } ControlledDirection;
  17. typedef unsigned int Counter;
  18. /**
  19. * struct eapol_authenticator - Global EAPOL authenticator data
  20. */
  21. struct eapol_authenticator {
  22. struct eapol_auth_config conf;
  23. struct eapol_auth_cb cb;
  24. u8 *default_wep_key;
  25. u8 default_wep_key_idx;
  26. };
  27. /**
  28. * struct eapol_state_machine - Per-Supplicant Authenticator state machines
  29. */
  30. struct eapol_state_machine {
  31. /* timers */
  32. int aWhile;
  33. int quietWhile;
  34. int reAuthWhen;
  35. /* global variables */
  36. Boolean authAbort;
  37. Boolean authFail;
  38. PortState authPortStatus;
  39. Boolean authStart;
  40. Boolean authTimeout;
  41. Boolean authSuccess;
  42. Boolean eapolEap;
  43. Boolean initialize;
  44. Boolean keyDone;
  45. Boolean keyRun;
  46. Boolean keyTxEnabled;
  47. PortTypes portControl;
  48. Boolean portValid;
  49. Boolean reAuthenticate;
  50. /* Port Timers state machine */
  51. /* 'Boolean tick' implicitly handled as registered timeout */
  52. /* Authenticator PAE state machine */
  53. enum { AUTH_PAE_INITIALIZE, AUTH_PAE_DISCONNECTED, AUTH_PAE_CONNECTING,
  54. AUTH_PAE_AUTHENTICATING, AUTH_PAE_AUTHENTICATED,
  55. AUTH_PAE_ABORTING, AUTH_PAE_HELD, AUTH_PAE_FORCE_AUTH,
  56. AUTH_PAE_FORCE_UNAUTH, AUTH_PAE_RESTART } auth_pae_state;
  57. /* variables */
  58. Boolean eapolLogoff;
  59. Boolean eapolStart;
  60. PortTypes portMode;
  61. unsigned int reAuthCount;
  62. /* constants */
  63. unsigned int quietPeriod; /* default 60; 0..65535 */
  64. #define AUTH_PAE_DEFAULT_quietPeriod 60
  65. unsigned int reAuthMax; /* default 2 */
  66. #define AUTH_PAE_DEFAULT_reAuthMax 2
  67. /* counters */
  68. Counter authEntersConnecting;
  69. Counter authEapLogoffsWhileConnecting;
  70. Counter authEntersAuthenticating;
  71. Counter authAuthSuccessesWhileAuthenticating;
  72. Counter authAuthTimeoutsWhileAuthenticating;
  73. Counter authAuthFailWhileAuthenticating;
  74. Counter authAuthEapStartsWhileAuthenticating;
  75. Counter authAuthEapLogoffWhileAuthenticating;
  76. Counter authAuthReauthsWhileAuthenticated;
  77. Counter authAuthEapStartsWhileAuthenticated;
  78. Counter authAuthEapLogoffWhileAuthenticated;
  79. /* Backend Authentication state machine */
  80. enum { BE_AUTH_REQUEST, BE_AUTH_RESPONSE, BE_AUTH_SUCCESS,
  81. BE_AUTH_FAIL, BE_AUTH_TIMEOUT, BE_AUTH_IDLE, BE_AUTH_INITIALIZE,
  82. BE_AUTH_IGNORE
  83. } be_auth_state;
  84. /* constants */
  85. unsigned int serverTimeout; /* default 30; 1..X */
  86. #define BE_AUTH_DEFAULT_serverTimeout 30
  87. /* counters */
  88. Counter backendResponses;
  89. Counter backendAccessChallenges;
  90. Counter backendOtherRequestsToSupplicant;
  91. Counter backendAuthSuccesses;
  92. Counter backendAuthFails;
  93. /* Reauthentication Timer state machine */
  94. enum { REAUTH_TIMER_INITIALIZE, REAUTH_TIMER_REAUTHENTICATE
  95. } reauth_timer_state;
  96. /* constants */
  97. unsigned int reAuthPeriod; /* default 3600 s */
  98. Boolean reAuthEnabled;
  99. /* Authenticator Key Transmit state machine */
  100. enum { AUTH_KEY_TX_NO_KEY_TRANSMIT, AUTH_KEY_TX_KEY_TRANSMIT
  101. } auth_key_tx_state;
  102. /* Key Receive state machine */
  103. enum { KEY_RX_NO_KEY_RECEIVE, KEY_RX_KEY_RECEIVE } key_rx_state;
  104. /* variables */
  105. Boolean rxKey;
  106. /* Controlled Directions state machine */
  107. enum { CTRL_DIR_FORCE_BOTH, CTRL_DIR_IN_OR_BOTH } ctrl_dir_state;
  108. /* variables */
  109. ControlledDirection adminControlledDirections;
  110. ControlledDirection operControlledDirections;
  111. Boolean operEdge;
  112. /* Authenticator Statistics Table */
  113. Counter dot1xAuthEapolFramesRx;
  114. Counter dot1xAuthEapolFramesTx;
  115. Counter dot1xAuthEapolStartFramesRx;
  116. Counter dot1xAuthEapolLogoffFramesRx;
  117. Counter dot1xAuthEapolRespIdFramesRx;
  118. Counter dot1xAuthEapolRespFramesRx;
  119. Counter dot1xAuthEapolReqIdFramesTx;
  120. Counter dot1xAuthEapolReqFramesTx;
  121. Counter dot1xAuthInvalidEapolFramesRx;
  122. Counter dot1xAuthEapLengthErrorFramesRx;
  123. Counter dot1xAuthLastEapolFrameVersion;
  124. /* Other variables - not defined in IEEE 802.1X */
  125. u8 addr[ETH_ALEN]; /* Supplicant address */
  126. int flags; /* EAPOL_SM_* */
  127. /* EAPOL/AAA <-> EAP full authenticator interface */
  128. struct eap_eapol_interface *eap_if;
  129. int radius_identifier;
  130. /* TODO: check when the last messages can be released */
  131. struct radius_msg *last_recv_radius;
  132. u8 last_eap_id; /* last used EAP Identifier */
  133. u8 *identity;
  134. size_t identity_len;
  135. u8 eap_type_authsrv; /* EAP type of the last EAP packet from
  136. * Authentication server */
  137. u8 eap_type_supp; /* EAP type of the last EAP packet from Supplicant */
  138. struct radius_class_data radius_class;
  139. struct wpabuf *radius_cui; /* Chargeable-User-Identity */
  140. struct eap_sm *eap;
  141. Boolean initializing; /* in process of initializing state machines */
  142. Boolean changed;
  143. struct eapol_authenticator *eapol;
  144. void *sta; /* station context pointer to use in callbacks */
  145. int remediation;
  146. u64 acct_multi_session_id;
  147. };
  148. #endif /* EAPOL_AUTH_SM_I_H */