Watt-32 tcp/ip  2.2 dev-rel.10
Data Structures | Functions
pcarp.h File Reference

Go to the source code of this file.

Data Structures

struct  gate_entry
 
struct  arp_entry
 
struct  route_entry
 

Functions

W32_FUNC int W32_CALL _arp_gateways_get (const struct gate_entry **)
 Gateway functions. More...
 
W32_FUNC int W32_CALL _arp_check_gateways (void)
 Return number of default gateways.
 
W32_FUNC BOOL W32_CALL _arp_add_gateway (const char *config_string, DWORD ip)
 Add a gateway to the routing table. More...
 
W32_FUNC BOOL W32_CALL _arp_have_default_gw (void)
 Check if we have at least one default gateway.
 
W32_FUNC void W32_CALL _arp_kill_gateways (void)
 Delete all gateways.
 
W32_FUNC BOOL W32_CALL _arp_resolve (DWORD ina, eth_address *eth)
 Blocking ARP resolve functions. More...
 
W32_FUNC BOOL W32_CALL _arp_check_own_ip (eth_address *eth)
 Used by DHCP initialisation. More...
 
W32_FUNC BOOL W32_CALL _arp_start_lookup (DWORD ip)
 New non-blocking functions, GvB 2002-09. More...
 
W32_FUNC BOOL W32_CALL _arp_lookup (DWORD ip, eth_address *eth)
 Lookup MAC-address of 'ip'. More...
 
W32_FUNC BOOL W32_CALL _arp_lookup_fixed (DWORD ip, eth_address *eth)
 Lookup fixed MAC-address of 'ip'. More...
 
W32_FUNC BOOL W32_CALL _arp_lookup_pending (DWORD ip)
 An ARP-lookup timeout check. More...
 
W32_FUNC BOOL W32_CALL _arp_cache_add (DWORD ip, const void *eth, BOOL expire)
 ARP cache functions. More...
 
W32_FUNC BOOL W32_CALL _arp_cache_del (DWORD ip)
 Delete given 'ip' address from ARP-cache (dynamic, fixed or pending). More...
 
W32_FUNC int W32_CALL _arp_cache_get (const struct arp_entry **)
 Return start of arp_list[]. More...
 
W32_FUNC void W32_CALL _arp_cache_dump (void)
 
W32_FUNC void W32_CALL _arp_gateways_dump (void)
 
W32_FUNC void W32_CALL _arp_routes_dump (void)
 
W32_FUNC void W32_CALL _arp_debug_dump (void)
 Debug-dump of configured gateways, route table and ARP cache. More...
 
W32_FUNC void W32_CALL _arp_init (void)
 'Internal' interface to pctcp.c & others. More...
 
W32_FUNC BOOL W32_CALL _arp_reply (const void *mac_dst, DWORD src_ip, DWORD dst_ip)
 Send unicast/broadcast ARP reply. More...
 
W32_FUNC BOOL W32_CALL _arp_handler (const arp_Header *arp, BOOL brdcast)
 Receive ARP handler. More...
 
W32_FUNC BOOL W32_CALL _arp_register (DWORD use_this_gateway_ip, DWORD for_this_host_ip)
 ICMP redirection. More...
 

Detailed Description

ARP handler module.

Definition in file pcarp.h.

Function Documentation

W32_FUNC BOOL W32_CALL _arp_add_gateway ( const char *  config_string,
DWORD  ip 
)

Add a gateway to the routing table.

The format of 'config_string' is: gateway [,subnet], mask]]

If 'config_string' is NULL, simply add 'ip' with zero mask and subnet.

eg. "gateway = 129.97.176.1" -> becomes the default route eg. "gateway = 129.97.176.2, 129.97.0.0, 255.255.0.0"

The first example shows how a default gateway is created. A default gateway is used if no other choices exist.

The second example shows how to specify a gateway for a particular subnet. In this example, whenever the 'top' 16 bits of the destination are 129.97.*.*, that gateway will be used.

Todo:
Move to route.c and rename to route_add().

Definition at line 247 of file pcarp.c.

References aton(), compare(), gate_entry::gate_ip, gate_entry::mask, and gate_entry::subnet.

W32_FUNC BOOL W32_CALL _arp_cache_add ( DWORD  ip,
const void eth,
BOOL  expires 
)

ARP cache functions.

ARP cache functions.

Note
'ip' is on host order.

Definition at line 1352 of file pcarp.c.

References _arp_cache_del(), _inet_ntoa(), arp_move_entry(), arp_entry::expiry, arp_entry::flags, arp_entry::hardware, arp_entry::ip, is_on_LAN(), MAC_address(), my_ip_addr, and set_timeout().

W32_FUNC BOOL W32_CALL _arp_cache_del ( DWORD  ip)

Delete given 'ip' address from ARP-cache (dynamic, fixed or pending).

