RFC 894 IP over Ethernet. More...
Data Structures | |
struct | _ETH_PROTOCOLS |
Typedefs | |
typedef struct _ETH_PROTOCOLS | ETH_PROTOCOLS |
Linked list of registered Ethernet protocols. | |
Functions | |
int | NutRegisterEthHandler (uint16_t type, uint16_t mask, int(*hdlr)(NUTDEVICE *, NETBUF *)) |
Register an additional Ethernet protocol handler. | |
void | NutEtherInput (NUTDEVICE *dev, NETBUF *nb) |
Handle incoming Ethernet frames. | |
int | NutEtherOutput (NUTDEVICE *dev, uint16_t type, uint8_t *ha, NETBUF *nb) |
Send Ethernet frame. | |
Variables | |
int(* | ether_demux )(NUTDEVICE *, NETBUF *) |
Pointer to an optional demultiplexer. |
RFC 894 IP over Ethernet.
These routines link the IP layer to the Ethernet driver. Applications do not directly use this.
typedef struct _ETH_PROTOCOLS ETH_PROTOCOLS |
Linked list of registered Ethernet protocols.
Register an additional Ethernet protocol handler.
The specified mask will be applied on the type field of incoming frames before compared with the type that had been specified for the handler. If more than one handler is registered for an incoming Ethernet frame, the handler being registered last is called first.
Each handler should return 0 if it processed the frame, in which case it is also assumed, that the handler releases the memory allocated for the NETBUF. Otherwise the handler should return -1, in which case the frame is passed to the next handler that fits.
The protocol types ETHERTYPE_IP and ETHERTYPE_ARP are pre-registered by default and processed by internal handlers after all registered handlers for that frame rejected processing. This allows to install filters on the Ethernet level.
type | Ethernet protocol type processed by this handler. |
mask | Ethernet protocol type mask. |
hdlr | Pointer to the protocol handler function. If NULL, the handler will be temporarily disabled. |
References calloc, ether_demux, _ETH_PROTOCOLS::ethp_input, _ETH_PROTOCOLS::ethp_mask, _ETH_PROTOCOLS::ethp_next, _ETH_PROTOCOLS::ethp_type, and NULL.
Handle incoming Ethernet frames.
Splits the Ethernet frame into the data link and the network part. Then the frame is routed to the proper handler, based on the type field in the Ethernet header.
If the frame neither contains an IP nor an ARP type telegram and if no registered handler exists or accepts the frame, then it is silently discarded.
dev | Identifies the device that received the frame. |
nb | Pointer to a network buffer structure containing the Ethernet frame. |
References _NUTDEVICE::dev_icb, ether_demux, ether_header::ether_type, ETHERTYPE_ARP, ETHERTYPE_IP, _NETBUF::nb_dl, _NETBUF::nb_nw, ntohs, NULL, NutArpInput(), NutIpInput(), NutNetBufFree(), _NBDATA::sz, and _NBDATA::vp.
Send Ethernet frame.
Send an Ethernet frame of a given type using the specified device.
dev | Identifies the device to use. |
type | Type of this frame, either ETHERTYPE_IP or ETHERTYPE_ARP. |
ha | MAC address of the destination, set null for broadcasts. |
nb | Network buffer structure containing the packet to be sent. The structure must have been allocated by a previous call NutNetBufAlloc() and will be freed if this function returns with an error. |
References _NUTDEVICE::dev_icb, ether_header::ether_dhost, ether_header::ether_shost, ether_header::ether_type, htons, ifnet::if_mac, ifnet::if_send, memcpy(), memset(), _NETBUF::nb_dl, NBAF_DATALINK, NUT_PERFMON_INC, NutNetBufAlloc(), NutNetBufFree(), and _NBDATA::vp.
int(* ether_demux)(NUTDEVICE *, NETBUF *) |
Pointer to an optional demultiplexer.
This pointer will be set on the first call to NutRegisterEthHandler().
Referenced by NutEtherInput(), and NutRegisterEthHandler().