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

Send and receive Ethernet frames directly using a Wiznet W5100 controller. More...

#include <w5100.h>

Public Member Functions

 EtherSia_W5100 (int8_t cs=SS)
 Constructor that uses the default hardware SPI pins. More...
 
boolean begin (const MACAddress &address)
 Initialise the Ethernet controller Must be called before sending or receiving Ethernet frames. More...
 
void end ()
 Shut down the Ethernet controlled.
 
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...
 
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

Send and receive Ethernet frames directly using a Wiznet W5100 controller.

Examples:
MiniHTTPServer.ino, SNTPClient.ino, and Syslog.ino.

Constructor & Destructor Documentation

◆ EtherSia_W5100()

EtherSia_W5100::EtherSia_W5100 ( int8_t  cs = SS)

Constructor that uses the default hardware SPI pins.

Parameters
csthe Arduino Chip Select / Slave Select pin (default 10 on Uno)

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]

boolean EtherSia_W5100::begin ( const MACAddress address)

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
Examples:
MiniHTTPServer.ino, SNTPClient.ino, and Syslog.ino.

References EtherSia::begin().

◆ readFrame()

uint16_t EtherSia_W5100::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()

uint16_t EtherSia_W5100::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.