| 265 | } |
| 266 | |
| 267 | static void |
| 268 | bstp_decode_bpdu(struct bstp_port *bp, struct bstp_cbpdu *cpdu, |
| 269 | struct bstp_config_unit *cu) |
| 270 | { |
| 271 | int flags; |
| 272 | |
| 273 | cu->cu_pv.pv_root_id = |
| 274 | (((uint64_t)ntohs(cpdu->cbu_rootpri)) << 48) | |
| 275 | (((uint64_t)cpdu->cbu_rootaddr[0]) << 40) | |
| 276 | (((uint64_t)cpdu->cbu_rootaddr[1]) << 32) | |
| 277 | (((uint64_t)cpdu->cbu_rootaddr[2]) << 24) | |
| 278 | (((uint64_t)cpdu->cbu_rootaddr[3]) << 16) | |
| 279 | (((uint64_t)cpdu->cbu_rootaddr[4]) << 8) | |
| 280 | (((uint64_t)cpdu->cbu_rootaddr[5]) << 0); |
| 281 | |
| 282 | cu->cu_pv.pv_dbridge_id = |
| 283 | (((uint64_t)ntohs(cpdu->cbu_bridgepri)) << 48) | |
| 284 | (((uint64_t)cpdu->cbu_bridgeaddr[0]) << 40) | |
| 285 | (((uint64_t)cpdu->cbu_bridgeaddr[1]) << 32) | |
| 286 | (((uint64_t)cpdu->cbu_bridgeaddr[2]) << 24) | |
| 287 | (((uint64_t)cpdu->cbu_bridgeaddr[3]) << 16) | |
| 288 | (((uint64_t)cpdu->cbu_bridgeaddr[4]) << 8) | |
| 289 | (((uint64_t)cpdu->cbu_bridgeaddr[5]) << 0); |
| 290 | |
| 291 | cu->cu_pv.pv_cost = ntohl(cpdu->cbu_rootpathcost); |
| 292 | cu->cu_message_age = ntohs(cpdu->cbu_messageage); |
| 293 | cu->cu_max_age = ntohs(cpdu->cbu_maxage); |
| 294 | cu->cu_hello_time = ntohs(cpdu->cbu_hellotime); |
| 295 | cu->cu_forward_delay = ntohs(cpdu->cbu_forwarddelay); |
| 296 | cu->cu_pv.pv_dport_id = ntohs(cpdu->cbu_portid); |
| 297 | cu->cu_pv.pv_port_id = bp->bp_port_id; |
| 298 | cu->cu_message_type = cpdu->cbu_bpdutype; |
| 299 | |
| 300 | /* Strip off unused flags in STP mode */ |
| 301 | flags = cpdu->cbu_flags; |
| 302 | switch (cpdu->cbu_protover) { |
| 303 | case BSTP_PROTO_STP: |
| 304 | flags &= BSTP_PDU_STPMASK; |
| 305 | /* A STP BPDU explicitly conveys a Designated Port */ |
| 306 | cu->cu_role = BSTP_ROLE_DESIGNATED; |
| 307 | break; |
| 308 | |
| 309 | case BSTP_PROTO_RSTP: |
| 310 | flags &= BSTP_PDU_RSTPMASK; |
| 311 | break; |
| 312 | } |
| 313 | |
| 314 | cu->cu_topology_change_ack = |
| 315 | (flags & BSTP_PDU_F_TCA) ? 1 : 0; |
| 316 | cu->cu_proposal = |
| 317 | (flags & BSTP_PDU_F_P) ? 1 : 0; |
| 318 | cu->cu_agree = |
| 319 | (flags & BSTP_PDU_F_A) ? 1 : 0; |
| 320 | cu->cu_learning = |
| 321 | (flags & BSTP_PDU_F_L) ? 1 : 0; |
| 322 | cu->cu_forwarding = |
| 323 | (flags & BSTP_PDU_F_F) ? 1 : 0; |
| 324 | cu->cu_topology_change = |
no outgoing calls
no test coverage detected