31#define MAC_HDR_SIZE 14
40#define IP_HDR_OFFSET MAC_HDR_SIZE
42#define IP_DATA_OFFSET (IP_HDR_OFFSET + IP_HDR_SIZE)
45#define UDP_HDR_OFFSET IP_DATA_OFFSET
47#define UDP_DATA_OFFSET (UDP_HDR_OFFSET + UDP_HDR_SIZE)
49#define ETYPE_IP 0x0800
50#define ETYPE_ARP 0x0806
58#define ICMP_ECHO_REPLY 0
59#define ICMP_ECHO_REQ 8
static int sum
Sum to make moving average easy.
Definition scamp-isr.c:166
IPTAG entry (32 bytes)
Definition scamp.h:376
uchar DS
DSCP/ECN.
Definition spinn_net.h:101
void send_arp_pkt(uchar *buf, const uchar *dest, const uchar *tha, const uchar *tpa, uint type)
Send an ARP packet.
Definition spinn_net.c:228
ushort length
Message length.
Definition spinn_net.h:102
ushort flg_off
Flags/fragment offset; SCAMP doesn't support fragments.
Definition spinn_net.h:104
void eth_transmit(uchar *buf, uint len, uint type, const uchar *dest)
Transmit ethernet packet.
Definition spinn_net.c:170
void arp_lookup(iptag_t *iptag)
Initiate ARP lookup if required. Lookup might be immediate (out of cache) or require network traffic.
Definition spinn_net.c:249
void arp_pkt(uchar *rx_pkt, uint rx_len, uint tag_table_size)
ARP packet received handler.
Definition spinn_net.c:281
uchar TTL
Time-to-live.
Definition spinn_net.h:105
ushort seq
Sequence number.
Definition spinn_net.h:88
uchar srce[6]
Source MAC address.
Definition spinn_net.h:94
void copy_mac(const uchar *f, uchar *t)
Copy MAC address.
Definition spinn_net.c:125
const uchar zero_mac[]
Zero MAC address.
Definition spinn_net.c:42
uchar ver_len
Version and header length.
Definition spinn_net.h:100
void icmp_pkt(uchar *rx_pkt, uint rx_len)
ICMP packet received handler.
Definition spinn_net.c:323
ushort checksum
Checksum.
Definition spinn_net.h:86
ushort htype
Hardware type.
Definition spinn_net.h:63
ushort ident
Conversation identifier.
Definition spinn_net.h:87
uchar plen
Protocol address length.
Definition spinn_net.h:66
uchar protocol
Protocol (e.g., PROT_UDP)
Definition spinn_net.h:106
ushort ptype
Protocol type (e.g., ETYPE_IP)
Definition spinn_net.h:64
void copy_ip_hdr(uchar *dest, uint prot, ip_hdr_t *ip, uint len)
Initialise IP header.
Definition spinn_net.c:152
ushort dest
Destination port.
Definition spinn_net.h:77
void copy_ip(const uchar *f, uchar *t)
Copy IP address.
Definition spinn_net.c:135
uint cmp_ip(const uchar *a, const uchar *b)
Compare IP addresses.
Definition spinn_net.c:144
void copy_udp(uchar *buf, uint len, uint dest, uint srce)
Initialise UDP packet header.
Definition spinn_net.c:364
void eth_init(uchar *mac)
Initialise the ethernet subsystem.
Definition spinn_net.c:91
void arp_add(uchar *mac, uchar *ip)
Add a MAC/IP address binding to our ARP cache.
Definition spinn_net.c:313
ushort type
Message type, "EtherType" (e.g., ETYPE_IP)
Definition spinn_net.h:95
ushort checksum
Checksum.
Definition spinn_net.h:107
uchar hlen
Hardware address length.
Definition spinn_net.h:65
uchar code
Error code (zero)
Definition spinn_net.h:85
ushort checksum
Checksum.
Definition spinn_net.h:79
ushort srce
Source port.
Definition spinn_net.h:76
uint ipsum(uchar *d, uint len, uint sum)
Compute an IP checksum.
Definition spinn_net.c:105
ushort length
Length.
Definition spinn_net.h:78
const uchar bc_mac[]
Broadcast MAC address.
Definition spinn_net.c:41
void eth_transmit2(uchar *hdr, uchar *buf, uint hdr_len, uint buf_len)
Transmit ethernet packet.
Definition spinn_net.c:201
ushort ident
Identification (for fragment reassembly)
Definition spinn_net.h:103
uchar dest[6]
Destination MAC address.
Definition spinn_net.h:93
uchar type
Message type (e.g., ICMP_ECHO_REQ)
Definition spinn_net.h:84
ushort op
Operation (e.g., ARP_REQ)
Definition spinn_net.h:67
ARP packet format.
Definition spinn_net.h:62
ICMP header.
Definition spinn_net.h:83
IP packet header.
Definition spinn_net.h:99
MAC header for ethernet packet.
Definition spinn_net.h:92
UDP header.
Definition spinn_net.h:75
unsigned char uchar
Unsigned integer - 8 bits.
Definition spinnaker.h:37
unsigned int uint
Unsigned integer - 32 bits.
Definition spinnaker.h:39
unsigned short ushort
Unsigned integer - 16 bits.
Definition spinnaker.h:38