Nut/OS  4.10.3
API Reference
if_ether.h File Reference

Ethernet interface definitions. More...

#include <net/if_var.h>
#include <net/if_arp.h>
Include dependency graph for if_ether.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ether_header
 Ethernet protocol header. More...
struct  ether_arp
 Ethernet ARP protocol structure. More...

Defines

#define ETHER_ADDR_LEN   6
 Length of an Ethernet address.
#define ETHER_TYPE_LEN   2
 Length of the Ethernet type field.
#define ETHER_CRC_LEN   4
 Length of the Ethernet CRC.
#define ETHER_HDR_LEN   (ETHER_ADDR_LEN + ETHER_ADDR_LEN + ETHER_TYPE_LEN)
 Length of an Ethernet header.
#define ETHER_MIN_LEN   64
 Minimum frame length, including CRC.
#define ETHER_MAX_LEN   1518
 Maximum frame length, including CRC.
#define ETHERMTU   (ETHER_MAX_LEN - ETHER_HDR_LEN - ETHER_CRC_LEN)
 Ethernet maximum transfer unit.
#define ETHERMIN   (ETHER_MIN_LEN - ETHER_HDR_LEN - ETHER_CRC_LEN)
 Ethernet minimum transfer unit.
#define ETHERTYPE_IP   0x0800
 IP protocol.
#define ETHERTYPE_ARP   0x0806
 Address resolution protocol.
#define ETHER_IS_ZERO(ea)   (((ea)[0] | (ea)[1] | (ea)[2] | (ea)[3] | (ea)[4] | (ea)[5]) == 0)
 Determine if a given Ethernet address is zero.
#define ETHER_IS_BROADCAST(ea)   (((ea)[0] & (ea)[1] & (ea)[2] & (ea)[3] & (ea)[4] & (ea)[5]) == 0xFF)
 Determine if a given Ethernet address is a broadcast address.
#define ETHER_IS_MULTICAST(ea)   ((ea)[0] & 1)
 Determine if a given Ethernet address is a multicast address.
#define ETHER_IS_UNICAST(ea)   (!ETHER_IS_ZERO(ea) && !ETHER_IS_MULTICAST(ea))
 Determine if a given Ethernet address is a unicast address.

Typedefs

typedef struct ether_header ETHERHDR
 Ethernet protocol header type.
typedef struct ether_arp ETHERARP
 Ethernet ARP protocol type.

Functions

uint8_tether_aton (CONST char *str)
 Convert an ASCII string to a binary Ethernet address.
char * ether_ntoa (CONST uint8_t *mac)
 Convert a binary Ethernet address to an ASCII string.
void NutArpInput (NUTDEVICE *dev, NETBUF *nb)
 Handle incoming ARP packets.
NETBUFNutArpAllocNetBuf (uint16_t type, uint32_t ip, uint8_t *mac)
 Allocate an ARP network buffer structure.
int NutArpOutput (NUTDEVICE *dev, NETBUF *nb)
 Send an ARP packet.
void NutArpCacheUpdate (NUTDEVICE *dev, uint32_t ip, uint8_t *ha)
 Update an ARP entry.
int NutArpCacheQuery (NUTDEVICE *dev, uint32_t ip, uint8_t *mac)

Detailed Description

Ethernet interface definitions.

Definition in file if_ether.h.


Define Documentation

#define ETHER_ADDR_LEN   6

Length of an Ethernet address.

Definition at line 53 of file if_ether.h.

#define ETHER_TYPE_LEN   2

Length of the Ethernet type field.

Definition at line 56 of file if_ether.h.

#define ETHER_CRC_LEN   4

Length of the Ethernet CRC.

Definition at line 59 of file if_ether.h.

#define ETHER_HDR_LEN   (ETHER_ADDR_LEN + ETHER_ADDR_LEN + ETHER_TYPE_LEN)

Length of an Ethernet header.

Definition at line 62 of file if_ether.h.

#define ETHER_MIN_LEN   64

Minimum frame length, including CRC.

