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-2026 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.6.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  //Attach TCP/IP stack context
107  if(settings->interface != NULL)
108  {
109  context->netContext = settings->interface->netContext;
110  }
111  else
112  {
113  context->netContext = NULL;
114  }
115 
116  //Save user settings
117  context->interface = settings->interface;
118  context->portIndex = settings->portIndex;
119  context->paeStateChangeCallback = settings->paeStateChangeCallback;
120  context->backendStateChangeCallback = settings->backendStateChangeCallback;
121  context->eapPeerStateChangeCallback = settings->eapPeerStateChangeCallback;
122  context->tickCallback = settings->tickCallback;
123 
124 #if (EAP_TLS_SUPPORT == ENABLED)
125  //TLS negotiation initialization callback function
126  context->tlsInitCallback = settings->tlsInitCallback;
127  //TLS negotiation completion callback function
128  context->tlsCompleteCallback = settings->tlsCompleteCallback;
129 #endif
130 
131  //Default value of parameters
132  context->portControl = SUPPLICANT_PORT_MODE_AUTO;
133  context->userLogoff = FALSE;
134  context->heldPeriod = SUPPLICANT_DEFAULT_HELD_PERIOD;
135  context->authPeriod = SUPPLICANT_DEFAULT_AUTH_PERIOD;
136  context->startPeriod = SUPPLICANT_DEFAULT_START_PERIOD;
137  context->maxStart = SUPPLICANT_DEFAULT_MAX_START;
138  context->clientTimeout = EAP_DEFAULT_CLIENT_TIMEOUT;
139 
140  //Initialize supplicant state machine
141  supplicantInitFsm(context);
142 
143  //Start of exception handling block
144  do
145  {
146  //Create a mutex to prevent simultaneous access to 802.1X supplicant
147  //context
148  if(!osCreateMutex(&context->mutex))
149  {
150  //Failed to create mutex
151  error = ERROR_OUT_OF_RESOURCES;
152  break;
153  }
154 
155  //Create an event object to poll the state of the raw socket
156  if(!osCreateEvent(&context->event))
157  {
158  //Failed to create event
159  error = ERROR_OUT_OF_RESOURCES;
160  break;
161  }
162 
163  //Successful initialization
164  error = NO_ERROR;
165 
166  //End of exception handling block
167  } while(0);
168 
169  //Any error to report?
170  if(error)
171  {
172  //Clean up side effects
173  supplicantDeinit(context);
174  }
175 
176  //Return status code
177  return error;
178 }
179 
180 
181 /**
182  * @brief Set user name
183  * @param[in] context Pointer to the 802.1X supplicant context
184  * @param[in] username NULL-terminated string containing the user name
185  * @return Error code
186  **/
187 
189  const char_t *username)
190 {
191  //Check parameters
192  if(context == NULL || username == NULL)
194 
195  //Make sure the length of the user name is acceptable
196  if(osStrlen(username) > SUPPLICANT_MAX_USERNAME_LEN)
197  return ERROR_INVALID_LENGTH;
198 
199  //Save user name
200  osStrcpy(context->username, username);
201 
202  //Successful processing
203  return NO_ERROR;
204 }
205 
206 
207 /**
208  * @brief Set password
209  * @param[in] context Pointer to the 802.1X supplicant context
210  * @param[in] password NULL-terminated string containing the password
211  * @return Error code
212  **/
213 
215  const char_t *password)
216 {
217 #if (EAP_MD5_SUPPORT == ENABLED)
218  //Check parameters
219  if(context == NULL || password == NULL)
221 
222  //Make sure the length of the password is acceptable
223  if(osStrlen(password) > SUPPLICANT_MAX_PASSWORD_LEN)
224  return ERROR_INVALID_LENGTH;
225 
226  //Save password
227  osStrcpy(context->password, password);
228 
229  //Successful processing
230  return NO_ERROR;
231 #else
232  //EAP-MD5 challenge is not implemented
233  return ERROR_NOT_IMPLEMENTED;
234 #endif
235 }
236 
237 
238 /**
239  * @brief Set the value of the heldPeriod parameter
240  * @param[in] context Pointer to the 802.1X supplicant context
241  * @param[in] heldPeriod Value of the heldPeriod parameter
242  * @return Error code
243  **/
244 
246 {
247  //Check parameters
248  if(context == NULL || heldPeriod == 0)
250 
251  //Acquire exclusive access to the 802.1X supplicant context
252  osAcquireMutex(&context->mutex);
253  //Save parameter value
254  context->heldPeriod = heldPeriod;
255  //Release exclusive access to the 802.1X supplicant context
256  osReleaseMutex(&context->mutex);
257 
258  //Successful processing
259  return NO_ERROR;
260 }
261 
262 
263 /**
264  * @brief Set the value of the authPeriod parameter
265  * @param[in] context Pointer to the 802.1X supplicant context
266  * @param[in] authPeriod Value of the authPeriod parameter
267  * @return Error code
268  **/
269 
271 {
272  //Check parameters
273  if(context == NULL || authPeriod == 0)
275 
276  //Acquire exclusive access to the 802.1X supplicant context
277  osAcquireMutex(&context->mutex);
278  //Save parameter value
279  context->authPeriod = authPeriod;
280  //Release exclusive access to the 802.1X supplicant context
281  osReleaseMutex(&context->mutex);
282 
283  //Successful processing
284  return NO_ERROR;
285 }
286 
287 
288 /**
289  * @brief Set the value of the startPeriod parameter
290  * @param[in] context Pointer to the 802.1X supplicant context
291  * @param[in] startPeriod Value of the startPeriod parameter
292  * @return Error code
293  **/
294 
296 {
297  //Check parameters
298  if(context == NULL || startPeriod == 0)
300 
301  //Acquire exclusive access to the 802.1X supplicant context
302  osAcquireMutex(&context->mutex);
303  //Save parameter value
304  context->startPeriod = startPeriod;
305  //Release exclusive access to the 802.1X supplicant context
306  osReleaseMutex(&context->mutex);
307 
308  //Successful processing
309  return NO_ERROR;
310 }
311 
312 
313 /**
314  * @brief Set the value of the maxStart parameter
315  * @param[in] context Pointer to the 802.1X supplicant context
316  * @param[in] maxStart Value of the maxStart parameter
317  * @return Error code
318  **/
319 
321 {
322  //Check parameters
323  if(context == NULL || maxStart == 0)
325 
326  //Acquire exclusive access to the 802.1X supplicant context
327  osAcquireMutex(&context->mutex);
328 
329  //Save parameter value
330  context->maxStart = maxStart;
331 
332  //Update supplicant state machines
333  if(context->running)
334  {
335  supplicantFsm(context);
336  }
337 
338  //Release exclusive access to the 802.1X supplicant context
339  osReleaseMutex(&context->mutex);
340 
341  //Successful processing
342  return NO_ERROR;
343 }
344 
345 
346 /**
347  * @brief Set the value of the clientTimeout parameter
348  * @param[in] context Pointer to the 802.1X supplicant context
349  * @param[in] clientTimeout Value of the clientTimeout parameter
350  * @return Error code
351  **/
352 
354  uint_t clientTimeout)
355 {
356  //Check parameters
357  if(context == NULL || clientTimeout == 0)
359 
360  //Acquire exclusive access to the 802.1X supplicant context
361  osAcquireMutex(&context->mutex);
362  //Save parameter value
363  context->clientTimeout = clientTimeout;
364  //Release exclusive access to the 802.1X supplicant context
365  osReleaseMutex(&context->mutex);
366 
367  //Successful processing
368  return NO_ERROR;
369 }
370 
371 
372 /**
373  * @brief Set the value of the portControl variable
374  * @param[in] context Pointer to the 802.1X supplicant context
375  * @param[in] portControl Value of the portControl variable
376  * @return Error code
377  **/
378 
380  SupplicantPortMode portControl)
381 {
382  //Make sure the 802.1X supplicant context is valid
383  if(context == NULL)
385 
386  //Acquire exclusive access to the 802.1X supplicant context
387  osAcquireMutex(&context->mutex);
388 
389  //The portControl variable is used to switch between the auto and non-auto
390  //modes of operation of the supplicant PAE state machine
391  context->portControl = portControl;
392 
393  //Update supplicant state machines
394  if(context->running)
395  {
396  supplicantFsm(context);
397  }
398 
399  //Release exclusive access to the 802.1X supplicant context
400  osReleaseMutex(&context->mutex);
401 
402  //Successful processing
403  return NO_ERROR;
404 }
405 
406 
407 /**
408  * @brief Perform user logon
409  * @param[in] context Pointer to the 802.1X supplicant context
410  * @return Error code
411  **/
412 
414 {
415  //Make sure the 802.1X supplicant context is valid
416  if(context == NULL)
418 
419  //Acquire exclusive access to the 802.1X supplicant context
420  osAcquireMutex(&context->mutex);
421 
422  //The userLogoff variable is controlled externally to the state machine and
423  //reflects the operation of the process in the supplicant system that
424  //controls the logged on/logged off state of the user of the system
425  context->userLogoff = FALSE;
426 
427  //Update supplicant state machines
428  if(context->running)
429  {
430  supplicantFsm(context);
431  }
432 
433  //Release exclusive access to the 802.1X supplicant context
434  osReleaseMutex(&context->mutex);
435 
436  //Successful processing
437  return NO_ERROR;
438 }
439 
440 
441 /**
442  * @brief Perform user logoff
443  * @param[in] context Pointer to the 802.1X supplicant context
444  * @return Error code
445  **/
446 
448 {
449  //Make sure the 802.1X supplicant context is valid
450  if(context == NULL)
452 
453  //Acquire exclusive access to the 802.1X supplicant context
454  osAcquireMutex(&context->mutex);
455 
456  //The userLogoff variable is controlled externally to the state machine and
457  //reflects the operation of the process in the supplicant system that
458  //controls the logged on/logged off state of the user of the system
459  context->userLogoff = TRUE;
460 
461  //Update supplicant state machines
462  if(context->running)
463  {
464  supplicantFsm(context);
465  }
466 
467  //Release exclusive access to the 802.1X supplicant context
468  osReleaseMutex(&context->mutex);
469 
470  //Successful processing
471  return NO_ERROR;
472 }
473 
474 
475 /**
476  * @brief Start 802.1X supplicant
477  * @param[in] context Pointer to the 802.1X supplicant context
478  * @return Error code
479  **/
480 
482 {
483  error_t error;
484 
485  //Make sure the supplicant context is valid
486  if(context == NULL)
488 
489  //Debug message
490  TRACE_INFO("Starting 802.1X supplicant...\r\n");
491 
492  //Make sure the supplicant is not already running
493  if(context->running)
494  return ERROR_ALREADY_RUNNING;
495 
496  //Start of exception handling block
497  do
498  {
499  //Open a raw socket
500  context->socket = socketOpenEx(context->netContext, SOCKET_TYPE_RAW_ETH,
502  //Failed to open socket?
503  if(context->socket == NULL)
504  {
505  //Report an error
506  error = ERROR_OPEN_FAILED;
507  break;
508  }
509 
510  //Force the socket to operate in non-blocking mode
511  error = socketSetTimeout(context->socket, 0);
512  //Any error to report?
513  if(error)
514  break;
515 
516  //Associate the socket with the relevant interface
517  error = socketBindToInterface(context->socket, context->interface);
518  //Any error to report?
519  if(error)
520  break;
521 
522  //The PAE group address is one of the reserved set of group MAC addresses
523  //that are not forwarded by MAC Bridges (refer to IEEE Std 802.1X-2010,
524  //section 7.8)
525  error = supplicantAcceptPaeGroupAddr(context);
526  //Any error to report?
527  if(error)
528  break;
529 
530  //Start the supplicant
531  context->stop = FALSE;
532  context->running = TRUE;
533 
534  //Save current time
535  context->timestamp = osGetSystemTime();
536 
537  //Reinitialize supplicant state machine
538  supplicantInitFsm(context);
539 
540  //Create a task
541  context->taskId = osCreateTask("Supplicant", (OsTaskCode) supplicantTask,
542  context, &context->taskParams);
543 
544  //Failed to create task?
545  if(context->taskId == OS_INVALID_TASK_ID)
546  {
547  //Report an error
548  error = ERROR_OUT_OF_RESOURCES;
549  break;
550  }
551 
552  //End of exception handling block
553  } while(0);
554 
555  //Any error to report?
556  if(error)
557  {
558  //Clean up side effects
559  context->running = FALSE;
560 
561  //Remove the PAE group address from the static MAC table
563 
564  //Close the raw socket
565  socketClose(context->socket);
566  context->socket = NULL;
567  }
568 
569  //Return status code
570  return error;
571 }
572 
573 
574 /**
575  * @brief Stop 802.1X supplicant
576  * @param[in] context Pointer to the 802.1X supplicant context
577  * @return Error code
578  **/
579 
581 {
582  //Make sure the supplicant context is valid
583  if(context == NULL)
585 
586  //Debug message
587  TRACE_INFO("Stopping 802.1X supplicant...\r\n");
588 
589  //Check whether the supplicant is running
590  if(context->running)
591  {
592 #if (NET_RTOS_SUPPORT == ENABLED)
593  //Stop the supplicant
594  context->stop = TRUE;
595  //Send a signal to the task to abort any blocking operation
596  osSetEvent(&context->event);
597 
598  //Wait for the task to terminate
599  while(context->running)
600  {
601  osDelayTask(1);
602  }
603 #endif
604 
605 #if (EAP_TLS_SUPPORT == ENABLED)
606  //Close TLS session
608 #endif
609 
610  //Remove the PAE group address from the static MAC table
612 
613  //Close the raw socket
614  socketClose(context->socket);
615  context->socket = NULL;
616  }
617 
618  //Successful processing
619  return NO_ERROR;
620 }
621 
622 
623 /**
624  * @brief 802.1X supplicant task
625  * @param[in] context Pointer to the 802.1X supplicant context
626  **/
627 
629 {
630  systime_t time;
631  systime_t timeout;
632  SocketEventDesc eventDesc;
633 
634 #if (NET_RTOS_SUPPORT == ENABLED)
635  //Task prologue
636  osEnterTask();
637 
638  //Process events
639  while(1)
640  {
641 #endif
642  //Get current time
643  time = osGetSystemTime();
644 
645  //Maximum time to wait for an incoming datagram
646  if((time - context->timestamp) < SUPPLICANT_TICK_INTERVAL)
647  {
648  timeout = context->timestamp + SUPPLICANT_TICK_INTERVAL - time;
649  }
650  else
651  {
652  timeout = 0;
653  }
654 
655  //Specify the events the application is interested in
656  eventDesc.socket = context->socket;
657  eventDesc.eventMask = SOCKET_EVENT_RX_READY;
658  eventDesc.eventFlags = 0;
659 
660  //Wait for an event
661  socketPoll(&eventDesc, 1, &context->event, timeout);
662 
663  //Stop request?
664  if(context->stop)
665  {
666  //Stop supplicant operation
667  context->running = FALSE;
668  //Task epilogue
669  osExitTask();
670  //Kill ourselves
672  }
673 
674  //Any EAPOL packet received?
675  if(eventDesc.eventFlags != 0)
676  {
677  //Acquire exclusive access to the 802.1X supplicant context
678  osAcquireMutex(&context->mutex);
679  //Process incoming EAPOL packet
680  supplicantProcessEapolPdu(context);
681  //Release exclusive access to the 802.1X supplicant context
682  osReleaseMutex(&context->mutex);
683  }
684 
685  //Get current time
686  time = osGetSystemTime();
687 
688  //Timers have a resolution of one second
689  if((time - context->timestamp) >= SUPPLICANT_TICK_INTERVAL)
690  {
691  //Acquire exclusive access to the 802.1X supplicant context
692  osAcquireMutex(&context->mutex);
693  //Handle periodic operations
694  supplicantTick(context);
695  //Release exclusive access to the 802.1X supplicant context
696  osReleaseMutex(&context->mutex);
697 
698  //Save current time
699  context->timestamp = time;
700  }
701 
702 #if (NET_RTOS_SUPPORT == ENABLED)
703  }
704 #endif
705 }
706 
707 
708 /**
709  * @brief Release 802.1X supplicant context
710  * @param[in] context Pointer to the 802.1X supplicant context
711  **/
712 
714 {
715  //Make sure the 802.1X supplicant context is valid
716  if(context != NULL)
717  {
718  //Free previously allocated resources
719  osDeleteMutex(&context->mutex);
720  osDeleteEvent(&context->event);
721 
722  //Clear supplicant context
723  osMemset(context, 0, sizeof(SupplicantContext));
724  }
725 }
726 
727 #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:2094
#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:353
@ 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:188
error_t supplicantSetPortControl(SupplicantContext *context, SupplicantPortMode portControl)
Set the value of the portControl variable.
Definition: supplicant.c:379
EAP-TLS authentication method.
#define osStrlen(s)
Definition: os_port.h:168
#define OS_SELF_TASK_ID
Structure describing socket events.
Definition: socket.h:433
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:713
void supplicantTask(SupplicantContext *context)
802.1X supplicant task
Definition: supplicant.c:628
@ 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:270
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:580
#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:320
void supplicantInitFsm(SupplicantContext *context)
Supplicant state machine initialization.
#define TRACE_INFO(...)
Definition: debug.h:105
@ ETH_TYPE_EAPOL
Definition: ethernet.h:171
#define SUPPLICANT_MAX_PASSWORD_LEN
Definition: supplicant.h:93
#define osEnterTask()
uint_t eventFlags
Returned events.
Definition: socket.h:436
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:2182
#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:214
uint32_t systime_t
System time.
error_t supplicantLogOn(SupplicantContext *context)
Perform user logon.
Definition: supplicant.c:413
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:245
void osReleaseMutex(OsMutex *mutex)
Release ownership of the specified mutex object.
Socket * socketOpenEx(NetContext *context, uint_t type, uint_t protocol)
Create a socket.
Definition: socket.c:146
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:481
error_t supplicantLogOff(SupplicantContext *context)
Perform user logoff.
Definition: supplicant.c:447
@ 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:434
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:295
#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:169
error_t supplicantDropPaeGroupAddr(SupplicantContext *context)
Remove the PAE group address from the static MAC table.
uint_t eventMask
Requested events.
Definition: socket.h:435
@ 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.