2a4b80d0fbe03ad69747e148b5fd93b0ed7f3f0c
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) 
27) /// initialize
Stefan Schuermans implemented IP + ICMP, fixe...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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