supplicant.c
Go to the documentation of this file.
1 /**
2  * @file supplicant.c
3  * @brief 802.1X supplicant
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2022-2025 Oryx Embedded SARL. All rights reserved.
10  *
11  * This file is part of CycloneEAP Open.
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software Foundation,
25  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26  *
27  * @author Oryx Embedded SARL (www.oryx-embedded.com)
28  * @version 2.5.0
29  **/
30 
31 //Switch to the appropriate trace level
32 #define TRACE_LEVEL SUPPLICANT_TRACE_LEVEL
33 
34 //Dependencies
35 #include "supplicant/supplicant.h"
38 #include "eap/eap_tls.h"
39 #include "debug.h"
40 
41 //Check EAP library configuration
42 #if (SUPPLICANT_SUPPORT == ENABLED)
43 
44 
45 /**
46  * @brief Initialize settings with default values
47  * @param[out] settings Structure that contains 802.1X supplicant settings
48  **/
49 
51 {
52  //Default task parameters
53  settings->task = OS_TASK_DEFAULT_PARAMS;
55  settings->task.priority = SUPPLICANT_PRIORITY;
56 
57  //The supplicant is not bound to any interface
58  settings->interface = NULL;
59  //Port index
60  settings->portIndex = 0;
61 
62 #if (EAP_TLS_SUPPORT == ENABLED)
63  //TLS negotiation initialization callback function
64  settings->tlsInitCallback = NULL;
65  //TLS negotiation completion callback function
66  settings->tlsCompleteCallback = NULL;
67 #endif
68 
69  //Supplicant PAE state change callback function
70  settings->paeStateChangeCallback = NULL;
71  //Supplicant backend state change callback function
72  settings->backendStateChangeCallback = NULL;
73  //EAP peer state change callback function
74  settings->eapPeerStateChangeCallback = NULL;
75  //Tick callback function
76  settings->tickCallback = NULL;
77 }
78 
79 
80 /**
81  * @brief Initialize 802.1X supplicant context
82  * @param[in] context Pointer to the 802.1X supplicant context
83  * @param[in] settings 802.1X supplicant specific settings
84  * @return Error code
85  **/
86 
88  const SupplicantSettings *settings)
89 {
90  error_t error;
91 
92  //Debug message
93  TRACE_INFO("Initializing 802.1X supplicant...\r\n");
94 
95  //Ensure the parameters are valid
96  if(context == NULL || settings == NULL)
98 
99  //Clear supplicant context
100  osMemset(context, 0, sizeof(SupplicantContext));
101 
102  //Initialize task parameters
103  context->taskParams = settings->task;
104  context->taskId = OS_INVALID_TASK_ID;
105 
106  //Initialize supplicant context
107  context->interface = settings->interface;
108  context->portIndex = settings->portIndex;
109  context->paeStateChangeCallback = settings->paeStateChangeCallback;
110  context->backendStateChangeCallback = settings->backendStateChangeCallback;
111  context->eapPeerStateChangeCallback = settings->eapPeerStateChangeCallback;
112  context->tickCallback = settings->tickCallback;
113 
114 #if (EAP_TLS_SUPPORT == ENABLED)
115  //TLS negotiation initialization callback function
116  context->tlsInitCallback = settings->tlsInitCallback;
117  //TLS negotiation completion callback function
118  context->tlsCompleteCallback = settings->tlsCompleteCallback;
119 #endif
120 
121  //Default value of parameters
122  context->portControl = SUPPLICANT_PORT_MODE_AUTO;
123  context->userLogoff = FALSE;
124  context->heldPeriod = SUPPLICANT_DEFAULT_HELD_PERIOD;
125  context->authPeriod = SUPPLICANT_DEFAULT_AUTH_PERIOD;
126  context->startPeriod = SUPPLICANT_DEFAULT_START_PERIOD;
127  context->maxStart = SUPPLICANT_DEFAULT_MAX_START;
128  context->clientTimeout = EAP_DEFAULT_CLIENT_TIMEOUT;
129 
130  //Initialize supplicant state machine
131  supplicantInitFsm(context);
132 
133  //Start of exception handling block
134  do
135  {
136  //Create a mutex to prevent simultaneous access to 802.1X supplicant
137  //context
138  if(!osCreateMutex(&context->mutex))
139  {
140  //Failed to create mutex
141  error = ERROR_OUT_OF_RESOURCES;
142  break;
143  }
144 
145  //Create an event object to poll the state of the raw socket
146  if(!osCreateEvent(&context->event))
147  {
148  //Failed to create event
149  error = ERROR_OUT_OF_RESOURCES;
150  break;
151  }
152 
153  //Successful initialization
154  error = NO_ERROR;
155 
156  //End of exception handling block
157  } while(0);
158 
159  //Any error to report?
160  if(error)
161  {
162  //Clean up side effects
163  supplicantDeinit(context);
164  }
165 
166  //Return status code
167  return error;
168 }
169 
170 
171 /**
172  * @brief Set user name
173  * @param[in] context Pointer to the 802.1X supplicant context
174  * @param[in] username NULL-terminated string containing the user name
175  * @return Error code
176  **/
177 
179  const char_t *username)
180 {
181  //Check parameters
182  if(context == NULL || username == NULL)
184 
185  //Make sure the length of the user name is acceptable
186  if(osStrlen(username) > SUPPLICANT_MAX_USERNAME_LEN)
187  return ERROR_INVALID_LENGTH;
188 
189  //Save user name
190  osStrcpy(context->username, username);
191 
192  //Successful processing
193  return NO_ERROR;
194 }
195 
196 
197 /**
198  * @brief Set password
199  * @param[in] context Pointer to the 802.1X supplicant context
200  * @param[in] password NULL-terminated string containing the password
201  * @return Error code
202  **/
203 
205  const char_t *password)
206 {
207 #if (EAP_MD5_SUPPORT == ENABLED)
208  //Check parameters
209  if(context == NULL || password == NULL)
211 
212  //Make sure the length of the password is acceptable
213  if(osStrlen(password) > SUPPLICANT_MAX_PASSWORD_LEN)
214  return ERROR_INVALID_LENGTH;
215 
216  //Save password
217  osStrcpy(context->password, password);
218 
219  //Successful processing
220  return NO_ERROR;
221 #else
222  //EAP-MD5 challenge is not implemented
223  return ERROR_NOT_IMPLEMENTED;
224 #endif
225 }
226 
227 
228 /**
229  * @brief Set the value of the heldPeriod parameter
230  * @param[in] context Pointer to the 802.1X supplicant context
231  * @param[in] heldPeriod Value of the heldPeriod parameter
232  * @return Error code
233  **/
234 
236 {
237  //Check parameters
238  if(context == NULL || heldPeriod == 0)
240 
241  //Acquire exclusive access to the 802.1X supplicant context
242  osAcquireMutex(&context->mutex);
243  //Save parameter value
244  context->heldPeriod = heldPeriod;
245  //Release exclusive access to the 802.1X supplicant context
246  osReleaseMutex(&context->mutex);
247 
248  //Successful processing
249  return NO_ERROR;
250 }
251 
252 
253 /**
254  * @brief Set the value of the authPeriod parameter
255  * @param[in] context Pointer to the 802.1X supplicant context
256  * @param[in] authPeriod Value of the authPeriod parameter
257  * @return Error code
258  **/
259 
261 {
262  //Check parameters
263  if(context == NULL || authPeriod == 0)
265 
266  //Acquire exclusive access to the 802.1X supplicant context
267  osAcquireMutex(&context->mutex);
268  //Save parameter value
269  context->authPeriod = authPeriod;
270  //Release exclusive access to the 802.1X supplicant context
271  osReleaseMutex(&context->mutex);
272 
273  //Successful processing
274  return NO_ERROR;
275 }
276 
277 
278 /**
279  * @brief Set the value of the startPeriod parameter
280  * @param[in] context Pointer to the 802.1X supplicant context
281  * @param[in] startPeriod Value of the startPeriod parameter
282  * @return Error code
283  **/
284 
286 {
287  //Check parameters
288  if(context == NULL || startPeriod == 0)
290 
291  //Acquire exclusive access to the 802.1X supplicant context
292  osAcquireMutex(&context->mutex);
293  //Save parameter value
294  context->startPeriod = startPeriod;
295  //Release exclusive access to the 802.1X supplicant context
296  osReleaseMutex(&context->mutex);
297 
298  //Successful processing
299  return NO_ERROR;
300 }
301 
302 
303 /**
304  * @brief Set the value of the maxStart parameter
305  * @param[in] context Pointer to the 802.1X supplicant context
306  * @param[in] maxStart Value of the maxStart parameter
307  * @return Error code
308  **/
309 
311 {
312  //Check parameters
313  if(context == NULL || maxStart == 0)
315 
316  //Acquire exclusive access to the 802.1X supplicant context
317  osAcquireMutex(&context->mutex);
318 
319  //Save parameter value
320  context->maxStart = maxStart;
321 
322  //Update supplicant state machines
323  if(context->running)
324  {
325  supplicantFsm(context);
326  }
327 
328  //Release exclusive access to the 802.1X supplicant context
329  osReleaseMutex(&context->mutex);
330 
331  //Successful processing
332  return NO_ERROR;
333 }
334 
335 
336 /**
337  * @brief Set the value of the clientTimeout parameter
338  * @param[in] context Pointer to the 802.1X supplicant context
339  * @param[in] clientTimeout Value of the clientTimeout parameter
340  * @return Error code
341  **/
342 
344  uint_t clientTimeout)
345 {
346  //Check parameters
347  if(context == NULL || clientTimeout == 0)
349 
350  //Acquire exclusive access to the 802.1X supplicant context
351  osAcquireMutex(&context->mutex);
352  //Save parameter value
353  context->clientTimeout = clientTimeout;
354  //Release exclusive access to the 802.1X supplicant context
355  osReleaseMutex(&context->mutex);
356 
357  //Successful processing
358  return NO_ERROR;
359 }
360 
361 
362 /**
363  * @brief Set the value of the portControl variable
364  * @param[in] context Pointer to the 802.1X supplicant context
365  * @param[in] portControl Value of the portControl variable
366  * @return Error code
367  **/
368 
370  SupplicantPortMode portControl)
371 {
372  //Make sure the 802.1X supplicant context is valid
373  if(context == NULL)
375 
376  //Acquire exclusive access to the 802.1X supplicant context
377  osAcquireMutex(&context->mutex);
378 
379  //The portControl variable is used to switch between the auto and non-auto
380  //modes of operation of the supplicant PAE state machine
381  context->portControl = portControl;
382 
383  //Update supplicant state machines
384  if(context->running)
385  {
386  supplicantFsm(context);
387  }
388 
389  //Release exclusive access to the 802.1X supplicant context
390  osReleaseMutex(&context->mutex);
391 
392  //Successful processing
393  return NO_ERROR;
394 }
395 
396 
397 /**
398  * @brief Perform user logon
399  * @param[in] context Pointer to the 802.1X supplicant context
400  * @return Error code
401  **/
402 
404 {
405  //Make sure the 802.1X supplicant context is valid
406  if(context == NULL)
408 
409  //Acquire exclusive access to the 802.1X supplicant context
410  osAcquireMutex(&context->mutex);
411 
412  //The userLogoff variable is controlled externally to the state machine and
413  //reflects the operation of the process in the supplicant system that
414  //controls the logged on/logged off state of the user of the system
415  context->userLogoff = FALSE;
416 
417  //Update supplicant state machines
418  if(context->running)
419  {
420  supplicantFsm(context);
421  }
422 
423  //Release exclusive access to the 802.1X supplicant context
424  osReleaseMutex(&context->mutex);
425 
426  //Successful processing
427  return NO_ERROR;
428 }
429 
430 
431 /**
432  * @brief Perform user logoff
433  * @param[in] context Pointer to the 802.1X supplicant context
434  * @return Error code
435  **/
436 
438 {
439  //Make sure the 802.1X supplicant context is valid
440  if(context == NULL)
442 
443  //Acquire exclusive access to the 802.1X supplicant context
444  osAcquireMutex(&context->mutex);
445 
446  //The userLogoff variable is controlled externally to the state machine and
447  //reflects the operation of the process in the supplicant system that
448  //controls the logged on/logged off state of the user of the system
449  context->userLogoff = TRUE;
450 
451  //Update supplicant state machines
452  if(context->running)
453  {
454  supplicantFsm(context);
455  }
456 
457  //Release exclusive access to the 802.1X supplicant context
458  osReleaseMutex(&context->mutex);
459 
460  //Successful processing
461  return NO_ERROR;
462 }
463 
464 
465 /**
466  * @brief Start 802.1X supplicant
467  * @param[in] context Pointer to the 802.1X supplicant context
468  * @return Error code
469  **/
470 
472 {
473  error_t error;
474 
475  //Make sure the supplicant context is valid
476  if(context == NULL)
478 
479  //Debug message
480  TRACE_INFO("Starting 802.1X supplicant...\r\n");
481 
482  //Make sure the supplicant is not already running
483  if(context->running)
484  return ERROR_ALREADY_RUNNING;
485 
486  //Start of exception handling block
487  do
488  {
489  //Open a raw socket
490  context->socket = socketOpen(SOCKET_TYPE_RAW_ETH, ETH_TYPE_EAPOL);
491  //Failed to open socket?
492  if(context->socket == NULL)
493  {
494  //Report an error
495  error = ERROR_OPEN_FAILED;
496  break;
497  }
498 
499  //Force the socket to operate in non-blocking mode
500  error = socketSetTimeout(context->socket, 0);
501  //Any error to report?
502  if(error)
503  break;
504 
505  //Associate the socket with the relevant interface
506  error = socketBindToInterface(context->socket, context->interface);
507  //Any error to report?
508  if(error)
509  break;
510 
511  //The PAE group address is one of the reserved set of group MAC addresses
512  //that are not forwarded by MAC Bridges (refer to IEEE Std 802.1X-2010,
513  //section 7.8)
514  error = supplicantAcceptPaeGroupAddr(context);
515  //Any error to report?
516  if(error)
517  break;
518 
519  //Start the supplicant
520  context->stop = FALSE;
521  context->running = TRUE;
522 
523  //Save current time
524  context->timestamp = osGetSystemTime();
525 
526  //Reinitialize supplicant state machine
527  supplicantInitFsm(context);
528 
529  //Create a task
530  context->taskId = osCreateTask("Supplicant", (OsTaskCode) supplicantTask,
531  context, &context->taskParams);
532 
533  //Failed to create task?
534  if(context->taskId == OS_INVALID_TASK_ID)
535  {
536  //Report an error
537  error = ERROR_OUT_OF_RESOURCES;
538  break;
539  }
540 
541  //End of exception handling block
542  } while(0);
543 
544  //Any error to report?
545  if(error)
546  {
547  //Clean up side effects
548  context->running = FALSE;
549 
550  //Remove the PAE group address from the static MAC table
552 
553  //Close the raw socket
554  socketClose(context->socket);
555  context->socket = NULL;
556  }
557 
558  //Return status code
559  return error;
560 }
561 
562 
563 /**
564  * @brief Stop 802.1X supplicant
565  * @param[in] context Pointer to the 802.1X supplicant context
566  * @return Error code
567  **/
568 
570 {
571  //Make sure the supplicant context is valid
572  if(context == NULL)
574 
575  //Debug message
576  TRACE_INFO("Stopping 802.1X supplicant...\r\n");
577 
578  //Check whether the supplicant is running
579  if(context->running)
580  {
581 #if (NET_RTOS_SUPPORT == ENABLED)
582  //Stop the supplicant
583  context->stop = TRUE;
584  //Send a signal to the task to abort any blocking operation
585  osSetEvent(&context->event);
586 
587  //Wait for the task to terminate
588  while(context->running)
589  {
590  osDelayTask(1);
591  }
592 #endif
593 
594 #if (EAP_TLS_SUPPORT == ENABLED)
595  //Close TLS session
597 #endif
598 
599  //Remove the PAE group address from the static MAC table
601 
602  //Close the raw socket
603  socketClose(context->socket);
604  context->socket = NULL;
605  }
606 
607  //Successful processing
608  return NO_ERROR;
609 }
610 
611 
612 /**
613  * @brief 802.1X supplicant task
614  * @param[in] context Pointer to the 802.1X supplicant context
615  **/
616 
618 {
619  systime_t time;
620  systime_t timeout;
621  SocketEventDesc eventDesc;
622 
623 #if (NET_RTOS_SUPPORT == ENABLED)
624  //Task prologue
625  osEnterTask();
626 
627  //Process events
628  while(1)
629  {
630 #endif
631  //Get current time
632  time = osGetSystemTime();
633 
634  //Maximum time to wait for an incoming datagram
635  if((time - context->timestamp) < SUPPLICANT_TICK_INTERVAL)
636  {
637  timeout = context->timestamp + SUPPLICANT_TICK_INTERVAL - time;
638  }
639  else
640  {
641  timeout = 0;
642  }
643 
644  //Specify the events the application is interested in
645  eventDesc.socket = context->socket;
646  eventDesc.eventMask = SOCKET_EVENT_RX_READY;
647  eventDesc.eventFlags = 0;
648 
649  //Wait for an event
650  socketPoll(&eventDesc, 1, &context->event, timeout);
651 
652  //Stop request?
653  if(context->stop)
654  {
655  //Stop supplicant operation
656  context->running = FALSE;
657  //Task epilogue
658  osExitTask();
659  //Kill ourselves
661  }
662 
663  //Any EAPOL packet received?
664  if(eventDesc.eventFlags != 0)
665  {
666  //Acquire exclusive access to the 802.1X supplicant context
667  osAcquireMutex(&context->mutex);
668  //Process incoming EAPOL packet
669  supplicantProcessEapolPdu(context);
670  //Release exclusive access to the 802.1X supplicant context
671  osReleaseMutex(&context->mutex);
672  }
673 
674  //Get current time
675  time = osGetSystemTime();
676 
677  //Timers have a resolution of one second
678  if((time - context->timestamp) >= SUPPLICANT_TICK_INTERVAL)
679  {
680  //Acquire exclusive access to the 802.1X supplicant context
681  osAcquireMutex(&context->mutex);
682  //Handle periodic operations
683  supplicantTick(context);
684  //Release exclusive access to the 802.1X supplicant context
685  osReleaseMutex(&context->mutex);
686 
687  //Save current time
688  context->timestamp = time;
689  }
690 
691 #if (NET_RTOS_SUPPORT == ENABLED)
692  }
693 #endif
694 }
695 
696 
697 /**
698  * @brief Release 802.1X supplicant context
699  * @param[in] context Pointer to the 802.1X supplicant context
700  **/
701 
703 {
704  //Make sure the 802.1X supplicant context is valid
705  if(context != NULL)
706  {
707  //Free previously allocated resources
708  osDeleteMutex(&context->mutex);
709  osDeleteEvent(&context->event);
710 
711  //Clear supplicant context
712  osMemset(context, 0, sizeof(SupplicantContext));
713  }
714 }
715 
716 #endif
OsTaskId osCreateTask(const char_t *name, OsTaskCode taskCode, void *arg, const OsTaskParameters *params)
Create a task.
SupplicantPortMode
Port modes.
error_t supplicantAcceptPaeGroupAddr(SupplicantContext *context)
Add the PAE group address to the static MAC table.
Supplicant state machine.
bool_t osCreateMutex(OsMutex *mutex)
Create a mutex object.
#define osExitTask()
@ ERROR_NOT_IMPLEMENTED
Definition: error.h:66
802.1X supplicant
OsTaskParameters task
Task parameters.
Definition: supplicant.h:194
#define TRUE
Definition: os_port.h:50
void supplicantGetDefaultSettings(SupplicantSettings *settings)
Initialize settings with default values.
Definition: supplicant.c:50
#define OS_INVALID_TASK_ID
void socketClose(Socket *socket)
Close an existing socket.
Definition: socket.c:2067
#define SupplicantContext
Definition: supplicant.h:36
@ ERROR_OUT_OF_RESOURCES
Definition: error.h:64
EapPeerStateChangeCallback eapPeerStateChangeCallback
EAP peer state change callback function.
Definition: supplicant.h:203
error_t supplicantSetClientTimeout(SupplicantContext *context, uint_t clientTimeout)
Set the value of the clientTimeout parameter.
Definition: supplicant.c:343
@ ERROR_SERVICE_CLOSING
Definition: error.h:253
#define SUPPLICANT_DEFAULT_START_PERIOD
Definition: supplicant.h:114
error_t supplicantSetUsername(SupplicantContext *context, const char_t *username)
Set user name.
Definition: supplicant.c:178
error_t supplicantSetPortControl(SupplicantContext *context, SupplicantPortMode portControl)
Set the value of the portControl variable.
Definition: supplicant.c:369
EAP-TLS authentication method.
#define osStrlen(s)
Definition: os_port.h:168
#define OS_SELF_TASK_ID
Structure describing socket events.
Definition: socket.h:432
void eapCloseTls(SupplicantContext *context, error_t error)
Close TLS session.
Definition: eap_tls.c:384
void supplicantDeinit(SupplicantContext *context)
Release 802.1X supplicant context.
Definition: supplicant.c:702
void supplicantTask(SupplicantContext *context)
802.1X supplicant task
Definition: supplicant.c:617
@ ERROR_OPEN_FAILED
Definition: error.h:75
void osDeleteTask(OsTaskId taskId)
Delete a task.
#define FALSE
Definition: os_port.h:46
@ ERROR_INVALID_PARAMETER
Invalid parameter.
Definition: error.h:47
NetInterface * interface
Underlying network interface.
Definition: supplicant.h:195
error_t supplicantSetAuthPeriod(SupplicantContext *context, uint_t authPeriod)
Set the value of the authPeriod parameter.
Definition: supplicant.c:260
error_t
Error codes.
Definition: error.h:43
void(* OsTaskCode)(void *arg)
Task routine.
void supplicantFsm(SupplicantContext *context)
Supplicant state machine implementation.
#define SUPPLICANT_TICK_INTERVAL
Definition: supplicant.h:65
SupplicantTlsCompleteCallback tlsCompleteCallback
TLS negotiation completion callback function.
Definition: supplicant.h:199
void supplicantTick(SupplicantContext *context)
Handle periodic operations.
void osDeleteEvent(OsEvent *event)
Delete an event object.
@ ERROR_INVALID_LENGTH
Definition: error.h:111
error_t supplicantStop(SupplicantContext *context)
Stop 802.1X supplicant.
Definition: supplicant.c:569
#define SUPPLICANT_DEFAULT_MAX_START
Definition: supplicant.h:121
const OsTaskParameters OS_TASK_DEFAULT_PARAMS
error_t supplicantSetMaxStart(SupplicantContext *context, uint_t maxStart)
Set the value of the maxStart parameter.
Definition: supplicant.c:310
void supplicantInitFsm(SupplicantContext *context)
Supplicant state machine initialization.
#define TRACE_INFO(...)
Definition: debug.h:105
@ ETH_TYPE_EAPOL
Definition: ethernet.h:169
Socket * socketOpen(uint_t type, uint_t protocol)
Create a socket (UDP or TCP)
Definition: socket.c:125
#define SUPPLICANT_MAX_PASSWORD_LEN
Definition: supplicant.h:93
#define osEnterTask()
uint_t eventFlags
Returned events.
Definition: socket.h:435
error_t socketPoll(SocketEventDesc *eventDesc, uint_t size, OsEvent *extEvent, systime_t timeout)
Wait for one of a set of sockets to become ready to perform I/O.
Definition: socket.c:2154
#define socketBindToInterface
Definition: net_legacy.h:193
SupplicantBackendStateChangeCallback backendStateChangeCallback
Supplicant backend state change callback function.
Definition: supplicant.h:202
void supplicantProcessEapolPdu(SupplicantContext *context)
Process incoming EAPOL PDU.
error_t supplicantSetPassword(SupplicantContext *context, const char_t *password)
Set password.
Definition: supplicant.c:204
uint32_t systime_t
System time.
error_t supplicantLogOn(SupplicantContext *context)
Perform user logon.
Definition: supplicant.c:403
802.1X supplicant settings
Definition: supplicant.h:193
char char_t
Definition: compiler_port.h:55
SupplicantTickCallback tickCallback
Tick callback function.
Definition: supplicant.h:204
SupplicantPaeStateChangeCallback paeStateChangeCallback
Supplicant PAE state change callback function.
Definition: supplicant.h:201
uint32_t time
void osDeleteMutex(OsMutex *mutex)
Delete a mutex object.
#define SUPPLICANT_DEFAULT_HELD_PERIOD
Definition: supplicant.h:100
@ SOCKET_EVENT_RX_READY
Definition: socket.h:179
#define EAP_DEFAULT_CLIENT_TIMEOUT
Definition: eap.h:105
void osAcquireMutex(OsMutex *mutex)
Acquire ownership of the specified mutex object.
error_t supplicantSetHeldPeriod(SupplicantContext *context, uint_t heldPeriod)
Set the value of the heldPeriod parameter.
Definition: supplicant.c:235
void osReleaseMutex(OsMutex *mutex)
Release ownership of the specified mutex object.
bool_t osCreateEvent(OsEvent *event)
Create an event object.
#define SUPPLICANT_MAX_USERNAME_LEN
Definition: supplicant.h:86
uint_t portIndex
Port index.
Definition: supplicant.h:196
error_t supplicantStart(SupplicantContext *context)
Start 802.1X supplicant.
Definition: supplicant.c:471
error_t supplicantLogOff(SupplicantContext *context)
Perform user logoff.
Definition: supplicant.c:437
@ SOCKET_TYPE_RAW_ETH
Definition: socket.h:95
void osDelayTask(systime_t delay)
Delay routine.
void osSetEvent(OsEvent *event)
Set the specified event object to the signaled state.
SupplicantTlsInitCallback tlsInitCallback
TLS negotiation initialization callback function.
Definition: supplicant.h:198
#define SUPPLICANT_STACK_SIZE
Definition: supplicant.h:53
Socket * socket
Handle to a socket to monitor.
Definition: socket.h:433
unsigned int uint_t
Definition: compiler_port.h:57
#define osMemset(p, value, length)
Definition: os_port.h:138
error_t supplicantSetStartPeriod(SupplicantContext *context, uint_t startPeriod)
Set the value of the startPeriod parameter.
Definition: supplicant.c:285
#define SUPPLICANT_DEFAULT_AUTH_PERIOD
Definition: supplicant.h:107
#define SUPPLICANT_PRIORITY
Definition: supplicant.h:60
@ SUPPLICANT_PORT_MODE_AUTO
#define osStrcpy(s1, s2)
Definition: os_port.h:210
error_t socketSetTimeout(Socket *socket, systime_t timeout)
Set timeout value for blocking operations.
Definition: socket.c:148
error_t supplicantDropPaeGroupAddr(SupplicantContext *context)
Remove the PAE group address from the static MAC table.
uint_t eventMask
Requested events.
Definition: socket.h:434
@ ERROR_ALREADY_RUNNING
Definition: error.h:294
@ NO_ERROR
Success.
Definition: error.h:44
Debugging facilities.
Helper functions for 802.1X supplicant.
error_t supplicantInit(SupplicantContext *context, const SupplicantSettings *settings)
Initialize 802.1X supplicant context.
Definition: supplicant.c:87
systime_t osGetSystemTime(void)
Retrieve system time.