mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-12-30 06:02:39 +01:00
eapol: Provide utility to open raw socket
Opens a raw socket to filter ETH_P_PAE based packets. Binds to specific interface index to read/write eapol frames.
This commit is contained in:
parent
6b018ca6f7
commit
db45cd8dbf
44
src/eapol.c
44
src/eapol.c
@ -25,6 +25,13 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <linux/if.h>
|
||||||
|
#include <linux/if_packet.h>
|
||||||
|
#include <linux/if_ether.h>
|
||||||
|
#include <arpa/inet.h>
|
||||||
#include <ell/ell.h>
|
#include <ell/ell.h>
|
||||||
|
|
||||||
#include "sha1.h"
|
#include "sha1.h"
|
||||||
@ -828,6 +835,43 @@ void __eapol_set_protocol_version(enum eapol_protocol_version version)
|
|||||||
protocol_version = version;
|
protocol_version = version;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct l_io *eapol_open_pae(uint32_t index)
|
||||||
|
{
|
||||||
|
struct l_io *io;
|
||||||
|
struct sockaddr_ll sll;
|
||||||
|
int fd;
|
||||||
|
|
||||||
|
fd = socket(PF_PACKET, SOCK_RAW | SOCK_CLOEXEC, 0);
|
||||||
|
if (fd < 0) {
|
||||||
|
l_error("Failed to create PAE socket %s (%d)",
|
||||||
|
strerror(errno), errno);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
memset(&sll, 0, sizeof(sll));
|
||||||
|
sll.sll_family = AF_PACKET;
|
||||||
|
sll.sll_protocol = htons(ETH_P_PAE);
|
||||||
|
sll.sll_ifindex = index;
|
||||||
|
|
||||||
|
if (bind(fd, (struct sockaddr *) &sll, sizeof(sll)) < 0) {
|
||||||
|
l_error("Failed to bind PAE socket %s (%d)",
|
||||||
|
strerror(errno), errno);
|
||||||
|
close(fd);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
io = l_io_new(fd);
|
||||||
|
if (!io) {
|
||||||
|
l_error("Failed to create IO handling for PAE socket ");
|
||||||
|
close(fd);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
l_io_set_close_on_destroy(io, true);
|
||||||
|
|
||||||
|
return io;
|
||||||
|
}
|
||||||
|
|
||||||
bool eapol_init()
|
bool eapol_init()
|
||||||
{
|
{
|
||||||
state_machines = l_hashmap_new();
|
state_machines = l_hashmap_new();
|
||||||
|
@ -146,6 +146,7 @@ void eapol_sm_set_ap_rsn(struct eapol_sm *sm, const uint8_t *rsn_ie,
|
|||||||
size_t len);
|
size_t len);
|
||||||
void eapol_sm_set_own_rsn(struct eapol_sm *sm, const uint8_t *rsn_ie,
|
void eapol_sm_set_own_rsn(struct eapol_sm *sm, const uint8_t *rsn_ie,
|
||||||
size_t len);
|
size_t len);
|
||||||
|
struct l_io *eapol_open_pae(uint32_t index);
|
||||||
|
|
||||||
void eapol_start(int ifindex, struct eapol_sm *sm);
|
void eapol_start(int ifindex, struct eapol_sm *sm);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user