1 /* 2 * mstp.h State machines from IEEE 802.1Q-2005 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License 6 * as published by the Free Software Foundation; either version 7 * 2 of the License, or (at your option) any later version. 8 * 9 * Authors: Vitalii Demianets <dvitasgs@gmail.com> 10 */ 11 12 #ifndef MSTP_H 13 #define MSTP_H 14 15 #include <sys/types.h> 16 #include <stdlib.h> 17 #include <libubox/list.h> 18 19 #include "bridge_ctl.h" 20 21 /* #define HMAC_MDS_TEST_FUNCTIONS */ 22 23 /* Useful macro for counting number of elements in array */ 24 #define COUNT_OF(x) ((sizeof(x)/sizeof(0[x])) / ((size_t)(!(sizeof(x) % sizeof(0[x]))))) 25 26 /* 27 * assign() and cmp() macros that also do strict type-checking. See the 28 * "unnecessary" pointer comparison. 29 * NOTE: potential double-evaluation of the first argument in assign macro! 30 * It is the price for type-safety ;) 31 */ 32 #define assign(x, y) ({ \ 33 typeof(x) _assign1 = (x); \ 34 typeof(y) _assign2 = (y); \ 35 (void)(&_assign1 == &_assign2); \ 36 (x) = _assign2; }) 37 #define _ncmp(x, y) ({ \ 38 typeof(x) _cmp1 = (x); \ 39 typeof(y) _cmp2 = (y); \ 40 (void)(&_cmp1 == &_cmp2); \ 41 memcmp(&_cmp1, &_cmp2, sizeof(_cmp1)); }) 42 #define cmp(x, _op, y) (_ncmp((x), (y)) _op 0) 43 44 /* 13.7, Table 13-1 */ 45 #define HMAC_KEY {0x13, 0xAC, 0x06, 0xA6, 0x2E, 0x47, 0xFD, 0x51, \ 46 0xF9, 0x5D, 0x2B, 0xA2, 0x43, 0xCD, 0x03, 0x46} 47 extern void hmac_md5(unsigned char * text, int text_len, unsigned char * key, 48 int key_len, caddr_t digest); 49 #ifdef HMAC_MDS_TEST_FUNCTIONS 50 extern bool MD5TestSuite(void); 51 #endif /* HMAC_MDS_TEST_FUNCTIONS */ 52 53 #define MAX_PORT_NUMBER 4095 54 #define MAX_VID 4094 55 #define MAX_FID 4095 56 #define MAX_MSTID 4094 57 58 /* MAX_xxx_MSTIS: CIST not counted */ 59 #define MAX_STANDARD_MSTIS 64 60 #define MAX_IMPLEMENTATION_MSTIS 63 61 62 /* 13.37.1 */ 63 #define MAX_PATH_COST 200000000u 64 65 typedef union 66 { 67 __u64 u; 68 struct 69 { 70 __be16 priority; 71 __u8 mac_address[ETH_ALEN]; 72 } __attribute__((packed)) s; 73 } bridge_identifier_t; 74 75 typedef __be16 port_identifier_t; 76 77 /* in steps of 4096, as in MSTP_IN_set_msti_bridge_config */ 78 #define DEFAULT_BRIDGE_PRIORITY 8 79 80 /* These macros work well for both PortID and BridgeID */ 81 #define GET_PRIORITY_FROM_IDENTIFIER(id) (((__u8 *)(&(id)))[0] & 0xF0) 82 #define SET_PRIORITY_IN_IDENTIFIER(pri, id) do{ \ 83 __u8 *first_octet = (__u8 *)(&(id)); \ 84 *first_octet &= 0x0F; \ 85 *first_octet |= (pri) & 0xF0; \ 86 }while(0) 87 88 #define CONFIGURATION_NAME_LEN 32 89 #define CONFIGURATION_DIGEST_LEN 16 90 typedef union 91 { 92 __u8 a[1 + CONFIGURATION_NAME_LEN + 2 + CONFIGURATION_DIGEST_LEN]; 93 struct 94 { 95 __u8 selector; /* always 0 */ 96 __u8 configuration_name[CONFIGURATION_NAME_LEN]; 97 __be16 revision_level; 98 __u8 configuration_digest[CONFIGURATION_DIGEST_LEN]; 99 } __attribute__((packed)) s; 100 } __attribute__((packed)) mst_configuration_identifier_t; 101 102 typedef struct 103 { 104 bridge_identifier_t RRootID; 105 __be32 IntRootPathCost; 106 bridge_identifier_t DesignatedBridgeID; 107 port_identifier_t DesignatedPortID; 108 /* not used for MSTIs, only for CIST */ 109 bridge_identifier_t RootID; 110 __be32 ExtRootPathCost; 111 } port_priority_vector_t; 112 113 typedef struct 114 { 115 __u8 remainingHops; 116 /* not used for MSTIs, only for CIST */ 117 __u8 Forward_Delay; 118 __u8 Max_Age; 119 __u8 Message_Age; 120 __u8 Hello_Time; 121 } times_t; 122 123 typedef struct 124 { 125 /* see bpduFlagOffset_t enum for offsets of flag bits */ 126 __u8 flags; 127 bridge_identifier_t mstiRRootID; 128 __be32 mstiIntRootPathCost; 129 /* only bits 7..4, bits 3..0 are zero on Tx and ignored on Rx */ 130 __u8 bridgeIdentifierPriority; 131 /* only bits 7..4, bits 3..0 are zero on Tx and ignored on Rx */ 132 __u8 portIdentifierPriority; 133 __u8 remainingHops; 134 } __attribute__((packed)) msti_configuration_message_t; 135 136 typedef struct 137 { 138 /* always zero for the Spanning Tree BPDUs */ 139 __be16 protocolIdentifier; 140 /* protoSTP for the Config and TCN 141 * protoRSTP for the RST 142 * protoMSTP for the MST 143 * (see protocol_version_t enum) */ 144 __u8 protocolVersion; 145 /* values are defined in bpduType_t enum */ 146 __u8 bpduType; 147 /* TCN BPDU ends here */ 148 /* see bpduFlagOffset_t enum for offsets of flag bits */ 149 __u8 flags; 150 bridge_identifier_t cistRootID; 151 __be32 cistExtRootPathCost; 152 bridge_identifier_t cistRRootID; 153 port_identifier_t cistPortID; 154 __u8 MessageAge[2]; 155 __u8 MaxAge[2]; 156 __u8 HelloTime[2]; 157 __u8 ForwardDelay[2]; 158 /* Config BPDU ends here */ 159 __u8 version1_len; /* always zero */ 160 /* RST BPDU ends here */ 161 __be16 version3_len; 162 mst_configuration_identifier_t mstConfigurationIdentifier; 163 __be32 cistIntRootPathCost; 164 bridge_identifier_t cistBridgeID; 165 __u8 cistRemainingHops; 166 msti_configuration_message_t mstConfiguration[MAX_STANDARD_MSTIS]; 167 } __attribute__((packed)) bpdu_t; 168 169 #define TCN_BPDU_SIZE offsetof(bpdu_t, flags) 170 #define CONFIG_BPDU_SIZE offsetof(bpdu_t, version1_len) 171 #define RST_BPDU_SIZE offsetof(bpdu_t, version3_len) 172 #define MST_BPDU_SIZE_WO_MSTI_MSGS offsetof(bpdu_t, mstConfiguration) 173 #define MST_BPDU_VER3LEN_WO_MSTI_MSGS (MST_BPDU_SIZE_WO_MSTI_MSGS \ 174 - offsetof(bpdu_t, mstConfigurationIdentifier)) 175 176 typedef enum 177 { 178 OtherInfo, 179 SuperiorDesignatedInfo, 180 RepeatedDesignatedInfo, 181 InferiorDesignatedInfo, 182 InferiorRootAlternateInfo 183 } port_info_t; 184 185 typedef enum 186 { 187 ioDisabled, 188 ioMine, 189 ioAged, 190 ioReceived 191 } port_info_origin_t; 192 193 typedef enum 194 { 195 roleDisabled, 196 roleRoot, 197 roleDesignated, 198 roleAlternate, 199 roleBackup, 200 roleMaster 201 } port_role_t; 202 203 typedef enum 204 { 205 encodedRoleMaster = 0, 206 encodedRoleAlternateBackup = 1, 207 encodedRoleRoot = 2, 208 encodedRoleDesignated = 3 209 } port_encoded_role_t; 210 211 typedef enum 212 { 213 protoSTP = 0, 214 protoRSTP = 2, 215 protoMSTP = 3 216 } protocol_version_t; 217 218 typedef enum 219 { 220 bpduTypeConfig = 0, 221 bpduTypeRST = 2, 222 bpduTypeTCN = 128 223 } bpduType_t; 224 225 typedef enum 226 { 227 offsetTc = 0, 228 offsetProposal = 1, 229 offsetRole = 2, /* actually, role is coded in two-bit field */ 230 offsetRole1 = 3, /* second bit of two-bit role field */ 231 offsetLearnig = 4, 232 offsetForwarding = 5, 233 offsetAgreement = 6, 234 offsetTcAck = 7 235 /* in MSTI Configuration Message flags bit7 is used for Master flag */ 236 #define offsetMaster offsetTcAck 237 } bpduFlagOffset_t; 238 239 #define BPDU_FLAGS_ROLE_SET(role) (((role) & 3) << offsetRole) 240 #define BPDU_FLAGS_ROLE_GET(flags) (((flags) >> offsetRole) & 3) 241 242 typedef enum 243 { 244 p2pAuto, 245 p2pForceTrue, 246 p2pForceFalse 247 } 248 admin_p2p_t; 249 250 /* 13.28 Port Receive state machine */ 251 typedef enum 252 { 253 PRSM_DISCARD, 254 PRSM_RECEIVE 255 } PRSM_states_t; 256 257 /* 13.29 Port Protocol Migration state machine */ 258 typedef enum 259 { 260 PPMSM_CHECKING_RSTP, 261 PPMSM_SELECTING_STP, 262 PPMSM_SENSING 263 } PPMSM_states_t; 264 265 /* 13.30 Bridge Detection state machine */ 266 typedef enum 267 { 268 BDSM_EDGE, 269 BDSM_NOT_EDGE 270 } BDSM_states_t; 271 272 /* 13.31 Port Transmit state machine */ 273 typedef enum 274 { 275 PTSM_TRANSMIT_INIT, 276 PTSM_TRANSMIT_CONFIG, 277 PTSM_TRANSMIT_TCN, 278 PTSM_TRANSMIT_RSTP, 279 PTSM_TRANSMIT_PERIODIC, 280 PTSM_IDLE 281 } PTSM_states_t; 282 283 /* 13.32 Port Information state machine */ 284 /* #define PISM_ENABLE_LOG */ 285 typedef enum 286 { 287 PISM_DISABLED, 288 PISM_AGED, 289 PISM_UPDATE, 290 PISM_SUPERIOR_DESIGNATED, 291 PISM_REPEATED_DESIGNATED, 292 PISM_INFERIOR_DESIGNATED, 293 PISM_NOT_DESIGNATED, 294 PISM_OTHER, 295 PISM_CURRENT, 296 PISM_RECEIVE 297 } PISM_states_t; 298 299 /* 13.33 Port Role Selection state machine */ 300 typedef enum 301 { 302 PRSSM_INIT_TREE, 303 PRSSM_ROLE_SELECTION 304 } PRSSM_states_t; 305 306 /* 13.34 Port Role Transitions state machine */ 307 /* #define PRTSM_ENABLE_LOG */ 308 typedef enum 309 { 310 /* Disabled Port role transitions */ 311 PRTSM_INIT_PORT, 312 PRTSM_DISABLE_PORT, 313 PRTSM_DISABLED_PORT, 314 /* MasterPort role transitions */ 315 PRTSM_MASTER_PROPOSED, 316 PRTSM_MASTER_AGREED, 317 PRTSM_MASTER_SYNCED, 318 PRTSM_MASTER_RETIRED, 319 PRTSM_MASTER_FORWARD, 320 PRTSM_MASTER_LEARN, 321 PRTSM_MASTER_DISCARD, 322 PRTSM_MASTER_PORT, 323 /* RootPort role transitions */ 324 PRTSM_ROOT_PROPOSED, 325 PRTSM_ROOT_AGREED, 326 PRTSM_ROOT_SYNCED, 327 PRTSM_REROOT, 328 PRTSM_ROOT_FORWARD, 329 PRTSM_ROOT_LEARN, 330 PRTSM_REROOTED, 331 PRTSM_ROOT_PORT, 332 /* DesignatedPort role transitions */ 333 PRTSM_DESIGNATED_PROPOSE, 334 PRTSM_DESIGNATED_AGREED, 335 PRTSM_DESIGNATED_SYNCED, 336 PRTSM_DESIGNATED_RETIRED, 337 PRTSM_DESIGNATED_FORWARD, 338 PRTSM_DESIGNATED_LEARN, 339 PRTSM_DESIGNATED_DISCARD, 340 PRTSM_DESIGNATED_PORT, 341 /* AlternatePort and BackupPort role transitions */ 342 PRTSM_BLOCK_PORT, 343 PRTSM_BACKUP_PORT, 344 PRTSM_ALTERNATE_PROPOSED, 345 PRTSM_ALTERNATE_AGREED, 346 PRTSM_ALTERNATE_PORT 347 } PRTSM_states_t; 348 349 /* 13.35 Port State Transition state machine */ 350 typedef enum 351 { 352 PSTSM_DISCARDING, 353 PSTSM_LEARNING, 354 PSTSM_FORWARDING 355 } PSTSM_states_t; 356 357 /* 13.36 Topology Change state machine */ 358 typedef enum 359 { 360 TCSM_INACTIVE, 361 TCSM_LEARNING, 362 TCSM_DETECTED, 363 TCSM_NOTIFIED_TCN, 364 TCSM_NOTIFIED_TC, 365 TCSM_PROPAGATING, 366 TCSM_ACKNOWLEDGED, 367 TCSM_ACTIVE 368 } TCSM_states_t; 369 370 /* 371 * Following standard-defined variables are not defined as variables. 372 * Their functionality is implemented indirectly by other means: 373 * - BEGIN, tick, ageingTime. 374 */ 375 376 typedef struct 377 { 378 struct list_head list; /* anchor in global list of bridges */ 379 380 /* List of all ports */ 381 struct list_head ports; 382 /* List of all tree instances, first in list (trees.next) is CIST */ 383 struct list_head trees; 384 #define GET_CIST_TREE(br) list_entry((br)->trees.next, tree_t, bridge_list) 385 386 bool bridgeEnabled; 387 388 /* Per-bridge configuration parameters */ 389 mst_configuration_identifier_t MstConfigId; /* 13.24.b */ 390 protocol_version_t ForceProtocolVersion; /* 13.22.e */ 391 __u8 MaxHops; /* 13.22.o */ 392 __u8 Forward_Delay; /* 13.22.f */ 393 __u8 Max_Age; /* 13.22.i */ 394 /* The 802.1Q-2005 (13.22.j) says that this parameter is substituted by 395 * the per-port Hello Time, but we still need it for compatibility 396 * with old STP implementations. 397 */ 398 __u8 Hello_Time; 399 unsigned int Transmit_Hold_Count; /* 13.22.g */ 400 unsigned int Migrate_Time; /* 13.22.h */ 401 unsigned int Ageing_Time; /* 8.8.3 */ 402 403 __u16 vid2fid[MAX_VID + 1]; 404 __be16 fid2mstid[MAX_FID + 1]; 405 406 /* not in standard */ 407 unsigned int uptime; 408 409 sysdep_br_data_t sysdeps; 410 } bridge_t; 411 412 typedef struct 413 { 414 struct list_head bridge_list; /* anchor in bridge's list of trees */ 415 bridge_t * bridge; 416 __be16 MSTID; /* 0 == CIST */ 417 418 /* List of the per-port data structures for this tree instance */ 419 struct list_head ports; 420 421 /* 13.23.(c,f,g) Per-bridge per-tree variables */ 422 bridge_identifier_t BridgeIdentifier; 423 port_identifier_t rootPortId; 424 port_priority_vector_t rootPriority; 425 426 /* 13.23.d This is totally calculated from BridgeIdentifier */ 427 port_priority_vector_t BridgePriority; 428 429 /* 13.23.e Some waste of space here, as MSTIs only use 430 * remainingHops member of the struct times_t, 431 * but saves extra checks and improves readability */ 432 times_t BridgeTimes, rootTimes; 433 434 /* 12.8.1.1.3.(b,c,d) */ 435 unsigned int time_since_topology_change; 436 unsigned int topology_change_count; 437 bool topology_change; 438 char topology_change_port[IFNAMSIZ]; 439 char last_topology_change_port[IFNAMSIZ]; 440 441 /* State machines */ 442 PRSSM_states_t PRSSM_state; 443 444 } tree_t; 445 446 typedef struct 447 { 448 struct list_head br_list; /* anchor in bridge's list of ports */ 449 bridge_t * bridge; 450 __be16 port_number; 451 452 /* List of all tree instances, first in list (trees.next) is CIST. 453 * List is sorted by MSTID (by insertion procedure MSTP_IN_create_msti). 454 */ 455 struct list_head trees; 456 #define GET_CIST_PTP_FROM_PORT(prt) \ 457 list_entry((prt)->trees.next, per_tree_port_t, port_list) 458 459 /* 13.21.(a,b,c) Per-port timers */ 460 unsigned int mdelayWhile, helloWhen, edgeDelayWhile; 461 462 /* 13.24.(b,c,e,f,g,j,k,l,m,n,o,p,q,r,aw) Per-port variables */ 463 unsigned int txCount; 464 bool operEdge, portEnabled, infoInternal, rcvdInternal; 465 bool mcheck, rcvdBpdu, rcvdRSTP, rcvdSTP, rcvdTcAck, rcvdTcn, sendRSTP; 466 bool tcAck, newInfo, newInfoMsti; 467 468 /* 6.4.3 */ 469 bool operPointToPointMAC; 470 471 /* Per-port configuration parameters */ 472 bool restrictedRole, restrictedTcn; /* 13.24.(h,i) */ 473 __u32 ExternalPortPathCost; /* 13.22.p */ 474 __u32 AdminExternalPortPathCost; /* 0 = calculate from speed */ 475 admin_p2p_t AdminP2P; /* 6.4.3 */ 476 bool AdminEdgePort; /* 13.22.k */ 477 bool AutoEdge; /* 13.22.m */ 478 bool BpduGuardPort; 479 bool BpduGuardError; 480 bool NetworkPort; 481 bool BaInconsistent; 482 bool dontTxmtBpdu; 483 bool bpduFilterPort; 484 485 unsigned int rapidAgeingWhile; 486 unsigned int brAssuRcvdInfoWhile; 487 488 /* State machines */ 489 PRSM_states_t PRSM_state; 490 PPMSM_states_t PPMSM_state; 491 BDSM_states_t BDSM_state; 492 PTSM_states_t PTSM_state; 493 494 /* Copy of the received BPDU */ 495 bpdu_t rcvdBpduData; 496 int rcvdBpduNumOfMstis; 497 498 bool deleted; 499 500 sysdep_if_data_t sysdeps; 501 unsigned int num_rx_bpdu_filtered; 502 unsigned int num_rx_bpdu; 503 unsigned int num_rx_tcn; 504 unsigned int num_tx_bpdu; 505 unsigned int num_tx_tcn; 506 unsigned int num_trans_fwd; 507 unsigned int num_trans_blk; 508 } port_t; 509 510 typedef struct 511 { 512 struct list_head port_list; /* anchor in port's list of trees */ 513 struct list_head tree_list; /* anchor in tree's list of per-port data */ 514 port_t *port; 515 tree_t *tree; 516 __be16 MSTID; /* 0 == CIST */ 517 518 int state; /* BR_STATE_xxx */ 519 520 /* 13.21.(d,e,f,g,h) Per-port per-tree timers */ 521 unsigned int fdWhile, rrWhile, rbWhile, tcWhile, rcvdInfoWhile; 522 523 /* 13.24.(s,t,u,v,w,x,y,z,aa,ab,ac,ad,ae,af,ag,ai,aj,ak,ap,as,at,au,av) 524 * Per-port per-tree variables */ 525 bool agree, agreed, disputed, forward, forwarding, learn, learning; 526 port_info_t rcvdInfo; 527 port_info_origin_t infoIs; 528 bool proposed, proposing, rcvdMsg, rcvdTc, reRoot, reselect, selected; 529 bool fdbFlush, tcProp, updtInfo, sync, synced; 530 port_identifier_t portId; 531 port_role_t role, selectedRole; 532 533 /* 13.24.(al,an,aq) Some waste of space here, as MSTIs don't use 534 * RootID and ExtRootPathCost members of the struct port_priority_vector_t, 535 * but saves extra checks and improves readability */ 536 port_priority_vector_t designatedPriority, msgPriority, portPriority; 537 538 /* 13.24.(am,ao,ar) Some waste of space here, as MSTIs only use 539 * remainingHops member of the struct times_t, 540 * but saves extra checks and improves readability */ 541 times_t designatedTimes, msgTimes, portTimes; 542 543 /* 13.24.(ax,ay) Per-port per-MSTI variables, not applicable to CIST */ 544 bool master, mastered; 545 546 /* Per-port per-tree configuration parameters */ 547 __u32 InternalPortPathCost; /* 13.22.q */ 548 __u32 AdminInternalPortPathCost; /* 0 = calculate from speed */ 549 550 /* not in standard, used for calculation of port uptime */ 551 unsigned int start_time; 552 553 /* State machines */ 554 PISM_states_t PISM_state; 555 PRTSM_states_t PRTSM_state; 556 PSTSM_states_t PSTSM_state; 557 TCSM_states_t TCSM_state; 558 559 /* Auxiliary flag, helps preventing infinite recursion */ 560 bool calledFromFlushRoutine; 561 562 /* Pointer to the corresponding MSTI Configuration Message 563 * in the port->rcvdBpduData */ 564 msti_configuration_message_t *rcvdMstiConfig; 565 } per_tree_port_t; 566 567 /* External events (inputs) */ 568 bool MSTP_IN_bridge_create(bridge_t *br, __u8 *macaddr); 569 bool MSTP_IN_port_create_and_add_tail(port_t *prt, __u16 portno); 570 void MSTP_IN_delete_port(port_t *prt); 571 void MSTP_IN_delete_bridge(bridge_t *br); 572 void MSTP_IN_set_bridge_address(bridge_t *br, __u8 *macaddr); 573 void MSTP_IN_set_bridge_enable(bridge_t *br, bool up); 574 void MSTP_IN_set_port_enable(port_t *prt, bool up, int speed, int duplex); 575 void MSTP_IN_one_second(bridge_t *br); 576 void MSTP_IN_all_fids_flushed(per_tree_port_t *ptp); 577 void MSTP_IN_rx_bpdu(port_t *prt, bpdu_t *bpdu, int size); 578 579 bool MSTP_IN_set_vid2fid(bridge_t *br, __u16 vid, __u16 fid); 580 bool MSTP_IN_set_all_vids2fids(bridge_t *br, __u16 *vids2fids); 581 bool MSTP_IN_set_fid2mstid(bridge_t *br, __u16 fid, __u16 mstid); 582 bool MSTP_IN_set_all_fids2mstids(bridge_t *br, __u16 *fids2mstids); 583 bool MSTP_IN_get_mstilist(bridge_t *br, int *num_mstis, __u16 *mstids); 584 bool MSTP_IN_create_msti(bridge_t *br, __u16 mstid); 585 bool MSTP_IN_delete_msti(bridge_t *br, __u16 mstid); 586 void MSTP_IN_set_mst_config_id(bridge_t *br, __u16 revision, __u8 *name); 587 588 /* External actions (outputs) */ 589 void MSTP_OUT_set_state(per_tree_port_t *ptp, int new_state); 590 void MSTP_OUT_flush_all_fids(per_tree_port_t *ptp); 591 void MSTP_OUT_set_ageing_time(port_t *prt, unsigned int ageingTime); 592 void MSTP_OUT_tx_bpdu(port_t *prt, bpdu_t *bpdu, int size); 593 void MSTP_OUT_shutdown_port(port_t *prt); 594 595 /* Structures for communicating with user */ 596 /* 12.8.1.1 Read CIST Bridge Protocol Parameters */ 597 typedef struct 598 { 599 bridge_identifier_t bridge_id; 600 unsigned int time_since_topology_change; 601 unsigned int topology_change_count; 602 bool topology_change; 603 char topology_change_port[IFNAMSIZ]; 604 char last_topology_change_port[IFNAMSIZ]; 605 bridge_identifier_t designated_root; 606 unsigned int root_path_cost; 607 port_identifier_t root_port_id; 608 __u8 root_max_age; 609 __u8 root_forward_delay; 610 __u8 bridge_max_age; 611 __u8 bridge_forward_delay; 612 unsigned int tx_hold_count; 613 protocol_version_t protocol_version; 614 bridge_identifier_t regional_root; 615 unsigned int internal_path_cost; 616 bool enabled; /* not in standard */ 617 unsigned int Ageing_Time; 618 __u8 max_hops; 619 __u8 bridge_hello_time; 620 } CIST_BridgeStatus; 621 622 void MSTP_IN_get_cist_bridge_status(bridge_t *br, CIST_BridgeStatus *status); 623 624 /* 12.8.1.2 Read MSTI Bridge Protocol Parameters */ 625 typedef struct 626 { 627 bridge_identifier_t bridge_id; 628 unsigned int time_since_topology_change; 629 unsigned int topology_change_count; 630 bool topology_change; 631 char topology_change_port[IFNAMSIZ]; 632 char last_topology_change_port[IFNAMSIZ]; 633 bridge_identifier_t regional_root; 634 unsigned int internal_path_cost; 635 port_identifier_t root_port_id; 636 } MSTI_BridgeStatus; 637 638 void MSTP_IN_get_msti_bridge_status(tree_t *tree, MSTI_BridgeStatus *status); 639 640 /* 12.8.1.3 Set CIST Bridge Protocol Parameters */ 641 typedef struct 642 { 643 __u8 bridge_max_age; 644 bool set_bridge_max_age; 645 646 __u8 bridge_forward_delay; 647 bool set_bridge_forward_delay; 648 649 /* Superseded by MSTP_IN_set_msti_bridge_config for the CIST. 650 * __u8 bridge_priority; 651 * bool set_bridge_priority; */ 652 653 protocol_version_t protocol_version; 654 bool set_protocol_version; 655 656 unsigned int tx_hold_count; 657 bool set_tx_hold_count; 658 659 __u8 max_hops; 660 bool set_max_hops; 661 662 __u8 bridge_hello_time; 663 bool set_bridge_hello_time; 664 665 unsigned int bridge_ageing_time; 666 bool set_bridge_ageing_time; 667 } CIST_BridgeConfig; 668 669 int MSTP_IN_set_cist_bridge_config(bridge_t *br, CIST_BridgeConfig *cfg); 670 671 /* 12.8.1.4 Set MSTI Bridge Protocol Parameters */ 672 /* No need in special structure for single parameter Bridge Priority */ 673 674 int MSTP_IN_set_msti_bridge_config(tree_t *tree, unsigned int bridge_priority); 675 676 /* 12.8.2.1 Read CIST Port Parameters */ 677 typedef struct 678 { 679 unsigned int uptime; 680 int state; /* BR_STATE_xxx */ 681 port_identifier_t port_id; 682 __u32 admin_external_port_path_cost; /* not in standard. 0 = auto */ 683 __u32 external_port_path_cost; 684 bridge_identifier_t designated_root; /* from portPriority */ 685 __u32 designated_external_cost; /* from portPriority */ 686 bridge_identifier_t designated_bridge; /* from portPriority */ 687 port_identifier_t designated_port; /* from portPriority */ 688 bool tc_ack; /* tcAck */ 689 __u8 port_hello_time; /* from portTimes */ 690 bool admin_edge_port; 691 bool auto_edge_port; /* not in standard */ 692 bool oper_edge_port; 693 /* 802.1Q-2005 wants here MAC_Enabled & MAC_Operational. We don't know 694 * neither of these. Return portEnabled and feel happy. */ 695 bool enabled; 696 admin_p2p_t admin_p2p; 697 bool oper_p2p; 698 bool restricted_role; 699 bool restricted_tcn; 700 port_role_t role; 701 bool disputed; 702 bridge_identifier_t designated_regional_root; /* from portPriority */ 703 __u32 designated_internal_cost; /* from portPriority */ 704 __u32 admin_internal_port_path_cost; /* not in standard. 0 = auto */ 705 __u32 internal_port_path_cost; /* not in standard */ 706 bool bpdu_guard_port; 707 bool bpdu_guard_error; 708 bool bpdu_filter_port; 709 bool network_port; 710 bool ba_inconsistent; 711 unsigned int num_rx_bpdu_filtered; 712 unsigned int num_rx_bpdu; 713 unsigned int num_rx_tcn; 714 unsigned int num_tx_bpdu; 715 unsigned int num_tx_tcn; 716 unsigned int num_trans_fwd; 717 unsigned int num_trans_blk; 718 bool rcvdBpdu; 719 bool rcvdRSTP; 720 bool rcvdSTP; 721 bool rcvdTcAck; 722 bool rcvdTcn; 723 bool sendRSTP; 724 } CIST_PortStatus; 725 726 void MSTP_IN_get_cist_port_status(port_t *prt, CIST_PortStatus *status); 727 728 /* 12.8.2.2 Read MSTI Port Parameters */ 729 typedef struct 730 { 731 unsigned int uptime; 732 int state; /* BR_STATE_xxx */ 733 port_identifier_t port_id; 734 __u32 admin_internal_port_path_cost; /* not in standard. 0 = auto */ 735 __u32 internal_port_path_cost; 736 bridge_identifier_t designated_regional_root; /* from portPriority */ 737 __u32 designated_internal_cost; /* from portPriority */ 738 bridge_identifier_t designated_bridge; /* from portPriority */ 739 port_identifier_t designated_port; /* from portPriority */ 740 port_role_t role; 741 bool disputed; 742 } MSTI_PortStatus; 743 744 void MSTP_IN_get_msti_port_status(per_tree_port_t *ptp, 745 MSTI_PortStatus *status); 746 747 /* 12.8.2.3 Set CIST port parameters */ 748 typedef struct 749 { 750 __u32 admin_external_port_path_cost; /* not in standard. 0 = auto */ 751 bool set_admin_external_port_path_cost; 752 753 /* Superseded by MSTP_IN_set_msti_port_config for the CIST. 754 * __u32 admin_internal_port_path_cost; 755 * bool set_admin_internal_port_path_cost; 756 * 757 * __u8 port_priority; 758 * bool set_port_priority; 759 */ 760 761 bool admin_edge_port; 762 bool set_admin_edge_port; 763 764 bool auto_edge_port; /* not in standard */ 765 bool set_auto_edge_port; 766 767 admin_p2p_t admin_p2p; 768 bool set_admin_p2p; 769 770 bool restricted_role; 771 bool set_restricted_role; 772 773 bool restricted_tcn; 774 bool set_restricted_tcn; 775 776 bool bpdu_guard_port; 777 bool set_bpdu_guard_port; 778 779 bool network_port; 780 bool set_network_port; 781 782 bool dont_txmt; 783 bool set_dont_txmt; 784 785 bool bpdu_filter_port; 786 bool set_bpdu_filter_port; 787 } CIST_PortConfig; 788 789 int MSTP_IN_set_cist_port_config(port_t *prt, CIST_PortConfig *cfg); 790 791 /* 12.8.2.4 Set MSTI port parameters */ 792 typedef struct 793 { 794 __u32 admin_internal_port_path_cost; /* 0 = auto */ 795 bool set_admin_internal_port_path_cost; 796 797 __u8 port_priority; 798 bool set_port_priority; 799 } MSTI_PortConfig; 800 801 int MSTP_IN_set_msti_port_config(per_tree_port_t *ptp, MSTI_PortConfig *cfg); 802 803 /* 12.8.2.5 Force BPDU Migration Check */ 804 int MSTP_IN_port_mcheck(port_t *prt); 805 806 #endif /* MSTP_H */ 807
This page was automatically generated by LXR 0.3.1. • OpenWrt