Note
'ip' is on host order.

Definition at line 1421 of file pcarp.c.

References arp_move_entry(), arp_entry::flags, and arp_entry::ip.

W32_FUNC int W32_CALL _arp_cache_get ( const struct arp_entry **  rc)

Return start of arp_list[].

Note
Called need to inspect the '*rc->flags' for validity.

Definition at line 527 of file pcarp.c.

W32_FUNC BOOL W32_CALL _arp_check_own_ip ( eth_address *  other_guy)

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.

Note
Blocks waiting for reply or timeout.

Definition at line 1729 of file pcarp.c.

References _arp_resolve(), and my_ip_addr.

W32_FUNC void W32_CALL _arp_debug_dump ( void  )

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 1907 of file pcarp.c.

References arp_entry::expiry, gate_entry::gate_ip, arp_entry::hardware, arp_entry::ip, MAC_address(), gate_entry::mask, set_timeout(), sin_mask, and gate_entry::subnet.

W32_FUNC int W32_CALL _arp_gateways_get ( const struct gate_entry **  rc)

Gateway functions.

Todo:
: Move to route.c and prefix with '_route'.
Note
: Exported only because ./bin/tcpinfo.c uses some of those. Therefore all functions use 'W32_CALL' convention too.

Gateway functions.

Note
Only 'gate_top' gateways are valid in result.

Definition at line 94 of file pcarp.c.

W32_FUNC BOOL W32_CALL _arp_handler ( const arp_Header ah,
BOOL  brdcast 
)
W32_FUNC void W32_CALL _arp_init ( void  )

'Internal' interface to pctcp.c & others.

'Internal' interface to pctcp.c & others.

Definition at line 1547 of file pcarp.c.

References arp_daemon().

W32_FUNC BOOL W32_CALL _arp_lookup ( DWORD  ip,
eth_address *  eth 
)

Lookup MAC-address of 'ip'.

Return values
TRUEMAC for 'ip' is known.

Definition at line 1186 of file pcarp.c.

References arp_check_common(), is_on_LAN(), LAN_lookup(), and route_lookup().

W32_FUNC BOOL W32_CALL _arp_lookup_fixed ( DWORD  ip,
eth_address *  eth 
)

Lookup fixed MAC-address of 'ip'.

Return values
TRUESupplied 'ip' has a fixed MAC entry.

Definition at line 1219 of file pcarp.c.

References arp_check_common(), and is_on_LAN().

W32_FUNC BOOL W32_CALL _arp_lookup_pending ( DWORD  ip)

An ARP-lookup timeout check.

Return values
TRUEThe lookup is currently underway ("pending").
FALSEThe IP has either been resolved (_arp_lookup() == TRUE), or the lookup has timed out, i.e. the host is unreachable.

Definition at line 1206 of file pcarp.c.

References is_on_LAN(), LAN_lookup_pending(), and route_lookup_pending().

W32_FUNC BOOL W32_CALL _arp_register ( DWORD  use_this_gateway_ip,
DWORD  for_this_host_ip 
)

ICMP redirection.

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 843 of file pcarp.c.

References is_on_LAN(), LAN_lookup(), LAN_start_lookup(), and sin_mask.

W32_FUNC BOOL W32_CALL _arp_reply ( const void e_dst,
DWORD  src_ip,
DWORD  dst_ip 
)

Send unicast/broadcast ARP reply.

'src_ip' and 'dst_ip' on host order.

Definition at line 489 of file pcarp.c.

References _eth_addr, _eth_brdcast, _eth_formatpacket(), _eth_get_hwtype(), arp_send(), arp_Header::hwAddrLen, MAC_address(), and arp_Header::protoAddrLen.

W32_FUNC BOOL W32_CALL _arp_resolve ( DWORD  ip,
eth_address *  eth 
)

Blocking ARP resolve functions.

Doesn't return until success or time-out.

Blocking ARP resolve functions.

Definition at line 1279 of file pcarp.c.

References _watt_cbroke, arp_check_common(), arp_daemon(), is_on_LAN(), LAN_lookup(), LAN_lookup_pending(), LAN_start_lookup(), route_lookup(), route_lookup_pending(), route_start_lookup(), and tcp_tick().

W32_FUNC BOOL W32_CALL _arp_start_lookup ( DWORD  ip)

New non-blocking functions, GvB 2002-09.

New non-blocking functions, GvB 2002-09.

These are the main functions visible from outside the module. Most of them simply check if the destination host IP is on the LAN or needs to be routed over a gateway, and then relay on to the apropriate LAN_...() or route_...() function. Initialise an ARP lookup. This is called by 'higher' routines to start an ARP request. This function is non-blocking, i.e. returns 'immediately'.

Definition at line 1169 of file pcarp.c.

References arp_check_common(), is_on_LAN(), LAN_start_lookup(), and route_start_lookup().