Functions | Variables
eapol.c File Reference

802.1X Extensible Authentication Protocol over LANs demultiplexer More...

#include <ipxe/netdevice.h>
#include <ipxe/iobuf.h>
#include <ipxe/if_ether.h>
#include <ipxe/eapol.h>
#include <errno.h>
#include <byteswap.h>

Go to the source code of this file.


static int eapol_rx (struct io_buffer *iob, struct net_device *netdev, const void *ll_dest, const void *ll_source, unsigned int flags __unused)
 Receive EAPOL network-layer packet. More...
static const char * eapol_ntoa (const void *net_addr __unused)
 Transcribe EAPOL network-layer address. More...


struct net_protocol eapol_protocol __net_protocol
 EAPOL network protocol. More...

Detailed Description

802.1X Extensible Authentication Protocol over LANs demultiplexer

Definition in file eapol.c.

Function Documentation



◆ eapol_rx()

static int eapol_rx ( struct io_buffer iob,
struct net_device netdev,
const void *  ll_dest,
const void *  ll_source,
unsigned int flags  __unused 

Receive EAPOL network-layer packet.

iobI/O buffer
netdevNetwork device
ll_destLink-layer destination address
ll_sourceLink-layer source address
flagsPacket flags

This function takes ownership of the I/O buffer passed to it.

Definition at line 46 of file eapol.c.

48  {
49  struct eapol_frame *eapol = iob->data;
50  struct eapol_handler *handler;
52  if ( iob_len ( iob ) < EAPOL_HDR_LEN ) {
53  free_iob ( iob );
54  return -EINVAL;
55  }
58  if ( handler->type == eapol->type ) {
59  iob_pull ( iob, EAPOL_HDR_LEN );
60  return handler->rx ( iob, netdev, ll_dest, ll_source );
61  }
62  }
64  free_iob ( iob );
65  return -( ENOTSUP | ( ( eapol->type & 0x1f ) << 8 ) );
66 }
#define iob_pull(iobuf, len)
Definition: iobuf.h:98
#define EINVAL
Invalid argument.
Definition: errno.h:428
An EAPOL frame.
Definition: eapol.h:63
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
Definition: iobuf.c:145
Definition: eapol.h:107
Length of an EAPOL frame header.
Definition: eapol.h:55
#define ENOTSUP
Operation not supported.
Definition: errno.h:589
int(* rx)(struct io_buffer *iob, struct net_device *netdev, const void *ll_dest, const void *ll_source)
Receive EAPOL-encapsulated packet of specified type.
Definition: eapol.h:103
static struct net_device * netdev
Definition: gdbudp.c:52
An EAPOL frame type handler.
Definition: eapol.h:85
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition: iobuf.h:151
#define for_each_table_entry(pointer, table)
Iterate through all entries within a linker table.
Definition: tables.h:358
u8 type
EAPOL archetype identifier indicating format of payload.
Definition: eapol.h:69
void * data
Start of data.
Definition: iobuf.h:44
u8 type
EAPOL archetype identifier for payload this handler will handle.
Definition: eapol.h:88

References io_buffer::data, EAPOL_HANDLERS, EAPOL_HDR_LEN, EINVAL, ENOTSUP, for_each_table_entry, free_iob(), iob_len(), iob_pull, netdev, eapol_handler::rx, eapol_frame::type, and eapol_handler::type.

◆ eapol_ntoa()

static const char* eapol_ntoa ( const void *net_addr  __unused)

Transcribe EAPOL network-layer address.

net_addrNetwork-layer address
Return values
strString representation of network-layer address

EAPOL doesn't have network-layer addresses, so we just return the string "<EAPOL>".

Definition at line 77 of file eapol.c.

78 {
79  return "<EAPOL>";
80 }

Variable Documentation

◆ __net_protocol

struct net_protocol eapol_protocol __net_protocol
Initial value:
= {
.name = "EAPOL",
.rx = eapol_rx,
.ntoa = eapol_ntoa,
.net_proto = htons ( ETH_P_EAPOL ),
static int eapol_rx(struct io_buffer *iob, struct net_device *netdev, const void *ll_dest, const void *ll_source, unsigned int flags __unused)
Receive EAPOL network-layer packet.
Definition: eapol.c:46
static const char * eapol_ntoa(const void *net_addr __unused)
Transcribe EAPOL network-layer address.
Definition: eapol.c:77
#define ETH_P_EAPOL
Definition: if_ether.h:24
#define htons(value)
Definition: byteswap.h:135

EAPOL network protocol.

AoE protocol.

Definition at line 83 of file eapol.c.