* Update private information that is derived from other private information */
| 2470 | * Update private information that is derived from other private information |
| 2471 | */ |
| 2472 | static void |
| 2473 | ng_ppp_update(node_p node, int newConf) |
| 2474 | { |
| 2475 | const priv_p priv = NG_NODE_PRIVATE(node); |
| 2476 | int i; |
| 2477 | |
| 2478 | /* Update active status for VJ Compression */ |
| 2479 | priv->vjCompHooked = priv->hooks[HOOK_INDEX_VJC_IP] != NULL |
| 2480 | && priv->hooks[HOOK_INDEX_VJC_COMP] != NULL |
| 2481 | && priv->hooks[HOOK_INDEX_VJC_UNCOMP] != NULL |
| 2482 | && priv->hooks[HOOK_INDEX_VJC_VJIP] != NULL; |
| 2483 | |
| 2484 | /* Increase latency for each link an amount equal to one MP header */ |
| 2485 | if (newConf) { |
| 2486 | for (i = 0; i < NG_PPP_MAX_LINKS; i++) { |
| 2487 | int hdrBytes; |
| 2488 | |
| 2489 | if (priv->links[i].conf.bandwidth == 0) |
| 2490 | continue; |
| 2491 | |
| 2492 | hdrBytes = MP_AVERAGE_LINK_OVERHEAD |
| 2493 | + (priv->links[i].conf.enableACFComp ? 0 : 2) |
| 2494 | + (priv->links[i].conf.enableProtoComp ? 1 : 2) |
| 2495 | + (priv->conf.xmitShortSeq ? 2 : 4); |
| 2496 | priv->links[i].latency = |
| 2497 | priv->links[i].conf.latency + |
| 2498 | (hdrBytes / priv->links[i].conf.bandwidth + 50) / 100; |
| 2499 | } |
| 2500 | } |
| 2501 | |
| 2502 | /* Update list of active links */ |
| 2503 | bzero(&priv->activeLinks, sizeof(priv->activeLinks)); |
| 2504 | priv->numActiveLinks = 0; |
| 2505 | priv->allLinksEqual = 1; |
| 2506 | for (i = 0; i < NG_PPP_MAX_LINKS; i++) { |
| 2507 | struct ng_ppp_link *const link = &priv->links[i]; |
| 2508 | |
| 2509 | /* Is link active? */ |
| 2510 | if (link->conf.enableLink && link->hook != NULL) { |
| 2511 | struct ng_ppp_link *link0; |
| 2512 | |
| 2513 | /* Add link to list of active links */ |
| 2514 | priv->activeLinks[priv->numActiveLinks++] = i; |
| 2515 | link0 = &priv->links[priv->activeLinks[0]]; |
| 2516 | |
| 2517 | /* Determine if all links are still equal */ |
| 2518 | if (link->latency != link0->latency |
| 2519 | || link->conf.bandwidth != link0->conf.bandwidth) |
| 2520 | priv->allLinksEqual = 0; |
| 2521 | |
| 2522 | /* Initialize rec'd sequence number */ |
| 2523 | if (link->seq == MP_NOSEQ) { |
| 2524 | link->seq = (link == link0) ? |
| 2525 | MP_INITIAL_SEQ : link0->seq; |
| 2526 | } |
| 2527 | } else |
| 2528 | link->seq = MP_NOSEQ; |
| 2529 | } |
no test coverage detected