EtherSia
A minimal IPv6 Ethernet library for Arduino.
Public Member Functions | List of all members
EtherSia_LinuxSocket Class Reference

Run EtherSia on Linux using a raw socket to Send and receive Ethernet frames Not intended for use with running EtherSia on Arduino. More...

#include <LinuxSocket.h>

Public Member Functions

 EtherSia_LinuxSocket (const char *iface=NULL)
 Constructor. More...
 
virtual boolean begin (const MACAddress &address)
 Initialise the Ethernet controller Must be called before sending or receiving Ethernet frames. More...
 
virtual uint16_t sendFrame (const uint8_t *data, uint16_t datalen)
 Send an Ethernet frame. More...
 
virtual uint16_t readFrame (uint8_t *buffer, uint16_t bufsize)
 Read an Ethernet frame. More...
 
virtual void end ()
 Close the raw ethernet socket.
 
boolean begin ()
 Configure the Ethernet interface and get things ready. More...
 
- Public Member Functions inherited from EtherSia
 EtherSia ()
 Default Constructor.
 
boolean begin ()
 Configure the Ethernet interface and get things ready. More...
 
void disableAutoconfiguration ()
 Disable stateless auto-configuration (SLAAC) More...
 
void enableAutoconfiguration ()
 Enable stateless auto-configuration (SLAAC) More...
 
void setGlobalAddress (IPv6Address &address)
 Manually set the global IPv6 address for the Ethernet Interface from an IPv6Address object. More...
 
void setGlobalAddress (const char *address)
 Manually set the global IPv6 address for the Ethernet Interface from human readable string. More...
 
IPv6AddressglobalAddress ()
 Get the global IPv6 address of the Ethernet Interface. More...
 
IPv6AddresslinkLocalAddress ()
 Get the link-local address of the Ethernet Interface This is generated automatically from the MAC address. More...
 
MACAddresslocalMac ()
 Get the local MAC address of this network interface. More...
 
MACAddressrouterMac ()
 Get the MAC address of the router on the local subnet. More...
 
void setRouter (MACAddress &routerMac)
 Manually set the MAC address of the router on the local subnet. More...
 
boolean setRouter (const char *address)
 Manually set the IPv6 address of the router on the local subnet. More...
 
boolean setRouter (IPv6Address &address)
 Manually set the IPv6 address of the router on the local subnet. More...
 
uint8_t isOurAddress (const IPv6Address &address)
 Check to see if an IPv6 address belongs to this Ethernet interface. More...
 
uint8_t inOurSubnet (const IPv6Address &address)
 Check if an address is in the same subnet as us. More...
 
void setDnsServerAddress (IPv6Address &address)
 Set the IPv6 address DNS server to use for hostname lookups. More...
 
IPv6AddressdnsServerAddress ()
 Get the IPv6 address of the DNS server. More...
 
uint16_t receivePacket ()
 Check if there is an IPv6 packet waiting for us and copy it into the buffer. More...
 
void rejectPacket ()
 Check the received packet, and reply with a rejection packet. More...
 
boolean bufferContainsReceived ()
 Check if the packet buffer contains a valid received packet. More...
 
IPv6Packetpacket ()
 Get a reference to the packet buffer (the last packet sent or received). More...
 
void send ()
 Send the packet currently in the packet buffer.
 
void prepareSend ()
 Get the packet buffer ready to send a packet. More...
 
void prepareReply ()
 Convert the packet current in the packet buffer into a reply. More...
 
IPv6AddresslookupHostname (const char *hostname)
 Lookup a hostname using DNS and get an IPv6 address for it. More...
 
MACAddressdiscoverNeighbour (const char *address)
 Perform Neighbour Discovery for an IPv6 address on the local subnet. More...
 
MACAddressdiscoverNeighbour (IPv6Address &address, uint8_t attempts=NEIGHBOUR_SOLICITATION_ATTEMPTS)
 Perform Neighbour Discovery for an IPv6 address on the local subnet. More...
 
void tcpSendRSTReply ()
 Send a reply with a TCP RST packet.
 

Detailed Description

Run EtherSia on Linux using a raw socket to Send and receive Ethernet frames Not intended for use with running EtherSia on Arduino.

Note
this is probably only useful for testing and development of EtherSia.

Constructor & Destructor Documentation

◆ EtherSia_LinuxSocket()

EtherSia_LinuxSocket::EtherSia_LinuxSocket ( const char *  iface = NULL)

Constructor.

Parameters
ifacethe name of the Ethernet interface to send/receive on

Member Function Documentation

◆ begin() [1/2]

boolean EtherSia::begin

Configure the Ethernet interface and get things ready.

If auto-configuration has not been disabled, then stateless auto-configuration will start - attempting to get an IP address and Router address using IGMPv6.

Returns
Returns true if setting up the Ethernet interface was successful

◆ begin() [2/2]

virtual boolean EtherSia_LinuxSocket::begin ( const MACAddress address)
virtual

Initialise the Ethernet controller Must be called before sending or receiving Ethernet frames.

Parameters
addressthe local MAC address for the Ethernet interface
Returns
Returns true if setting up the Ethernet interface was successful

◆ readFrame()

virtual uint16_t EtherSia_LinuxSocket::readFrame ( uint8_t *  buffer,
uint16_t  bufsize 
)
virtual

Read an Ethernet frame.

Parameters
buffera pointer to a buffer to write the packet to
bufsizethe available space in the buffer
Returns
the length of the received packet or 0 if no packet was received

Implements EtherSia.

◆ sendFrame()

virtual uint16_t EtherSia_LinuxSocket::sendFrame ( const uint8_t *  data,
uint16_t  datalen 
)
virtual

Send an Ethernet frame.

Parameters
dataa pointer to the data to send
datalenthe length of the data in the packet
Returns
the number of bytes transmitted

Implements EtherSia.