From afa1bfe51da2ce663ad99105748c7ad55042b75f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Mon, 29 Oct 2007 23:37:35 +0000 Subject: [PATCH] IFT_ETHER expects an arpcom structure at if_l2com; this would actually need to be expanded for other types, but for now, we'll probably only get IFT_ETHER anyway. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22766 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/libs/compat/freebsd_network/device.c | 2 +- src/libs/compat/freebsd_network/if.c | 34 ++++++++++++++++-------- 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/src/libs/compat/freebsd_network/device.c b/src/libs/compat/freebsd_network/device.c index 71a2aade2c..1e6a012831 100644 --- a/src/libs/compat/freebsd_network/device.c +++ b/src/libs/compat/freebsd_network/device.c @@ -263,7 +263,7 @@ compat_control(void *cookie, uint32 op, void *arg, size_t len) return B_OK; case ETHER_GETADDR: - return user_memcpy(arg, IF_LLADDR(dev->ifp), ETHER_ADDR_LEN); + return user_memcpy(arg, IF_LLADDR(ifp), ETHER_ADDR_LEN); case ETHER_NONBLOCK: { diff --git a/src/libs/compat/freebsd_network/if.c b/src/libs/compat/freebsd_network/if.c index 49fb38cc13..f442e3a976 100644 --- a/src/libs/compat/freebsd_network/if.c +++ b/src/libs/compat/freebsd_network/if.c @@ -11,12 +11,14 @@ #include "device.h" #include +#include #include #include #include #include +#include #include #include @@ -29,8 +31,15 @@ if_alloc(u_char type) if (ifp == NULL) return NULL; - ifp->if_type = type; + if (type == IFT_ETHER) { + ifp->if_l2com = _kernel_malloc(sizeof(struct arpcom), M_ZERO); + if (ifp->if_l2com == NULL) { + _kernel_free(ifp); + return NULL; + } + } + ifp->if_type = type; IF_ADDR_LOCK_INIT(ifp); return ifp; } @@ -40,6 +49,9 @@ void if_free(struct ifnet *ifp) { IF_ADDR_LOCK_DESTROY(ifp); + if (ifp->if_type == IFT_ETHER) + _kernel_free(ifp->if_l2com); + _kernel_free(ifp); } @@ -306,17 +318,17 @@ ether_ioctl(struct ifnet *ifp, int command, caddr_t data) struct ifreq *ifr = (struct ifreq *)data; switch (command) { - case SIOCSIFMTU: - if (ifr->ifr_mtu > ETHERMTU) - return EINVAL; - else - ; - /* need to fix our ifreq to work with C... */ - /* ifp->ifr_mtu = ifr->ifr_mtu; */ - break; + case SIOCSIFMTU: + if (ifr->ifr_mtu > ETHERMTU) + return EINVAL; + else + ; + /* need to fix our ifreq to work with C... */ + /* ifp->ifr_mtu = ifr->ifr_mtu; */ + break; - default: - return EINVAL; + default: + return EINVAL; } return 0;