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