Watt-32 tcp/ip  2.2 dev-rel.10
Data Structures | Functions | Variables
pcicmp.c File Reference

Go to the source code of this file.

Data Structures

struct  _pkt
 

Functions

static void icmp_print (int dbg_lvl, const char *msg, DWORD src)
 
static void icmp_bogus (const in_Header *ip, int type, const char *msg)
 Print info about bogus and possibly dangerous ICMP messages. More...
 
static BOOL icmp_check (const in_Header *ip, int type)
 Check if ip-source is a (directed) broadcast address. More...
 
static int icmp_send (struct _pkt *pkt, DWORD src, DWORD dest, int length)
 Format and send a ICMP packet. More...
 
int icmp_send_unreach (const in_Header *ip, int code)
 Send an ICMP destination/protocol unreachable back to 'ip->source'. More...
 
int icmp_send_timexceed (const in_Header *ip, const void *mac_dest)
 Send an "ICMP Time Exceeded" (reassebly timeout) back to 'ip->source'.
 
int icmp_send_mask_req (void)
 
static int icmp_echo_reply (const in_Header *ip, const union ICMP_PKT *req, unsigned len)
 
static void icmp_redirect (const union ICMP_PKT *icmp, const in_Header *ip, const in_Header *orig_ip, int code)
 Handle ICMP_REDIRECT messages.
 
void icmp_handler (const in_Header *ip, BOOL broadcast)
 Handler for incoming ICMP packets. More...
 
void icmp_doredirect (const char *value)
 Determine which protocols we shall act upon when ICMP redirect is received.
 

Variables

const char * icmp_type_str [ICMP_MAXTYPE+1]
 
const char * icmp_unreach_str [16]
 
const char * icmp_redirect_str [4]
 
const char * icmp_exceed_str [2]
 
struct {
   char   icmp
 
   char   igmp
 
   char   udp
 
   char   tcp
 
do_redirect = { 1,1,1,1 }
 
static WORD addr_mask_id = 0
 Send an ICMP Address Mask Request as link-layer + IP broadcast. More...
 
static WORD addr_mask_seq = 0
 

Detailed Description

ICMP for IPv4 (RFC 792).

Definition in file pcicmp.c.

Function Documentation

static void icmp_bogus ( const in_Header ip,
int  type,
const char *  msg 
)
static

Print info about bogus and possibly dangerous ICMP messages.

e.g. "ICMP: (144.133.122.111) Bogus Redirect; GW = 111.110.109.108"

Definition at line 126 of file pcicmp.c.

static BOOL icmp_check ( const in_Header ip,
int  type 
)
static

Check if ip-source is a (directed) broadcast address.

Some hacker may try to create a broadcast storm. Also check for null source address (0.0.0.0). Broadcast destination is already filtered out by icmp_handler().

Definition at line 143 of file pcicmp.c.

References icmp_bogus(), and sin_mask.

void icmp_handler ( const in_Header ip,
BOOL  broadcast 
)

Handler for incoming ICMP packets.

Todo:
Handle cancelling raw sockets
Todo:
!!
Todo:
!!

<

Todo:
send reply?

<

Todo:
should store

<

Todo:
send reply

<

Todo:
send reply upwards

Definition at line 376 of file pcicmp.c.

References _do_mask_req, _tcp_cancel(), _udp_cancel(), add_ping(), block_icmp, icmp_bogus(), icmp_redirect(), set_timeout(), and sin_mask.

static int icmp_send ( struct _pkt pkt,
DWORD  src,
DWORD  dest,
int  length 
)
static

Format and send a ICMP packet.

Note
: src and dest are on network order.

Definition at line 179 of file pcicmp.c.

int icmp_send_unreach ( const in_Header ip,
int  code 
)

Send an ICMP destination/protocol unreachable back to 'ip->source'.

Limit the rate of these to 20 per second. Ref. RFC-1812.

Definition at line 194 of file pcicmp.c.

References _eth_formatpacket(), chk_timeout(), icmp_check(), icmp_send(), and set_timeout().

Variable Documentation

WORD addr_mask_id = 0
static

Send an ICMP Address Mask Request as link-layer + IP broadcast.

Even if we know our address, we send with src = 0.0.0.0.

Definition at line 258 of file pcicmp.c.

const char* icmp_exceed_str[2]
Initial value:
= {
__LANG("TTL exceeded in transit"),
__LANG("Fragment reassembly time exceeded")
}

Definition at line 80 of file pcicmp.c.

const char* icmp_redirect_str[4]
Initial value:
= {
__LANG("Redirect for Network"),
__LANG("Redirect for Host"),
__LANG("Redirect for TOS and Network"),
__LANG("Redirect for TOS and Host")
}

Definition at line 71 of file pcicmp.c.

const char* icmp_type_str[ICMP_MAXTYPE+1]
Initial value:
= {
__LANG("Echo Reply"), "1", "2",
__LANG("Destination Unreachable"),
__LANG("Source Quench"),
__LANG("Redirect"), "6", "7",
__LANG("Echo Request"),
__LANG("Router Advert"),
__LANG("Router Solic"),
__LANG("TTL exceeded"),
__LANG("Param Problem"),
__LANG("Timestamp Message"),
__LANG("Timestamp Reply"),
__LANG("Info Request"),
__LANG("Info Reply"),
__LANG("Mask Request"),
__LANG("Mask Reply")
}

Definition at line 30 of file pcicmp.c.

const char* icmp_unreach_str[16]
Initial value:
= {
__LANG("Network Unreachable"),
__LANG("Host Unreachable"),
__LANG("Protocol Unreachable"),
__LANG("Port Unreachable"),
__LANG("Fragmentation needed and DF set"),
__LANG("Source Route Failed"),
__LANG("Network unknown"),
__LANG("Host unknown"),
__LANG("Source host isolated"),
__LANG("Net-access denied"),
__LANG("Host-access denied"),
__LANG("Bad TOS for net"),
__LANG("Bad TOS for host"),
__LANG("Admin prohibited"),
__LANG("Host precedence violation"),
__LANG("Precedence cutoff")
}

Definition at line 50 of file pcicmp.c.