MCPcopy Create free account
hub / github.com/F-Stack/f-stack / bstp_set_port_role

Function bstp_set_port_role

freebsd/net/bridgestp.c:1239–1311  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1237}
1238
1239static void
1240bstp_set_port_role(struct bstp_port *bp, int role)
1241{
1242 struct bstp_state *bs = bp->bp_bs;
1243
1244 if (bp->bp_role == role)
1245 return;
1246
1247 /* perform pre-change tasks */
1248 switch (bp->bp_role) {
1249 case BSTP_ROLE_DISABLED:
1250 bstp_timer_start(&bp->bp_forward_delay_timer,
1251 bp->bp_desg_max_age);
1252 break;
1253
1254 case BSTP_ROLE_BACKUP:
1255 bstp_timer_start(&bp->bp_recent_backup_timer,
1256 bp->bp_desg_htime * 2);
1257 /* fall through */
1258 case BSTP_ROLE_ALTERNATE:
1259 bstp_timer_start(&bp->bp_forward_delay_timer,
1260 bp->bp_desg_fdelay);
1261 bp->bp_sync = 0;
1262 bp->bp_synced = 1;
1263 bp->bp_reroot = 0;
1264 break;
1265
1266 case BSTP_ROLE_ROOT:
1267 bstp_timer_start(&bp->bp_recent_root_timer,
1268 BSTP_DEFAULT_FORWARD_DELAY);
1269 break;
1270 }
1271
1272 bp->bp_role = role;
1273 /* clear values not carried between roles */
1274 bp->bp_proposing = 0;
1275 bs->bs_allsynced = 0;
1276
1277 /* initialise the new role */
1278 switch (bp->bp_role) {
1279 case BSTP_ROLE_DISABLED:
1280 case BSTP_ROLE_ALTERNATE:
1281 case BSTP_ROLE_BACKUP:
1282 DPRINTF("%s role -> ALT/BACK/DISABLED\n",
1283 bp->bp_ifp->if_xname);
1284 bstp_set_port_state(bp, BSTP_IFSTATE_DISCARDING);
1285 bstp_timer_stop(&bp->bp_recent_root_timer);
1286 bstp_timer_latch(&bp->bp_forward_delay_timer);
1287 bp->bp_sync = 0;
1288 bp->bp_synced = 1;
1289 bp->bp_reroot = 0;
1290 break;
1291
1292 case BSTP_ROLE_ROOT:
1293 DPRINTF("%s role -> ROOT\n",
1294 bp->bp_ifp->if_xname);
1295 bstp_set_port_state(bp, BSTP_IFSTATE_DISCARDING);
1296 bstp_timer_latch(&bp->bp_recent_root_timer);

Callers 4

bstp_assign_rolesFunction · 0.85
bstp_set_protocolFunction · 0.85
bstp_reinitFunction · 0.85
bstp_createFunction · 0.85

Calls 5

bstp_timer_startFunction · 0.85
bstp_set_port_stateFunction · 0.85
bstp_timer_stopFunction · 0.85
bstp_timer_latchFunction · 0.85
bstp_update_tcFunction · 0.85

Tested by

no test coverage detected