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

Function ng_ppp_config_valid

freebsd/netgraph/ng_ppp.c:2567–2604  ·  view source on GitHub ↗

* Determine if a new configuration would represent a valid change * from the current configuration and link activity status. */

Source from the content-addressed store, hash-verified

2565 * from the current configuration and link activity status.
2566 */
2567static int
2568ng_ppp_config_valid(node_p node, const struct ng_ppp_node_conf *newConf)
2569{
2570 const priv_p priv = NG_NODE_PRIVATE(node);
2571 int i, newNumLinksActive;
2572
2573 /* Check per-link config and count how many links would be active */
2574 for (newNumLinksActive = i = 0; i < NG_PPP_MAX_LINKS; i++) {
2575 if (newConf->links[i].enableLink && priv->links[i].hook != NULL)
2576 newNumLinksActive++;
2577 if (!newConf->links[i].enableLink)
2578 continue;
2579 if (newConf->links[i].mru < MP_MIN_LINK_MRU)
2580 return (0);
2581 if (newConf->links[i].bandwidth == 0)
2582 return (0);
2583 if (newConf->links[i].bandwidth > NG_PPP_MAX_BANDWIDTH)
2584 return (0);
2585 if (newConf->links[i].latency > NG_PPP_MAX_LATENCY)
2586 return (0);
2587 }
2588
2589 /* Disallow changes to multi-link configuration while MP is active */
2590 if (priv->numActiveLinks > 0 && newNumLinksActive > 0) {
2591 if (!priv->conf.enableMultilink
2592 != !newConf->bund.enableMultilink
2593 || !priv->conf.xmitShortSeq != !newConf->bund.xmitShortSeq
2594 || !priv->conf.recvShortSeq != !newConf->bund.recvShortSeq)
2595 return (0);
2596 }
2597
2598 /* At most one link can be active unless multi-link is enabled */
2599 if (!newConf->bund.enableMultilink && newNumLinksActive > 1)
2600 return (0);
2601
2602 /* Configuration change would be valid */
2603 return (1);
2604}
2605
2606/*
2607 * Free all entries in the fragment queue

Callers 1

ng_ppp_rcvmsgFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected