- 论坛徽章:
- 0
|
IPDUMP SOURCE
/*********************************************************
convert ip fragment_type to string
*********************************************************/
char *
ip_ftoa (int flag)
{
static int f[] = { 'R', 'D', 'M' };
static char str[17];
u_int mask = 0x8000; //mask
int i;
for (i = 0; i < 3; i++)
{
if (((flag << i) & mask) != 0)
{
str = f;
}
else
{
str = '0';
}
}
str = '\0';
return str;
}
/**********************************************************
convert ip header TOS into string
**********************************************************/
char *
ip_ttoa (int flag)
{
static int f[] = { '1', '1', '1', 'D', 'T', 'R', 'C', 'X' };
static char str[17];
u_int mask = 0x80;
int i;
for (i = 0; i < 8; i++)
{
if (((flag << i) & mask) != 0)
{
str = f;
}
else
{
str = '0';
}
}
str = '\0';
return str;
}
/***********************************************************
display icmp header
***********************************************************/
void
print_icmp (struct icmp *icmp)
{
static char *type_name[] = {
"Echo Reply",
"Undefine",
"Undefine",
"Destination Unreachable",
"source Quench",
"Redirect(change route)",
"Undefine",
"Undefine",
"Echo Request",
"Undefine",
"Undefine",
"Time Exceeded",
" arameter Problem",
"Timestamp Request",
"Timestamp Reply",
"Information Request",
"Information Reply",
"Address Mask Request",
"Address Mask Reply",
"Unknown"
};
print_ip (ip);
int type = icmp->;icmp_type;
if (type < 0 || type >; 
{
type = 19;
}
printf (" rotocol:ICMP(%s)\n", type_name[type]);
printf ("+------------------------------------------+\n" ;
printf ("|Type:%3u| Code:%3u| Checksum:%5u|\n",
icmp->;icmp_type, icmp->;icmp_code, ntohs (icmp->;icmp_cksum));
printf ("+------------------------------------------+\n" ;
if (icmp->;icmp_type == 0 || icmp->;icmp_type == 
{
printf ("|Identification:%5u|Sequence Number:%5u|\n",
ntohs (icmp->;icmp_id), ntohs (icmp->;icmp_seq));
printf ("+------------------------------------------+\n" ;
}
else if (icmp->;icmp_type == 3)
{
if (icmp->;icmp_code == 4)
{
printf ("|Void:%5u|Next MTU:%5u|\n",
ntohs (icmp->;icmp_pmvoid),
ntohs (icmp->;icmp_nextmtu));
printf ("+------------------------------------------+\n" ;
}
else
{
printf ("|Unused:%10lu|\n",
(u_long) ntohl (icmp->;icmp_void));
printf ("+------------------------------------------+\n" ;
}
}
else if (icmp->;icmp_type == 5)
{
printf ("|Router IP Address:%15u|\n",
inet_ntoa (*(struct in_addr *) &(icmp->;icmp_gwaddr)));
printf ("+------------------------------------------+\n" ;
}
else if (icmp->;icmp_type == 11)
{
printf ("|Unused:%10lu|\n", (u_long) ntohl (icmp->;icmp_void));
printf ("+------------------------------------------+\n" ;
}
if (icmp->;icmp_type == 3 || icmp->;icmp_type == 5
|| icmp->;icmp_type == 11)
print_ip ((struct ip *) (((char *) icmp) + );
} |
|