|
peapod
0.1.0
EAPOL Proxy Daemon
|
Network interface and socket setup. More...
#include <stdio.h>#include <string.h>#include <unistd.h>#include <arpa/inet.h>#include <netinet/ether.h>#include <linux/filter.h>#include <linux/if_packet.h>#include <sys/epoll.h>#include <sys/ioctl.h>#include "iface.h"#include "log.h"
Functions | |
| static int | validate (struct iface_t *iface) |
| Check that a network interface is up and get its MTU. More... | |
| static int | epoll_register (int epfd, struct iface_t *iface) |
Register the skt field of iface with an epoll instance. More... | |
| static u_char * | get_mac (struct iface_t *iface) |
| Query the kernel for the MAC address of a network interface. More... | |
| static int | sockopt (struct iface_t *iface) |
Set socket options for the skt field of a struct iface_t. More... | |
| int | iface_init (struct iface_t *ifaces, int epfd) |
Create raw sockets for interfaces in a list and add them to an epoll instance. More... | |
| int | iface_count (struct iface_t *ifaces) |
| Count number of items in a list of struct iface_t. More... | |
| int | iface_set_mac (struct iface_t *iface, u_char *src_mac) |
| Set the MAC address of a network interface. More... | |
| char * | iface_strmac (u_char *mac) |
| Convert a MAC address to a string. More... | |
Variables | |
| static const u_char | eapol_grp_mac [3][ETH_ALEN] |
| EAPOL multicast group MAC addresses. More... | |
BPF filter for EAPOL packets | |
Scenario - Create a socket with Just kidding! Providing our own
| |
| static struct sock_filter | eapol_sock_filter [] |
A simple bpf filter for EAPOL packets. More... | |
| static const struct sock_fprog | eapol_fprog |
The complete bpf filter program provided to setsockopt(3) More... | |
Network interface and socket setup.
|
static |
Check that a network interface is up and get its MTU.
Also sets the mtu field of iface to the interface's current MTU.
| iface | Pointer to a struct iface_t representing an interface |
|
static |
Register the skt field of iface with an epoll instance.
Provide iface itself as the event data, so we know on which interface an EPOLLIN event occurred.
| epfd | File descriptor for an epoll instance |
| iface | Pointer to a struct iface_t representing an interface |
|
static |
Query the kernel for the MAC address of a network interface.
| iface | Pointer to a struct iface_t representing an interface |
ETH_ALEN bytes if successful, or NULL if unsuccessful
|
static |
Set socket options for the skt field of a struct iface_t.
Attaches a bpf filter for the 802.1X EtherType, sets multicast or promiscuous mode, and requests a PACKET_AUXDATA cmsg from the kernel.
| iface | Pointer to a struct iface_t representing an interface |
cmsg(3) | int iface_init | ( | struct iface_t * | ifaces, |
| int | epfd | ||
| ) |
Create raw sockets for interfaces in a list and add them to an epoll instance.
Also set interface MAC if set-mac was specified in the config file.
| ifaces | Pointer to a list of struct iface_t structures representing network interfaces |
| epfd | File descriptor for an epoll instance |
epoll | int iface_count | ( | struct iface_t * | ifaces | ) |
| int iface_set_mac | ( | struct iface_t * | iface, |
| u_char * | src_mac | ||
| ) |
Set the MAC address of a network interface.
| iface | Pointer to a struct iface_t representing an interface |
| src_mac | Pointer to ETH_ALEN bytes containing a MAC address |
| char* iface_strmac | ( | u_char * | mac | ) |
Convert a MAC address to a string.
| mac | Pointer to ETH_ALEN bytes containing a MAC address |
mac converted to a human-readable, colon-delimited MAC address ether_ntoa(3) ether_ntoa(3)
|
static |
EAPOL multicast group MAC addresses.
|
static |
A simple bpf filter for EAPOL packets.
The tcpdump-style bpf assembly equivalent is:
|
static |
The complete bpf filter program provided to setsockopt(3)
1.8.11