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

Function ng_ether_rcvmsg

freebsd/netgraph/ng_ether.c:491–645  ·  view source on GitHub ↗

* Receive an incoming control message. */

Source from the content-addressed store, hash-verified

489 * Receive an incoming control message.
490 */
491static int
492ng_ether_rcvmsg(node_p node, item_p item, hook_p lasthook)
493{
494 const priv_p priv = NG_NODE_PRIVATE(node);
495 struct ng_mesg *resp = NULL;
496 int error = 0;
497 struct ng_mesg *msg;
498
499 NGI_GET_MSG(item, msg);
500 switch (msg->header.typecookie) {
501 case NGM_ETHER_COOKIE:
502 switch (msg->header.cmd) {
503 case NGM_ETHER_GET_IFNAME:
504 NG_MKRESPONSE(resp, msg, IFNAMSIZ, M_NOWAIT);
505 if (resp == NULL) {
506 error = ENOMEM;
507 break;
508 }
509 strlcpy(resp->data, priv->ifp->if_xname, IFNAMSIZ);
510 break;
511 case NGM_ETHER_GET_IFINDEX:
512 NG_MKRESPONSE(resp, msg, sizeof(u_int32_t), M_NOWAIT);
513 if (resp == NULL) {
514 error = ENOMEM;
515 break;
516 }
517 *((u_int32_t *)resp->data) = priv->ifp->if_index;
518 break;
519 case NGM_ETHER_GET_ENADDR:
520 NG_MKRESPONSE(resp, msg, ETHER_ADDR_LEN, M_NOWAIT);
521 if (resp == NULL) {
522 error = ENOMEM;
523 break;
524 }
525 bcopy(IF_LLADDR(priv->ifp),
526 resp->data, ETHER_ADDR_LEN);
527 break;
528 case NGM_ETHER_SET_ENADDR:
529 {
530 if (msg->header.arglen != ETHER_ADDR_LEN) {
531 error = EINVAL;
532 break;
533 }
534 error = if_setlladdr(priv->ifp,
535 (u_char *)msg->data, ETHER_ADDR_LEN);
536 break;
537 }
538 case NGM_ETHER_GET_PROMISC:
539 NG_MKRESPONSE(resp, msg, sizeof(u_int32_t), M_NOWAIT);
540 if (resp == NULL) {
541 error = ENOMEM;
542 break;
543 }
544 *((u_int32_t *)resp->data) = priv->promisc;
545 break;
546 case NGM_ETHER_SET_PROMISC:
547 {
548 u_char want;

Callers

nothing calls this directly

Calls 8

if_setlladdrFunction · 0.85
ifpromiscFunction · 0.85
bzeroFunction · 0.85
if_findmultiFunction · 0.85
if_addmultiFunction · 0.85
if_delmultiFunction · 0.85
ng_ether_detachFunction · 0.85
strlcpyFunction · 0.50

Tested by

no test coverage detected