spinnaker_tools 3.4.0
SpiNNaker API, sark, sc&mp, bmp firmware and build tools
|
Ethernet/IP support routines for Spinnaker. More...
#include "spinnaker.h"
#include "sark.h"
#include "scamp.h"
#include "spinn_net.h"
#include <string.h>
Data Structures | |
struct | arp_entry |
An ARP cache entry. More... | |
Macros | |
#define | MAX_ARP_ENTRIES 5 |
Max size of ARP cache. | |
Functions | |
static void | eth_discard (void) |
Clear the ethernet receive buffer. | |
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 | |
srom_data_t | srom |
Copy of SROM struct. | |
iptag_t | tag_table [] |
Table of all IPTags. | |
const uchar | bc_mac [] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff} |
Broadcast MAC address. | |
const uchar | zero_mac [] = {0, 0, 0, 0, 0, 0} |
Zero MAC address. | |
static struct arp_entry | arp_entries [MAX_ARP_ENTRIES] |
The ARP cache. | |
static uint | next_arp_entry = MAX_ARP_ENTRIES |
Which is the next ARP cache entry to allocate (or evict and reuse) | |
Ethernet/IP support routines for Spinnaker.
struct arp_entry |
An ARP cache entry.
This remembers what MAC address to send an ethernet packet to in order to deliver an IP packet to a particular address. That MAC address might be the address of a router, not the target machine.
Data Fields | ||
---|---|---|
uchar | mac[6] | The MAC address. |
uchar | ip[4] | The IP address. |
struct arp_entry * | next | Next entry in use. |
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 |