Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | \ ========== Copyright Header Begin ========================================== |
2 | \ | |
3 | \ Hypervisor Software File: arp-h.fth | |
4 | \ | |
5 | \ Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. | |
6 | \ | |
7 | \ - Do no alter or remove copyright notices | |
8 | \ | |
9 | \ - Redistribution and use of this software in source and binary forms, with | |
10 | \ or without modification, are permitted provided that the following | |
11 | \ conditions are met: | |
12 | \ | |
13 | \ - Redistribution of source code must retain the above copyright notice, | |
14 | \ this list of conditions and the following disclaimer. | |
15 | \ | |
16 | \ - Redistribution in binary form must reproduce the above copyright notice, | |
17 | \ this list of conditions and the following disclaimer in the | |
18 | \ documentation and/or other materials provided with the distribution. | |
19 | \ | |
20 | \ Neither the name of Sun Microsystems, Inc. or the names of contributors | |
21 | \ may be used to endorse or promote products derived from this software | |
22 | \ without specific prior written permission. | |
23 | \ | |
24 | \ This software is provided "AS IS," without a warranty of any kind. | |
25 | \ ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, | |
26 | \ INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A | |
27 | \ PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN | |
28 | \ MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR | |
29 | \ ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR | |
30 | \ DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN | |
31 | \ OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR | |
32 | \ FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE | |
33 | \ DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, | |
34 | \ ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF | |
35 | \ SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. | |
36 | \ | |
37 | \ You acknowledge that this software is not designed, licensed or | |
38 | \ intended for use in the design, construction, operation or maintenance of | |
39 | \ any nuclear facility. | |
40 | \ | |
41 | \ ========== Copyright Header End ============================================ | |
42 | id: @(#)arp-h.fth 1.1 04/09/07 | |
43 | purpose: | |
44 | copyright: Copyright 2004 Sun Microsystems, Inc. All Rights Reserved | |
45 | copyright: Use is subject to license terms. | |
46 | ||
47 | headerless | |
48 | ||
49 | struct | |
50 | /w field >arp-hwtype \ Format of hardware address | |
51 | /w field >arp-prtype \ Format of protocol address | |
52 | /c field >arp-hwlen \ Length of hardware address | |
53 | /c field >arp-prlen \ Length of protocol address | |
54 | /w field >arp-op \ ARP Opcode | |
55 | constant /arp-header | |
56 | ||
57 | : >arp-sha ( pkt -- adr ) /arp-header + ; | |
58 | : >arp-spa ( pkt -- adr ) /arp-header + if-addrlen@ + ; | |
59 | : >arp-tha ( pkt -- adr ) /arp-header + if-addrlen@ + /ip-addr + ; | |
60 | : >arp-tpa ( pkt -- adr ) /arp-header + if-addrlen@ 2* + /ip-addr + ; | |
61 | ||
62 | : /arp-packet ( -- n ) | |
63 | /arp-header if-addrlen@ /ip-addr + 2* + | |
64 | ; | |
65 | ||
66 | \ ARP/RARP Opcodes | |
67 | 1 constant ARP_REQ | |
68 | 2 constant ARP_REPLY | |
69 | 3 constant RARP_REQ | |
70 | d# 4 constant RARP_REPLY | |
71 | ||
72 | \ ARP cache entry structure | |
73 | struct | |
74 | /ip-addr field >ae-ipaddr \ Protocol Address | |
75 | MAX_HWADDR_LEN field >ae-hwaddr \ Hardware Address | |
76 | dup aligned over - field >ae-pad \ For structure alignment | |
77 | /queue-head field >ae-pktq \ Queue of pending packets | |
78 | /timer field >ae-timer \ "Aging" timer entry | |
79 | /l field >ae-state \ State of this entry | |
80 | /l field >ae-attempts \ Number of retries so far | |
81 | constant /arp-entry | |
82 | ||
83 | \ ARP cache entry states | |
84 | 0 constant AE_FREE \ Entry is free | |
85 | 1 constant AE_PENDING \ Entry is awaiting address resolution | |
86 | 2 constant AE_RESOLVED \ Entry is valid | |
87 | ||
88 | 0 instance value arp-table \ ARP cache | |
89 | d# 8 constant ARP_TABLE_SIZE \ Size of ARP cache | |
90 | ||
91 | d# 4 constant ARP_MAX_RETRIES \ Maximum number of retries | |
92 | d# 1000 constant ARP_RETRY_INTERVAL \ Minimum retry interval | |
93 | d# 600000 constant ARP_ENTRY_TTL \ Lifetime of valid ARP cache entry | |
94 | ||
95 | : ae-state@ ( adr -- state ) >ae-state l@ ; | |
96 | : ae-state! ( state adr -- ) >ae-state l! ; | |
97 | ||
98 | : index>arp-entry ( index -- adr ) /arp-entry * arp-table + ; | |
99 | ||
100 | headers |