ArvernOS
Loading...
Searching...
No Matches
ethernet.h File Reference
#include <net/net.h>
#include <stdint.h>
Include dependency graph for ethernet.h:

Data Structures

struct  ethernet_header_t
 

Functions

void ethernet_receive_frame (net_interface_t *interface, uint8_t *data, uint32_t len)
 
void ethernet_send_frame (net_interface_t *interface, uint8_t dst_mac[6], uint16_t ethertype, uint8_t *data, uint32_t len)
 

Detailed Description

Function Documentation

◆ ethernet_receive_frame()

void ethernet_receive_frame ( net_interface_t * interface,
uint8_t * data,
uint32_t len )

Receives an Ethernet frame on an interface. This is a handler that gets called by the lower layer (i.e. the network driver). After having decoded the frame, this handler will likely call a handler of this layer (2) or the layer above (3).

Parameters
interfacethe network interface that received the frame
datathe data containing the Ethernet frame
lenthe length of the data

◆ ethernet_send_frame()

void ethernet_send_frame ( net_interface_t * interface,
uint8_t dst_mac[6],
uint16_t ethertype,
uint8_t * data,
uint32_t len )

Sends an Ethernet frame over an interface.

We are at the Ethernet level, so we can only communicate with machines in the same LAN and we use MAC addresses for that. The destination MAC address is therefore used by one of the machines in the LAN, usually the DNS server or the "gateway" (but it could be any other machine for LAN exchanges). We will use the MAC address of the gateway when we will send Internet packets for instance.

Parameters
interfacethe network interface used to send the frame
dst_macthe destination MAC address
ethertypea value indicating which protocol is encapsulated in the payload of the frame
datathe encapsulated payload
lenthe length of the data