00d70bee0c1121134e74c1402ebdc9b80807a3bf
Stefan Schuermans implementation of ethernet...

Stefan Schuermans authored 12 years ago

1) #ifndef ARP_H
2) #define ARP_H
3) 
4) #include "ethernet.h"
5) 
Stefan Schuermans added padding of ethernet p...

Stefan Schuermans authored 12 years ago

6) /// header of ARP packet
Stefan Schuermans implementation of ethernet...

Stefan Schuermans authored 12 years ago

7) struct arp_header
8) {
9)   unsigned short hw_type;
10)   unsigned short proto_type;
11)   unsigned char hw_len;
12)   unsigned char proto_len;
13)   unsigned short op;
14)   unsigned char src_mac[6];
15)   unsigned char src_ip[4];
16)   unsigned char dest_mac[6];
17)   unsigned char dest_ip[4];
18) } __attribute__((packed));
19) 
Stefan Schuermans added padding of ethernet p...

Stefan Schuermans authored 12 years ago

20) /// ARP packet
Stefan Schuermans implementation of ethernet...

Stefan Schuermans authored 12 years ago

21) struct arp_packet
22) {
23)   struct ethernet_header eth_hdr;
24)   struct arp_header arp_hdr;
25) } __attribute__((packed));
26) 
Stefan Schuermans added padding of ethernet p...

Stefan Schuermans authored 12 years ago

27) /// ARP packet with padding
28) ETHERNET_PAD(arp_packet);
29) 
Stefan Schuermans implementation of ethernet...

Stefan Schuermans authored 12 years ago

30) /// initialize
Stefan Schuermans implemented IP + ICMP, fixe...

Stefan Schuermans authored 12 years ago

31) void arp_init(void);
Stefan Schuermans implementation of ethernet...

Stefan Schuermans authored 12 years ago

32) 
33) /// tick procedure - call every 200ms
Stefan Schuermans implemented IP + ICMP, fixe...

Stefan Schuermans authored 12 years ago

34) void arp_tick200(void);
Stefan Schuermans implementation of ethernet...

Stefan Schuermans authored 12 years ago

35) 
36) /**
37)  * @brief process a received ARP packet
38)  * @param[in] ptr pointer to data of packet
39)  * @param[in] sz size of packet
40)  */
Stefan Schuermans implemented IP + ICMP, fixe...

Stefan Schuermans authored 12 years ago

41) void arp_recv(void *ptr, unsigned int sz);
Stefan Schuermans implementation of ethernet...

Stefan Schuermans authored 12 years ago

42) 
43) /**
44)  * @brief look up the MAC for an IP address
45)  * @param[in] ip IP address to look up
46)  * @param[out] mac MAC address for this IP address
47)  * @return 0 in case of success, 1 if the MAC address is unknown
48)  */
Stefan Schuermans implemented IP + ICMP, fixe...

Stefan Schuermans authored 12 years ago

49) int arp_lookup(unsigned char ip[4], unsigned char mac[6]);