|
|
1.1 root 1: /* netboot
2: *
3: * arp.h,v
4: * Revision 1.1 1993/07/08 16:03:48 brezak
5: * Diskless boot prom code from Jim McKim ([email protected])
6: *
7: * Revision 1.2 1993/06/30 20:14:12 mckim
8: * Added BOOTP support.
9: *
10: * Revision 1.1.1.1 1993/05/28 11:41:07 mckim
11: * Initial version.
12: *
13: *
14: * source in this file came from
15: * the Mach ethernet boot written by Leendert van Doorn.
16: *
17: * Ethernet Address Resolution Protocol (see RFC 826)
18: */
19:
20: /*
21: * ARP packets are variable in size; the arphdr_t type defines the
22: * 10Mb Ethernet variant. Field names used correspond to RFC 826.
23: */
24: typedef struct {
25: u_short arp_hrd; /* format of hardware address */
26: #define ARPHRD_ETHER 1 /* ethernet hardware address */
27: u_short arp_pro; /* format of proto. address */
28: u_char arp_hln; /* length of hardware address */
29: u_char arp_pln; /* length of protocol address */
30: u_short arp_op;
31: #define ARPOP_REQUEST 1 /* request to resolve address */
32: #define ARPOP_REPLY 2 /* response to previous request */
33: #define REVARP_REQUEST 3 /* reverse ARP request */
34: #define REVARP_REPLY 4 /* reverse ARP reply */
35: u_char arp_sha[ETH_ADDRSIZE]; /* sender hardware address */
36: u_char arp_spa[4]; /* sender protocol address */
37: u_char arp_tha[ETH_ADDRSIZE]; /* target hardware address */
38: u_char arp_tpa[4]; /* target protocol address */
39: } arphdr_t;
40:
41: /*
42: * Internet to hardware address resolution table
43: */
44: typedef struct {
45: ipaddr_t at_ipaddr; /* internet address */
46: u_char at_eaddr[ETH_ADDRSIZE]; /* ethernet address */
47: u_long at_timer; /* time when referenced */
48: u_char at_flags; /* flags */
49: packet_t *at_hold; /* ast packet until resolved/timeout */
50: } arptab_t;
51:
52: /* at_flags field values */
53: #define ATF_INUSE 1 /* entry in use */
54: #define ATF_COM 2 /* completed entry (eaddr valid) */
55:
56: #define ARPTAB_BSIZ 3 /* bucket size */
57: #define ARPTAB_NB 2 /* number of buckets */
58: #define ARPTAB_SIZE (ARPTAB_BSIZ * ARPTAB_NB)
59:
60: #define ARPTAB_HASH(a) \
61: ((short)((((a) >> 16) ^ (a)) & 0x7fff) % ARPTAB_NB)
62:
63: #define ARPTAB_LOOK(at, addr) { \
64: register n; \
65: at = &arptab[ARPTAB_HASH(addr) * ARPTAB_BSIZ]; \
66: for (n = 0; n < ARPTAB_BSIZ; n++, at++) \
67: if (at->at_ipaddr == addr) \
68: break; \
69: if (n >= ARPTAB_BSIZ) \
70: at = 0; }
71:
72: ipaddr_t GetIpAddress(ipaddr_t *server, ipaddr_t *my_addr, ipaddr_t *gateway, char *filename);
73: void ArpInput(packet_t *);
74: int ArpResolve(packet_t *, ipaddr_t, u_char *);
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.