2002-09 Gundolf von Bachhaus: 90% rewrite - Optional non-blocking ARP lookup & redirect handling Gateway / Route / ARP data stored & accessed sererately Module encapsulated - no global variables
Definition in file pcarp.c.
Go to the source code of this file.
Data Structures | |
| struct | route_entry |
| ROUTE (& REDIRECT) HANDLING. More... | |
Functions | |
| BOOL | LAN_lookup (DWORD ip, eth_address *eth) |
| Lookup host in fixed/dynamic list. | |
| BOOL | is_on_LAN (DWORD ip) |
| This should probably go in pcconfig.c. | |
| void | arp_daemon (void) |
| ARP "background" daemon. | |
| int | _arp_list_gateways (struct gate_entry *gw, int max) |
| Gateway functions. | |
| int | ping_gateway (DWORD host, void *eth) |
| void | check_dead_gw (void) |
| BOOL | _arp_add_gateway (const char *config_string, DWORD ip) |
| Add a gateway to the routing table. | |
| void | _arp_kill_gateways (void) |
| Delete all gateways. | |
| BOOL | _arp_have_default_gw (void) |
| Check if we have at least one default gateway. | |
| __inline BOOL | arp_send (const arp_Header *arp, unsigned line) |
| Low-level ARP send function. | |
| BOOL | arp_send_request (DWORD ip) |
| Send broadcast ARP request. | |
| BOOL | _arp_reply (const void *mac_dst, DWORD src_ip, DWORD dst_ip) |
| Send unicast/broadcast ARP reply. | |
| __inline void | arp_move_entry (int to_index, int from_index) |
| Move an ARP entry from from_index to to_index. | |
| BOOL | LAN_start_lookup (DWORD ip) |
| Start a host lookup on the LAN. | |
| BOOL | LAN_lookup_pending (DWORD ip) |
| Lookup host in pending list. | |
| void | arp_check_timeouts (BOOL check_dynamic_entries) |
| Check ARP entries for timeout. | |
| __inline void | route_move_entry (int to_index, int from_index) |
| BOOL | route_makeNewSlot (DWORD host_ip, DWORD gate_ip) |
| BOOL | _arp_register (DWORD use_this_gateway_ip, DWORD for_this_host_ip) |
| ICMP redirection. | |
| BOOL | route_lookup (DWORD host_ip, eth_address *eth) |
| Gets MAC of gateway needed to reach the given host. | |
| BOOL | route_lookup_pending (DWORD host_ip) |
| Returns TRUE if the lookup of the gateway (assigned to the supplied host) is still pending. | |
| BOOL | route_start_lookup (DWORD host_ip) |
| Start a route lookup. | |
| void | route_check_timeouts (BOOL check_dynamic_entries) |
| Periodic route checker. | |
| BOOL | arp_start_lookup (DWORD ip) |
| New non-blocking functions, GvB 2002-09. | |
| BOOL | arp_lookup (DWORD ip, eth_address *eth) |
| Lookup MAC-address of 'ip'. | |
| BOOL | arp_lookup_pending (DWORD ip) |
| An ARP-lookup timeout check. | |
| BOOL | arp_lookup_fixed (DWORD ip, eth_address *eth) |
| Lookup fixed MAC-address of 'ip'. | |
| BOOL | _arp_resolve (DWORD ip, eth_address *eth) |
| Blocking ARP resolve functions. | |
| BOOL | _arp_add_cache (DWORD ip, const void *eth, BOOL expires) |
| ARP cache functions. | |
| BOOL | _arp_delete_cache (DWORD ip) |
| Delete given 'ip' address from ARP-cache (dynamic or fixed). | |
| void | arp_parse (const char *name, const char *value) |
| void | arp_alloc (void) |
| void | _arp_init (void) |
| 'Internal' interface to pctcp.c & others. | |
| BOOL | _arp_handler (const arp_Header *ah, BOOL brdcast) |
| Receive ARP handler. | |
| BOOL | _arp_check_own_ip (eth_address *other_guy) |
| Used by DHCP initialisation. | |
| int | _arp_list_cache (struct arp_entry *arp, int max) |
| Return contents of ARP cache. | |
| int | _arp_check_gateways (void) |
| Return number of default gateways. | |
| void | _arp_debug_dump (void) |
| Debug-dump of configured gateways, route table and ARP cache. | |
Variables | |
| int | arp_timeout = 2 |
| int | arp_alive = 300 |
| int | arp_rexmit_to = 250 |
| int | arp_num_cache = 64 |
| BOOL | dead_gw_detect = FALSE |
| BOOL | arp_gratiotous = FALSE |
| int | gate_top = 0 |
| gate_entry | gate_list [GATE_TOP_OF_CACHE] |
| WORD | icmp_id = 0 |
| Send a ping (with ttl=1) to a gateway. | |
| WORD | icmp_seq = 0 |
| int | arp_first_pending = ARP_TOP_PENDING |
| int | arp_first_free = 0 |
| int | arp_first_dynamic = 0 |
| arp_entry | arp_list [ARP_TOP_OF_CACHE] |
| int | route_first_pending = route_top_pending |
| int | route_first_free = 0 |
| route_entry | route_list [route_top_of_cache] |
| void(* | prev_cfg_hook )(const char *, const char *) |
| Parser for "\c ARP.xx" keywords in "\c WATTCP.CFG". | |
| void(* | prev_post_hook )(void) |
|
||||||||||||||||
|
ARP cache functions.
References _arp_delete_cache(), arp_move_entry(), DWORD, arp_entry::ip, is_on_LAN(), my_ip_addr, and set_timeout(). |
|
||||||||||||
|
Add a gateway to the routing table. The format of 'config_string' is: IP-address [, subnet] , mask]] If 'config_string' is NULL, simply add 'ip' with zero mask and subnet. Definition at line 185 of file pcarp.c. References aton(), DWORD, and gate_entry::gate_ip. |
|
|
Used by DHCP initialisation. Do an ARP resolve on our own IP address to check if someone else is replying. Return non-zero if someone replied.
References _arp_resolve(), DWORD, eth_address, and my_ip_addr. |
|
|
Debug-dump of configured gateways, route table and ARP cache. Redone + moved here from pcdbug.c for encapsulation reasons GvB 2002-09 Definition at line 1625 of file pcarp.c. References _inet_ntoa(), DWORD, MAC_address(), gate_entry::mask, set_timeout(), and sin_mask. |
|
|
Delete given 'ip' address from ARP-cache (dynamic or fixed).
References arp_move_entry(), DWORD, arp_entry::flags, and arp_entry::ip. |
|
||||||||||||
|
Receive ARP handler. This processes incoming 'raw' ARP packets supplied by tcp_tick(). Definition at line 1412 of file pcarp.c. References _arp_add_cache(), _arp_reply(), _eth_addr, _eth_brdcast, _eth_get_hwtype(), _eth_mac_len, _inet_ntoa(), _pkt_rxmode, arp_move_entry(), arp_Header::dstIPAddr, DWORD, eth_address, arp_entry::expiry, arp_entry::flags, arp_Header::hwAddrLen, arp_Header::hwType, arp_entry::ip, MAC_address(), my_ip_addr, arp_Header::opcode, arp_Header::protoAddrLen, arp_Header::protType, RXMODE_BROADCAST, set_timeout(), arp_Header::srcEthAddr, arp_Header::srcIPAddr, and WORD. |
|
||||||||||||
|
Return contents of ARP cache. 'max' entries are returned in 'arp[]' buffers. Only entries in-use are returned. Definition at line 1576 of file pcarp.c. References eth_address, arp_entry::expiry, arp_entry::flags, arp_entry::hardware, and arp_entry::ip. |
|
||||||||||||
|
Gateway functions.
References gate_entry::echo_pending, gate_entry::gate_ip, gate_entry::is_dead, gate_entry::mask, and gate_entry::subnet. |
|
||||||||||||
|
ICMP redirection. Called on ICMP-redirects. Redirects are sent from a gateway/router, telling us that a different gateway is better suited to connect to the specified host than the one we were using. Definition at line 718 of file pcarp.c. References DWORD, route_entry::gate_ip, is_on_LAN(), LAN_lookup(), and LAN_start_lookup(). |
|
||||||||||||||||
|
Send unicast/broadcast ARP reply. 'src_ip' and 'dst_ip' on network order. Definition at line 409 of file pcarp.c. References _eth_addr, _eth_brdcast, _eth_formatpacket(), _eth_get_hwtype(), arp_send(), arp_Header::dstEthAddr, arp_Header::dstIPAddr, DWORD, arp_Header::hwAddrLen, arp_Header::hwType, arp_Header::opcode, arp_Header::protoAddrLen, arp_Header::protType, arp_Header::srcEthAddr, and arp_Header::srcIPAddr. |
|
||||||||||||
|
Blocking ARP resolve functions. Doesn't return until success or time-out. Definition at line 1108 of file pcarp.c. References _eth_addr, _pktserial, arp_daemon(), DWORD, eth_address, is_on_LAN(), LAN_lookup(), LAN_lookup_pending(), LAN_start_lookup(), route_lookup(), route_lookup_pending(), route_start_lookup(), tcp_tick(), and WORD. |
|
|
Check ARP entries for timeout. This function runs through the 'pending' section of the ARP table and checks for entries that have either expired or require a re-send. The 'dynamic' entries are checked for expiry if requested. Definition at line 551 of file pcarp.c. References arp_move_entry(), arp_send_request(), chk_timeout(), arp_entry::flags, and set_timeout(). |
|
|
ARP "background" daemon. Calls timeout-checks / retransmitters. We don't check the dynamic entries for a timeout on every call, once a second is plenty enough. Definition at line 1323 of file pcarp.c. References _arp_check_gateways(), arp_check_timeouts(), chk_timeout(), DWORD, route_check_timeouts(), and set_timeout(). |
|
||||||||||||
|
Lookup MAC-address of 'ip'.
References _eth_addr, _pktserial, DWORD, eth_address, is_on_LAN(), LAN_lookup(), and route_lookup(). |
|
||||||||||||
|
Lookup fixed MAC-address of 'ip'.
References _pktserial, DWORD, eth_address, arp_entry::ip, and is_on_LAN(). |
|
|
An ARP-lookup timeout check.
References DWORD, is_on_LAN(), LAN_lookup_pending(), and route_lookup_pending(). |
|
|
New non-blocking functions, GvB 2002-09. This is called by 'higher' routines to start an ARP request. This function is non-blocking, i.e. returns 'immediately'. Definition at line 1012 of file pcarp.c. References _pktserial, DWORD, is_on_LAN(), LAN_start_lookup(), and route_start_lookup(). |
|
|
Start a host lookup on the LAN. This is called by 'higher' routines to start an ARP request. This function is non-blocking, i.e. returns 'immediately'. Definition at line 446 of file pcarp.c. References arp_send_request(), DWORD, arp_entry::ip, and set_timeout(). |
|
|
Periodic route checker. Run through all pending entries and check if an attempt to reach a gateway was successfull, or has timed-out. If the attempt timed-out, we try the next fitting gateway. If there are no more fitting gateways to try, the connect has failed Definition at line 893 of file pcarp.c. References gate_entry::gate_ip, is_on_LAN(), LAN_lookup(), LAN_lookup_pending(), and LAN_start_lookup(). |
|
|
Send a ping (with ttl=1) to a gateway. |
1.3.8