c2b040193a777c09bdc595c95492b57a2521db87
Stefan Schuermans added file headers

Stefan Schuermans authored 12 years ago

1) /* MIPS I system
2)  * Copyright 2011-2012 Stefan Schuermans <stefan@schuermans.info>
3)  * Copyleft GNU public license V2 or later
4)  *          http://www.gnu.org/copyleft/gpl.html
5)  */
6) 
Stefan Schuermans implementation of ethernet...

Stefan Schuermans authored 12 years ago

7) #ifndef ARP_H
8) #define ARP_H
9) 
10) #include "ethernet.h"
11) 
Stefan Schuermans added padding of ethernet p...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

13) struct arp_header
14) {
15)   unsigned short hw_type;
16)   unsigned short proto_type;
17)   unsigned char hw_len;
18)   unsigned char proto_len;
19)   unsigned short op;
20)   unsigned char src_mac[6];
21)   unsigned char src_ip[4];
22)   unsigned char dest_mac[6];
23)   unsigned char dest_ip[4];
24) } __attribute__((packed));
25) 
Stefan Schuermans added padding of ethernet p...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

27) struct arp_packet
28) {
29)   struct ethernet_header eth_hdr;
30)   struct arp_header arp_hdr;
31) } __attribute__((packed));
32) 
33) /// initialize
Stefan Schuermans implemented IP + ICMP, fixe...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

52) int arp_lookup(unsigned char ip[4], unsigned char mac[6]);
Stefan Schuermans implementation of ethernet...

Stefan Schuermans authored 12 years ago

53) 
Stefan Schuermans use implicit MAC/IP informa...

Stefan Schuermans authored 12 years ago

54) /**
55)  * @brief store the MAC for an IP address
56)  * @param[in] ip IP address to store MAC for
57)  * @param[out] mac MAC address for this IP address
58)  */
59) void arp_store(unsigned char ip[4], unsigned char mac[6]);
60)