Annotation of embedaddon/hping2/logicmp.c, revision 1.1
1.1 ! misho 1: /*
! 2: * $smu-mark$
! 3: * $name: logicmp.c$
! 4: * $author: Salvatore Sanfilippo <antirez@invece.org>$
! 5: * $copyright: Copyright (C) 1999 by Salvatore Sanfilippo$
! 6: * $license: This software is under GPL version 2 of license$
! 7: * $date: Fri Nov 5 11:55:48 MET 1999$
! 8: * $rev: 8$
! 9: */
! 10:
! 11: #include <stdio.h>
! 12: #include <sys/types.h> /* this should be not needed, but ip_icmp.h lacks it */
! 13:
! 14: #include "hping2.h"
! 15: #include "globals.h"
! 16:
! 17: void log_icmp_timeexc(char *src_addr, unsigned short icmp_code)
! 18: {
! 19: switch(icmp_code) {
! 20: case ICMP_EXC_TTL:
! 21: printf("TTL 0 during transit from ip=%s", src_addr);
! 22: break;
! 23: case ICMP_EXC_FRAGTIME:
! 24: printf("TTL 0 during reassembly from ip=%s", src_addr);
! 25: break;
! 26: }
! 27: if (opt_gethost) {
! 28: char *hostn;
! 29:
! 30: fflush(stdout);
! 31: hostn = get_hostname(src_addr);
! 32: printf("name=%s", (hostn) ? hostn : "UNKNOWN");
! 33: }
! 34: putchar('\n');
! 35: }
! 36:
! 37: void log_icmp_unreach(char *src_addr, unsigned short icmp_code)
! 38: {
! 39: static char* icmp_unreach_msg[]={
! 40: "Network Unreachable from", /* code 0 */
! 41: "Host Unreachable from", /* code 1 */
! 42: "Protocol Unreachable from", /* code 2 */
! 43: "Port Unreachable from", /* code 3 */
! 44: "Fragmentation Needed/DF set from", /* code 4 */
! 45: "Source Route failed from", /* code 5 */
! 46: NULL, /* code 6 */
! 47: NULL, /* code 7 */
! 48: NULL, /* code 8 */
! 49: NULL, /* code 9 */
! 50: NULL, /* code 10 */
! 51: NULL, /* code 11 */
! 52: NULL, /* code 12 */
! 53: "Packet filtered from", /* code 13 */
! 54: "Precedence violation from", /* code 14 */
! 55: "precedence cut off from" /* code 15 */
! 56: };
! 57:
! 58: if (icmp_unreach_msg[icmp_code] != NULL)
! 59: printf("ICMP %s ip=%s", icmp_unreach_msg[icmp_code], src_addr);
! 60: else
! 61: printf("ICMP Unreachable type=%d from ip=%s",
! 62: icmp_code, src_addr);
! 63:
! 64: if (opt_gethost) {
! 65: char *hostn;
! 66:
! 67: fflush(stdout);
! 68: hostn = get_hostname(src_addr);
! 69: printf("name=%s", (hostn) ? hostn : "UNKNOWN");
! 70: }
! 71: putchar('\n');
! 72: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>