spinnaker_tools 3.4.0
SpiNNaker API, sark, sc&mp, bmp firmware and build tools
|
Ethernet/IP support routines for Spinnaker. More...
Go to the source code of this file.
Data Structures | |
struct | arp_pkt_t |
ARP packet format. More... | |
struct | udp_hdr_t |
UDP header. More... | |
struct | icmp_hdr_t |
ICMP header. More... | |
struct | mac_hdr_t |
MAC header for ethernet packet. More... | |
struct | ip_hdr_t |
IP packet header. More... | |
Macros | |
#define | MAC_HDR_SIZE 14 |
Size of mac_hdr_t. | |
#define | IP_HDR_SIZE 20 |
Size of ip_hdr_t. | |
#define | UDP_HDR_SIZE 8 |
Size of udp_hdr_t. | |
#define | SDP_PAD_SIZE 2 |
Padding added to start of SDP for alignment efficiency. | |
#define | IP_HDR_OFFSET MAC_HDR_SIZE |
Offset from start of packet to start of IP header. | |
#define | IP_DATA_OFFSET (IP_HDR_OFFSET + IP_HDR_SIZE) |
Offset from start of packet to start of IP data. | |
#define | UDP_HDR_OFFSET IP_DATA_OFFSET |
Offset from start of packet to start of UDP header. | |
#define | UDP_DATA_OFFSET (UDP_HDR_OFFSET + UDP_HDR_SIZE) |
Offset from start of packet to start of UDP data. | |
#define | ETYPE_IP 0x0800 |
Ethernet message type: IP. | |
#define | ETYPE_ARP 0x0806 |
Ethernet message type: ARP. | |
#define | PROT_ICMP 1 |
Protocol: ICMP. | |
#define | PROT_UDP 17 |
Protocol: UDP. | |
#define | ARP_REQ 1 |
ARP message operation: request. | |
#define | ARP_REPLY 2 |
ARP message operation: reply. | |
#define | ICMP_ECHO_REPLY 0 |
ICMP echo (ping) reply. | |
#define | ICMP_ECHO_REQ 8 |
ICMP echo (ping) request. | |
Functions | |
void | eth_init (uchar *mac) |
Initialise the ethernet subsystem. | |
uint | ipsum (uchar *d, uint len, uint sum) |
Compute an IP checksum. | |
void | copy_mac (const uchar *f, uchar *t) |
Copy MAC address. | |
void | copy_ip (const uchar *f, uchar *t) |
Copy IP address. | |
uint | cmp_ip (const uchar *a, const uchar *b) |
Compare IP addresses. | |
void | copy_ip_hdr (uchar *dest, uint prot, ip_hdr_t *ip, uint len) |
Initialise IP header. | |
void | eth_transmit (uchar *buf, uint len, uint type, const uchar *dest) |
Transmit ethernet packet. | |
void | eth_transmit2 (uchar *hdr, uchar *buf, uint hdr_len, uint buf_len) |
Transmit ethernet packet. | |
void | send_arp_pkt (uchar *buf, const uchar *dest, const uchar *tha, const uchar *tpa, uint type) |
Send an ARP packet. | |
void | arp_lookup (iptag_t *iptag) |
Initiate ARP lookup if required. Lookup might be immediate (out of cache) or require network traffic. | |
void | arp_pkt (uchar *rx_pkt, uint rx_len, uint tag_table_size) |
ARP packet received handler. | |
void | arp_add (uchar *mac, uchar *ip) |
Add a MAC/IP address binding to our ARP cache. | |
void | icmp_pkt (uchar *rx_pkt, uint rx_len) |
ICMP packet received handler. | |
void | copy_udp (uchar *buf, uint len, uint dest, uint srce) |
Initialise UDP packet header. | |
Variables | |
const uchar | bc_mac [] |
Broadcast MAC address. | |
const uchar | zero_mac [] |
Zero MAC address. | |
Ethernet/IP support routines for Spinnaker.
struct arp_pkt_t |
ARP packet format.
Data Fields | ||
---|---|---|
ushort | htype | Hardware type. |
ushort | ptype | Protocol type (e.g., ETYPE_IP) |
uchar | hlen | Hardware address length. |
uchar | plen | Protocol address length. |
ushort | op | Operation (e.g., ARP_REQ) |
uchar | sha[6] | Sender hardware address. |
uchar | spa[4] | Sender protocol address. |
uchar | tha[6] | Target hardware address. |
uchar | tpa[4] | Target protocol address. |
struct udp_hdr_t |
struct icmp_hdr_t |
struct mac_hdr_t |
struct ip_hdr_t |
IP packet header.
Data Fields | ||
---|---|---|
uchar | ver_len | Version and header length. |
uchar | DS | DSCP/ECN. |
ushort | length | Message length. |
ushort | ident | Identification (for fragment reassembly) |
ushort | flg_off | Flags/fragment offset; SCAMP doesn't support fragments. |
uchar | TTL | Time-to-live. |
uchar | protocol | Protocol (e.g., PROT_UDP) |
ushort | checksum | Checksum. |
uchar | srce[4] | Source IP address. |
uchar | dest[4] | Destination IP address. |
void eth_init | ( | uchar * | mac | ) |
Initialise the ethernet subsystem.
[in] | mac | Our MAC address |
Compute an IP checksum.
[in] | d | The data to checksum |
[in] | len | Number of bytes in data |
[in] | sum | Initial value; allows chaining of summing |
Copy MAC address.
[in] | f | Where to copy from. Must be at least half-word aligned |
[out] | t | Where to copy to. Must be at least half-word aligned |
Copy IP address.
[in] | f | Where to copy from. Must be at least half-word aligned |
[out] | t | Where to copy to. Must be at least half-word aligned |
Compare IP addresses.
[in] | a | First address to compare |
[in] | b | Second address to compare |
Initialise IP header.
[in] | dest | Destination address |
[in] | prot | Protocol to use |
[in,out] | ip | Packet with header to initialise, copying dest into. The payload must have already been placed in the packet. |
[in] | len | The length of the payload in the packet. |
Transmit ethernet packet.
[in,out] | buf | The buffer containing the packet to send. Will have the parts that are the ethernet header modified. |
[in] | len | Length of buffer (headers and payload) |
[in] | type | The type of ethernet packet to send |
[in] | dest | The destination MAC address |
Transmit ethernet packet.
[in] | hdr | The ethernet header, already prepared. |
[in] | buf | The buffer containing the payload to send. |
[in] | hdr_len | Length of header, hdr |
[in] | buf_len | Length of payload, buf |
void send_arp_pkt | ( | uchar * | buf, |
const uchar * | dest, | ||
const uchar * | tha, | ||
const uchar * | tpa, | ||
uint | type | ||
) |
Send an ARP packet.
[in,out] | buf | Buffer containing ARP packet. Payload must have been set. |
[in] | dest | Destination MAC address |
[in] | tha | Target hadrware address |
[in] | tpa | Target protocol address |
[in] | type | Opcode (e.g., ARP_REQ) |
void arp_lookup | ( | iptag_t * | iptag | ) |
Initiate ARP lookup if required. Lookup might be immediate (out of cache) or require network traffic.
[in,out] | iptag | The IPTag that needs the lookup done. Will be updated with results when available. |
ARP packet received handler.
[in] | rx_pkt | The received packet |
[in] | rx_len | The length of the received packet |
[in] | tag_table_size | How large is our tag table? |
Add a MAC/IP address binding to our ARP cache.
[in] | mac | The MAC address |
[in] | ip | The IP address |
ICMP packet received handler.
[in] | rx_pkt | The received packet |
[in] | rx_len | The length of the received packet |