Deleted Added
full compact
40c40
< * $FreeBSD: head/sys/netgraph/ng_ether.c 63543 2000-07-19 17:33:53Z archie $
---
> * $FreeBSD: head/sys/netgraph/ng_ether.c 64358 2000-08-07 18:52:26Z archie $
75a76,77
> u_char autoSrcAddr; /* always overwrite source address */
> u_char promisc; /* promiscuous mode enabled */
104a107,117
> /* Parse type for an Ethernet address. Slightly better than an array of
> six int8's would be the more common colon-separated hex byte format. */
> static const struct ng_parse_fixedarray_info ng_ether_enaddr_type_info = {
> &ng_parse_int8_type,
> ETHER_ADDR_LEN
> };
> static const struct ng_parse_type ng_ether_enaddr_type = {
> &ng_parse_fixedarray_type,
> &ng_ether_enaddr_type_info
> };
>
120a134,154
> {
> NGM_ETHER_COOKIE,
> NGM_ETHER_GET_ENADDR,
> "getenaddr",
> NULL,
> &ng_ether_enaddr_type
> },
> {
> NGM_ETHER_COOKIE,
> NGM_ETHER_SET_PROMISC,
> "setpromisc",
> &ng_parse_int32_type,
> NULL
> },
> {
> NGM_ETHER_COOKIE,
> NGM_ETHER_SET_AUTOSRC,
> "setautosrc",
> &ng_parse_int32_type,
> NULL
> },
268a303
> priv->autoSrcAddr = 1;
456a492,523
> case NGM_ETHER_GET_ENADDR:
> NG_MKRESPONSE(resp, msg, ETHER_ADDR_LEN, M_NOWAIT);
> if (resp == NULL) {
> error = ENOMEM;
> break;
> }
> bcopy((IFP2AC(priv->ifp))->ac_enaddr,
> resp->data, ETHER_ADDR_LEN);
> break;
> case NGM_ETHER_SET_PROMISC:
> {
> u_char want;
>
> if (msg->header.arglen != sizeof(u_int32_t)) {
> error = EINVAL;
> break;
> }
> want = !!*((u_int32_t *)msg->data);
> if (want ^ priv->promisc) {
> if ((error = ifpromisc(priv->ifp, want)) != 0)
> break;
> priv->promisc = want;
> }
> break;
> }
> case NGM_ETHER_SET_AUTOSRC:
> if (msg->header.arglen != sizeof(u_int32_t)) {
> error = EINVAL;
> break;
> }
> priv->autoSrcAddr = !!*((u_int32_t *)msg->data);
> break;
498d564
< struct ether_header *eh;
511,513c577,582
< /* drop in the MAC address */
< eh = mtod(m, struct ether_header *);
< bcopy((IFP2AC(priv->ifp))->ac_enaddr, eh->ether_shost, 6);
---
> /* Drop in the MAC address if desired */
> if (priv->autoSrcAddr) {
> bcopy((IFP2AC(priv->ifp))->ac_enaddr,
> mtod(m, struct ether_header *)->ether_shost,
> ETHER_ADDR_LEN);
> }
554a624,625
> const priv_p priv = node->private;
>
556a628,632
> if (priv->promisc) { /* disable promiscuous mode */
> (void)ifpromisc(priv->ifp, 0);
> priv->promisc = 0;
> }
> priv->autoSrcAddr = 1; /* reset auto-src-addr flag */