rstp.c
Go to the documentation of this file.
1 /**
2  * @file rstp.c
3  * @brief RSTP (Rapid Spanning Tree Protocol)
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2019-2024 Oryx Embedded SARL. All rights reserved.
10  *
11  * This file is part of CycloneSTP 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.4.0
29  **/
30 
31 //Switch to the appropriate trace level
32 #define TRACE_LEVEL RSTP_TRACE_LEVEL
33 
34 //Dependencies
35 #include "rstp/rstp.h"
36 #include "rstp/rstp_mgmt.h"
37 #include "rstp/rstp_fsm.h"
38 #include "rstp/rstp_conditions.h"
39 #include "rstp/rstp_misc.h"
40 #include "debug.h"
41 
42 //Check TCP/IP stack configuration
43 #if (RSTP_SUPPORT == ENABLED)
44 
45 
46 /**
47  * @brief Initialize settings with default values
48  * @param[out] settings Structure that contains RSTP bridge settings
49  **/
50 
52 {
53  //Underlying network interface
54  settings->interface = NULL;
55 
56  //Number of ports
57  settings->numPorts = 0;
58  //Bridge's ports
59  settings->ports = NULL;
60 }
61 
62 
63 /**
64  * @brief Initialize RSTP bridge context
65  * @param[in] context Pointer to the RSTP bridge context
66  * @param[in] settings RSTP bridge specific settings
67  * @return Error code
68  **/
69 
71 {
72  uint_t i;
74 
75  //Debug message
76  TRACE_INFO("Initializing RSTP bridge...\r\n");
77 
78  //Ensure the parameters are valid
79  if(context == NULL || settings == NULL)
81 
82  //The bridge must be bound to a valid interface
83  if(settings->interface == NULL)
85 
86  //Sanity check
87  if(settings->numPorts < 1 || settings->ports == NULL)
89 
90  //Clear RSTP bridge context
91  osMemset(context, 0, sizeof(RstpBridgeContext));
92 
93  //Initialize RSTP bridge context
94  context->interface = settings->interface;
95  context->bridgeId.addr = settings->interface->macAddr;
96  context->bridgeId.priority = RSTP_DEFAULT_BRIDGE_PRIORITY;
97  context->numPorts = settings->numPorts;
98  context->ports = settings->ports;
99 
100  //Default bridge parameters
101  context->params.forceProtocolVersion = RSTP_PROTOCOL_VERSION;
102  context->params.migrateTime = RSTP_DEFAULT_MIGRATE_TIME;
103  context->params.bridgeMaxAge = RSTP_DEFAULT_BRIDGE_MAX_AGE;
104  context->params.bridgeHelloTime = RSTP_DEFAULT_BRIDGE_HELLO_TIME;
105  context->params.bridgeForwardDelay = RSTP_DEFAULT_BRIDGE_FORWARD_DELAY;
106  context->params.transmitHoldCount = RSTP_DEFAULT_TRANSMIT_HOLD_COUNT;
107  context->params.ageingTime = RSTP_DEFAULT_AGEING_TIME;
108 
109  //Loop through the ports of the bridge
110  for(i = 0; i < context->numPorts; i++)
111  {
112  //Point to the current bridge port
113  port = &context->ports[i];
114 
115  //Attach RSTP bridge context to each port
116  port->context = context;
117 
118  //Set port index
119  port->portIndex = i + 1;
120  //Default port identifier
121  port->portId = (RSTP_DEFAULT_PORT_PRIORITY << 8) | port->portIndex;
122 
123  //Each port must assigned a unique MAC address
125 
126  //Default port parameters
127  port->params.adminPortState = FALSE;
128  port->params.adminPathCost = RSTP_DEFAULT_PORT_PATH_COST;
129  port->params.adminPointToPointMac = RSTP_ADMIN_P2P_MAC_FORCE_TRUE;
130  port->params.adminEdgePort = FALSE;
131  port->params.autoEdgePort = TRUE;
132 
133  //Default operation mode
134  port->macOperState = FALSE;
135  port->linkSpeed = NIC_LINK_SPEED_UNKNOWN;
136  port->duplexMode = NIC_UNKNOWN_DUPLEX_MODE;
137 
138  //The portEnabled variable is set if the MAC entity can transmit and
139  //receive frames to and from the attached LAN
140  port->portEnabled = port->macOperState && port->params.adminPortState;
141 
142  //Recalculate the contribution of the port to the root path cost
144 
145  //The MAC is considered to be connected to a point-to-point LAN if the
146  //MAC entity is configured for full duplex operation
148  }
149 
150  //Get exclusive access
151  rstpLock(context);
152  //Initialize RSTP state machine
153  rstpFsmInit(context);
154  //Release exclusive access
155  rstpUnlock(context);
156 
157  //Successful initialization
158  return NO_ERROR;
159 }
160 
161 
162 /**
163  * @brief Start RSTP bridge operation
164  * @param[in] context Pointer to the RSTP bridge context
165  * @return Error code
166  **/
167 
169 {
170  error_t error;
171  NetInterface *interface;
172 
173  //Make sure the RSTP bridge context is valid
174  if(context == NULL)
176 
177  //Debug message
178  TRACE_INFO("Starting RSTP bridge...\r\n");
179 
180  //Get exclusive access
181  rstpLock(context);
182 
183  //Check RSTP bridge operation state
184  if(!context->running)
185  {
186  //Point to the underlying network interface
187  interface = context->interface;
188 
189  //Start of exception handling block
190  do
191  {
192  //The Bridge Group Address is used as destination MAC address to
193  //carry BPDUs between STP entities
194  error = ethAcceptMacAddr(interface, &RSTP_BRIDGE_GROUP_ADDR);
195  //Any error to report?
196  if(error)
197  break;
198 
199  //Configure the permanent database
200  error = rstpConfigurePermanentDatabase(context);
201  //Any error to report?
202  if(error)
203  break;
204 
205  //Register a callback to process incoming LLC frames
206  error = ethAttachLlcRxCalback(interface, rstpProcessLlcFrame,
207  context);
208  //Any error to report?
209  if(error)
210  break;
211 
212  //Register timer callback
214  (NetTimerCallback) rstpTick, context);
215  //Any error to report?
216  if(error)
217  break;
218 
219  //The RSTP bridge is now running
220  context->running = TRUE;
221  //Reinitialize RSTP state machine
222  rstpFsmInit(context);
223 
224  //End of exception handling block
225  } while(0);
226 
227  //Check status code
228  if(error)
229  {
230  //Clean up side effects
233  ethDetachLlcRxCalback(interface);
235  }
236  }
237  else
238  {
239  //The RSTP bridge is already running
240  error = ERROR_ALREADY_RUNNING;
241  }
242 
243  //Release exclusive access
244  rstpUnlock(context);
245 
246  //Return status code
247  return error;
248 }
249 
250 
251 /**
252  * @brief Stop RSTP bridge operation
253  * @param[in] context Pointer to the RSTP bridge context
254  * @return Error code
255  **/
256 
258 {
259  uint_t i;
260  NetInterface *interface;
261 
262  //Make sure the RSTP bridge context is valid
263  if(context == NULL)
265 
266  //Debug message
267  TRACE_INFO("Stopping RSTP bridge...\r\n");
268 
269  //Get exclusive access
270  rstpLock(context);
271 
272  //Check RSTP bridge operation state
273  if(context->running)
274  {
275  //Point to the underlying network interface
276  interface = context->interface;
277 
278  //Remove the Bridge Group Address from the MAC filter table
280  //Unconfigure the permanent database
282 
283  //Unregister LLC receive callback function
284  ethDetachLlcRxCalback(interface);
285  //Unregister timer callback
287 
288  //Restore default ageing time
290 
291  //Loop through the ports of the bridge
292  for(i = 0; i < context->numPorts; i++)
293  {
294  //Restore default port state
296  }
297 
298  //The RSTP bridge is not running anymore
299  context->running = FALSE;
300  }
301 
302  //Release exclusive access
303  rstpUnlock(context);
304 
305  //Successful processing
306  return NO_ERROR;
307 }
308 
309 
310 /**
311  * @brief Set protocol version
312  * @param[in] context Pointer to the RSTP bridge context
313  * @param[in] value Protocol version
314  * @return Error code
315  **/
316 
318 {
319  error_t error;
320 
321  //Make sure the RSTP bridge context is valid
322  if(context != NULL)
323  {
324  //Acquire exclusive access to the RSTP bridge context
325  rstpLock(context);
326  //Perform management operation
327  error = rstpMgmtSetVersion(context, value, TRUE);
328  //Release exclusive access to the RSTP bridge context
329  rstpUnlock(context);
330  }
331  else
332  {
333  //Report an error
334  error = ERROR_INVALID_PARAMETER;
335  }
336 
337  //Return status code
338  return error;
339 }
340 
341 
342 /**
343  * @brief Set bridge priority
344  * @param[in] context Pointer to the RSTP bridge context
345  * @param[in] value Bridge priority
346  * @return Error code
347  **/
348 
350 {
351  error_t error;
352 
353  //Make sure the RSTP bridge context is valid
354  if(context != NULL)
355  {
356  //Acquire exclusive access to the RSTP bridge context
357  rstpLock(context);
358  //Perform management operation
359  error = rstpMgmtSetBridgePriority(context, value, TRUE);
360  //Release exclusive access to the RSTP bridge context
361  rstpUnlock(context);
362  }
363  else
364  {
365  //Report an error
366  error = ERROR_INVALID_PARAMETER;
367  }
368 
369  //Return status code
370  return error;
371 }
372 
373 
374 /**
375  * @brief Set Bridge Max Age parameter
376  * @param[in] context Pointer to the RSTP bridge context
377  * @param[in] value Value of the Bridge Max Age parameter, in seconds
378  * @return Error code
379  **/
380 
382 {
383  error_t error;
384 
385  //Make sure the RSTP bridge context is valid
386  if(context != NULL)
387  {
388  //Acquire exclusive access to the RSTP bridge context
389  rstpLock(context);
390  //Perform management operation
391  error = rstpMgmtSetBridgeMaxAge(context, value, TRUE);
392  //Release exclusive access to the RSTP bridge context
393  rstpUnlock(context);
394  }
395  else
396  {
397  //Report an error
398  error = ERROR_INVALID_PARAMETER;
399  }
400 
401  //Return status code
402  return error;
403 }
404 
405 
406 /**
407  * @brief Set Bridge Hello Time parameter
408  * @param[in] context Pointer to the RSTP bridge context
409  * @param[in] value Value of the Bridge Hello Time parameter, in seconds
410  * @return Error code
411  **/
412 
414 {
415  error_t error;
416 
417  //Make sure the RSTP bridge context is valid
418  if(context != NULL)
419  {
420  //Acquire exclusive access to the RSTP bridge context
421  rstpLock(context);
422  //Perform management operation
423  error = rstpMgmtSetBridgeHelloTime(context, value, TRUE);
424  //Release exclusive access to the RSTP bridge context
425  rstpUnlock(context);
426  }
427  else
428  {
429  //Report an error
430  error = ERROR_INVALID_PARAMETER;
431  }
432 
433  //Return status code
434  return error;
435 }
436 
437 
438 /**
439  * @brief Set Bridge Forward Delay parameter
440  * @param[in] context Pointer to the RSTP bridge context
441  * @param[in] value Value of the Bridge Forward Delay parameter, in seconds
442  * @return Error code
443  **/
444 
446 {
447  error_t error;
448 
449  //Make sure the RSTP bridge context is valid
450  if(context != NULL)
451  {
452  //Acquire exclusive access to the RSTP bridge context
453  rstpLock(context);
454  //Perform management operation
455  error = rstpMgmtSetBridgeForwardDelay(context, value, TRUE);
456  //Release exclusive access to the RSTP bridge context
457  rstpUnlock(context);
458  }
459  else
460  {
461  //Report an error
462  error = ERROR_INVALID_PARAMETER;
463  }
464 
465  //Return status code
466  return error;
467 }
468 
469 
470 /**
471  * @brief Set Transmit Hold Count parameter
472  * @param[in] context Pointer to the RSTP bridge context
473  * @param[in] value Value of the Transmit Hold Count parameter
474  * @return Error code
475  **/
476 
478 {
479  error_t error;
480 
481  //Make sure the RSTP bridge context is valid
482  if(context != NULL)
483  {
484  //Acquire exclusive access to the RSTP bridge context
485  rstpLock(context);
486  //Perform management operation
487  error = rstpMgmtSetTxHoldCount(context, value, TRUE);
488  //Release exclusive access to the RSTP bridge context
489  rstpUnlock(context);
490  }
491  else
492  {
493  //Report an error
494  error = ERROR_INVALID_PARAMETER;
495  }
496 
497  //Return status code
498  return error;
499 }
500 
501 
502 /**
503  * @brief Set Ageing Time parameter
504  * @param[in] context Pointer to the RSTP bridge context
505  * @param[in] value Value of the Ageing Time parameter
506  * @return Error code
507  **/
508 
510 {
511  error_t error;
512 
513  //Make sure the RSTP bridge context is valid
514  if(context != NULL)
515  {
516  //Acquire exclusive access to the RSTP bridge context
517  rstpLock(context);
518  //Perform management operation
519  error = rstpMgmtSetAgeingTime(context, value, TRUE);
520  //Release exclusive access to the RSTP bridge context
521  rstpUnlock(context);
522  }
523  else
524  {
525  //Report an error
526  error = ERROR_INVALID_PARAMETER;
527  }
528 
529  //Return status code
530  return error;
531 }
532 
533 
534 /**
535  * @brief Get the number of ports
536  * @param[in] context Pointer to the RSTP bridge context
537  * @param[out] value Number of ports
538  * @return Error code
539  **/
540 
542 {
543  error_t error;
544 
545  //Make sure the RSTP bridge context is valid
546  if(context != NULL)
547  {
548  //Acquire exclusive access to the RSTP bridge context
549  rstpLock(context);
550  //Perform management operation
551  error = rstpMgmtGetNumPorts(context, value);
552  //Release exclusive access to the RSTP bridge context
553  rstpUnlock(context);
554  }
555  else
556  {
557  //Report an error
558  error = ERROR_INVALID_PARAMETER;
559  }
560 
561  //Return status code
562  return error;
563 }
564 
565 
566 /**
567  * @brief Get assigned protocol version
568  * @param[in] context Pointer to the RSTP bridge context
569  * @param[out] value Protocol version
570  * @return Error code
571  **/
572 
574 {
575  error_t error;
576 
577  //Make sure the RSTP bridge context is valid
578  if(context != NULL)
579  {
580  //Acquire exclusive access to the RSTP bridge context
581  rstpLock(context);
582  //Perform management operation
583  error = rstpMgmtGetVersion(context, value);
584  //Release exclusive access to the RSTP bridge context
585  rstpUnlock(context);
586  }
587  else
588  {
589  //Report an error
590  error = ERROR_INVALID_PARAMETER;
591  }
592 
593  //Return status code
594  return error;
595 }
596 
597 
598 /**
599  * @brief Get the MAC address assigned to the bridge
600  * @param[in] context Pointer to the RSTP bridge context
601  * @param[out] value MAC address of the bridge
602  * @return Error code
603  **/
604 
606 {
607  error_t error;
608 
609  //Make sure the RSTP bridge context is valid
610  if(context != NULL)
611  {
612  //Acquire exclusive access to the RSTP bridge context
613  rstpLock(context);
614  //Perform management operation
615  error = rstpMgmtGetBridgeAddr(context, value);
616  //Release exclusive access to the RSTP bridge context
617  rstpUnlock(context);
618  }
619  else
620  {
621  //Report an error
622  error = ERROR_INVALID_PARAMETER;
623  }
624 
625  //Return status code
626  return error;
627 }
628 
629 
630 /**
631  * @brief Get the assigned bridge priority
632  * @param[in] context Pointer to the RSTP bridge context
633  * @param[out] value Bridge priority
634  * @return Error code
635  **/
636 
638 {
639  error_t error;
640 
641  //Make sure the RSTP bridge context is valid
642  if(context != NULL)
643  {
644  //Acquire exclusive access to the RSTP bridge context
645  rstpLock(context);
646  //Perform management operation
647  error = rstpMgmtGetBridgePriority(context, value);
648  //Release exclusive access to the RSTP bridge context
649  rstpUnlock(context);
650  }
651  else
652  {
653  //Report an error
654  error = ERROR_INVALID_PARAMETER;
655  }
656 
657  //Return status code
658  return error;
659 }
660 
661 
662 /**
663  * @brief Get the assigned value of the Bridge Max Age parameter
664  * @param[in] context Pointer to the RSTP bridge context
665  * @param[out] value Value of the Bridge Max Age parameter, in seconds
666  * @return Error code
667  **/
668 
670 {
671  error_t error;
672 
673  //Make sure the RSTP bridge context is valid
674  if(context != NULL)
675  {
676  //Acquire exclusive access to the RSTP bridge context
677  rstpLock(context);
678  //Perform management operation
679  error = rstpMgmtGetBridgeMaxAge(context, value);
680  //Release exclusive access to the RSTP bridge context
681  rstpUnlock(context);
682  }
683  else
684  {
685  //Report an error
686  error = ERROR_INVALID_PARAMETER;
687  }
688 
689  //Return status code
690  return error;
691 }
692 
693 
694 /**
695  * @brief Get the assigned value of the Bridge Hello Time parameter
696  * @param[in] context Pointer to the RSTP bridge context
697  * @param[out] value Value of the Bridge Hello Time parameter, in seconds
698  * @return Error code
699  **/
700 
702 {
703  error_t error;
704 
705  //Make sure the RSTP bridge context is valid
706  if(context != NULL)
707  {
708  //Acquire exclusive access to the RSTP bridge context
709  rstpLock(context);
710  //Perform management operation
711  error = rstpMgmtGetBridgeHelloTime(context, value);
712  //Release exclusive access to the RSTP bridge context
713  rstpUnlock(context);
714  }
715  else
716  {
717  //Report an error
718  error = ERROR_INVALID_PARAMETER;
719  }
720 
721  //Return status code
722  return error;
723 }
724 
725 
726 /**
727  * @brief Get the assigned value of the Bridge Forward Delay parameter
728  * @param[in] context Pointer to the RSTP bridge context
729  * @param[out] value Value of the Bridge Forward Delay parameter, in seconds
730  * @return Error code
731  **/
732 
734 {
735  error_t error;
736 
737  //Make sure the RSTP bridge context is valid
738  if(context != NULL)
739  {
740  //Acquire exclusive access to the RSTP bridge context
741  rstpLock(context);
742  //Perform management operation
743  error = rstpMgmtGetBridgeForwardDelay(context, value);
744  //Release exclusive access to the RSTP bridge context
745  rstpUnlock(context);
746  }
747  else
748  {
749  //Report an error
750  error = ERROR_INVALID_PARAMETER;
751  }
752 
753  //Return status code
754  return error;
755 }
756 
757 
758 /**
759  * @brief Get the assigned value of the Transmit Hold Count parameter
760  * @param[in] context Pointer to the RSTP bridge context
761  * @param[out] value Value of the Transmit Hold Count parameter
762  * @return Error code
763  **/
764 
766 {
767  error_t error;
768 
769  //Make sure the RSTP bridge context is valid
770  if(context != NULL)
771  {
772  //Acquire exclusive access to the RSTP bridge context
773  rstpLock(context);
774  //Perform management operation
775  error = rstpMgmtGetTxHoldCount(context, value);
776  //Release exclusive access to the RSTP bridge context
777  rstpUnlock(context);
778  }
779  else
780  {
781  //Report an error
782  error = ERROR_INVALID_PARAMETER;
783  }
784 
785  //Return status code
786  return error;
787 }
788 
789 
790 /**
791  * @brief Get the assigned value of the Ageing Time parameter
792  * @param[in] context Pointer to the RSTP bridge context
793  * @param[out] value Value of the Ageing Time parameter
794  * @return Error code
795  **/
796 
798 {
799  error_t error;
800 
801  //Make sure the RSTP bridge context is valid
802  if(context != NULL)
803  {
804  //Acquire exclusive access to the RSTP bridge context
805  rstpLock(context);
806  //Perform management operation
807  error = rstpMgmtGetAgeingTime(context, value);
808  //Release exclusive access to the RSTP bridge context
809  rstpUnlock(context);
810  }
811  else
812  {
813  //Report an error
814  error = ERROR_INVALID_PARAMETER;
815  }
816 
817  //Return status code
818  return error;
819 }
820 
821 
822 /**
823  * @brief Get the bridge identifier of the root of the spanning tree
824  * @param[in] context Pointer to the RSTP bridge context
825  * @param[out] value Bridge identifier
826  * @return Error code
827  **/
828 
830 {
831  error_t error;
832 
833  //Make sure the RSTP bridge context is valid
834  if(context != NULL)
835  {
836  //Acquire exclusive access to the RSTP bridge context
837  rstpLock(context);
838  //Perform management operation
839  error = rstpMgmtGetDesignatedRoot(context, value);
840  //Release exclusive access to the RSTP bridge context
841  rstpUnlock(context);
842  }
843  else
844  {
845  //Report an error
846  error = ERROR_INVALID_PARAMETER;
847  }
848 
849  //Return status code
850  return error;
851 }
852 
853 
854 /**
855  * @brief Get the current cost of the path to the root
856  * @param[in] context Pointer to the RSTP bridge context
857  * @param[out] value Root path cost
858  * @return Error code
859  **/
860 
862 {
863  error_t error;
864 
865  //Make sure the RSTP bridge context is valid
866  if(context != NULL)
867  {
868  //Acquire exclusive access to the RSTP bridge context
869  rstpLock(context);
870  //Perform management operation
871  error = rstpMgmtGetRootPathCost(context, value);
872  //Release exclusive access to the RSTP bridge context
873  rstpUnlock(context);
874  }
875  else
876  {
877  //Report an error
878  error = ERROR_INVALID_PARAMETER;
879  }
880 
881  //Return status code
882  return error;
883 }
884 
885 
886 /**
887  * @brief Get the current root port
888  * @param[in] context Pointer to the RSTP bridge context
889  * @param[out] value Port number
890  * @return Error code
891  **/
892 
894 {
895  error_t error;
896 
897  //Make sure the RSTP bridge context is valid
898  if(context != NULL)
899  {
900  //Acquire exclusive access to the RSTP bridge context
901  rstpLock(context);
902  //Perform management operation
903  error = rstpMgmtGetRootPort(context, value);
904  //Release exclusive access to the RSTP bridge context
905  rstpUnlock(context);
906  }
907  else
908  {
909  //Report an error
910  error = ERROR_INVALID_PARAMETER;
911  }
912 
913  //Return status code
914  return error;
915 }
916 
917 
918 /**
919  * @brief Get the current Max Age value
920  * @param[in] context Pointer to the RSTP bridge context
921  * @param[out] value Max Age value, in seconds
922  * @return Error code
923  **/
924 
926 {
927  error_t error;
928 
929  //Make sure the RSTP bridge context is valid
930  if(context != NULL)
931  {
932  //Acquire exclusive access to the RSTP bridge context
933  rstpLock(context);
934  //Perform management operation
935  error = rstpMgmtGetMaxAge(context, value);
936  //Release exclusive access to the RSTP bridge context
937  rstpUnlock(context);
938  }
939  else
940  {
941  //Report an error
942  error = ERROR_INVALID_PARAMETER;
943  }
944 
945  //Return status code
946  return error;
947 }
948 
949 
950 /**
951  * @brief Get the current Hello Time value
952  * @param[in] context Pointer to the RSTP bridge context
953  * @param[out] value Hello Time value, in seconds
954  * @return Error code
955  **/
956 
958 {
959  error_t error;
960 
961  //Make sure the RSTP bridge context is valid
962  if(context != NULL)
963  {
964  //Acquire exclusive access to the RSTP bridge context
965  rstpLock(context);
966  //Perform management operation
967  error = rstpMgmtGetHelloTime(context, value);
968  //Release exclusive access to the RSTP bridge context
969  rstpUnlock(context);
970  }
971  else
972  {
973  //Report an error
974  error = ERROR_INVALID_PARAMETER;
975  }
976 
977  //Return status code
978  return error;
979 }
980 
981 
982 /**
983  * @brief Get the current Forward Delay value
984  * @param[in] context Pointer to the RSTP bridge context
985  * @param[out] value Forward Delay value, in seconds
986  * @return Error code
987  **/
989 {
990  error_t error;
991 
992  //Make sure the RSTP bridge context is valid
993  if(context != NULL)
994  {
995  //Acquire exclusive access to the RSTP bridge context
996  rstpLock(context);
997  //Perform management operation
998  error = rstpMgmtGetForwardDelay(context, value);
999  //Release exclusive access to the RSTP bridge context
1000  rstpUnlock(context);
1001  }
1002  else
1003  {
1004  //Report an error
1005  error = ERROR_INVALID_PARAMETER;
1006  }
1007 
1008  //Return status code
1009  return error;
1010 }
1011 
1012 
1013 /**
1014  * @brief Get the number of topology changes
1015  * @param[in] context Pointer to the RSTP bridge context
1016  * @param[out] value Number of topology changes
1017  * @return Error code
1018  **/
1019 
1021 {
1022  error_t error;
1023 
1024  //Make sure the RSTP bridge context is valid
1025  if(context != NULL)
1026  {
1027  //Acquire exclusive access to the RSTP bridge context
1028  rstpLock(context);
1029  //Perform management operation
1030  error = rstpMgmtGetTopologyChanges(context, value);
1031  //Release exclusive access to the RSTP bridge context
1032  rstpUnlock(context);
1033  }
1034  else
1035  {
1036  //Report an error
1037  error = ERROR_INVALID_PARAMETER;
1038  }
1039 
1040  //Return status code
1041  return error;
1042 }
1043 
1044 
1045 /**
1046  * @brief Get the time since a topology change was last detected
1047  * @param[in] context Pointer to the RSTP bridge context
1048  * @param[out] value Time since a topology change was last detected
1049  * @return Error code
1050  **/
1051 
1053  uint_t *value)
1054 {
1055  error_t error;
1056 
1057  //Make sure the RSTP bridge context is valid
1058  if(context != NULL)
1059  {
1060  //Acquire exclusive access to the RSTP bridge context
1061  rstpLock(context);
1062  //Perform management operation
1063  error = rstpMgmtGetTimeSinceTopologyChange(context, value);
1064  //Release exclusive access to the RSTP bridge context
1065  rstpUnlock(context);
1066  }
1067  else
1068  {
1069  //Report an error
1070  error = ERROR_INVALID_PARAMETER;
1071  }
1072 
1073  //Return status code
1074  return error;
1075 }
1076 
1077 
1078 /**
1079  * @brief Set port number
1080  * @param[in] context Pointer to the RSTP bridge context
1081  * @param[in] portIndex Port index
1082  * @param[in] value Port number
1083  * @return Error code
1084  **/
1085 
1087  uint16_t value)
1088 {
1089  error_t error;
1091 
1092  //Initialize status code
1093  error = NO_ERROR;
1094 
1095  //Make sure the RSTP bridge context is valid
1096  if(context != NULL)
1097  {
1098  //Acquire exclusive access to the RSTP bridge context
1099  rstpLock(context);
1100 
1101  //Valid port index?
1102  if(portIndex >= 1 && portIndex <= context->numPorts)
1103  {
1104  //Point to the port that matches the specified port index
1105  port = &context->ports[portIndex - 1];
1106 
1107  //Check the value of the parameter
1108  if(value <= 4095)
1109  {
1110  //The port identifier is updated using the supplied value
1111  port->portId = (port->portId & RSTP_PORT_PRIORITY_MASK) | value;
1112  }
1113  else
1114  {
1115  //The parameter value is not valid
1116  error = ERROR_INVALID_VALUE;
1117  }
1118  }
1119  else
1120  {
1121  //The port index is out of range
1122  error = ERROR_INVALID_PORT;
1123  }
1124 
1125  //Release exclusive access to the RSTP bridge context
1126  rstpUnlock(context);
1127  }
1128  else
1129  {
1130  //Report an error
1131  error = ERROR_INVALID_PARAMETER;
1132  }
1133 
1134  //Return status code
1135  return error;
1136 }
1137 
1138 
1139 /**
1140  * @brief Set port address
1141  * @param[in] context Pointer to the RSTP bridge context
1142  * @param[in] portIndex Port index
1143  * @param[in] value MAC address of the individual MAC entity for the port
1144  * @return Error code
1145  **/
1146 
1148  const MacAddr *value)
1149 {
1150  error_t error;
1152 
1153  //Initialize status code
1154  error = NO_ERROR;
1155 
1156  //Make sure the RSTP bridge context is valid
1157  if(context != NULL)
1158  {
1159  //Acquire exclusive access to the RSTP bridge context
1160  rstpLock(context);
1161 
1162  //Valid port index?
1163  if(portIndex >= 1 && portIndex <= context->numPorts)
1164  {
1165  //Point to the port that matches the specified port index
1166  port = &context->ports[portIndex - 1];
1167  //Set the MAC address of the individual MAC entity for the port
1168  port->macAddr = *value;
1169  }
1170  else
1171  {
1172  //The port index is out of range
1173  error = ERROR_INVALID_PORT;
1174  }
1175 
1176  //Release exclusive access to the RSTP bridge context
1177  rstpUnlock(context);
1178  }
1179  else
1180  {
1181  //Report an error
1182  error = ERROR_INVALID_PARAMETER;
1183  }
1184 
1185  //Return status code
1186  return error;
1187 }
1188 
1189 
1190 /**
1191  * @brief Set port priority
1192  * @param[in] context Pointer to the RSTP bridge context
1193  * @param[in] portIndex Port index
1194  * @param[in] value Port priority
1195  * @return Error code
1196  **/
1197 
1199  uint8_t value)
1200 {
1201  error_t error;
1202 
1203  //Make sure the RSTP bridge context is valid
1204  if(context != NULL)
1205  {
1206  //Acquire exclusive access to the RSTP bridge context
1207  rstpLock(context);
1208  //Perform management operation
1209  error = rstpMgmtSetPortPriority(context, portIndex, value, TRUE);
1210  //Release exclusive access to the RSTP bridge context
1211  rstpUnlock(context);
1212  }
1213  else
1214  {
1215  //Report an error
1216  error = ERROR_INVALID_PARAMETER;
1217  }
1218 
1219  //Return status code
1220  return error;
1221 }
1222 
1223 
1224 /**
1225  * @brief Set administrative bridge port state
1226  * @param[in] context Pointer to the RSTP bridge context
1227  * @param[in] portIndex Port index
1228  * @param[in] value Administrative bridge port state
1229  * @return Error code
1230  **/
1231 
1233  bool_t value)
1234 {
1235  error_t error;
1236 
1237  //Make sure the RSTP bridge context is valid
1238  if(context != NULL)
1239  {
1240  //Acquire exclusive access to the RSTP bridge context
1241  rstpLock(context);
1242  //Perform management operation
1243  error = rstpMgmtSetAdminPortState(context, portIndex, value, TRUE);
1244  //Release exclusive access to the RSTP bridge context
1245  rstpUnlock(context);
1246  }
1247  else
1248  {
1249  //Report an error
1250  error = ERROR_INVALID_PARAMETER;
1251  }
1252 
1253  //Return status code
1254  return error;
1255 }
1256 
1257 
1258 /**
1259  * @brief Set administrative port path cost
1260  * @param[in] context Pointer to the RSTP bridge context
1261  * @param[in] portIndex Port index
1262  * @param[in] value Administrative port path cost
1263  * @return Error code
1264  **/
1265 
1267  uint32_t value)
1268 {
1269  error_t error;
1270 
1271  //Make sure the RSTP bridge context is valid
1272  if(context != NULL)
1273  {
1274  //Acquire exclusive access to the RSTP bridge context
1275  rstpLock(context);
1276  //Perform management operation
1277  error = rstpMgmtSetAdminPortPathCost(context, portIndex, value, TRUE);
1278  //Release exclusive access to the RSTP bridge context
1279  rstpUnlock(context);
1280  }
1281  else
1282  {
1283  //Report an error
1284  error = ERROR_INVALID_PARAMETER;
1285  }
1286 
1287  //Return status code
1288  return error;
1289 }
1290 
1291 
1292 /**
1293  * @brief Set administrative point-to-point status of the LAN segment
1294  * @param[in] context Pointer to the RSTP bridge context
1295  * @param[in] portIndex Port index
1296  * @param[in] value Administrative point-to-point status of the LAN segment
1297  * attached to this port
1298  * @return Error code
1299  **/
1300 
1303 {
1304  error_t error;
1305 
1306  //Make sure the RSTP bridge context is valid
1307  if(context != NULL)
1308  {
1309  //Acquire exclusive access to the RSTP bridge context
1310  rstpLock(context);
1311  //Perform management operation
1312  error = rstpMgmtSetAdminPointToPointMac(context, portIndex, value, TRUE);
1313  //Release exclusive access to the RSTP bridge context
1314  rstpUnlock(context);
1315  }
1316  else
1317  {
1318  //Report an error
1319  error = ERROR_INVALID_PARAMETER;
1320  }
1321 
1322  //Return status code
1323  return error;
1324 }
1325 
1326 
1327 /**
1328  * @brief Set administrative value of the Edge Port parameter
1329  * @param[in] context Pointer to the RSTP bridge context
1330  * @param[in] portIndex Port index
1331  * @param[in] value Administrative value of the Edge Port parameter
1332  * @return Error code
1333  **/
1334 
1336  bool_t value)
1337 {
1338  error_t error;
1339 
1340  //Make sure the RSTP bridge context is valid
1341  if(context != NULL)
1342  {
1343  //Acquire exclusive access to the RSTP bridge context
1344  rstpLock(context);
1345  //Perform management operation
1346  error = rstpMgmtSetAdminEdgePort(context, portIndex, value, TRUE);
1347  //Release exclusive access to the RSTP bridge context
1348  rstpUnlock(context);
1349  }
1350  else
1351  {
1352  //Report an error
1353  error = ERROR_INVALID_PARAMETER;
1354  }
1355 
1356  //Return status code
1357  return error;
1358 }
1359 
1360 /**
1361  * @brief Set AutoEdgePort parameter
1362  * @param[in] context Pointer to the RSTP bridge context
1363  * @param[in] portIndex Port index
1364  * @param[in] value AutoEdgePort parameter for the port
1365  * @return Error code
1366  **/
1367 
1369  bool_t value)
1370 {
1371  error_t error;
1372 
1373  //Make sure the RSTP bridge context is valid
1374  if(context != NULL)
1375  {
1376  //Acquire exclusive access to the RSTP bridge context
1377  rstpLock(context);
1378  //Perform management operation
1379  error = rstpMgmtSetAutoEdgePort(context, portIndex, value, TRUE);
1380  //Release exclusive access to the RSTP bridge context
1381  rstpUnlock(context);
1382  }
1383  else
1384  {
1385  //Report an error
1386  error = ERROR_INVALID_PARAMETER;
1387  }
1388 
1389  //Return status code
1390  return error;
1391 }
1392 
1393 
1394 /**
1395  * @brief Force protocol migration
1396  * @param[in] context Pointer to the RSTP bridge context
1397  * @param[in] portIndex Port index
1398  * @param[in] value Value of the mcheck parameter. Setting mcheck variable to
1399  * FALSE has no effect
1400  * @return Error code
1401  **/
1402 
1404  bool_t value)
1405 {
1406  error_t error;
1407 
1408  //Make sure the RSTP bridge context is valid
1409  if(context != NULL)
1410  {
1411  //Acquire exclusive access to the RSTP bridge context
1412  rstpLock(context);
1413  //Perform management operation
1414  error = rstpMgmtSetProtocolMigration(context, portIndex, value, TRUE);
1415  //Release exclusive access to the RSTP bridge context
1416  rstpUnlock(context);
1417  }
1418  else
1419  {
1420  //Report an error
1421  error = ERROR_INVALID_PARAMETER;
1422  }
1423 
1424  //Return status code
1425  return error;
1426 }
1427 
1428 
1429 /**
1430  * @brief Get the port number assigned to the port
1431  * @param[in] context Pointer to the RSTP bridge context
1432  * @param[in] portIndex Port index
1433  * @param[out] value Port number
1434  * @return Error code
1435  **/
1436 
1438  uint16_t *value)
1439 {
1440  error_t error;
1442 
1443  //Make sure the RSTP bridge context is valid
1444  if(context != NULL)
1445  {
1446  //Acquire exclusive access to the RSTP bridge context
1447  rstpLock(context);
1448 
1449  //Valid port index?
1450  if(portIndex >= 1 && portIndex <= context->numPorts)
1451  {
1452  //Point to the port that matches the specified port index
1453  port = &context->ports[portIndex - 1];
1454  //Retrieve the assigned port number
1455  *value = port->portId & RSTP_PORT_NUM_MASK;
1456  }
1457  else
1458  {
1459  //The port index is out of range
1460  error = ERROR_INVALID_PORT;
1461  }
1462 
1463  //Release exclusive access to the RSTP bridge context
1464  rstpUnlock(context);
1465  }
1466  else
1467  {
1468  //Report an error
1469  error = ERROR_INVALID_PARAMETER;
1470  }
1471 
1472  //Return status code
1473  return error;
1474 }
1475 
1476 
1477 /**
1478  * @brief Get the MAC address assigned to the port
1479  * @param[in] context Pointer to the RSTP bridge context
1480  * @param[in] portIndex Port index
1481  * @param[out] value MAC address of the individual MAC entity for the port
1482  * @return Error code
1483  **/
1484 
1486  MacAddr *value)
1487 {
1488  error_t error;
1489 
1490  //Make sure the RSTP bridge context is valid
1491  if(context != NULL)
1492  {
1493  //Acquire exclusive access to the RSTP bridge context
1494  rstpLock(context);
1495  //Perform management operation
1496  error = rstpMgmtGetPortAddr(context, portIndex, value);
1497  //Release exclusive access to the RSTP bridge context
1498  rstpUnlock(context);
1499  }
1500  else
1501  {
1502  //Report an error
1503  error = ERROR_INVALID_PARAMETER;
1504  }
1505 
1506  //Return status code
1507  return error;
1508 }
1509 
1510 
1511 /**
1512  * @brief Get the priority assigned to the port
1513  * @param[in] context Pointer to the RSTP bridge context
1514  * @param[in] portIndex Port index
1515  * @param[out] value Port priority
1516  * @return Error code
1517  **/
1518 
1520  uint8_t *value)
1521 {
1522  error_t error;
1523 
1524  //Make sure the RSTP bridge context is valid
1525  if(context != NULL)
1526  {
1527  //Acquire exclusive access to the RSTP bridge context
1528  rstpLock(context);
1529  //Perform management operation
1530  error = rstpMgmtGetPortPriority(context, portIndex, value);
1531  //Release exclusive access to the RSTP bridge context
1532  rstpUnlock(context);
1533  }
1534  else
1535  {
1536  //Report an error
1537  error = ERROR_INVALID_PARAMETER;
1538  }
1539 
1540  //Return status code
1541  return error;
1542 }
1543 
1544 
1545 /**
1546  * @brief Get the administrative port state
1547  * @param[in] context Pointer to the RSTP bridge context
1548  * @param[in] portIndex Port index
1549  * @param[out] value Administrative port state
1550  * @return Error code
1551  **/
1552 
1554  bool_t *value)
1555 {
1556  error_t error;
1557 
1558  //Make sure the RSTP bridge context is valid
1559  if(context != NULL)
1560  {
1561  //Acquire exclusive access to the RSTP bridge context
1562  rstpLock(context);
1563  //Perform management operation
1564  error = rstpMgmtGetAdminPortState(context, portIndex, value);
1565  //Release exclusive access to the RSTP bridge context
1566  rstpUnlock(context);
1567  }
1568  else
1569  {
1570  //Report an error
1571  error = ERROR_INVALID_PARAMETER;
1572  }
1573 
1574  //Return status code
1575  return error;
1576 }
1577 
1578 
1579 /**
1580  * @brief Get the current MAC operational state
1581  * @param[in] context Pointer to the RSTP bridge context
1582  * @param[in] portIndex Port index
1583  * @param[out] value MAC operational state
1584  * @return Error code
1585  **/
1586 
1588  bool_t *value)
1589 {
1590  error_t error;
1591 
1592  //Make sure the RSTP bridge context is valid
1593  if(context != NULL)
1594  {
1595  //Acquire exclusive access to the RSTP bridge context
1596  rstpLock(context);
1597  //Perform management operation
1598  error = rstpMgmtGetMacOperState(context, portIndex, value);
1599  //Release exclusive access to the RSTP bridge context
1600  rstpUnlock(context);
1601  }
1602  else
1603  {
1604  //Report an error
1605  error = ERROR_INVALID_PARAMETER;
1606  }
1607 
1608  //Return status code
1609  return error;
1610 }
1611 
1612 
1613 /**
1614  * @brief Get the administrative port path cost
1615  * @param[in] context Pointer to the RSTP bridge context
1616  * @param[in] portIndex Port index
1617  * @param[out] value Administrative port path cost
1618  * @return Error code
1619  **/
1620 
1622  uint32_t *value)
1623 {
1624  error_t error;
1625 
1626  //Make sure the RSTP bridge context is valid
1627  if(context != NULL)
1628  {
1629  //Acquire exclusive access to the RSTP bridge context
1630  rstpLock(context);
1631  //Perform management operation
1632  error = rstpMgmtGetAdminPortPathCost(context, portIndex, value);
1633  //Release exclusive access to the RSTP bridge context
1634  rstpUnlock(context);
1635  }
1636  else
1637  {
1638  //Report an error
1639  error = ERROR_INVALID_PARAMETER;
1640  }
1641 
1642  //Return status code
1643  return error;
1644 }
1645 
1646 
1647 /**
1648  * @brief Get the current value of the port path cost
1649  * @param[in] context Pointer to the RSTP bridge context
1650  * @param[in] portIndex Port index
1651  * @param[out] value Port path cost
1652  * @return Error code
1653  **/
1654 
1656  uint32_t *value)
1657 {
1658  error_t error;
1659 
1660  //Make sure the RSTP bridge context is valid
1661  if(context != NULL)
1662  {
1663  //Acquire exclusive access to the RSTP bridge context
1664  rstpLock(context);
1665  //Perform management operation
1666  error = rstpMgmtGetPortPathCost(context, portIndex, value);
1667  //Release exclusive access to the RSTP bridge context
1668  rstpUnlock(context);
1669  }
1670  else
1671  {
1672  //Report an error
1673  error = ERROR_INVALID_PARAMETER;
1674  }
1675 
1676  //Return status code
1677  return error;
1678 }
1679 
1680 
1681 /**
1682  * @brief Get the administrative point-to-point status of the LAN segment
1683  * @param[in] context Pointer to the RSTP bridge context
1684  * @param[in] portIndex Port index
1685  * @param[out] value Administrative point-to-point status of the LAN segment
1686  * attached to this port
1687  * @return Error code
1688  **/
1689 
1692 {
1693  error_t error;
1694 
1695  //Make sure the RSTP bridge context is valid
1696  if(context != NULL)
1697  {
1698  //Acquire exclusive access to the RSTP bridge context
1699  rstpLock(context);
1700  //Perform management operation
1701  error = rstpMgmtGetAdminPointToPointMac(context, portIndex, value);
1702  //Release exclusive access to the RSTP bridge context
1703  rstpUnlock(context);
1704  }
1705  else
1706  {
1707  //Report an error
1708  error = ERROR_INVALID_PARAMETER;
1709  }
1710 
1711  //Return status code
1712  return error;
1713 }
1714 
1715 
1716 /**
1717  * @brief Get the operational point-to-point status of the LAN segment
1718  * @param[in] context Pointer to the RSTP bridge context
1719  * @param[in] portIndex Port index
1720  * @param[out] value Operational point-to-point status of the LAN segment
1721  * attached to this port
1722  * @return Error code
1723  **/
1724 
1726  uint_t portIndex, bool_t *value)
1727 {
1728  error_t error;
1729 
1730  //Make sure the RSTP bridge context is valid
1731  if(context != NULL)
1732  {
1733  //Acquire exclusive access to the RSTP bridge context
1734  rstpLock(context);
1735  //Perform management operation
1736  error = rstpMgmtGetOperPointToPointMac(context, portIndex, value);
1737  //Release exclusive access to the RSTP bridge context
1738  rstpUnlock(context);
1739  }
1740  else
1741  {
1742  //Report an error
1743  error = ERROR_INVALID_PARAMETER;
1744  }
1745 
1746  //Return status code
1747  return error;
1748 }
1749 
1750 
1751 /**
1752  * @brief Get the administrative value of the Edge Port parameter
1753  * @param[in] context Pointer to the RSTP bridge context
1754  * @param[in] portIndex Port index
1755  * @param[out] value Administrative value of the Edge Port parameter
1756  * @return Error code
1757  **/
1758 
1760  bool_t *value)
1761 {
1762  error_t error;
1763 
1764  //Make sure the RSTP bridge context is valid
1765  if(context != NULL)
1766  {
1767  //Acquire exclusive access to the RSTP bridge context
1768  rstpLock(context);
1769  //Perform management operation
1770  error = rstpMgmtGetAdminEdgePort(context, portIndex, value);
1771  //Release exclusive access to the RSTP bridge context
1772  rstpUnlock(context);
1773  }
1774  else
1775  {
1776  //Report an error
1777  error = ERROR_INVALID_PARAMETER;
1778  }
1779 
1780  //Return status code
1781  return error;
1782 }
1783 
1784 
1785 /**
1786  * @brief Get the value of the AutoEdgePort parameter
1787  * @param[in] context Pointer to the RSTP bridge context
1788  * @param[in] portIndex Port index
1789  * @param[out] value Value of the AutoEdgePort parameter for the port
1790  * @return Error code
1791  **/
1792 
1794  bool_t *value)
1795 {
1796  error_t error;
1797 
1798  //Make sure the RSTP bridge context is valid
1799  if(context != NULL)
1800  {
1801  //Acquire exclusive access to the RSTP bridge context
1802  rstpLock(context);
1803  //Perform management operation
1804  error = rstpMgmtGetAutoEdgePort(context, portIndex, value);
1805  //Release exclusive access to the RSTP bridge context
1806  rstpUnlock(context);
1807  }
1808  else
1809  {
1810  //Report an error
1811  error = ERROR_INVALID_PARAMETER;
1812  }
1813 
1814  //Return status code
1815  return error;
1816 }
1817 
1818 
1819 /**
1820  * @brief Get the operational value of the Edge Port parameter
1821  * @param[in] context Pointer to the RSTP bridge context
1822  * @param[in] portIndex Port index
1823  * @param[out] value Operational value of the Edge Port parameter
1824  * @return Error code
1825  **/
1826 
1828  bool_t *value)
1829 {
1830  error_t error;
1831 
1832  //Make sure the RSTP bridge context is valid
1833  if(context != NULL)
1834  {
1835  //Acquire exclusive access to the RSTP bridge context
1836  rstpLock(context);
1837  //Perform management operation
1838  error = rstpMgmtGetOperEdgePort(context, portIndex, value);
1839  //Release exclusive access to the RSTP bridge context
1840  rstpUnlock(context);
1841  }
1842  else
1843  {
1844  //Report an error
1845  error = ERROR_INVALID_PARAMETER;
1846  }
1847 
1848  //Return status code
1849  return error;
1850 }
1851 
1852 
1853 /**
1854  * @brief Get the current state of the port
1855  * @param[in] context Pointer to the RSTP bridge context
1856  * @param[in] portIndex Port index
1857  * @param[out] value Port state
1858  * @return Error code
1859  **/
1860 
1863 {
1864  error_t error;
1865 
1866  //Make sure the RSTP bridge context is valid
1867  if(context != NULL)
1868  {
1869  //Acquire exclusive access to the RSTP bridge context
1870  rstpLock(context);
1871  //Perform management operation
1872  error = rstpMgmtGetPortState(context, portIndex, value);
1873  //Release exclusive access to the RSTP bridge context
1874  rstpUnlock(context);
1875  }
1876  else
1877  {
1878  //Report an error
1879  error = ERROR_INVALID_PARAMETER;
1880  }
1881 
1882  //Return status code
1883  return error;
1884 }
1885 
1886 
1887 /**
1888  * @brief Get the assigned role of the port
1889  * @param[in] context Pointer to the RSTP bridge context
1890  * @param[in] portIndex Port index
1891  * @param[out] value Port role
1892  * @return Error code
1893  **/
1894 
1896  StpPortRole *value)
1897 {
1898  error_t error;
1899 
1900  //Make sure the RSTP bridge context is valid
1901  if(context != NULL)
1902  {
1903  //Acquire exclusive access to the RSTP bridge context
1904  rstpLock(context);
1905  //Perform management operation
1906  error = rstpMgmtGetPortRole(context, portIndex, value);
1907  //Release exclusive access to the RSTP bridge context
1908  rstpUnlock(context);
1909  }
1910  else
1911  {
1912  //Report an error
1913  error = ERROR_INVALID_PARAMETER;
1914  }
1915 
1916  //Return status code
1917  return error;
1918 }
1919 
1920 
1921 /**
1922  * @brief Get the bridge identifier of the designated root bridge
1923  * @param[in] context Pointer to the RSTP bridge context
1924  * @param[in] portIndex Port index
1925  * @param[out] value Bridge identifier
1926  * @return Error code
1927  **/
1928 
1930  StpBridgeId *value)
1931 {
1932  error_t error;
1933 
1934  //Make sure the RSTP bridge context is valid
1935  if(context != NULL)
1936  {
1937  //Acquire exclusive access to the RSTP bridge context
1938  rstpLock(context);
1939  //Perform management operation
1940  error = rstpMgmtGetPortDesignatedRoot(context, portIndex, value);
1941  //Release exclusive access to the RSTP bridge context
1942  rstpUnlock(context);
1943  }
1944  else
1945  {
1946  //Report an error
1947  error = ERROR_INVALID_PARAMETER;
1948  }
1949 
1950  //Return status code
1951  return error;
1952 }
1953 
1954 
1955 /**
1956  * @brief Get the designated cost of the port
1957  * @param[in] context Pointer to the RSTP bridge context
1958  * @param[in] portIndex Port index
1959  * @param[out] value Designated cost of the port
1960  * @return Error code
1961  **/
1962 
1964  uint32_t *value)
1965 {
1966  error_t error;
1967 
1968  //Make sure the RSTP bridge context is valid
1969  if(context != NULL)
1970  {
1971  //Acquire exclusive access to the RSTP bridge context
1972  rstpLock(context);
1973  //Perform management operation
1974  error = rstpMgmtGetPortDesignatedCost(context, portIndex, value);
1975  //Release exclusive access to the RSTP bridge context
1976  rstpUnlock(context);
1977  }
1978  else
1979  {
1980  //Report an error
1981  error = ERROR_INVALID_PARAMETER;
1982  }
1983 
1984  //Return status code
1985  return error;
1986 }
1987 
1988 
1989 /**
1990  * @brief Get the bridge identifier of the designated bridge
1991  * @param[in] context Pointer to the RSTP bridge context
1992  * @param[in] portIndex Port index
1993  * @param[out] value Bridge identifier
1994  * @return Error code
1995  **/
1996 
1998  uint_t portIndex, StpBridgeId *value)
1999 {
2000  error_t error;
2001 
2002  //Make sure the RSTP bridge context is valid
2003  if(context != NULL)
2004  {
2005  //Acquire exclusive access to the RSTP bridge context
2006  rstpLock(context);
2007  //Perform management operation
2008  error = rstpMgmtGetPortDesignatedBridge(context, portIndex, value);
2009  //Release exclusive access to the RSTP bridge context
2010  rstpUnlock(context);
2011  }
2012  else
2013  {
2014  //Report an error
2015  error = ERROR_INVALID_PARAMETER;
2016  }
2017 
2018  //Return status code
2019  return error;
2020 }
2021 
2022 
2023 /**
2024  * @brief Get the port identifier of the designated bridge
2025  * @param[in] context Pointer to the RSTP bridge context
2026  * @param[in] portIndex Port index
2027  * @param[out] value Port identifier
2028  * @return Error code
2029  **/
2030 
2032  uint16_t *value)
2033 {
2034  error_t error;
2035 
2036  //Make sure the RSTP bridge context is valid
2037  if(context != NULL)
2038  {
2039  //Acquire exclusive access to the RSTP bridge context
2040  rstpLock(context);
2041  //Perform management operation
2042  error = rstpMgmtGetPortDesignatedPort(context, portIndex, value);
2043  //Release exclusive access to the RSTP bridge context
2044  rstpUnlock(context);
2045  }
2046  else
2047  {
2048  //Report an error
2049  error = ERROR_INVALID_PARAMETER;
2050  }
2051 
2052  //Return status code
2053  return error;
2054 }
2055 
2056 
2057 /**
2058  * @brief Get the number of times the port has transitioned to Forwarding state
2059  * @param[in] context Pointer to the RSTP bridge context
2060  * @param[in] portIndex Port index
2061  * @param[out] value Number of transitions to Forwarding state
2062  * @return Error code
2063  **/
2064 
2066  uint_t *value)
2067 {
2068  error_t error;
2069 
2070  //Make sure the RSTP bridge context is valid
2071  if(context != NULL)
2072  {
2073  //Acquire exclusive access to the RSTP bridge context
2074  rstpLock(context);
2075  //Perform management operation
2076  error = rstpMgmtGetForwardTransitions(context, portIndex, value);
2077  //Release exclusive access to the RSTP bridge context
2078  rstpUnlock(context);
2079  }
2080  else
2081  {
2082  //Report an error
2083  error = ERROR_INVALID_PARAMETER;
2084  }
2085 
2086  //Return status code
2087  return error;
2088 }
2089 
2090 
2091 /**
2092  * @brief Release RSTP bridge context
2093  * @param[in] context Pointer to the RSTP bridge context
2094  **/
2095 
2097 {
2098  //Make sure the RSTP bridge context is valid
2099  if(context != NULL)
2100  {
2101  //Clear RSTP bridge context
2102  osMemset(context, 0, sizeof(RstpBridgeContext));
2103  }
2104 }
2105 
2106 #endif
unsigned int uint_t
Definition: compiler_port.h:50
int bool_t
Definition: compiler_port.h:53
Debugging facilities.
#define TRACE_INFO(...)
Definition: debug.h:95
uint16_t port
Definition: dns_common.h:267
error_t
Error codes.
Definition: error.h:43
@ ERROR_INVALID_PORT
Definition: error.h:104
@ ERROR_ALREADY_RUNNING
Definition: error.h:292
@ ERROR_INVALID_VALUE
Definition: error.h:116
@ NO_ERROR
Success.
Definition: error.h:44
@ ERROR_INVALID_PARAMETER
Invalid parameter.
Definition: error.h:47
error_t ethDetachLlcRxCalback(NetInterface *interface)
Unregister LLC frame received callback.
Definition: ethernet.c:747
error_t ethDropMacAddr(NetInterface *interface, const MacAddr *macAddr)
Remove a unicast/multicast address from the MAC filter table.
Definition: ethernet.c:664
error_t ethAttachLlcRxCalback(NetInterface *interface, LlcRxCallback callback, void *param)
Register LLC frame received callback.
Definition: ethernet.c:719
error_t ethAcceptMacAddr(NetInterface *interface, const MacAddr *macAddr)
Add a unicast/multicast address to the MAC filter table.
Definition: ethernet.c:594
MacAddr
Definition: ethernet.h:195
#define NetInterface
Definition: net.h:36
error_t netDetachTimerCallback(NetTimerCallback callback, void *param)
Unregister timer callback.
Definition: net_misc.c:382
error_t netAttachTimerCallback(systime_t period, NetTimerCallback callback, void *param)
Register timer callback.
Definition: net_misc.c:344
void(* NetTimerCallback)(void *param)
Timer callback.
Definition: net_misc.h:84
@ NIC_UNKNOWN_DUPLEX_MODE
Definition: nic.h:123
@ SWITCH_PORT_STATE_FORWARDING
Definition: nic.h:140
@ NIC_LINK_SPEED_UNKNOWN
Definition: nic.h:110
#define osMemset(p, value, length)
Definition: os_port.h:135
#define TRUE
Definition: os_port.h:50
#define FALSE
Definition: os_port.h:46
error_t rstpSetBridgePriority(RstpBridgeContext *context, uint16_t value)
Set bridge priority.
Definition: rstp.c:349
error_t rstpGetTopologyChanges(RstpBridgeContext *context, uint_t *value)
Get the number of topology changes.
Definition: rstp.c:1020
error_t rstpStop(RstpBridgeContext *context)
Stop RSTP bridge operation.
Definition: rstp.c:257
error_t rstpGetBridgePriority(RstpBridgeContext *context, uint16_t *value)
Get the assigned bridge priority.
Definition: rstp.c:637
error_t rstpGetTxHoldCount(RstpBridgeContext *context, uint_t *value)
Get the assigned value of the Transmit Hold Count parameter.
Definition: rstp.c:765
error_t rstpGetVersion(RstpBridgeContext *context, uint_t *value)
Get assigned protocol version.
Definition: rstp.c:573
error_t rstpGetAdminPortPathCost(RstpBridgeContext *context, uint_t portIndex, uint32_t *value)
Get the administrative port path cost.
Definition: rstp.c:1621
error_t rstpGetRootPort(RstpBridgeContext *context, uint16_t *value)
Get the current root port.
Definition: rstp.c:893
error_t rstpGetPortDesignatedBridge(RstpBridgeContext *context, uint_t portIndex, StpBridgeId *value)
Get the bridge identifier of the designated bridge.
Definition: rstp.c:1997
error_t rstpGetPortDesignatedPort(RstpBridgeContext *context, uint_t portIndex, uint16_t *value)
Get the port identifier of the designated bridge.
Definition: rstp.c:2031
error_t rstpSetAdminPortPathCost(RstpBridgeContext *context, uint_t portIndex, uint32_t value)
Set administrative port path cost.
Definition: rstp.c:1266
error_t rstpSetAutoEdgePort(RstpBridgeContext *context, uint_t portIndex, bool_t value)
Set AutoEdgePort parameter.
Definition: rstp.c:1368
error_t rstpGetOperPointToPointMac(RstpBridgeContext *context, uint_t portIndex, bool_t *value)
Get the operational point-to-point status of the LAN segment.
Definition: rstp.c:1725
error_t rstpGetBridgeForwardDelay(RstpBridgeContext *context, uint_t *value)
Get the assigned value of the Bridge Forward Delay parameter.
Definition: rstp.c:733
error_t rstpGetDesignatedRoot(RstpBridgeContext *context, StpBridgeId *value)
Get the bridge identifier of the root of the spanning tree.
Definition: rstp.c:829
error_t rstpGetPortDesignatedRoot(RstpBridgeContext *context, uint_t portIndex, StpBridgeId *value)
Get the bridge identifier of the designated root bridge.
Definition: rstp.c:1929
error_t rstpGetPortPathCost(RstpBridgeContext *context, uint_t portIndex, uint32_t *value)
Get the current value of the port path cost.
Definition: rstp.c:1655
error_t rstpSetAdminPointToPointMac(RstpBridgeContext *context, uint_t portIndex, RstpAdminPointToPointMac value)
Set administrative point-to-point status of the LAN segment.
Definition: rstp.c:1301
error_t rstpGetPortDesignatedCost(RstpBridgeContext *context, uint_t portIndex, uint32_t *value)
Get the designated cost of the port.
Definition: rstp.c:1963
error_t rstpGetAdminPointToPointMac(RstpBridgeContext *context, uint_t portIndex, RstpAdminPointToPointMac *value)
Get the administrative point-to-point status of the LAN segment.
Definition: rstp.c:1690
error_t rstpSetProtocolMigration(RstpBridgeContext *context, uint_t portIndex, bool_t value)
Force protocol migration.
Definition: rstp.c:1403
error_t rstpGetForwardDelay(RstpBridgeContext *context, uint_t *value)
Get the current Forward Delay value.
Definition: rstp.c:988
error_t rstpGetPortAddr(RstpBridgeContext *context, uint_t portIndex, MacAddr *value)
Get the MAC address assigned to the port.
Definition: rstp.c:1485
error_t rstpSetVersion(RstpBridgeContext *context, uint_t value)
Set protocol version.
Definition: rstp.c:317
error_t rstpGetNumPorts(RstpBridgeContext *context, uint_t *value)
Get the number of ports.
Definition: rstp.c:541
error_t rstpGetTimeSinceTopologyChange(RstpBridgeContext *context, uint_t *value)
Get the time since a topology change was last detected.
Definition: rstp.c:1052
error_t rstpGetOperEdgePort(RstpBridgeContext *context, uint_t portIndex, bool_t *value)
Get the operational value of the Edge Port parameter.
Definition: rstp.c:1827
error_t rstpGetForwardTransitions(RstpBridgeContext *context, uint_t portIndex, uint_t *value)
Get the number of times the port has transitioned to Forwarding state.
Definition: rstp.c:2065
error_t rstpGetBridgeHelloTime(RstpBridgeContext *context, uint_t *value)
Get the assigned value of the Bridge Hello Time parameter.
Definition: rstp.c:701
error_t rstpGetAdminPortState(RstpBridgeContext *context, uint_t portIndex, bool_t *value)
Get the administrative port state.
Definition: rstp.c:1553
error_t rstpGetBridgeAddr(RstpBridgeContext *context, MacAddr *value)
Get the MAC address assigned to the bridge.
Definition: rstp.c:605
error_t rstpSetBridgeMaxAge(RstpBridgeContext *context, uint_t value)
Set Bridge Max Age parameter.
Definition: rstp.c:381
error_t rstpSetPortNum(RstpBridgeContext *context, uint_t portIndex, uint16_t value)
Set port number.
Definition: rstp.c:1086
error_t rstpGetBridgeMaxAge(RstpBridgeContext *context, uint_t *value)
Get the assigned value of the Bridge Max Age parameter.
Definition: rstp.c:669
error_t rstpSetPortPriority(RstpBridgeContext *context, uint_t portIndex, uint8_t value)
Set port priority.
Definition: rstp.c:1198
error_t rstpGetHelloTime(RstpBridgeContext *context, uint_t *value)
Get the current Hello Time value.
Definition: rstp.c:957
void rstpDeinit(RstpBridgeContext *context)
Release RSTP bridge context.
Definition: rstp.c:2096
error_t rstpSetAdminEdgePort(RstpBridgeContext *context, uint_t portIndex, bool_t value)
Set administrative value of the Edge Port parameter.
Definition: rstp.c:1335
error_t rstpGetPortRole(RstpBridgeContext *context, uint_t portIndex, StpPortRole *value)
Get the assigned role of the port.
Definition: rstp.c:1895
error_t rstpGetAutoEdgePort(RstpBridgeContext *context, uint_t portIndex, bool_t *value)
Get the value of the AutoEdgePort parameter.
Definition: rstp.c:1793
error_t rstpGetMacOperState(RstpBridgeContext *context, uint_t portIndex, bool_t *value)
Get the current MAC operational state.
Definition: rstp.c:1587
error_t rstpSetAgeingTime(RstpBridgeContext *context, uint_t value)
Set Ageing Time parameter.
Definition: rstp.c:509
error_t rstpInit(RstpBridgeContext *context, RstpBridgeSettings *settings)
Initialize RSTP bridge context.
Definition: rstp.c:70
error_t rstpSetPortAddr(RstpBridgeContext *context, uint_t portIndex, const MacAddr *value)
Set port address.
Definition: rstp.c:1147
error_t rstpSetBridgeHelloTime(RstpBridgeContext *context, uint_t value)
Set Bridge Hello Time parameter.
Definition: rstp.c:413
error_t rstpStart(RstpBridgeContext *context)
Start RSTP bridge operation.
Definition: rstp.c:168
error_t rstpSetTxHoldCount(RstpBridgeContext *context, uint_t value)
Set Transmit Hold Count parameter.
Definition: rstp.c:477
error_t rstpGetPortPriority(RstpBridgeContext *context, uint_t portIndex, uint8_t *value)
Get the priority assigned to the port.
Definition: rstp.c:1519
void rstpGetDefaultSettings(RstpBridgeSettings *settings)
Initialize settings with default values.
Definition: rstp.c:51
error_t rstpGetAdminEdgePort(RstpBridgeContext *context, uint_t portIndex, bool_t *value)
Get the administrative value of the Edge Port parameter.
Definition: rstp.c:1759
error_t rstpSetAdminPortState(RstpBridgeContext *context, uint_t portIndex, bool_t value)
Set administrative bridge port state.
Definition: rstp.c:1232
error_t rstpGetPortState(RstpBridgeContext *context, uint_t portIndex, StpPortState *value)
Get the current state of the port.
Definition: rstp.c:1861
error_t rstpGetRootPathCost(RstpBridgeContext *context, uint32_t *value)
Get the current cost of the path to the root.
Definition: rstp.c:861
error_t rstpGetAgeingTime(RstpBridgeContext *context, uint_t *value)
Get the assigned value of the Ageing Time parameter.
Definition: rstp.c:797
error_t rstpGetMaxAge(RstpBridgeContext *context, uint_t *value)
Get the current Max Age value.
Definition: rstp.c:925
error_t rstpSetBridgeForwardDelay(RstpBridgeContext *context, uint_t value)
Set Bridge Forward Delay parameter.
Definition: rstp.c:445
error_t rstpGetPortNum(RstpBridgeContext *context, uint_t portIndex, uint16_t *value)
Get the port number assigned to the port.
Definition: rstp.c:1437
RSTP (Rapid Spanning Tree Protocol)
#define RSTP_DEFAULT_TRANSMIT_HOLD_COUNT
Definition: rstp.h:163
#define RSTP_DEFAULT_PORT_PATH_COST
Definition: rstp.h:205
#define RSTP_DEFAULT_BRIDGE_PRIORITY
Definition: rstp.h:72
#define RSTP_DEFAULT_BRIDGE_FORWARD_DELAY
Definition: rstp.h:142
#define RSTP_DEFAULT_BRIDGE_HELLO_TIME
Definition: rstp.h:121
RstpAdminPointToPointMac
Administrative state of the point-to-point status.
Definition: rstp.h:255
@ RSTP_ADMIN_P2P_MAC_FORCE_TRUE
Definition: rstp.h:257
#define RstpBridgeContext
Definition: rstp.h:36
#define RstpBridgePort
Definition: rstp.h:40
#define RSTP_DEFAULT_PORT_PRIORITY
Definition: rstp.h:79
#define RSTP_DEFAULT_BRIDGE_MAX_AGE
Definition: rstp.h:100
#define RSTP_DEFAULT_AGEING_TIME
Definition: rstp.h:184
#define RSTP_TICK_INTERVAL
Definition: rstp.h:65
#define RSTP_DEFAULT_MIGRATE_TIME
Definition: rstp.h:86
const MacAddr RSTP_BRIDGE_GROUP_ADDR
Definition: rstp_bpdu.c:46
void rstpProcessLlcFrame(NetInterface *interface, EthHeader *ethHeader, const uint8_t *data, size_t length, NetRxAncillary *ancillary, void *param)
Process incoming LLC frame.
Definition: rstp_bpdu.c:75
#define RSTP_PORT_NUM_MASK
Definition: rstp_bpdu.h:44
#define RSTP_PORT_PRIORITY_MASK
Definition: rstp_bpdu.h:43
RSTP state machine conditions.
void rstpFsmInit(RstpBridgeContext *context)
RSTP state machine initialization.
Definition: rstp_fsm.c:49
Rapid Spanning Tree state machines.
error_t rstpMgmtSetProtocolMigration(RstpBridgeContext *context, uint_t portIndex, bool_t value, bool_t commit)
Force protocol migration.
Definition: rstp_mgmt.c:1127
error_t rstpMgmtGetMaxAge(RstpBridgeContext *context, uint_t *value)
Get the current Max Age value.
Definition: rstp_mgmt.c:690
error_t rstpMgmtGetRootPort(RstpBridgeContext *context, uint16_t *value)
Get the current root port.
Definition: rstp_mgmt.c:668
error_t rstpMgmtSetBridgeForwardDelay(RstpBridgeContext *context, uint_t value, bool_t commit)
Set Bridge Forward Delay parameter.
Definition: rstp_mgmt.c:276
error_t rstpMgmtGetNumPorts(RstpBridgeContext *context, uint_t *value)
Get the number of ports.
Definition: rstp_mgmt.c:435
error_t rstpMgmtGetAgeingTime(RstpBridgeContext *context, uint_t *value)
Get the assigned value of the Ageing Time parameter.
Definition: rstp_mgmt.c:604
error_t rstpMgmtSetAgeingTime(RstpBridgeContext *context, uint_t value, bool_t commit)
Set Ageing Time parameter.
Definition: rstp_mgmt.c:391
error_t rstpMgmtGetBridgeMaxAge(RstpBridgeContext *context, uint_t *value)
Get the assigned value of the Bridge Max Age parameter.
Definition: rstp_mgmt.c:520
error_t rstpMgmtGetAdminPointToPointMac(RstpBridgeContext *context, uint_t portIndex, RstpAdminPointToPointMac *value)
Get the administrative point-to-point status of the LAN segment.
Definition: rstp_mgmt.c:1374
error_t rstpMgmtSetAdminEdgePort(RstpBridgeContext *context, uint_t portIndex, bool_t value, bool_t commit)
Set administrative value of the Edge Port parameter.
Definition: rstp_mgmt.c:1029
error_t rstpMgmtGetPortPriority(RstpBridgeContext *context, uint_t portIndex, uint8_t *value)
Get the priority assigned to the port.
Definition: rstp_mgmt.c:1212
error_t rstpMgmtGetBridgeHelloTime(RstpBridgeContext *context, uint_t *value)
Get the assigned value of the Bridge Hello Time parameter.
Definition: rstp_mgmt.c:541
error_t rstpMgmtSetAdminPortState(RstpBridgeContext *context, uint_t portIndex, bool_t value, bool_t commit)
Set administrative bridge port state.
Definition: rstp_mgmt.c:860
error_t rstpMgmtSetAdminPortPathCost(RstpBridgeContext *context, uint_t portIndex, uint32_t value, bool_t commit)
Set administrative port path cost.
Definition: rstp_mgmt.c:910
error_t rstpMgmtGetAdminEdgePort(RstpBridgeContext *context, uint_t portIndex, bool_t *value)
Get the administrative value of the Edge Port parameter.
Definition: rstp_mgmt.c:1440
error_t rstpMgmtSetPortPriority(RstpBridgeContext *context, uint_t portIndex, uint8_t value, bool_t commit)
Set port priority.
Definition: rstp_mgmt.c:804
error_t rstpMgmtGetPortDesignatedCost(RstpBridgeContext *context, uint_t portIndex, uint32_t *value)
Get the designated cost of the port.
Definition: rstp_mgmt.c:1690
error_t rstpMgmtGetMacOperState(RstpBridgeContext *context, uint_t portIndex, bool_t *value)
Get the current MAC operational state.
Definition: rstp_mgmt.c:1276
error_t rstpMgmtSetAdminPointToPointMac(RstpBridgeContext *context, uint_t portIndex, RstpAdminPointToPointMac value, bool_t commit)
Set administrative point-to-point status of the LAN segment.
Definition: rstp_mgmt.c:971
error_t rstpMgmtGetBridgeForwardDelay(RstpBridgeContext *context, uint_t *value)
Get the assigned value of the Bridge Forward Delay parameter.
Definition: rstp_mgmt.c:562
error_t rstpMgmtGetBridgeAddr(RstpBridgeContext *context, MacAddr *value)
Get the MAC address assigned to the bridge.
Definition: rstp_mgmt.c:478
error_t rstpMgmtGetPortPathCost(RstpBridgeContext *context, uint_t portIndex, uint32_t *value)
Get the current value of the port path cost.
Definition: rstp_mgmt.c:1340
error_t rstpMgmtSetBridgeMaxAge(RstpBridgeContext *context, uint_t value, bool_t commit)
Set Bridge Max Age parameter.
Definition: rstp_mgmt.c:156
error_t rstpMgmtGetVersion(RstpBridgeContext *context, uint_t *value)
Get assigned protocol version.
Definition: rstp_mgmt.c:456
error_t rstpMgmtGetTimeSinceTopologyChange(RstpBridgeContext *context, uint_t *value)
Get the time since a topology change was last detected.
Definition: rstp_mgmt.c:778
error_t rstpMgmtGetAdminPortState(RstpBridgeContext *context, uint_t portIndex, bool_t *value)
Get the administrative port state.
Definition: rstp_mgmt.c:1244
error_t rstpMgmtGetPortState(RstpBridgeContext *context, uint_t portIndex, StpPortState *value)
Get the current state of the port.
Definition: rstp_mgmt.c:1536
error_t rstpMgmtGetBridgePriority(RstpBridgeContext *context, uint16_t *value)
Get the assigned bridge priority.
Definition: rstp_mgmt.c:499
error_t rstpMgmtGetTxHoldCount(RstpBridgeContext *context, uint_t *value)
Get the assigned value of the Transmit Hold Count parameter.
Definition: rstp_mgmt.c:583
error_t rstpMgmtSetVersion(RstpBridgeContext *context, uint_t value, bool_t commit)
Set protocol version.
Definition: rstp_mgmt.c:55
error_t rstpMgmtGetPortRole(RstpBridgeContext *context, uint_t portIndex, StpPortRole *value)
Get the assigned role of the port.
Definition: rstp_mgmt.c:1624
error_t rstpMgmtGetHelloTime(RstpBridgeContext *context, uint_t *value)
Get the current Hello Time value.
Definition: rstp_mgmt.c:712
error_t rstpMgmtGetOperEdgePort(RstpBridgeContext *context, uint_t portIndex, bool_t *value)
Get the operational value of the Edge Port parameter.
Definition: rstp_mgmt.c:1504
error_t rstpMgmtGetForwardDelay(RstpBridgeContext *context, uint_t *value)
Get the current Forward Delay value.
Definition: rstp_mgmt.c:735
error_t rstpMgmtGetPortDesignatedRoot(RstpBridgeContext *context, uint_t portIndex, StpBridgeId *value)
Get the bridge identifier of the designated root bridge.
Definition: rstp_mgmt.c:1656
error_t rstpMgmtGetForwardTransitions(RstpBridgeContext *context, uint_t portIndex, uint_t *value)
Get the number of times the port has transitioned to Forwarding state.
Definition: rstp_mgmt.c:1789
error_t rstpMgmtSetAutoEdgePort(RstpBridgeContext *context, uint_t portIndex, bool_t value, bool_t commit)
Set AutoEdgePort parameter.
Definition: rstp_mgmt.c:1079
error_t rstpMgmtGetPortAddr(RstpBridgeContext *context, uint_t portIndex, MacAddr *value)
Get the MAC address assigned to the port.
Definition: rstp_mgmt.c:1180
error_t rstpMgmtGetPortDesignatedPort(RstpBridgeContext *context, uint_t portIndex, uint16_t *value)
Get the port identifier of the designated bridge.
Definition: rstp_mgmt.c:1756
error_t rstpMgmtGetPortDesignatedBridge(RstpBridgeContext *context, uint_t portIndex, StpBridgeId *value)
Get the bridge identifier of the designated bridge.
Definition: rstp_mgmt.c:1723
error_t rstpMgmtSetBridgeHelloTime(RstpBridgeContext *context, uint_t value, bool_t commit)
Set Bridge Hello Time parameter.
Definition: rstp_mgmt.c:216
error_t rstpMgmtSetBridgePriority(RstpBridgeContext *context, uint16_t value, bool_t commit)
Set bridge priority.
Definition: rstp_mgmt.c:96
error_t rstpMgmtGetDesignatedRoot(RstpBridgeContext *context, StpBridgeId *value)
Get the bridge identifier of the root of the spanning tree.
Definition: rstp_mgmt.c:625
error_t rstpMgmtGetAutoEdgePort(RstpBridgeContext *context, uint_t portIndex, bool_t *value)
Get the value of the AutoEdgePort parameter.
Definition: rstp_mgmt.c:1472
error_t rstpMgmtGetAdminPortPathCost(RstpBridgeContext *context, uint_t portIndex, uint32_t *value)
Get the administrative port path cost.
Definition: rstp_mgmt.c:1308
error_t rstpMgmtSetTxHoldCount(RstpBridgeContext *context, uint_t value, bool_t commit)
Set Transmit Hold Count parameter.
Definition: rstp_mgmt.c:339
error_t rstpMgmtGetRootPathCost(RstpBridgeContext *context, uint32_t *value)
Get the current cost of the path to the root.
Definition: rstp_mgmt.c:647
error_t rstpMgmtGetTopologyChanges(RstpBridgeContext *context, uint_t *value)
Get the number of topology changes.
Definition: rstp_mgmt.c:757
error_t rstpMgmtGetOperPointToPointMac(RstpBridgeContext *context, uint_t portIndex, bool_t *value)
Get the operational point-to-point status of the LAN segment.
Definition: rstp_mgmt.c:1408
Management of the RSTP bridge.
void rstpUpdatePortState(RstpBridgePort *port, SwitchPortState state)
Set port state.
Definition: rstp_misc.c:495
void rstpLock(RstpBridgeContext *context)
Acquire exclusive access to the RSTP bridge context.
Definition: rstp_misc.c:50
void rstpGeneratePortAddr(RstpBridgePort *port)
Port's MAC address generation.
Definition: rstp_misc.c:815
error_t rstpConfigurePermanentDatabase(RstpBridgeContext *context)
Configure the permanent database.
Definition: rstp_misc.c:743
void rstpUnlock(RstpBridgeContext *context)
Release exclusive access to the RSTP bridge context.
Definition: rstp_misc.c:62
void rstpUpdateAgeingTime(RstpBridgeContext *context, uint32_t ageingTime)
Set ageing time for dynamic filtering entries.
Definition: rstp_misc.c:527
void rstpUpdateOperPointToPointMac(RstpBridgePort *port)
Update the value of the operPointToPointMac variable.
Definition: rstp_misc.c:455
void rstpUpdatePortPathCost(RstpBridgePort *port)
Update the value of the portPathCost variable.
Definition: rstp_misc.c:425
void rstpTick(RstpBridgeContext *context)
RSTP tick handler.
Definition: rstp_misc.c:77
void rstpUnconfigurePermanentDatabase(RstpBridgeContext *context)
Unconfigure the permanent database.
Definition: rstp_misc.c:788
RSTP helper functions.
StpBridgeId
Definition: stp_common.h:148
@ RSTP_PROTOCOL_VERSION
RSTP version.
Definition: stp_common.h:98
StpPortRole
Port role values.
Definition: stp_common.h:123
StpPortState
Port states.
Definition: stp_common.h:108
RSTP bridge settings.
Definition: rstp.h:409
uint_t numPorts
Number of ports.
Definition: rstp.h:411
RstpBridgePort * ports
Bridge's ports.
Definition: rstp.h:412
NetInterface * interface
Underlying network interface.
Definition: rstp.h:410
uint8_t value[]
Definition: tcp.h:369