bridge_mib_impl_stp.c
Go to the documentation of this file.
1 /**
2  * @file bridge_mib_impl.c
3  * @brief Bridge MIB module implementation (dot1dStp subtree)
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 SNMP_TRACE_LEVEL
33 
34 //Dependencies
35 #include "core/net.h"
36 #include "mibs/mib_common.h"
37 #include "mibs/bridge_mib_module.h"
38 #include "mibs/bridge_mib_impl.h"
40 #include "core/crypto.h"
41 #include "encoding/asn1.h"
42 #include "encoding/oid.h"
43 #include "stp/stp.h"
44 #include "stp/stp_mgmt.h"
45 #include "rstp/rstp.h"
46 #include "rstp/rstp_mgmt.h"
47 #include "debug.h"
48 
49 //Check TCP/IP stack configuration
50 #if (BRIDGE_MIB_SUPPORT == ENABLED)
51 
52 
53 /**
54  * @brief Get dot1dStpProtocolSpecification object value
55  * @param[in] object Pointer to the MIB object descriptor
56  * @param[in] oid Object identifier (object name and instance identifier)
57  * @param[in] oidLen Length of the OID, in bytes
58  * @param[out] value Object value
59  * @param[in,out] valueLen Length of the object value, in bytes
60  * @return Error code
61  **/
62 
64  size_t oidLen, MibVariant *value, size_t *valueLen)
65 {
66  //This object indicates what version of the Spanning Tree Protocol is
67  //being run
69 
70  //Successful processing
71  return NO_ERROR;
72 }
73 
74 
75 /**
76  * @brief Set dot1dStpPriority object value
77  * @param[in] object Pointer to the MIB object descriptor
78  * @param[in] oid Object identifier (object name and instance identifier)
79  * @param[in] oidLen Length of the OID, in bytes
80  * @param[in] value Object value
81  * @param[in] valueLen Length of the object value, in bytes
82  * @param[in] commit This flag tells whether the changes shall be committed
83  * to the MIB base
84  * @return Error code
85  **/
86 
87 error_t bridgeMibSetDot1dStpPriority(const MibObject *object, const uint8_t *oid,
88  size_t oidLen, const MibVariant *value, size_t valueLen, bool_t commit)
89 {
90 #if (BRIDGE_MIB_SET_SUPPORT == ENABLED)
91  error_t error;
92 
93  //Ensure that the supplied value is valid
94  if(value->integer >= 0 && value->integer <= 65535)
95  {
96 #if (STP_SUPPORT == ENABLED)
97  //Valid STP bridge context?
99  {
100  //This object specifies the value of the write-able portion of the
101  //Bridge ID
103  value->integer, commit);
104  }
105  else
106 #endif
107 #if (RSTP_SUPPORT == ENABLED)
108  //Valid RSTP bridge context?
109  if(bridgeMibBase.rstpBridgeContext != NULL)
110  {
111  //This object specifies the value of the write-able portion of the
112  //Bridge ID
114  value->integer, commit);
115  }
116  else
117 #endif
118  //Invalid bridge context?
119  {
120  //Report an error
121  error = ERROR_WRITE_FAILED;
122  }
123  }
124  else
125  {
126  //Report an error
127  error = ERROR_WRONG_VALUE;
128  }
129 
130  //Return status code
131  return error;
132 #else
133  //SET operation is not supported
134  return ERROR_WRITE_FAILED;
135 #endif
136 }
137 
138 
139 /**
140  * @brief Get dot1dStpPriority object value
141  * @param[in] object Pointer to the MIB object descriptor
142  * @param[in] oid Object identifier (object name and instance identifier)
143  * @param[in] oidLen Length of the OID, in bytes
144  * @param[out] value Object value
145  * @param[in,out] valueLen Length of the object value, in bytes
146  * @return Error code
147  **/
148 
149 error_t bridgeMibGetDot1dStpPriority(const MibObject *object, const uint8_t *oid,
150  size_t oidLen, MibVariant *value, size_t *valueLen)
151 {
152  error_t error;
153  uint16_t bridgePriority;
154 
155  //Initialize object value
156  bridgePriority = 0;
157 
158 #if (STP_SUPPORT == ENABLED)
159  //Valid STP bridge context?
160  if(bridgeMibBase.stpBridgeContext != NULL)
161  {
162  //This object specifies the value of the write-able portion of the
163  //Bridge ID
165  &bridgePriority);
166  }
167  else
168 #endif
169 #if (RSTP_SUPPORT == ENABLED)
170  //Valid RSTP bridge context?
171  if(bridgeMibBase.rstpBridgeContext != NULL)
172  {
173  //This object specifies the value of the write-able portion of the
174  //Bridge ID
176  &bridgePriority);
177  }
178  else
179 #endif
180  //Invalid bridge context?
181  {
182  //Report an error
183  error = ERROR_READ_FAILED;
184  }
185 
186  //Check status code
187  if(!error)
188  {
189  //Return the value of the object
190  value->integer = bridgePriority;
191  }
192 
193  //Return status code
194  return error;
195 }
196 
197 
198 /**
199  * @brief Get dot1dStpTimeSinceTopologyChange object value
200  * @param[in] object Pointer to the MIB object descriptor
201  * @param[in] oid Object identifier (object name and instance identifier)
202  * @param[in] oidLen Length of the OID, in bytes
203  * @param[out] value Object value
204  * @param[in,out] valueLen Length of the object value, in bytes
205  * @return Error code
206  **/
207 
209  size_t oidLen, MibVariant *value, size_t *valueLen)
210 {
211  error_t error;
212  uint_t timeSinceTopologyChange;
213 
214  //Initialize object value
215  timeSinceTopologyChange = 0;
216 
217 #if (STP_SUPPORT == ENABLED)
218  //Valid STP bridge context?
219  if(bridgeMibBase.stpBridgeContext != NULL)
220  {
221  //Retrieve the time since the last time a topology change was detected by
222  //the bridge entity
224  &timeSinceTopologyChange);
225  }
226  else
227 #endif
228 #if (RSTP_SUPPORT == ENABLED)
229  //Valid RSTP bridge context?
230  if(bridgeMibBase.rstpBridgeContext != NULL)
231  {
232  //Retrieve the time since the last time a topology change was detected by
233  //the bridge entity
235  &timeSinceTopologyChange);
236  }
237  else
238 #endif
239  //Invalid bridge context?
240  {
241  //Report an error
242  error = ERROR_READ_FAILED;
243  }
244 
245  //Check status code
246  if(!error)
247  {
248  //Return the value of the object (in hundredths of a second)
249  value->integer = timeSinceTopologyChange * 100;
250  }
251 
252  //Return status code
253  return error;
254 }
255 
256 
257 /**
258  * @brief Get dot1dStpTopChanges object value
259  * @param[in] object Pointer to the MIB object descriptor
260  * @param[in] oid Object identifier (object name and instance identifier)
261  * @param[in] oidLen Length of the OID, in bytes
262  * @param[out] value Object value
263  * @param[in,out] valueLen Length of the object value, in bytes
264  * @return Error code
265  **/
266 
267 error_t bridgeMibGetDot1dStpTopChanges(const MibObject *object, const uint8_t *oid,
268  size_t oidLen, MibVariant *value, size_t *valueLen)
269 {
270  error_t error;
271  uint_t topologyChanges;
272 
273  //Initialize object value
274  topologyChanges = 0;
275 
276 #if (STP_SUPPORT == ENABLED)
277  //Valid STP bridge context?
278  if(bridgeMibBase.stpBridgeContext != NULL)
279  {
280  //Get the total number of topology changes detected by this bridge since
281  //the management entity was last reset or initialized
283  &topologyChanges);
284  }
285  else
286 #endif
287 #if (RSTP_SUPPORT == ENABLED)
288  //Valid RSTP bridge context?
289  if(bridgeMibBase.rstpBridgeContext != NULL)
290  {
291  //Get the total number of topology changes detected by this bridge since
292  //the management entity was last reset or initialized
294  &topologyChanges);
295  }
296  else
297 #endif
298  //Invalid bridge context?
299  {
300  //Report an error
301  error = ERROR_READ_FAILED;
302  }
303 
304  //Check status code
305  if(!error)
306  {
307  //Return the value of the object
308  value->integer = topologyChanges;
309  }
310 
311  //Return status code
312  return error;
313 }
314 
315 
316 /**
317  * @brief Get dot1dStpDesignatedRoot object value
318  * @param[in] object Pointer to the MIB object descriptor
319  * @param[in] oid Object identifier (object name and instance identifier)
320  * @param[in] oidLen Length of the OID, in bytes
321  * @param[out] value Object value
322  * @param[in,out] valueLen Length of the object value, in bytes
323  * @return Error code
324  **/
325 
327  size_t oidLen, MibVariant *value, size_t *valueLen)
328 {
329  error_t error;
330  StpBridgeId designatedRoot;
331 
332  //Make sure the buffer is large enough to hold the entire object
333  if(*valueLen < sizeof(StpBridgeId))
334  return ERROR_BUFFER_OVERFLOW;
335 
336  //Initialize object value
337  designatedRoot.priority = 0;
338  designatedRoot.addr = MAC_UNSPECIFIED_ADDR;
339 
340 #if (STP_SUPPORT == ENABLED)
341  //Valid STP bridge context?
342  if(bridgeMibBase.stpBridgeContext != NULL)
343  {
344  //Get the bridge identifier of the root of the spanning tree
346  &designatedRoot);
347  }
348  else
349 #endif
350 #if (RSTP_SUPPORT == ENABLED)
351  //Valid RSTP bridge context?
352  if(bridgeMibBase.rstpBridgeContext != NULL)
353  {
354  //Get the bridge identifier of the root of the spanning tree
356  &designatedRoot);
357  }
358  else
359 #endif
360  //Invalid bridge context?
361  {
362  //Report an error
363  error = ERROR_READ_FAILED;
364  }
365 
366  //Check status code
367  if(!error)
368  {
369  //Convert the priority field to network byte order
370  designatedRoot.priority = htons(designatedRoot.priority);
371  //Copy the bridge identifier
372  osMemcpy(value->octetString, &designatedRoot, sizeof(StpBridgeId));
373  //A bridge identifier shall be encoded as eight octets
374  *valueLen = sizeof(StpBridgeId);
375  }
376 
377  //Return status code
378  return error;
379 }
380 
381 
382 /**
383  * @brief Get dot1dStpRootCost object value
384  * @param[in] object Pointer to the MIB object descriptor
385  * @param[in] oid Object identifier (object name and instance identifier)
386  * @param[in] oidLen Length of the OID, in bytes
387  * @param[out] value Object value
388  * @param[in,out] valueLen Length of the object value, in bytes
389  * @return Error code
390  **/
391 
392 error_t bridgeMibGetDot1dStpRootCost(const MibObject *object, const uint8_t *oid,
393  size_t oidLen, MibVariant *value, size_t *valueLen)
394 {
395  error_t error;
396  uint32_t rootPathCost;
397 
398  //Initialize object value
399  rootPathCost = 0;
400 
401 #if (STP_SUPPORT == ENABLED)
402  //Valid STP bridge context?
403  if(bridgeMibBase.stpBridgeContext != NULL)
404  {
405  //Get the cost of the path to the root as seen from this bridge
407  &rootPathCost);
408  }
409  else
410 #endif
411 #if (RSTP_SUPPORT == ENABLED)
412  //Valid RSTP bridge context?
413  if(bridgeMibBase.rstpBridgeContext != NULL)
414  {
415  //Get the cost of the path to the root as seen from this bridge
417  &rootPathCost);
418  }
419  else
420 #endif
421  //Invalid bridge context?
422  {
423  //Report an error
424  error = ERROR_READ_FAILED;
425  }
426 
427  //Check status code
428  if(!error)
429  {
430  //Return the value of the object
431  value->integer = rootPathCost;
432  }
433 
434  //Return status code
435  return error;
436 }
437 
438 
439 /**
440  * @brief Get dot1dStpRootPort object value
441  * @param[in] object Pointer to the MIB object descriptor
442  * @param[in] oid Object identifier (object name and instance identifier)
443  * @param[in] oidLen Length of the OID, in bytes
444  * @param[out] value Object value
445  * @param[in,out] valueLen Length of the object value, in bytes
446  * @return Error code
447  **/
448 
449 error_t bridgeMibGetDot1dStpRootPort(const MibObject *object, const uint8_t *oid,
450  size_t oidLen, MibVariant *value, size_t *valueLen)
451 {
452  error_t error;
453  uint16_t rootPort;
454 
455  //Initialize object value
456  rootPort = 0;
457 
458 #if (STP_SUPPORT == ENABLED)
459  //Valid STP bridge context?
460  if(bridgeMibBase.stpBridgeContext != NULL)
461  {
462  //This parameter is used to identify the port through which the path to
463  //the Root is established. It is not significant when the bridge is the
464  //Root, and is set to zero
466  }
467  else
468 #endif
469 #if (RSTP_SUPPORT == ENABLED)
470  //Valid RSTP bridge context?
471  if(bridgeMibBase.rstpBridgeContext != NULL)
472  {
473  //This parameter is used to identify the port through which the path to
474  //the Root is established. It is not significant when the bridge is the
475  //Root, and is set to zero
477  }
478  else
479 #endif
480  //Invalid bridge context?
481  {
482  //Report an error
483  error = ERROR_READ_FAILED;
484  }
485 
486  //Check status code
487  if(!error)
488  {
489  //Return the value of the object
490  value->integer = rootPort;
491  }
492 
493  //Return status code
494  return error;
495 }
496 
497 
498 /**
499  * @brief Get dot1dStpMaxAge object value
500  * @param[in] object Pointer to the MIB object descriptor
501  * @param[in] oid Object identifier (object name and instance identifier)
502  * @param[in] oidLen Length of the OID, in bytes
503  * @param[out] value Object value
504  * @param[in,out] valueLen Length of the object value, in bytes
505  * @return Error code
506  **/
507 
508 error_t bridgeMibGetDot1dStpMaxAge(const MibObject *object, const uint8_t *oid,
509  size_t oidLen, MibVariant *value, size_t *valueLen)
510 {
511  error_t error;
512  uint_t maxAge;
513 
514  //Initialize object value
515  maxAge = 0;
516 
517 #if (STP_SUPPORT == ENABLED)
518  //Valid STP bridge context?
519  if(bridgeMibBase.stpBridgeContext != NULL)
520  {
521  //This object specifies the maximum age of Spanning Tree Protocol
522  //information learned from the network on any port before it is discarded
524  }
525  else
526 #endif
527 #if (RSTP_SUPPORT == ENABLED)
528  //Valid RSTP bridge context?
529  if(bridgeMibBase.rstpBridgeContext != NULL)
530  {
531  //This object specifies the maximum age of Spanning Tree Protocol
532  //information learned from the network on any port before it is discarded
534  }
535  else
536 #endif
537  //Invalid bridge context?
538  {
539  //Report an error
540  error = ERROR_READ_FAILED;
541  }
542 
543  //Check status code
544  if(!error)
545  {
546  //Return the value of the object (in hundredths of a second)
547  value->integer = maxAge * 100;
548  }
549 
550  //Return status code
551  return error;
552 }
553 
554 
555 /**
556  * @brief Get dot1dStpHelloTime object value
557  * @param[in] object Pointer to the MIB object descriptor
558  * @param[in] oid Object identifier (object name and instance identifier)
559  * @param[in] oidLen Length of the OID, in bytes
560  * @param[out] value Object value
561  * @param[in,out] valueLen Length of the object value, in bytes
562  * @return Error code
563  **/
564 
565 error_t bridgeMibGetDot1dStpHelloTime(const MibObject *object, const uint8_t *oid,
566  size_t oidLen, MibVariant *value, size_t *valueLen)
567 {
568  error_t error;
570 
571  //Initialize object value
572  helloTime = 0;
573 
574 #if (STP_SUPPORT == ENABLED)
575  //Valid STP bridge context?
576  if(bridgeMibBase.stpBridgeContext != NULL)
577  {
578  //This object specifies the amount of time between the transmission of
579  //Configuration bridge PDUs by this node on any port when it is the root
580  //of the spanning tree, or trying to become so
582  }
583  else
584 #endif
585 #if (RSTP_SUPPORT == ENABLED)
586  //Valid RSTP bridge context?
587  if(bridgeMibBase.rstpBridgeContext != NULL)
588  {
589  //This object specifies the amount of time between the transmission of
590  //Configuration bridge PDUs by this node on any port when it is the root
591  //of the spanning tree, or trying to become so
593  }
594  else
595 #endif
596  //Invalid bridge context?
597  {
598  //Report an error
599  error = ERROR_READ_FAILED;
600  }
601 
602  //Check status code
603  if(!error)
604  {
605  //Return the value of the object (in hundredths of a second)
606  value->integer = helloTime * 100;
607  }
608 
609  //Return status code
610  return error;
611 }
612 
613 
614 /**
615  * @brief Get dot1dStpHoldTime object value
616  * @param[in] object Pointer to the MIB object descriptor
617  * @param[in] oid Object identifier (object name and instance identifier)
618  * @param[in] oidLen Length of the OID, in bytes
619  * @param[out] value Object value
620  * @param[in,out] valueLen Length of the object value, in bytes
621  * @return Error code
622  **/
623 
624 error_t bridgeMibGetDot1dStpHoldTime(const MibObject *object, const uint8_t *oid,
625  size_t oidLen, MibVariant *value, size_t *valueLen)
626 {
627  error_t error;
628 
629 #if (STP_SUPPORT == ENABLED)
630  //Valid STP bridge context?
631  if(bridgeMibBase.stpBridgeContext != NULL)
632  {
633  uint_t holdTime;
634 
635  //This time value determines the interval length during which no more
636  //than two Configuration bridge PDUs shall be transmitted by this node
638 
639  //Check status code
640  if(!error)
641  {
642  //The hold time value is expressed in hundredths of a second
643  value->integer = holdTime * 100;
644  }
645  }
646  else
647 #endif
648 #if (RSTP_SUPPORT == ENABLED)
649  //Valid RSTP bridge context?
650  if(bridgeMibBase.rstpBridgeContext != NULL)
651  {
652  uint_t txHoldCount;
653  RstpBridgeContext *context;
654 
655  //Point to the RSTP bridge context
657 
658  //The Transmit Hold Count parameter specifies the number or BPDUs that
659  //can be transmitted during every hello time period ranges
660  error = rstpMgmtGetTxHoldCount(context, &txHoldCount);
661 
662  //Check status code
663  if(!error)
664  {
665  //The hold time value is expressed in hundredths of a second
666  if(txHoldCount > 0)
667  {
668  value->integer = (context->params.bridgeHelloTime * 100) /
669  txHoldCount;
670  }
671  else
672  {
673  value->integer = 0;
674  }
675  }
676  }
677  else
678 #endif
679  //Invalid bridge context?
680  {
681  //Report an error
682  error = ERROR_READ_FAILED;
683  }
684 
685  //Return status code
686  return error;
687 }
688 
689 
690 /**
691  * @brief Get dot1dStpForwardDelay object value
692  * @param[in] object Pointer to the MIB object descriptor
693  * @param[in] oid Object identifier (object name and instance identifier)
694  * @param[in] oidLen Length of the OID, in bytes
695  * @param[out] value Object value
696  * @param[in,out] valueLen Length of the object value, in bytes
697  * @return Error code
698  **/
699 
701  size_t oidLen, MibVariant *value, size_t *valueLen)
702 {
703  error_t error;
705 
706  //Initialize object value
707  forwardDelay = 0;
708 
709 #if (STP_SUPPORT == ENABLED)
710  //Valid STP bridge context?
711  if(bridgeMibBase.stpBridgeContext != NULL)
712  {
713  //This time value controls how fast a port changes its spanning state
714  //when moving towards the Forwarding state. The value determines how
715  //long the port stays in each of the Listening and Learning states, which
716  //precede the Forwarding state
718  &forwardDelay);
719  }
720  else
721 #endif
722 #if (RSTP_SUPPORT == ENABLED)
723  //Valid RSTP bridge context?
724  if(bridgeMibBase.rstpBridgeContext != NULL)
725  {
726  //This time value controls how fast a port changes its spanning state
727  //when moving towards the Forwarding state. The value determines how
728  //long the port stays in each of the Listening and Learning states, which
729  //precede the Forwarding state
731  &forwardDelay);
732  }
733  else
734 #endif
735  //Invalid bridge context?
736  {
737  //Report an error
738  error = ERROR_READ_FAILED;
739  }
740 
741  //Check status code
742  if(!error)
743  {
744  //Return the value of the object (in hundredths of a second)
745  value->integer = forwardDelay * 100;
746  }
747 
748  //Return status code
749  return error;
750 }
751 
752 
753 /**
754  * @brief Set dot1dStpBridgeMaxAge object value
755  * @param[in] object Pointer to the MIB object descriptor
756  * @param[in] oid Object identifier (object name and instance identifier)
757  * @param[in] oidLen Length of the OID, in bytes
758  * @param[in] value Object value
759  * @param[in] valueLen Length of the object value, in bytes
760  * @param[in] commit This flag tells whether the changes shall be committed
761  * to the MIB base
762  * @return Error code
763  **/
764 
766  size_t oidLen, const MibVariant *value, size_t valueLen, bool_t commit)
767 {
768 #if (BRIDGE_MIB_SET_SUPPORT == ENABLED)
769  error_t error;
770  uint_t bridgeMaxAge;
771 
772  //The granularity of this timer is specified by 802.1D-1998 to be 1 second.
773  //An agent may return a badValue error if a set is attempted to a value that
774  //is not a whole number of seconds
775  if((value->integer % 100) != 0)
776  return ERROR_WRONG_VALUE;
777 
778  //The value is expressed in hundredths of a second
779  bridgeMaxAge = value->integer / 100;
780 
781 #if (STP_SUPPORT == ENABLED)
782  //Valid STP bridge context?
783  if(bridgeMibBase.stpBridgeContext != NULL)
784  {
785  //This object specifies the value that all bridges use for MaxAge when
786  //this bridge is acting as the root
788  bridgeMaxAge, commit);
789  }
790  else
791 #endif
792 #if (RSTP_SUPPORT == ENABLED)
793  //Valid RSTP bridge context?
794  if(bridgeMibBase.rstpBridgeContext != NULL)
795  {
796  //This object specifies the value that all bridges use for MaxAge when
797  //this bridge is acting as the root
799  bridgeMaxAge, commit);
800  }
801  else
802 #endif
803  //Invalid bridge context?
804  {
805  //Report an error
806  error = ERROR_WRITE_FAILED;
807  }
808 
809  //Return status code
810  return error;
811 #else
812  //SET operation is not supported
813  return ERROR_WRITE_FAILED;
814 #endif
815 }
816 
817 
818 /**
819  * @brief Get dot1dStpBridgeMaxAge object value
820  * @param[in] object Pointer to the MIB object descriptor
821  * @param[in] oid Object identifier (object name and instance identifier)
822  * @param[in] oidLen Length of the OID, in bytes
823  * @param[out] value Object value
824  * @param[in,out] valueLen Length of the object value, in bytes
825  * @return Error code
826  **/
827 
829  size_t oidLen, MibVariant *value, size_t *valueLen)
830 {
831  error_t error;
832  uint_t bridgeMaxAge;
833 
834  //Initialize object value
835  bridgeMaxAge = 0;
836 
837 #if (STP_SUPPORT == ENABLED)
838  //Valid STP bridge context?
839  if(bridgeMibBase.stpBridgeContext != NULL)
840  {
841  //This object specifies the value that all bridges use for MaxAge when
842  //this bridge is acting as the root
844  &bridgeMaxAge);
845  }
846  else
847 #endif
848 #if (RSTP_SUPPORT == ENABLED)
849  //Valid RSTP bridge context?
850  if(bridgeMibBase.rstpBridgeContext != NULL)
851  {
852  //This object specifies the value that all bridges use for MaxAge when
853  //this bridge is acting as the root
855  &bridgeMaxAge);
856  }
857  else
858 #endif
859  //Invalid bridge context?
860  {
861  //Report an error
862  error = ERROR_READ_FAILED;
863  }
864 
865  //Check status code
866  if(!error)
867  {
868  //Return the value of the object (in hundredths of a second)
869  value->integer = bridgeMaxAge * 100;
870  }
871 
872  //Return status code
873  return error;
874 }
875 
876 
877 /**
878  * @brief Set dot1dStpBridgeHelloTime object value
879  * @param[in] object Pointer to the MIB object descriptor
880  * @param[in] oid Object identifier (object name and instance identifier)
881  * @param[in] oidLen Length of the OID, in bytes
882  * @param[in] value Object value
883  * @param[in] valueLen Length of the object value, in bytes
884  * @param[in] commit This flag tells whether the changes shall be committed
885  * to the MIB base
886  * @return Error code
887  **/
888 
890  size_t oidLen, const MibVariant *value, size_t valueLen, bool_t commit)
891 {
892 #if (BRIDGE_MIB_SET_SUPPORT == ENABLED)
893  error_t error;
894  uint_t bridgeHelloTime;
895 
896  //The granularity of this timer is specified by 802.1D-1998 to be 1 second.
897  //An agent may return a badValue error if a set is attempted to a value that
898  //is not a whole number of seconds
899  if((value->integer % 100) != 0)
900  return ERROR_WRONG_VALUE;
901 
902  //The value is expressed in hundredths of a second
903  bridgeHelloTime = value->integer / 100;
904 
905 #if (STP_SUPPORT == ENABLED)
906  //Valid STP bridge context?
907  if(bridgeMibBase.stpBridgeContext != NULL)
908  {
909  //This object specifies the value that all bridges use for HelloTime when
910  //this bridge is acting as the root
912  bridgeHelloTime, commit);
913  }
914  else
915 #endif
916 #if (RSTP_SUPPORT == ENABLED)
917  //Valid RSTP bridge context?
918  if(bridgeMibBase.rstpBridgeContext != NULL)
919  {
920  //This object specifies the value that all bridges use for HelloTime when
921  //this bridge is acting as the root
923  bridgeHelloTime, commit);
924  }
925  else
926 #endif
927  //Invalid bridge context?
928  {
929  //Report an error
930  error = ERROR_WRITE_FAILED;
931  }
932 
933  //Return status code
934  return error;
935 #else
936  //SET operation is not supported
937  return ERROR_WRITE_FAILED;
938 #endif
939 }
940 
941 
942 /**
943  * @brief Get dot1dStpBridgeHelloTime object value
944  * @param[in] object Pointer to the MIB object descriptor
945  * @param[in] oid Object identifier (object name and instance identifier)
946  * @param[in] oidLen Length of the OID, in bytes
947  * @param[out] value Object value
948  * @param[in,out] valueLen Length of the object value, in bytes
949  * @return Error code
950  **/
951 
953  size_t oidLen, MibVariant *value, size_t *valueLen)
954 {
955  error_t error;
956  uint_t bridgeHelloTime;
957 
958  //Initialize object value
959  bridgeHelloTime = 0;
960 
961 #if (STP_SUPPORT == ENABLED)
962  //Valid STP bridge context?
963  if(bridgeMibBase.stpBridgeContext != NULL)
964  {
965  //This object specifies the value that all bridges use for HelloTime when
966  //this bridge is acting as the root
968  &bridgeHelloTime);
969  }
970  else
971 #endif
972 #if (RSTP_SUPPORT == ENABLED)
973  //Valid RSTP bridge context?
974  if(bridgeMibBase.rstpBridgeContext != NULL)
975  {
976  //This object specifies the value that all bridges use for HelloTime when
977  //this bridge is acting as the root
979  &bridgeHelloTime);
980  }
981  else
982 #endif
983  //Invalid bridge context?
984  {
985  //Report an error
986  error = ERROR_READ_FAILED;
987  }
988 
989  //Check status code
990  if(!error)
991  {
992  //Return the value of the object (in hundredths of a second)
993  value->integer = bridgeHelloTime * 100;
994  }
995 
996  //Return status code
997  return error;
998 }
999 
1000 
1001 /**
1002  * @brief Set dot1dStpBridgeForwardDelay object value
1003  * @param[in] object Pointer to the MIB object descriptor
1004  * @param[in] oid Object identifier (object name and instance identifier)
1005  * @param[in] oidLen Length of the OID, in bytes
1006  * @param[in] value Object value
1007  * @param[in] valueLen Length of the object value, in bytes
1008  * @param[in] commit This flag tells whether the changes shall be committed
1009  * to the MIB base
1010  * @return Error code
1011  **/
1012 
1014  size_t oidLen, const MibVariant *value, size_t valueLen, bool_t commit)
1015 {
1016 #if (BRIDGE_MIB_SET_SUPPORT == ENABLED)
1017  error_t error;
1018  uint_t bridgeForwardDelay;
1019 
1020  //The granularity of this timer is specified by 802.1D-1998 to be 1 second.
1021  //An agent may return a badValue error if a set is attempted to a value that
1022  //is not a whole number of seconds
1023  if((value->integer % 100) != 0)
1024  return ERROR_WRONG_VALUE;
1025 
1026  //The value is expressed in hundredths of a second
1027  bridgeForwardDelay = value->integer / 100;
1028 
1029 #if (STP_SUPPORT == ENABLED)
1030  //Valid STP bridge context?
1031  if(bridgeMibBase.stpBridgeContext != NULL)
1032  {
1033  //This object specifies the value that all bridges use for ForwardDelay
1034  //when this bridge is acting as the root
1036  bridgeForwardDelay, commit);
1037  }
1038  else
1039 #endif
1040 #if (RSTP_SUPPORT == ENABLED)
1041  //Valid RSTP bridge context?
1042  if(bridgeMibBase.rstpBridgeContext != NULL)
1043  {
1044  //This object specifies the value that all bridges use for ForwardDelay
1045  //when this bridge is acting as the root
1047  bridgeForwardDelay, commit);
1048  }
1049  else
1050 #endif
1051  //Invalid bridge context?
1052  {
1053  //Report an error
1054  error = ERROR_WRITE_FAILED;
1055  }
1056 
1057  //Return status code
1058  return error;
1059 #else
1060  //SET operation is not supported
1061  return ERROR_WRITE_FAILED;
1062 #endif
1063 }
1064 
1065 
1066 /**
1067  * @brief Get dot1dStpBridgeForwardDelay object value
1068  * @param[in] object Pointer to the MIB object descriptor
1069  * @param[in] oid Object identifier (object name and instance identifier)
1070  * @param[in] oidLen Length of the OID, in bytes
1071  * @param[out] value Object value
1072  * @param[in,out] valueLen Length of the object value, in bytes
1073  * @return Error code
1074  **/
1075 
1077  size_t oidLen, MibVariant *value, size_t *valueLen)
1078 {
1079  error_t error;
1080  uint_t bridgeForwardDelay;
1081 
1082  //Initialize object value
1083  bridgeForwardDelay = 0;
1084 
1085 #if (STP_SUPPORT == ENABLED)
1086  //Valid STP bridge context?
1087  if(bridgeMibBase.stpBridgeContext != NULL)
1088  {
1089  //This object specifies the value that all bridges use for ForwardDelay
1090  //when this bridge is acting as the root
1092  &bridgeForwardDelay);
1093  }
1094  else
1095 #endif
1096 #if (RSTP_SUPPORT == ENABLED)
1097  //Valid RSTP bridge context?
1098  if(bridgeMibBase.rstpBridgeContext != NULL)
1099  {
1100  //This object specifies the value that all bridges use for ForwardDelay
1101  //when this bridge is acting as the root
1103  &bridgeForwardDelay);
1104  }
1105  else
1106 #endif
1107  //Invalid bridge context?
1108  {
1109  //Report an error
1110  error = ERROR_READ_FAILED;
1111  }
1112 
1113  //Check status code
1114  if(!error)
1115  {
1116  //Return the value of the object (in hundredths of a second)
1117  value->integer = bridgeForwardDelay * 100;
1118  }
1119 
1120  //Return status code
1121  return error;
1122 }
1123 
1124 
1125 /**
1126  * @brief Set dot1dStpPortEntry object value
1127  * @param[in] object Pointer to the MIB object descriptor
1128  * @param[in] oid Object identifier (object name and instance identifier)
1129  * @param[in] oidLen Length of the OID, in bytes
1130  * @param[in] value Object value
1131  * @param[in] valueLen Length of the object value, in bytes
1132  * @param[in] commit This flag tells whether the changes shall be committed
1133  * to the MIB base
1134  * @return Error code
1135  **/
1136 
1137 error_t bridgeMibSetDot1dStpPortEntry(const MibObject *object, const uint8_t *oid,
1138  size_t oidLen, const MibVariant *value, size_t valueLen, bool_t commit)
1139 {
1140 #if (BRIDGE_MIB_SET_SUPPORT == ENABLED)
1141  error_t error;
1142  size_t n;
1143  uint_t portIndex;
1144  uint16_t dot1dStpPort;
1145 
1146  //Point to the instance identifier
1147  n = object->oidLen;
1148 
1149  //dot1dStpPort is used as instance identifier
1150  error = mibDecodePort(oid, oidLen, &n, &dot1dStpPort);
1151  //Invalid instance identifier?
1152  if(error)
1153  return error;
1154 
1155  //Sanity check
1156  if(n != oidLen)
1157  return ERROR_INSTANCE_NOT_FOUND;
1158 
1159  //Retrieve the port that matches the specified port number
1160  portIndex = bridgeMibGetPortIndex(dot1dStpPort);
1161  //Invalid port number?
1162  if(portIndex == 0)
1163  return ERROR_INSTANCE_NOT_FOUND;
1164 
1165  //dot1dStpPortPriority object?
1166  if(!strcmp(object->name, "dot1dStpPortPriority"))
1167  {
1168  //This object specifies the value of the priority field that is
1169  //contained in the first octet of the Port Identifier
1170  error = bridgeMibSetDot1dStpPortPriority(portIndex, value, valueLen,
1171  commit);
1172  }
1173  //dot1dStpPortEnable object?
1174  else if(!strcmp(object->name, "dot1dStpPortEnable"))
1175  {
1176  //This object specifies the enabled/disabled status of the port
1177  error = bridgeMibSetDot1dStpPortEnable(portIndex, value, valueLen,
1178  commit);
1179  }
1180  //dot1dStpPortPathCost object?
1181  else if(!strcmp(object->name, "dot1dStpPortPathCost"))
1182  {
1183  //This object specifies the contribution of this port to the path
1184  //cost of paths towards the spanning tree root which include this
1185  //port
1186  error = bridgeMibSetDot1dStpPortPathCost(portIndex, value, valueLen,
1187  commit);
1188  }
1189  //dot1dStpPortPathCost32 object?
1190  else if(!strcmp(object->name, "dot1dStpPortPathCost32"))
1191  {
1192  //This object specifies the contribution of this port to the path
1193  //cost of paths towards the spanning tree root which include this
1194  //port
1195  error = bridgeMibSetDot1dStpPortPathCost32(portIndex, value, valueLen,
1196  commit);
1197  }
1198  //Unknown object?
1199  else
1200  {
1201  //The specified object does not exist
1202  error = ERROR_OBJECT_NOT_FOUND;
1203  }
1204 
1205  //Return status code
1206  return error;
1207 #else
1208  //SET operation is not supported
1209  return ERROR_WRITE_FAILED;
1210 #endif
1211 }
1212 
1213 
1214 /**
1215  * @brief Get dot1dStpPortEntry object value
1216  * @param[in] object Pointer to the MIB object descriptor
1217  * @param[in] oid Object identifier (object name and instance identifier)
1218  * @param[in] oidLen Length of the OID, in bytes
1219  * @param[out] value Object value
1220  * @param[in,out] valueLen Length of the object value, in bytes
1221  * @return Error code
1222  **/
1223 
1224 error_t bridgeMibGetDot1dStpPortEntry(const MibObject *object, const uint8_t *oid,
1225  size_t oidLen, MibVariant *value, size_t *valueLen)
1226 {
1227  error_t error;
1228  size_t n;
1229  uint_t portIndex;
1230  uint16_t dot1dStpPort;
1231 
1232  //Point to the instance identifier
1233  n = object->oidLen;
1234 
1235  //dot1dStpPort is used as instance identifier
1236  error = mibDecodePort(oid, oidLen, &n, &dot1dStpPort);
1237  //Invalid instance identifier?
1238  if(error)
1239  return error;
1240 
1241  //Sanity check
1242  if(n != oidLen)
1243  return ERROR_INSTANCE_NOT_FOUND;
1244 
1245  //Retrieve the port that matches the specified port number
1246  portIndex = bridgeMibGetPortIndex(dot1dStpPort);
1247  //Invalid port number?
1248  if(portIndex == 0)
1249  return ERROR_INSTANCE_NOT_FOUND;
1250 
1251  //dot1dStpPort object?
1252  if(!strcmp(object->name, "dot1dStpPort"))
1253  {
1254  //This object specifies the port number of the port for which this
1255  //entry contains Spanning Tree Protocol management information
1256  value->integer = dot1dStpPort;
1257  }
1258  //dot1dStpPortPriority object?
1259  else if(!strcmp(object->name, "dot1dStpPortPriority"))
1260  {
1261  //This object specifies the value of the priority field that is contained
1262  //in the first octet of the Port Identifier
1263  error = bridgeMibGetDot1dStpPortPriority(portIndex, value, valueLen);
1264  }
1265  //dot1dStpPortState object?
1266  else if(!strcmp(object->name, "dot1dStpPortState"))
1267  {
1268  //This object specifies the port's current state, as defined by
1269  //application of the Spanning Tree Protocol
1270  error = bridgeMibGetDot1dStpPortState(portIndex, value, valueLen);
1271  }
1272  //dot1dStpPortEnable object?
1273  else if(!strcmp(object->name, "dot1dStpPortEnable"))
1274  {
1275  //This object specifies the enabled/disabled status of the port
1276  error = bridgeMibGetDot1dStpPortEnable(portIndex, value, valueLen);
1277  }
1278  //dot1dStpPortPathCost object?
1279  else if(!strcmp(object->name, "dot1dStpPortPathCost"))
1280  {
1281  //This object specifies the contribution of this port to the path cost
1282  //of paths towards the spanning tree root which include this port
1283  error = bridgeMibGetDot1dStpPortPathCost(portIndex, value, valueLen);
1284  }
1285  //dot1dStpPortDesignatedRoot object?
1286  else if(!strcmp(object->name, "dot1dStpPortDesignatedRoot"))
1287  {
1288  //This object specifies the unique Bridge Identifier of the bridge
1289  //recorded as the Root in the Configuration BPDUs transmitted by the
1290  //Designated Bridge for the segment to which the port is attached
1291  error = bridgeMibGetDot1dStpPortDesignatedRoot(portIndex, value,
1292  valueLen);
1293  }
1294  //dot1dStpPortDesignatedCost object?
1295  else if(!strcmp(object->name, "dot1dStpPortDesignatedCost"))
1296  {
1297  //This object specifies the path cost of the Designated Port of the
1298  //segment connected to this port
1299  error = bridgeMibGetDot1dStpPortDesignatedCost(portIndex, value,
1300  valueLen);
1301  }
1302  //dot1dStpPortDesignatedBridge object?
1303  else if(!strcmp(object->name, "dot1dStpPortDesignatedBridge"))
1304  {
1305  //This object specifies the Bridge Identifier of the bridge that this
1306  //port considers to be the Designated Bridge for this port's segment
1308  valueLen);
1309  }
1310  //dot1dStpPortDesignatedPort object?
1311  else if(!strcmp(object->name, "dot1dStpPortDesignatedPort"))
1312  {
1313  //This object specifies the Port Identifier of the port on the
1314  //Designated Bridge for this port's segment
1315  error = bridgeMibGetDot1dStpPortDesignatedPort(portIndex, value,
1316  valueLen);
1317  }
1318  //dot1dStpPortForwardTransitions object?
1319  else if(!strcmp(object->name, "dot1dStpPortForwardTransitions"))
1320  {
1321  //The number of times this port has transitioned from the Learning state
1322  //to the Forwarding state
1324  valueLen);
1325  }
1326  //dot1dStpPortPathCost32 object?
1327  else if(!strcmp(object->name, "dot1dStpPortPathCost32"))
1328  {
1329  //This object specifies the contribution of this port to the path cost
1330  //of paths towards the spanning tree root which include this port
1331  error = bridgeMibGetDot1dStpPortPathCost32(portIndex, value,
1332  valueLen);
1333  }
1334  //Unknown object?
1335  else
1336  {
1337  //The specified object does not exist
1338  error = ERROR_OBJECT_NOT_FOUND;
1339  }
1340 
1341  //Return status code
1342  return error;
1343 }
1344 
1345 
1346 /**
1347  * @brief Get next dot1dStpPortEntry object
1348  * @param[in] object Pointer to the MIB object descriptor
1349  * @param[in] oid Object identifier
1350  * @param[in] oidLen Length of the OID, in bytes
1351  * @param[out] nextOid OID of the next object in the MIB
1352  * @param[out] nextOidLen Length of the next object identifier, in bytes
1353  * @return Error code
1354  **/
1355 
1357  size_t oidLen, uint8_t *nextOid, size_t *nextOidLen)
1358 {
1359  error_t error;
1360  uint_t i;
1361  size_t n;
1362  uint_t numPorts;
1363  uint16_t portNum;
1364  uint16_t curPortNum;
1365 
1366  //Initialize variable
1367  portNum = 0;
1368 
1369  //Make sure the buffer is large enough to hold the OID prefix
1370  if(*nextOidLen < object->oidLen)
1371  return ERROR_BUFFER_OVERFLOW;
1372 
1373  //Copy OID prefix
1374  osMemcpy(nextOid, object->oid, object->oidLen);
1375 
1376  //Retrieve the number of ports
1377  numPorts = bridgeMibGetNumPorts();
1378 
1379  //Loop through the ports of the bridge
1380  for(i = 1; i <= numPorts; i++)
1381  {
1382  //Retrieve the port number associated with the current port
1383  curPortNum = bridgeMibGetPortNum(i);
1384 
1385  //Append the instance identifier to the OID prefix
1386  n = object->oidLen;
1387 
1388  //dot1dStpPort is used as instance identifier
1389  error = mibEncodeIndex(nextOid, *nextOidLen, &n, curPortNum);
1390  //Any error to report?
1391  if(error)
1392  return error;
1393 
1394  //Check whether the resulting object identifier lexicographically
1395  //follows the specified OID
1396  if(oidComp(nextOid, n, oid, oidLen) > 0)
1397  {
1398  //Save the closest object identifier that follows the specified
1399  //OID in lexicographic order
1400  if(portNum == 0 || curPortNum < portNum)
1401  {
1402  portNum = curPortNum;
1403  }
1404  }
1405  }
1406 
1407  //The specified OID does not lexicographically precede the name
1408  //of some object?
1409  if(portNum == 0)
1410  return ERROR_OBJECT_NOT_FOUND;
1411 
1412  //Append the instance identifier to the OID prefix
1413  n = object->oidLen;
1414 
1415  //dot1dStpPort is used as instance identifier
1416  error = mibEncodeIndex(nextOid, *nextOidLen, &n, portNum);
1417  //Any error to report?
1418  if(error)
1419  return error;
1420 
1421  //Save the length of the resulting object identifier
1422  *nextOidLen = n;
1423  //Next object found
1424  return NO_ERROR;
1425 }
1426 
1427 
1428 /**
1429  * @brief Set dot1dStpPortPriority object value
1430  * @param[in] portNum Port number
1431  * @param[in] value Object value
1432  * @param[in] valueLen Length of the object value, in bytes
1433  * @param[in] commit This flag tells whether the changes shall be committed
1434  * to the MIB base
1435  * @return Error code
1436  **/
1437 
1439  const MibVariant *value, size_t valueLen, bool_t commit)
1440 {
1441  error_t error;
1442 
1443  //Ensure that the supplied value is valid
1444  if(value->integer >= 0 && value->integer <= 255)
1445  {
1446 #if (STP_SUPPORT == ENABLED)
1447  //Valid STP bridge context?
1448  if(bridgeMibBase.stpBridgeContext != NULL)
1449  {
1450  //This object specifies the value of the priority field that is
1451  //contained in the first octet of the Port Identifier
1453  portNum, value->integer, commit);
1454  }
1455  else
1456 #endif
1457 #if (RSTP_SUPPORT == ENABLED)
1458  //Valid RSTP bridge context?
1459  if(bridgeMibBase.rstpBridgeContext != NULL)
1460  {
1461  //This object specifies the value of the priority field that is
1462  //contained in the first octet of the Port Identifier
1464  portNum, value->integer, commit);
1465  }
1466  else
1467 #endif
1468  //Invalid bridge context?
1469  {
1470  //Report an error
1471  error = ERROR_WRITE_FAILED;
1472  }
1473  }
1474  else
1475  {
1476  //Report an error
1477  error = ERROR_WRONG_VALUE;
1478  }
1479 
1480  //Return status code
1481  return error;
1482 }
1483 
1484 
1485 /**
1486  * @brief Get dot1dStpPortPriority object value
1487  * @param[in] portNum Port number
1488  * @param[out] value Object value
1489  * @param[in,out] valueLen Length of the object value, in bytes
1490  * @return Error code
1491  **/
1492 
1494  MibVariant *value, size_t *valueLen)
1495 {
1496  error_t error;
1497  uint8_t portPriority;
1498 
1499  //Initialize object value
1500  portPriority = 0;
1501 
1502 #if (STP_SUPPORT == ENABLED)
1503  //Valid STP bridge context?
1504  if(bridgeMibBase.stpBridgeContext != NULL)
1505  {
1506  //This object specifies the value of the priority field that is contained
1507  //in the first octet of the Port Identifier
1509  portNum, &portPriority);
1510  }
1511  else
1512 #endif
1513 #if (RSTP_SUPPORT == ENABLED)
1514  //Valid RSTP bridge context?
1515  if(bridgeMibBase.rstpBridgeContext != NULL)
1516  {
1517  //This object specifies the value of the priority field that is contained
1518  //in the first octet of the Port Identifier
1520  portNum, &portPriority);
1521  }
1522  else
1523 #endif
1524  //Invalid bridge context?
1525  {
1526  //Report an error
1527  error = ERROR_READ_FAILED;
1528  }
1529 
1530  //Check status code
1531  if(!error)
1532  {
1533  //Return the value of the object
1534  value->integer = portPriority;
1535  }
1536 
1537  //Return status code
1538  return error;
1539 }
1540 
1541 
1542 /**
1543  * @brief Get dot1dStpPortState object value
1544  * @param[in] portNum Port number
1545  * @param[out] value Object value
1546  * @param[in,out] valueLen Length of the object value, in bytes
1547  * @return Error code
1548  **/
1549 
1551  MibVariant *value, size_t *valueLen)
1552 {
1553  error_t error;
1554  StpPortState portState;
1555 
1556  //Initialize object value
1557  portState = STP_PORT_STATE_DISABLED;
1558 
1559 #if (STP_SUPPORT == ENABLED)
1560  //Valid STP bridge context?
1561  if(bridgeMibBase.stpBridgeContext != NULL)
1562  {
1563  //This object specifies the port's current state, as defined by
1564  //application of the Spanning Tree Protocol
1566  portNum, &portState);
1567  }
1568  else
1569 #endif
1570 #if (RSTP_SUPPORT == ENABLED)
1571  //Valid RSTP bridge context?
1572  if(bridgeMibBase.rstpBridgeContext != NULL)
1573  {
1574  //This object specifies the port's current state, as defined by
1575  //application of the Spanning Tree Protocol
1577  portNum, &portState);
1578  }
1579  else
1580 #endif
1581  //Invalid bridge context?
1582  {
1583  //Report an error
1584  error = ERROR_READ_FAILED;
1585  }
1586 
1587  //Check status code
1588  if(!error)
1589  {
1590  //Return the value of the object
1591  switch(portState)
1592  {
1595  break;
1596  case STP_PORT_STATE_BROKEN:
1598  break;
1601  break;
1604  break;
1607  break;
1610  break;
1611  default:
1613  break;
1614  }
1615  }
1616 
1617  //Return status code
1618  return error;
1619 }
1620 
1621 
1622 /**
1623  * @brief Set dot1dStpPortEnable object value
1624  * @param[in] portNum Port number
1625  * @param[in] value Object value
1626  * @param[in] valueLen Length of the object value, in bytes
1627  * @param[in] commit This flag tells whether the changes shall be committed
1628  * to the MIB base
1629  * @return Error code
1630  **/
1631 
1633  const MibVariant *value, size_t valueLen, bool_t commit)
1634 {
1635  error_t error;
1636 
1637 #if (STP_SUPPORT == ENABLED)
1638  //Valid STP bridge context?
1639  if(bridgeMibBase.stpBridgeContext != NULL)
1640  {
1641  //This object specifies the enabled/disabled status of the port
1642  if(value->integer == BRIDGE_MIB_PORT_STATUS_ENABLED)
1643  {
1644  //Enable the port
1646  portNum, TRUE, commit);
1647  }
1648  else if(value->integer == BRIDGE_MIB_PORT_STATUS_DISABLED)
1649  {
1650  //Disable the port
1652  portNum, FALSE, commit);
1653  }
1654  else
1655  {
1656  //Report an error
1657  error = ERROR_WRONG_VALUE;
1658  }
1659  }
1660  else
1661 #endif
1662 #if (RSTP_SUPPORT == ENABLED)
1663  //Valid RSTP bridge context?
1664  if(bridgeMibBase.rstpBridgeContext != NULL)
1665  {
1666  //This object specifies the enabled/disabled status of the port
1667  if(value->integer == BRIDGE_MIB_PORT_STATUS_ENABLED)
1668  {
1669  //Enable the port
1671  portNum, TRUE, commit);
1672  }
1673  else if(value->integer == BRIDGE_MIB_PORT_STATUS_DISABLED)
1674  {
1675  //Disable the port
1677  portNum, FALSE, commit);
1678  }
1679  else
1680  {
1681  //Report an error
1682  error = ERROR_WRONG_VALUE;
1683  }
1684  }
1685  else
1686 #endif
1687  //Invalid bridge context?
1688  {
1689  //Report an error
1690  error = ERROR_WRITE_FAILED;
1691  }
1692 
1693  //Return status code
1694  return error;
1695 }
1696 
1697 
1698 /**
1699  * @brief Get dot1dStpPortEnable object value
1700  * @param[in] portNum Port number
1701  * @param[out] value Object value
1702  * @param[in,out] valueLen Length of the object value, in bytes
1703  * @return Error code
1704  **/
1705 
1707  MibVariant *value, size_t *valueLen)
1708 {
1709  error_t error;
1710  bool_t adminPortState;
1711 
1712  //Initialize object value
1713  adminPortState = 0;
1714 
1715 #if (STP_SUPPORT == ENABLED)
1716  //Valid STP bridge context?
1717  if(bridgeMibBase.stpBridgeContext != NULL)
1718  {
1719  //This object specifies the enabled/disabled status of the port
1721  portNum, &adminPortState);
1722  }
1723  else
1724 #endif
1725 #if (RSTP_SUPPORT == ENABLED)
1726  //Valid RSTP bridge context?
1727  if(bridgeMibBase.rstpBridgeContext != NULL)
1728  {
1729  //This object specifies the enabled/disabled status of the port
1731  portNum, &adminPortState);
1732  }
1733  else
1734 #endif
1735  //Invalid bridge context?
1736  {
1737  //Report an error
1738  error = ERROR_READ_FAILED;
1739  }
1740 
1741  //Check status code
1742  if(!error)
1743  {
1744  //Return the value of the object
1745  if(adminPortState)
1746  {
1748  }
1749  else
1750  {
1752  }
1753  }
1754 
1755  //Return status code
1756  return error;
1757 }
1758 
1759 
1760 /**
1761  * @brief Set dot1dStpPortPathCost object value
1762  * @param[in] portNum Port number
1763  * @param[in] value Object value
1764  * @param[in] valueLen Length of the object value, in bytes
1765  * @param[in] commit This flag tells whether the changes shall be committed
1766  * to the MIB base
1767  * @return Error code
1768  **/
1769 
1771  const MibVariant *value, size_t valueLen, bool_t commit)
1772 {
1773  error_t error;
1774 
1775  //Ensure that the supplied value is valid
1776  if(value->integer >= 1 && value->integer <= 65535)
1777  {
1778 #if (STP_SUPPORT == ENABLED)
1779  //Valid STP bridge context?
1780  if(bridgeMibBase.stpBridgeContext != NULL)
1781  {
1782  //This object specifies the contribution of this port to the path cost
1783  //of paths towards the spanning tree root which include this port
1785  portNum, value->integer, commit);
1786  }
1787  else
1788 #endif
1789 #if (RSTP_SUPPORT == ENABLED)
1790  //Valid RSTP bridge context?
1791  if(bridgeMibBase.rstpBridgeContext != NULL)
1792  {
1793  //This object specifies the contribution of this port to the path cost
1794  //of paths towards the spanning tree root which include this port
1796  portNum, value->integer, commit);
1797  }
1798  else
1799 #endif
1800  //Invalid bridge context?
1801  {
1802  //Report an error
1803  error = ERROR_WRITE_FAILED;
1804  }
1805  }
1806  else
1807  {
1808  //Report an error
1809  error = ERROR_WRONG_VALUE;
1810  }
1811 
1812  //Return status code
1813  return error;
1814 }
1815 
1816 
1817 /**
1818  * @brief Get dot1dStpPortPathCost object value
1819  * @param[in] portNum Port number
1820  * @param[out] value Object value
1821  * @param[in,out] valueLen Length of the object value, in bytes
1822  * @return Error code
1823  **/
1824 
1826  MibVariant *value, size_t *valueLen)
1827 {
1828  error_t error;
1829  uint32_t portPathCost;
1830 
1831  //Initialize object value
1832  portPathCost = 0;
1833 
1834 #if (STP_SUPPORT == ENABLED)
1835  //Valid STP bridge context?
1836  if(bridgeMibBase.stpBridgeContext != NULL)
1837  {
1838  //This object specifies the contribution of this port to the path cost
1839  //of paths towards the spanning tree root which include this port
1841  portNum, &portPathCost);
1842  }
1843  else
1844 #endif
1845 #if (RSTP_SUPPORT == ENABLED)
1846  //Valid RSTP bridge context?
1847  if(bridgeMibBase.rstpBridgeContext != NULL)
1848  {
1849  //This object specifies the contribution of this port to the path cost
1850  //of paths towards the spanning tree root which include this port
1852  portNum, &portPathCost);
1853  }
1854  else
1855 #endif
1856  //Invalid bridge context?
1857  {
1858  //Report an error
1859  error = ERROR_READ_FAILED;
1860  }
1861 
1862  //Check status code
1863  if(!error)
1864  {
1865  //If the port path costs exceeds the maximum value of this object then
1866  //this object should report the maximum value, namely 65535
1867  value->integer = MIN(portPathCost, 65535);
1868  }
1869 
1870  //Return status code
1871  return error;
1872 }
1873 
1874 
1875 /**
1876  * @brief Get dot1dStpPortDesignatedRoot object value
1877  * @param[in] portNum Port number
1878  * @param[out] value Object value
1879  * @param[in,out] valueLen Length of the object value, in bytes
1880  * @return Error code
1881  **/
1882 
1884  MibVariant *value, size_t *valueLen)
1885 {
1886  error_t error;
1887  StpBridgeId designatedRoot;
1888 
1889  //Make sure the buffer is large enough to hold the entire object
1890  if(*valueLen < sizeof(StpBridgeId))
1891  return ERROR_BUFFER_OVERFLOW;
1892 
1893  //Initialize object value
1894  designatedRoot.priority = 0;
1895  designatedRoot.addr = MAC_UNSPECIFIED_ADDR;
1896 
1897 #if (STP_SUPPORT == ENABLED)
1898  //Valid STP bridge context?
1899  if(bridgeMibBase.stpBridgeContext != NULL)
1900  {
1901  //This object specifies the unique Bridge Identifier of the bridge
1902  //recorded as the Root in the Configuration BPDUs transmitted by the
1903  //Designated Bridge for the segment to which the port is attached
1905  portNum, &designatedRoot);
1906  }
1907  else
1908 #endif
1909 #if (RSTP_SUPPORT == ENABLED)
1910  //Valid RSTP bridge context?
1911  if(bridgeMibBase.rstpBridgeContext != NULL)
1912  {
1913  //This object specifies the unique Bridge Identifier of the bridge
1914  //recorded as the Root in the Configuration BPDUs transmitted by the
1915  //Designated Bridge for the segment to which the port is attached
1917  portNum, &designatedRoot);
1918  }
1919  else
1920 #endif
1921  //Invalid bridge context?
1922  {
1923  //Report an error
1924  error = ERROR_READ_FAILED;
1925  }
1926 
1927  //Check status code
1928  if(!error)
1929  {
1930  //Convert the priority field to network byte order
1931  designatedRoot.priority = htons(designatedRoot.priority);
1932  //Copy the bridge identifier
1933  osMemcpy(value->octetString, &designatedRoot, sizeof(StpBridgeId));
1934  //A bridge identifier shall be encoded as eight octets
1935  *valueLen = sizeof(StpBridgeId);
1936  }
1937 
1938  //Return status code
1939  return error;
1940 }
1941 
1942 
1943 /**
1944  * @brief Get dot1dStpPortDesignatedCost object value
1945  * @param[in] portNum Port number
1946  * @param[out] value Object value
1947  * @param[in,out] valueLen Length of the object value, in bytes
1948  * @return Error code
1949  **/
1950 
1952  MibVariant *value, size_t *valueLen)
1953 {
1954  error_t error;
1955  uint32_t designatedCost;
1956 
1957  //Initialize object value
1958  designatedCost = 0;
1959 
1960 #if (STP_SUPPORT == ENABLED)
1961  //Valid STP bridge context?
1962  if(bridgeMibBase.stpBridgeContext != NULL)
1963  {
1964  //This object specifies the path cost of the Designated Port of the
1965  //segment connected to this port
1967  portNum, &designatedCost);
1968  }
1969  else
1970 #endif
1971 #if (RSTP_SUPPORT == ENABLED)
1972  //Valid RSTP bridge context?
1973  if(bridgeMibBase.rstpBridgeContext != NULL)
1974  {
1975  //This object specifies the path cost of the Designated Port of the
1976  //segment connected to this port
1978  portNum, &designatedCost);
1979  }
1980  else
1981 #endif
1982  //Invalid bridge context?
1983  {
1984  //Report an error
1985  error = ERROR_READ_FAILED;
1986  }
1987 
1988  //Check status code
1989  if(!error)
1990  {
1991  //Return the value of the object
1992  value->integer = designatedCost;
1993  }
1994 
1995  //Return status code
1996  return error;
1997 }
1998 
1999 
2000 /**
2001  * @brief Get dot1dStpPortDesignatedBridge object value
2002  * @param[in] portNum Port number
2003  * @param[out] value Object value
2004  * @param[in,out] valueLen Length of the object value, in bytes
2005  * @return Error code
2006  **/
2007 
2009  MibVariant *value, size_t *valueLen)
2010 {
2011  error_t error;
2012  StpBridgeId designatedBridge;
2013 
2014  //Make sure the buffer is large enough to hold the entire object
2015  if(*valueLen < sizeof(StpBridgeId))
2016  return ERROR_BUFFER_OVERFLOW;
2017 
2018  //Initialize object value
2019  designatedBridge.priority = 0;
2020  designatedBridge.addr = MAC_UNSPECIFIED_ADDR;
2021 
2022 #if (STP_SUPPORT == ENABLED)
2023  //Valid STP bridge context?
2024  if(bridgeMibBase.stpBridgeContext != NULL)
2025  {
2026  //This object specifies the Bridge Identifier of the bridge that this
2027  //port considers to be the Designated Bridge for this port's segment
2029  portNum, &designatedBridge);
2030  }
2031  else
2032 #endif
2033 #if (RSTP_SUPPORT == ENABLED)
2034  //Valid RSTP bridge context?
2035  if(bridgeMibBase.rstpBridgeContext != NULL)
2036  {
2037  //This object specifies the Bridge Identifier of the bridge that this
2038  //port considers to be the Designated Bridge for this port's segment
2040  portNum, &designatedBridge);
2041  }
2042  else
2043 #endif
2044  //Invalid bridge context?
2045  {
2046  //Report an error
2047  error = ERROR_READ_FAILED;
2048  }
2049 
2050  //Check status code
2051  if(!error)
2052  {
2053  //Convert the priority field to network byte order
2054  designatedBridge.priority = htons(designatedBridge.priority);
2055  //Copy the bridge identifier
2056  osMemcpy(value->octetString, &designatedBridge, sizeof(StpBridgeId));
2057  //A bridge identifier shall be encoded as eight octets
2058  *valueLen = sizeof(StpBridgeId);
2059  }
2060 
2061  //Return status code
2062  return error;
2063 }
2064 
2065 
2066 /**
2067  * @brief Get dot1dStpPortDesignatedPort object value
2068  * @param[in] portNum Port number
2069  * @param[out] value Object value
2070  * @param[in,out] valueLen Length of the object value, in bytes
2071  * @return Error code
2072  **/
2073 
2075  MibVariant *value, size_t *valueLen)
2076 {
2077  error_t error;
2078  uint16_t designatedPort;
2079 
2080  //Make sure the buffer is large enough to hold the entire object
2081  if(*valueLen < sizeof(uint16_t))
2082  return ERROR_BUFFER_OVERFLOW;
2083 
2084  //Initialize object value
2085  designatedPort = 0;
2086 
2087 #if (STP_SUPPORT == ENABLED)
2088  //Valid STP bridge context?
2089  if(bridgeMibBase.stpBridgeContext != NULL)
2090  {
2091  //This object specifies the Port Identifier of the port on the Designated
2092  //Bridge for this port's segment
2094  portNum, &designatedPort);
2095  }
2096  else
2097 #endif
2098 #if (RSTP_SUPPORT == ENABLED)
2099  //Valid RSTP bridge context?
2100  if(bridgeMibBase.rstpBridgeContext != NULL)
2101  {
2102  //This object specifies the Port Identifier of the port on the Designated
2103  //Bridge for this port's segment
2105  portNum, &designatedPort);
2106  }
2107  else
2108 #endif
2109  //Invalid bridge context?
2110  {
2111  //Report an error
2112  error = ERROR_READ_FAILED;
2113  }
2114 
2115  //Check status code
2116  if(!error)
2117  {
2118  //Return the value of the object
2119  STORE16BE(designatedPort, value->octetString);
2120  //A Port Identifier shall be encoded as two octets
2121  *valueLen = sizeof(uint16_t);
2122  }
2123 
2124  //Return status code
2125  return error;
2126 }
2127 
2128 
2129 /**
2130  * @brief Get dot1dStpPortForwardTransitions object value
2131  * @param[in] portNum Port number
2132  * @param[out] value Object value
2133  * @param[in,out] valueLen Length of the object value, in bytes
2134  * @return Error code
2135  **/
2136 
2138  MibVariant *value, size_t *valueLen)
2139 {
2140  error_t error;
2141  uint_t forwardTransitions;
2142 
2143  //Initialize object value
2144  forwardTransitions = 0;
2145 
2146 #if (STP_SUPPORT == ENABLED)
2147  //Valid STP bridge context?
2148  if(bridgeMibBase.stpBridgeContext != NULL)
2149  {
2150  //The number of times this port has transitioned from the Learning state
2151  //to the Forwarding state
2153  portNum, &forwardTransitions);
2154  }
2155  else
2156 #endif
2157 #if (RSTP_SUPPORT == ENABLED)
2158  //Valid RSTP bridge context?
2159  if(bridgeMibBase.rstpBridgeContext != NULL)
2160  {
2161  //The number of times this port has transitioned from the Learning state
2162  //to the Forwarding state
2164  portNum, &forwardTransitions);
2165  }
2166  else
2167 #endif
2168  //Invalid bridge context?
2169  {
2170  //Report an error
2171  error = ERROR_READ_FAILED;
2172  }
2173 
2174  //Check status code
2175  if(!error)
2176  {
2177  //Return the value of the object
2178  value->integer = forwardTransitions;
2179  }
2180 
2181  //Return status code
2182  return error;
2183 }
2184 
2185 
2186 /**
2187  * @brief Set dot1dStpPortPathCost32 object value
2188  * @param[in] portNum Port number
2189  * @param[in] value Object value
2190  * @param[in] valueLen Length of the object value, in bytes
2191  * @param[in] commit This flag tells whether the changes shall be committed
2192  * to the MIB base
2193  * @return Error code
2194  **/
2195 
2197  const MibVariant *value, size_t valueLen, bool_t commit)
2198 {
2199  error_t error;
2200 
2201  //Ensure that the supplied value is valid
2202  if(value->integer >= 1)
2203  {
2204 #if (STP_SUPPORT == ENABLED)
2205  //Valid STP bridge context?
2206  if(bridgeMibBase.stpBridgeContext != NULL)
2207  {
2208  //This object specifies the contribution of this port to the path cost
2209  //of paths towards the spanning tree root which include this port
2211  portNum, value->integer, commit);
2212  }
2213  else
2214 #endif
2215 #if (RSTP_SUPPORT == ENABLED)
2216  //Valid RSTP bridge context?
2217  if(bridgeMibBase.rstpBridgeContext != NULL)
2218  {
2219  //This object specifies the contribution of this port to the path cost
2220  //of paths towards the spanning tree root which include this port
2222  portNum, value->integer, commit);
2223  }
2224  else
2225 #endif
2226  //Invalid bridge context?
2227  {
2228  //Report an error
2229  error = ERROR_WRITE_FAILED;
2230  }
2231  }
2232  else
2233  {
2234  //Report an error
2235  error = ERROR_WRONG_VALUE;
2236  }
2237 
2238  //Return status code
2239  return error;
2240 }
2241 
2242 
2243 /**
2244  * @brief Get dot1dStpPortPathCost32 object value
2245  * @param[in] portNum Port number
2246  * @param[out] value Object value
2247  * @param[in,out] valueLen Length of the object value, in bytes
2248  * @return Error code
2249  **/
2250 
2252  MibVariant *value, size_t *valueLen)
2253 {
2254  error_t error;
2255  uint32_t portPathCost;
2256 
2257  //Initialize object value
2258  portPathCost = 0;
2259 
2260 #if (STP_SUPPORT == ENABLED)
2261  //Valid STP bridge context?
2262  if(bridgeMibBase.stpBridgeContext != NULL)
2263  {
2264  //This object specifies the contribution of this port to the path cost
2265  //of paths towards the spanning tree root which include this port
2267  portNum, &portPathCost);
2268  }
2269  else
2270 #endif
2271 #if (RSTP_SUPPORT == ENABLED)
2272  //Valid RSTP bridge context?
2273  if(bridgeMibBase.rstpBridgeContext != NULL)
2274  {
2275  //This object specifies the contribution of this port to the path cost
2276  //of paths towards the spanning tree root which include this port
2278  portNum, &portPathCost);
2279  }
2280  else
2281 #endif
2282  //Invalid bridge context?
2283  {
2284  //Report an error
2285  error = ERROR_READ_FAILED;
2286  }
2287 
2288  //Check status code
2289  if(!error)
2290  {
2291  //Return the value of the object
2292  value->integer = portPathCost;
2293  }
2294 
2295  //Return status code
2296  return error;
2297 }
2298 
2299 #endif
ASN.1 (Abstract Syntax Notation One)
uint16_t bridgeMibGetPortNum(uint16_t portIndex)
Get the port number that matches the specified port index.
uint_t bridgeMibGetNumPorts(void)
Get the number of ports.
uint_t bridgeMibGetPortIndex(uint16_t portNum)
Get the port index that matches the specified port number.
Bridge MIB module implementation.
error_t bridgeMibSetDot1dStpPriority(const MibObject *object, const uint8_t *oid, size_t oidLen, const MibVariant *value, size_t valueLen, bool_t commit)
Set dot1dStpPriority object value.
error_t bridgeMibGetDot1dStpPortDesignatedPort(uint16_t portNum, MibVariant *value, size_t *valueLen)
Get dot1dStpPortDesignatedPort object value.
error_t bridgeMibGetDot1dStpTopChanges(const MibObject *object, const uint8_t *oid, size_t oidLen, MibVariant *value, size_t *valueLen)
Get dot1dStpTopChanges object value.
error_t bridgeMibSetDot1dStpPortPathCost(uint16_t portNum, const MibVariant *value, size_t valueLen, bool_t commit)
Set dot1dStpPortPathCost object value.
error_t bridgeMibGetDot1dStpPortState(uint16_t portNum, MibVariant *value, size_t *valueLen)
Get dot1dStpPortState object value.
error_t bridgeMibGetDot1dStpPortDesignatedCost(uint16_t portNum, MibVariant *value, size_t *valueLen)
Get dot1dStpPortDesignatedCost object value.
error_t bridgeMibSetDot1dStpPortPriority(uint16_t portNum, const MibVariant *value, size_t valueLen, bool_t commit)
Set dot1dStpPortPriority object value.
error_t bridgeMibGetDot1dStpPortDesignatedBridge(uint16_t portNum, MibVariant *value, size_t *valueLen)
Get dot1dStpPortDesignatedBridge object value.
error_t bridgeMibSetDot1dStpBridgeMaxAge(const MibObject *object, const uint8_t *oid, size_t oidLen, const MibVariant *value, size_t valueLen, bool_t commit)
Set dot1dStpBridgeMaxAge object value.
error_t bridgeMibSetDot1dStpPortPathCost32(uint16_t portNum, const MibVariant *value, size_t valueLen, bool_t commit)
Set dot1dStpPortPathCost32 object value.
error_t bridgeMibGetDot1dStpDesignatedRoot(const MibObject *object, const uint8_t *oid, size_t oidLen, MibVariant *value, size_t *valueLen)
Get dot1dStpDesignatedRoot object value.
error_t bridgeMibGetDot1dStpPortForwardTransitions(uint16_t portNum, MibVariant *value, size_t *valueLen)
Get dot1dStpPortForwardTransitions object value.
error_t bridgeMibSetDot1dStpBridgeForwardDelay(const MibObject *object, const uint8_t *oid, size_t oidLen, const MibVariant *value, size_t valueLen, bool_t commit)
Set dot1dStpBridgeForwardDelay object value.
error_t bridgeMibSetDot1dStpPortEnable(uint16_t portNum, const MibVariant *value, size_t valueLen, bool_t commit)
Set dot1dStpPortEnable object value.
error_t bridgeMibSetDot1dStpBridgeHelloTime(const MibObject *object, const uint8_t *oid, size_t oidLen, const MibVariant *value, size_t valueLen, bool_t commit)
Set dot1dStpBridgeHelloTime object value.
error_t bridgeMibGetDot1dStpHoldTime(const MibObject *object, const uint8_t *oid, size_t oidLen, MibVariant *value, size_t *valueLen)
Get dot1dStpHoldTime object value.
error_t bridgeMibGetDot1dStpRootCost(const MibObject *object, const uint8_t *oid, size_t oidLen, MibVariant *value, size_t *valueLen)
Get dot1dStpRootCost object value.
error_t bridgeMibGetNextDot1dStpPortEntry(const MibObject *object, const uint8_t *oid, size_t oidLen, uint8_t *nextOid, size_t *nextOidLen)
Get next dot1dStpPortEntry object.
error_t bridgeMibGetDot1dStpHelloTime(const MibObject *object, const uint8_t *oid, size_t oidLen, MibVariant *value, size_t *valueLen)
Get dot1dStpHelloTime object value.
error_t bridgeMibGetDot1dStpMaxAge(const MibObject *object, const uint8_t *oid, size_t oidLen, MibVariant *value, size_t *valueLen)
Get dot1dStpMaxAge object value.
error_t bridgeMibGetDot1dStpPortDesignatedRoot(uint16_t portNum, MibVariant *value, size_t *valueLen)
Get dot1dStpPortDesignatedRoot object value.
error_t bridgeMibGetDot1dStpPortPathCost32(uint16_t portNum, MibVariant *value, size_t *valueLen)
Get dot1dStpPortPathCost32 object value.
error_t bridgeMibGetDot1dStpPortEntry(const MibObject *object, const uint8_t *oid, size_t oidLen, MibVariant *value, size_t *valueLen)
Get dot1dStpPortEntry object value.
error_t bridgeMibGetDot1dStpPriority(const MibObject *object, const uint8_t *oid, size_t oidLen, MibVariant *value, size_t *valueLen)
Get dot1dStpPriority object value.
error_t bridgeMibGetDot1dStpBridgeHelloTime(const MibObject *object, const uint8_t *oid, size_t oidLen, MibVariant *value, size_t *valueLen)
Get dot1dStpBridgeHelloTime object value.
error_t bridgeMibGetDot1dStpForwardDelay(const MibObject *object, const uint8_t *oid, size_t oidLen, MibVariant *value, size_t *valueLen)
Get dot1dStpForwardDelay object value.
error_t bridgeMibGetDot1dStpBridgeForwardDelay(const MibObject *object, const uint8_t *oid, size_t oidLen, MibVariant *value, size_t *valueLen)
Get dot1dStpBridgeForwardDelay object value.
error_t bridgeMibGetDot1dStpPortPathCost(uint16_t portNum, MibVariant *value, size_t *valueLen)
Get dot1dStpPortPathCost object value.
error_t bridgeMibGetDot1dStpProtocolSpecification(const MibObject *object, const uint8_t *oid, size_t oidLen, MibVariant *value, size_t *valueLen)
Get dot1dStpProtocolSpecification object value.
error_t bridgeMibGetDot1dStpTimeSinceTopologyChange(const MibObject *object, const uint8_t *oid, size_t oidLen, MibVariant *value, size_t *valueLen)
Get dot1dStpTimeSinceTopologyChange object value.
error_t bridgeMibGetDot1dStpPortEnable(uint16_t portNum, MibVariant *value, size_t *valueLen)
Get dot1dStpPortEnable object value.
error_t bridgeMibGetDot1dStpPortPriority(uint16_t portNum, MibVariant *value, size_t *valueLen)
Get dot1dStpPortPriority object value.
error_t bridgeMibGetDot1dStpRootPort(const MibObject *object, const uint8_t *oid, size_t oidLen, MibVariant *value, size_t *valueLen)
Get dot1dStpRootPort object value.
error_t bridgeMibGetDot1dStpBridgeMaxAge(const MibObject *object, const uint8_t *oid, size_t oidLen, MibVariant *value, size_t *valueLen)
Get dot1dStpBridgeMaxAge object value.
error_t bridgeMibSetDot1dStpPortEntry(const MibObject *object, const uint8_t *oid, size_t oidLen, const MibVariant *value, size_t valueLen, bool_t commit)
Set dot1dStpPortEntry object value.
BridgeMibBase bridgeMibBase
Bridge MIB base.
Bridge MIB module.
@ BRIDGE_MIB_PORT_STATUS_ENABLED
@ BRIDGE_MIB_PORT_STATUS_DISABLED
@ BRIDGE_MIB_PORT_STATE_LEARNING
@ BRIDGE_MIB_PORT_STATE_FORWARDING
@ BRIDGE_MIB_PORT_STATE_BROKEN
@ BRIDGE_MIB_PORT_STATE_BLOCKING
@ BRIDGE_MIB_PORT_STATE_UNKNOWN
@ BRIDGE_MIB_PORT_STATE_LISTENING
@ BRIDGE_MIB_PORT_STATE_DISABLED
unsigned int uint_t
Definition: compiler_port.h:50
int bool_t
Definition: compiler_port.h:53
#define htons(value)
Definition: cpu_endian.h:413
#define STORE16BE(a, p)
Definition: cpu_endian.h:262
General definitions for cryptographic algorithms.
Debugging facilities.
uint8_t n
error_t
Error codes.
Definition: error.h:43
@ ERROR_WRITE_FAILED
Definition: error.h:221
@ ERROR_OBJECT_NOT_FOUND
Definition: error.h:255
@ ERROR_INSTANCE_NOT_FOUND
Definition: error.h:256
@ ERROR_WRONG_VALUE
Definition: error.h:123
@ NO_ERROR
Success.
Definition: error.h:44
@ ERROR_BUFFER_OVERFLOW
Definition: error.h:142
@ ERROR_READ_FAILED
Definition: error.h:222
const MacAddr MAC_UNSPECIFIED_ADDR
Definition: ethernet.c:53
uint8_t oid[]
Definition: lldp_tlv.h:300
uint8_t oidLen
Definition: lldp_tlv.h:299
error_t mibDecodePort(const uint8_t *oid, size_t oidLen, size_t *pos, uint16_t *port)
Decode instance identifier (port number)
Definition: mib_common.c:495
error_t mibEncodeIndex(uint8_t *oid, size_t maxOidLen, size_t *pos, uint_t index)
Encode instance identifier (index)
Definition: mib_common.c:47
Common definitions for MIB modules.
#define MibObject
Definition: mib_common.h:46
MibVariant
Definition: mib_common.h:196
TCP/IP stack core.
int_t oidComp(const uint8_t *oid1, size_t oidLen1, const uint8_t *oid2, size_t oidLen2)
Compare object identifiers.
Definition: oid.c:103
OID (Object Identifier)
#define osMemcpy(dest, src, length)
Definition: os_port.h:141
#define MIN(a, b)
Definition: os_port.h:63
#define TRUE
Definition: os_port.h:50
#define FALSE
Definition: os_port.h:46
RSTP (Rapid Spanning Tree Protocol)
#define RstpBridgeContext
Definition: rstp.h:36
uint16_t forwardDelay
Definition: rstp_bpdu.h:109
uint16_t helloTime
Definition: rstp_bpdu.h:108
uint16_t maxAge
Definition: rstp_bpdu.h:107
uint32_t rootPathCost
Definition: rstp_bpdu.h:103
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 rstpMgmtGetBridgeMaxAge(RstpBridgeContext *context, uint_t *value)
Get the assigned value of the Bridge Max Age parameter.
Definition: rstp_mgmt.c:520
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 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 rstpMgmtGetBridgeForwardDelay(RstpBridgeContext *context, uint_t *value)
Get the assigned value of the Bridge Forward Delay parameter.
Definition: rstp_mgmt.c:562
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 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 rstpMgmtGetHelloTime(RstpBridgeContext *context, uint_t *value)
Get the current Hello Time value.
Definition: rstp_mgmt.c:712
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 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 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
Management of the RSTP bridge.
STP (Spanning Tree Protocol)
StpBridgeId
Definition: stp_common.h:148
StpPortState
Port states.
Definition: stp_common.h:108
@ STP_PORT_STATE_BLOCKING
Definition: stp_common.h:111
@ STP_PORT_STATE_LEARNING
Definition: stp_common.h:113
@ STP_PORT_STATE_LISTENING
Definition: stp_common.h:112
@ STP_PORT_STATE_BROKEN
Definition: stp_common.h:110
@ STP_PORT_STATE_FORWARDING
Definition: stp_common.h:114
@ STP_PORT_STATE_DISABLED
Definition: stp_common.h:109
error_t stpMgmtGetTimeSinceTopologyChange(StpBridgeContext *context, uint_t *value)
Get the time since a topology change was last detected.
Definition: stp_mgmt.c:676
error_t stpMgmtGetDesignatedRoot(StpBridgeContext *context, StpBridgeId *value)
Get the bridge identifier of the root of the spanning tree.
Definition: stp_mgmt.c:523
error_t stpMgmtGetBridgePriority(StpBridgeContext *context, uint16_t *value)
Get the assigned bridge priority.
Definition: stp_mgmt.c:397
error_t stpMgmtGetForwardTransitions(StpBridgeContext *context, uint_t portIndex, uint_t *value)
Get the number of times the port has transitioned to Forwarding state.
Definition: stp_mgmt.c:1356
error_t stpMgmtGetHelloTime(StpBridgeContext *context, uint_t *value)
Get the current Hello Time value.
Definition: stp_mgmt.c:610
error_t stpMgmtGetAdminPortState(StpBridgeContext *context, uint_t portIndex, bool_t *value)
Get the administrative port state.
Definition: stp_mgmt.c:999
error_t stpMgmtGetBridgeHelloTime(StpBridgeContext *context, uint_t *value)
Get the assigned value of the Bridge Hello Time parameter.
Definition: stp_mgmt.c:439
error_t stpMgmtSetBridgeHelloTime(StpBridgeContext *context, uint_t value, bool_t commit)
Set Bridge Hello Time parameter.
Definition: stp_mgmt.c:198
error_t stpMgmtSetBridgeMaxAge(StpBridgeContext *context, uint_t value, bool_t commit)
Set Bridge Max Age parameter.
Definition: stp_mgmt.c:137
error_t stpMgmtGetBridgeMaxAge(StpBridgeContext *context, uint_t *value)
Get the assigned value of the Bridge Max Age parameter.
Definition: stp_mgmt.c:418
error_t stpMgmtGetRootPort(StpBridgeContext *context, uint16_t *value)
Get the current root port.
Definition: stp_mgmt.c:566
error_t stpMgmtGetPortDesignatedPort(StpBridgeContext *context, uint_t portIndex, uint16_t *value)
Get the port identifier of the designated bridge.
Definition: stp_mgmt.c:1323
error_t stpMgmtGetHoldTime(StpBridgeContext *context, uint_t *value)
Get the assigned value of the Hold Time parameter.
Definition: stp_mgmt.c:481
error_t stpMgmtSetBridgePriority(StpBridgeContext *context, uint16_t value, bool_t commit)
Set bridge priority.
Definition: stp_mgmt.c:55
error_t stpMgmtGetPortPriority(StpBridgeContext *context, uint_t portIndex, uint8_t *value)
Get the priority assigned to the port.
Definition: stp_mgmt.c:967
error_t stpMgmtSetBridgeForwardDelay(StpBridgeContext *context, uint_t value, bool_t commit)
Set Bridge Forward Delay parameter.
Definition: stp_mgmt.c:253
error_t stpMgmtSetAdminPortState(StpBridgeContext *context, uint_t portIndex, bool_t value, bool_t commit)
Set administrative bridge port state.
Definition: stp_mgmt.c:774
error_t stpMgmtGetPortState(StpBridgeContext *context, uint_t portIndex, StpPortState *value)
Get the current state of the port.
Definition: stp_mgmt.c:1096
error_t stpMgmtGetPortDesignatedCost(StpBridgeContext *context, uint_t portIndex, uint32_t *value)
Get the designated cost of the port.
Definition: stp_mgmt.c:1257
error_t stpMgmtGetTopologyChanges(StpBridgeContext *context, uint_t *value)
Get the number of topology changes.
Definition: stp_mgmt.c:655
error_t stpMgmtGetForwardDelay(StpBridgeContext *context, uint_t *value)
Get the current Forward Delay value.
Definition: stp_mgmt.c:633
error_t stpMgmtGetPortDesignatedRoot(StpBridgeContext *context, uint_t portIndex, StpBridgeId *value)
Get the bridge identifier of the designated root bridge.
Definition: stp_mgmt.c:1223
error_t stpMgmtGetBridgeForwardDelay(StpBridgeContext *context, uint_t *value)
Get the assigned value of the Bridge Forward Delay parameter.
Definition: stp_mgmt.c:460
error_t stpMgmtSetPortPathCost(StpBridgeContext *context, uint_t portIndex, uint32_t value, bool_t commit)
Set administrative port path cost.
Definition: stp_mgmt.c:886
error_t stpMgmtGetRootPathCost(StpBridgeContext *context, uint32_t *value)
Get the current cost of the path to the root.
Definition: stp_mgmt.c:545
error_t stpMgmtGetMaxAge(StpBridgeContext *context, uint_t *value)
Get the current Max Age value.
Definition: stp_mgmt.c:588
error_t stpMgmtGetPortDesignatedBridge(StpBridgeContext *context, uint_t portIndex, StpBridgeId *value)
Get the bridge identifier of the designated bridge.
Definition: stp_mgmt.c:1290
error_t stpMgmtSetPortPriority(StpBridgeContext *context, uint_t portIndex, uint8_t value, bool_t commit)
Set port priority.
Definition: stp_mgmt.c:702
error_t stpMgmtGetPortPathCost(StpBridgeContext *context, uint_t portIndex, uint32_t *value)
Get the current value of the port path cost.
Definition: stp_mgmt.c:1063
Management of the STP bridge.
StpBridgeContext * stpBridgeContext
int32_t dot1dStpProtocolSpecification
RstpBridgeContext * rstpBridgeContext
uint8_t value[]
Definition: tcp.h:369