1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
|
#include <stdio.h>
#include <sys/types.h> /* this should be not needed, but ip_icmp.h lacks it */
#include "hping2.h"
#include "globals.h"
void log_icmp_timeexc(char *src_addr, unsigned short icmp_code)
{
switch(icmp_code) {
case ICMP_EXC_TTL:
printf("TTL 0 during transit from ip=%s", src_addr);
break;
case ICMP_EXC_FRAGTIME:
printf("TTL 0 during reassembly from ip=%s", src_addr);
break;
}
if (opt_gethost) {
char *hostn;
fflush(stdout);
hostn = get_hostname(src_addr);
printf("name=%s", (hostn) ? hostn : "UNKNOWN");
}
putchar('\n');
}
void log_icmp_unreach(char *src_addr, unsigned short icmp_code)
{
static char* icmp_unreach_msg[]={
"Network Unreachable from",
"Host Unreachable from",
"Protocol Unreachable from",
"Port Unreachable from",
"Fragmentation Needed/DF set from",
"Source Route failed from",
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
"Packet filtered from",
"Precedence violation from",
"precedence cut off from"
};
if (icmp_unreach_msg[icmp_code] != NULL)
printf("ICMP %s ip=%s", icmp_unreach_msg[icmp_code], src_addr);
else
printf("ICMP Unreachable type=%d from ip=%s",
icmp_code, src_addr);
if (opt_gethost) {
char *hostn;
fflush(stdout);
hostn = get_hostname(src_addr);
printf("name=%s", (hostn) ? hostn : "UNKNOWN");
}
putchar('\n');
}
|