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

Function ng_ppp_rcvmsg

freebsd/netgraph/ng_ppp.c:582–729  ·  view source on GitHub ↗

* Receive a control message */

Source from the content-addressed store, hash-verified

580 * Receive a control message
581 */
582static int
583ng_ppp_rcvmsg(node_p node, item_p item, hook_p lasthook)
584{
585 const priv_p priv = NG_NODE_PRIVATE(node);
586 struct ng_mesg *resp = NULL;
587 int error = 0;
588 struct ng_mesg *msg;
589
590 NGI_GET_MSG(item, msg);
591 switch (msg->header.typecookie) {
592 case NGM_PPP_COOKIE:
593 switch (msg->header.cmd) {
594 case NGM_PPP_SET_CONFIG:
595 {
596 struct ng_ppp_node_conf *const conf =
597 (struct ng_ppp_node_conf *)msg->data;
598 int i;
599
600 /* Check for invalid or illegal config */
601 if (msg->header.arglen != sizeof(*conf))
602 ERROUT(EINVAL);
603 if (!ng_ppp_config_valid(node, conf))
604 ERROUT(EINVAL);
605
606 /* Copy config */
607 priv->conf = conf->bund;
608 for (i = 0; i < NG_PPP_MAX_LINKS; i++)
609 priv->links[i].conf = conf->links[i];
610 ng_ppp_update(node, 1);
611 break;
612 }
613 case NGM_PPP_GET_CONFIG:
614 {
615 struct ng_ppp_node_conf *conf;
616 int i;
617
618 NG_MKRESPONSE(resp, msg, sizeof(*conf), M_NOWAIT);
619 if (resp == NULL)
620 ERROUT(ENOMEM);
621 conf = (struct ng_ppp_node_conf *)resp->data;
622 conf->bund = priv->conf;
623 for (i = 0; i < NG_PPP_MAX_LINKS; i++)
624 conf->links[i] = priv->links[i].conf;
625 break;
626 }
627 case NGM_PPP_GET_MP_STATE:
628 {
629 struct ng_ppp_mp_state *info;
630 int i;
631
632 NG_MKRESPONSE(resp, msg, sizeof(*info), M_NOWAIT);
633 if (resp == NULL)
634 ERROUT(ENOMEM);
635 info = (struct ng_ppp_mp_state *)resp->data;
636 bzero(info, sizeof(*info));
637 for (i = 0; i < NG_PPP_MAX_LINKS; i++) {
638 if (priv->links[i].seq != MP_NOSEQ)
639 info->rseq[i] = priv->links[i].seq;

Callers

nothing calls this directly

Calls 3

ng_ppp_config_validFunction · 0.85
ng_ppp_updateFunction · 0.85
bzeroFunction · 0.85

Tested by

no test coverage detected