Definition at line 66 of file if_ether.h.

#define ETHER_MAX_LEN   1518

Maximum frame length, including CRC.

Definition at line 71 of file if_ether.h.

#define ETHERMTU   (ETHER_MAX_LEN - ETHER_HDR_LEN - ETHER_CRC_LEN)

Ethernet maximum transfer unit.

Must be checked by the hardware driver.

Definition at line 95 of file if_ether.h.

#define ETHERMIN   (ETHER_MIN_LEN - ETHER_HDR_LEN - ETHER_CRC_LEN)

Ethernet minimum transfer unit.

Must be checked by the hardware driver.

Definition at line 101 of file if_ether.h.

#define ETHERTYPE_IP   0x0800

IP protocol.

Definition at line 103 of file if_ether.h.

Referenced by NutArpAllocNetBuf(), NutArpInput(), NutEtherInput(), and NutIpOutput().

#define ETHERTYPE_ARP   0x0806

Address resolution protocol.

Definition at line 104 of file if_ether.h.

Referenced by NutArpOutput(), and NutEtherInput().

#define ETHER_IS_ZERO (   ea)    (((ea)[0] | (ea)[1] | (ea)[2] | (ea)[3] | (ea)[4] | (ea)[5]) == 0)

Determine if a given Ethernet address is zero.

Parameters:
eaPointer to a character array containing the address.

Return 1 if the address is zero. Otherwise 0 is returned.

Definition at line 113 of file if_ether.h.

Referenced by NicRxLanc().

#define ETHER_IS_BROADCAST (   ea)    (((ea)[0] & (ea)[1] & (ea)[2] & (ea)[3] & (ea)[4] & (ea)[5]) == 0xFF)

Determine if a given Ethernet address is a broadcast address.

Parameters:
eaPointer to a character array containing the address.

Return 1 if the address is a broadcast address. Otherwise 0 is returned.

Definition at line 122 of file if_ether.h.

Referenced by NicRxLanc().

#define ETHER_IS_MULTICAST (   ea)    ((ea)[0] & 1)

Determine if a given Ethernet address is a multicast address.

The broadcast address is defined as a special multicast address.

Parameters:
eaPointer to a character array containing the address.

Return 1 if the address is a multicast address. Otherwise 0 is returned.

Definition at line 133 of file if_ether.h.

#define ETHER_IS_UNICAST (   ea)    (!ETHER_IS_ZERO(ea) && !ETHER_IS_MULTICAST(ea))

Determine if a given Ethernet address is a unicast address.

By definition, an address with all zeros is not a valid unicast address.

Parameters:
eaPointer to a character array containing the address.

Return 1 if the address is a unicast address. Otherwise 0 is returned.

Definition at line 144 of file if_ether.h.

Referenced by EmacRxThread(), NicRxAsix(), NicRxLanc(), and NutNetIfSetup().


Typedef Documentation

Ethernet protocol header type.

Ethernet ARP protocol type.


Function Documentation

uint8_t* ether_aton ( CONST char *  str)

Convert an ASCII string to a binary Ethernet address.

Note:
This function returns a pointer to internal static storage space that will be overwritten by subsequent calls.
Parameters:
strString to convert.
Returns:
Pointer to a static string that contains the converted binary address.
Examples:
editconf/editconf.c.

Definition at line 60 of file ether_addr.c.

References CONST, and memset().

Referenced by main(), and NutNetLoadConfig().

Here is the call graph for this function:

char* ether_ntoa ( CONST uint8_t mac)

Convert a binary Ethernet address to an ASCII string.

Note:
This function returns a pointer to internal static storage space that will be overwritten by subsequent calls.
Parameters:
macAddress to convert.
Returns:
Pointer to a static string that contains the converted ASCII string.
Examples:
editconf/editconf.c.

Definition at line 99 of file ether_addr.c.

Referenced by main().

int NutArpCacheQuery ( NUTDEVICE dev,
uint32_t  ip,
uint8_t mac 
)

Referenced by NutIpOutput().