summaryrefslogtreecommitdiff
path: root/sys/net/if.c
diff options
context:
space:
mode:
authorStefan Sperling <stsp@cvs.openbsd.org>2015-09-27 16:50:04 +0000
committerStefan Sperling <stsp@cvs.openbsd.org>2015-09-27 16:50:04 +0000
commitf63ab67e3567461588a69698df0c1794287833d7 (patch)
treededd6266e561824a9e50aee065de49e03565c869 /sys/net/if.c
parentdee4e5bf5b6cbd465a67453a45861ca80764422a (diff)
Add if_setlladdr(), factored out from ifioctl(). Will be used by iwm(4) soon.
With suggestions from tedu@ and guenther@ ok kettenis@
Diffstat (limited to 'sys/net/if.c')
-rw-r--r--sys/net/if.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/sys/net/if.c b/sys/net/if.c
index 6968e645c27..d5460277f67 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if.c,v 1.380 2015/09/13 18:15:03 mpi Exp $ */
+/* $OpenBSD: if.c,v 1.381 2015/09/27 16:50:03 stsp Exp $ */
/* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */
/*
@@ -1568,6 +1568,18 @@ if_put(struct ifnet *ifp)
atomic_dec_int(&ifp->if_refcnt);
}
+int
+if_setlladdr(struct ifnet *ifp, const uint8_t *lladdr)
+{
+ if (ifp->if_sadl == NULL)
+ return (EINVAL);
+
+ memcpy(((struct arpcom *)ifp)->ac_enaddr, lladdr, ETHER_ADDR_LEN);
+ memcpy(LLADDR(ifp->if_sadl), lladdr, ETHER_ADDR_LEN);
+
+ return (0);
+}
+
/*
* Interface ioctls.
*/
@@ -1969,11 +1981,7 @@ ifioctl(struct socket *so, u_long cmd, caddr_t data, struct proc *p)
case IFT_CARP:
case IFT_XETHER:
case IFT_ISO88025:
- bcopy((caddr_t)ifr->ifr_addr.sa_data,
- (caddr_t)((struct arpcom *)ifp)->ac_enaddr,
- ETHER_ADDR_LEN);
- bcopy((caddr_t)ifr->ifr_addr.sa_data,
- LLADDR(sdl), ETHER_ADDR_LEN);
+ if_setlladdr(ifp, ifr->ifr_addr.sa_data);
error = (*ifp->if_ioctl)(ifp, cmd, data);
if (error == ENOTTY)
error = 0;