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:
parent
719196b159
commit
d373725686
1 changed files with 5 additions and 33 deletions
|
@ -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)
|
int encrypt, const u8 *own_addr)
|
||||||
{
|
{
|
||||||
struct bsd_driver_data *drv = priv;
|
struct bsd_driver_data *drv = priv;
|
||||||
unsigned char *bp;
|
wpa_hexdump(MSG_MSGDUMP, "TX EAPOL", data, data_len);
|
||||||
struct l2_ethhdr *eth;
|
return l2_packet_send(drv->sock_xmit, addr, ETH_P_EAPOL, data,
|
||||||
size_t len;
|
data_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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
handle_read(void *ctx, const u8 *src_addr, const u8 *buf, size_t len)
|
handle_read(void *ctx, const u8 *src_addr, const u8 *buf, size_t len)
|
||||||
{
|
{
|
||||||
struct bsd_driver_data *drv = ctx;
|
struct bsd_driver_data *drv = ctx;
|
||||||
drv_event_eapol_rx(drv->hapd, src_addr, buf + sizeof(struct l2_ethhdr),
|
drv_event_eapol_rx(drv->hapd, src_addr, buf, len);
|
||||||
len - sizeof(struct l2_ethhdr));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
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));
|
memcpy(drv->iface, params->ifname, sizeof(drv->iface));
|
||||||
|
|
||||||
drv->sock_xmit = l2_packet_init(drv->iface, NULL, ETH_P_EAPOL,
|
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)
|
if (drv->sock_xmit == NULL)
|
||||||
goto bad;
|
goto bad;
|
||||||
if (l2_packet_get_own_addr(drv->sock_xmit, params->own_addr))
|
if (l2_packet_get_own_addr(drv->sock_xmit, params->own_addr))
|
||||||
|
|
Loading…
Add table
Reference in a new issue