peapod  0.1.0
EAPOL Proxy Daemon
Functions | Variables
proxy.c File Reference

Main event loop, related operations. More...

#include <signal.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <sys/epoll.h>
#include "args.h"
#include "log.h"
#include "packet.h"
#include "process.h"
Include dependency graph for proxy.c:

Functions

static void check_signals (void)
 Check and set signal counters. More...
 
static int create_epoll (void)
 Create an epoll instance. More...
 
static void spurious_event (char *name, uint32_t events)
 Log an error on receiving a spurious epoll event. More...
 
void proxy (struct iface_t *ifaces)
 Main event loop. More...
 

Variables

volatile sig_atomic_t sig_hup
 
volatile sig_atomic_t sig_int
 
volatile sig_atomic_t sig_usr1
 
volatile sig_atomic_t sig_term
 
struct args_t args
 Program arguments data structure. More...
 

Detailed Description

Main event loop, related operations.

Function Documentation

static void check_signals ( void  )
static

Check and set signal counters.

static int create_epoll ( void  )
static

Create an epoll instance.

Returns
0 if successful, -1 if unsuccessful
static void spurious_event ( char *  name,
uint32_t  events 
)
static

Log an error on receiving a spurious epoll event.

Parameters
nameThe name of a network interface
eventsThe events field of a struct epoll_event
See also
epoll(4)
void proxy ( struct iface_t ifaces)

Main event loop.

The loop flow approximates the following:

  1. Ingress phase: Receive an EAPOL packet (packet) on a configured interface (iface).
    packet is an Ethernet frame containing an EAPOL MPDU and iface is a network interface configured in the config file.
    • If packet is the first EAPOL packet to be received on iface, and any other interfaces are configured to have their MAC address set from the source MAC address of such a packet:
      • Set each such interface's MAC address.
      • Drop packet entirely and restart the loop.
    • If iface has an ingress script defined matching the EAPOL Packet Type or EAP Code of packet, execute the ingress script.
    • If iface has an ingress filter defined matching packet, apply the ingress filter (i.e. drop packet entirely and restart the loop).
  2. Egress phase: Proxy to other configured interfaces ("egress interfaces").
    For each egress interface (eiface):
    • Make a local copy of packet (epacket).
    • If eiface has a dot1q option defined, add/change/remove the 802.1Q VLAN tag in epacket.
    • If eiface has an egress filter defined matching epacket, apply the egress filter.
      This means dropping epacket entirely on eiface and moving on to proxying packet on the next egress interface.
    • If eiface has an egress script defined matching epacket, execute the egress script.
    • Send epacket on eiface.
  3. Restart the loop.
Parameters
ifacesPointer to a list of struct iface_t structures representing network interfaces

Variable Documentation

volatile sig_atomic_t sig_hup
volatile sig_atomic_t sig_int
volatile sig_atomic_t sig_usr1
volatile sig_atomic_t sig_term
struct args_t args

Program arguments data structure.

Note
Global