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
This commit is contained in:
Axel Dörfler
2007-10-29 23:37:35 +00:00
parent 91c1b58f82
commit afa1bfe51d
2 changed files with 24 additions and 12 deletions
+1 -1
View File
@@ -263,7 +263,7 @@ compat_control(void *cookie, uint32 op, void *arg, size_t len)
return B_OK; return B_OK;
case ETHER_GETADDR: 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: case ETHER_NONBLOCK:
{ {
+23 -11
View File
@@ -11,12 +11,14 @@
#include "device.h" #include "device.h"
#include <stdio.h> #include <stdio.h>
#include <net/if_types.h>
#include <sys/sockio.h> #include <sys/sockio.h>
#include <compat/sys/bus.h> #include <compat/sys/bus.h>
#include <compat/sys/kernel.h> #include <compat/sys/kernel.h>
#include <compat/net/if.h> #include <compat/net/if.h>
#include <compat/net/if_arp.h>
#include <compat/net/if_var.h> #include <compat/net/if_var.h>
#include <compat/sys/malloc.h> #include <compat/sys/malloc.h>
@@ -29,8 +31,15 @@ if_alloc(u_char type)
if (ifp == NULL) if (ifp == NULL)
return 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); IF_ADDR_LOCK_INIT(ifp);
return ifp; return ifp;
} }
@@ -40,6 +49,9 @@ void
if_free(struct ifnet *ifp) if_free(struct ifnet *ifp)
{ {
IF_ADDR_LOCK_DESTROY(ifp); IF_ADDR_LOCK_DESTROY(ifp);
if (ifp->if_type == IFT_ETHER)
_kernel_free(ifp->if_l2com);
_kernel_free(ifp); _kernel_free(ifp);
} }
@@ -306,17 +318,17 @@ ether_ioctl(struct ifnet *ifp, int command, caddr_t data)
struct ifreq *ifr = (struct ifreq *)data; struct ifreq *ifr = (struct ifreq *)data;
switch (command) { switch (command) {
case SIOCSIFMTU: case SIOCSIFMTU:
if (ifr->ifr_mtu > ETHERMTU) if (ifr->ifr_mtu > ETHERMTU)
return EINVAL; return EINVAL;
else else
; ;
/* need to fix our ifreq to work with C... */ /* need to fix our ifreq to work with C... */
/* ifp->ifr_mtu = ifr->ifr_mtu; */ /* ifp->ifr_mtu = ifr->ifr_mtu; */
break; break;
default: default:
return EINVAL; return EINVAL;
} }
return 0; return 0;