driver_bsd: Clean up EAPOL frame transmission code

The bsd_send_eapol() adds Ethernet header by itself. This patch changes it
to use l2_packet functionality.

I have tested on NetBSD 5.0.1 with WPA-PSK(TKIP).
This commit is contained in:
Masashi Honma 2010-02-08 21:28:59 +02:00 committed by Jouni Malinen
parent 719196b159
commit d373725686

View file

@ -758,44 +758,16 @@ bsd_send_eapol(void *priv, const u8 *addr, const u8 *data, size_t data_len,
int encrypt, const u8 *own_addr)
{
struct bsd_driver_data *drv = priv;
unsigned char *bp;
struct l2_ethhdr *eth;
size_t len;
int status;
/*
* Prepend the Ethernet header. If the caller left us
* space at the front we could just insert it but since
* we don't know we copy to a local buffer. Given the frequency
* and size of frames this probably doesn't matter.
*/
len = data_len + sizeof(struct l2_ethhdr);
bp = os_zalloc(len);
if (bp == NULL) {
wpa_printf(MSG_ERROR, "malloc() failed for bsd_send_eapol"
"(len=%lu)", (unsigned long) len);
return -1;
}
eth = (struct l2_ethhdr *) bp;
os_memcpy(eth->h_dest, addr, ETH_ALEN);
os_memcpy(eth->h_source, own_addr, ETH_ALEN);
eth->h_proto = htons(ETH_P_EAPOL);
os_memcpy(eth + 1, data, data_len);
wpa_hexdump(MSG_MSGDUMP, "TX EAPOL", bp, len);
status = l2_packet_send(drv->sock_xmit, addr, ETH_P_EAPOL, bp, len);
os_free(bp);
return status;
wpa_hexdump(MSG_MSGDUMP, "TX EAPOL", data, data_len);
return l2_packet_send(drv->sock_xmit, addr, ETH_P_EAPOL, data,
data_len);
}
static void
handle_read(void *ctx, const u8 *src_addr, const u8 *buf, size_t len)
{
struct bsd_driver_data *drv = ctx;
drv_event_eapol_rx(drv->hapd, src_addr, buf + sizeof(struct l2_ethhdr),
len - sizeof(struct l2_ethhdr));
drv_event_eapol_rx(drv->hapd, src_addr, buf, len);
}
static int
@ -866,7 +838,7 @@ bsd_init(struct hostapd_data *hapd, struct wpa_init_params *params)
memcpy(drv->iface, params->ifname, sizeof(drv->iface));
drv->sock_xmit = l2_packet_init(drv->iface, NULL, ETH_P_EAPOL,
handle_read, drv, 1);
handle_read, drv, 0);
if (drv->sock_xmit == NULL)
goto bad;
if (l2_packet_get_own_addr(drv->sock_xmit, params->own_addr))