Add two new netgraph messages NGM_ETHER_ADD_MULTI and NGM_ETHER_DEL_MULTI,
to join and leave Ethernet multicast membership, respectively. Messages take MAC address as argument. Sponsored by: Rinet ISP
This commit is contained in:
parent
953a8b2e6d
commit
810d5e89f4
@ -57,6 +57,7 @@
|
||||
|
||||
#include <net/bridge.h>
|
||||
#include <net/if.h>
|
||||
#include <net/if_dl.h>
|
||||
#include <net/if_types.h>
|
||||
#include <net/if_arp.h>
|
||||
#include <net/if_var.h>
|
||||
@ -171,6 +172,20 @@ static const struct ng_cmdlist ng_ether_cmdlist[] = {
|
||||
&ng_parse_int32_type,
|
||||
NULL
|
||||
},
|
||||
{
|
||||
NGM_ETHER_COOKIE,
|
||||
NGM_ETHER_ADD_MULTI,
|
||||
"addmulti",
|
||||
&ng_parse_enaddr_type,
|
||||
NULL
|
||||
},
|
||||
{
|
||||
NGM_ETHER_COOKIE,
|
||||
NGM_ETHER_DEL_MULTI,
|
||||
"delmulti",
|
||||
&ng_parse_enaddr_type,
|
||||
NULL
|
||||
},
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
@ -492,6 +507,47 @@ ng_ether_rcvmsg(node_p node, item_p item, hook_p lasthook)
|
||||
}
|
||||
priv->autoSrcAddr = !!*((u_int32_t *)msg->data);
|
||||
break;
|
||||
case NGM_ETHER_ADD_MULTI:
|
||||
{
|
||||
struct sockaddr_dl sa_dl;
|
||||
struct ifmultiaddr *ifm;
|
||||
|
||||
if (msg->header.arglen != ETHER_ADDR_LEN) {
|
||||
error = EINVAL;
|
||||
break;
|
||||
}
|
||||
sa_dl.sdl_len = sizeof(struct sockaddr_dl);
|
||||
sa_dl.sdl_family = AF_LINK;
|
||||
sa_dl.sdl_index = 0;
|
||||
sa_dl.sdl_nlen = 0;
|
||||
sa_dl.sdl_alen = 6;
|
||||
sa_dl.sdl_slen = 0;
|
||||
bcopy((void *)msg->data, LLADDR(&sa_dl),
|
||||
ETHER_ADDR_LEN);
|
||||
error = if_addmulti(priv->ifp,
|
||||
(struct sockaddr *)&sa_dl, &ifm);
|
||||
break;
|
||||
}
|
||||
case NGM_ETHER_DEL_MULTI:
|
||||
{
|
||||
struct sockaddr_dl sa_dl;
|
||||
|
||||
if (msg->header.arglen != ETHER_ADDR_LEN) {
|
||||
error = EINVAL;
|
||||
break;
|
||||
}
|
||||
sa_dl.sdl_len = sizeof(struct sockaddr_dl);
|
||||
sa_dl.sdl_family = AF_LINK;
|
||||
sa_dl.sdl_index = 0;
|
||||
sa_dl.sdl_nlen = 0;
|
||||
sa_dl.sdl_alen = 6;
|
||||
sa_dl.sdl_slen = 0;
|
||||
bcopy((void *)msg->data, LLADDR(&sa_dl),
|
||||
ETHER_ADDR_LEN);
|
||||
error = if_delmulti(priv->ifp,
|
||||
(struct sockaddr *)&sa_dl);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
error = EINVAL;
|
||||
break;
|
||||
|
@ -47,7 +47,7 @@
|
||||
|
||||
/* Node type name and magic cookie */
|
||||
#define NG_ETHER_NODE_TYPE "ether"
|
||||
#define NGM_ETHER_COOKIE 917786906
|
||||
#define NGM_ETHER_COOKIE 1108206947
|
||||
|
||||
/* Hook names */
|
||||
#define NG_ETHER_HOOK_LOWER "lower" /* connection to raw device */
|
||||
@ -65,7 +65,8 @@ enum {
|
||||
NGM_ETHER_SET_PROMISC, /* enable/disable promiscuous mode */
|
||||
NGM_ETHER_GET_AUTOSRC, /* get source address override */
|
||||
NGM_ETHER_SET_AUTOSRC, /* enable/disable src addr override */
|
||||
NGM_ETHER_ADD_MULTI, /* add multicast membership */
|
||||
NGM_ETHER_DEL_MULTI, /* delete multicast membership */
|
||||
};
|
||||
|
||||
#endif /* _NETGRAPH_NG_ETHER_H_ */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user