--- icmpinfo-1.11.orig/Makefile +++ icmpinfo-1.11/Makefile @@ -22,7 +22,7 @@ LDFLAGS= $(CFLAGS) -OBJECTS= recvping.o print.o err.o icmpinfo.o +OBJECTS= recvping.o print.o err.o icmpinfo.o pid.o TARGET = icmpinfo $(TARGET): $(OBJECTS) --- icmpinfo-1.11.orig/debian/README.Debian +++ icmpinfo-1.11/debian/README.Debian @@ -0,0 +1,9 @@ +The following things have been changed for the Debian distribution by +Peter Tobias: + +- changed the makefile (added an install target) +- added icmpinfo.c an option ('-k') to kill an icmpinfo background job +- added pid.c (functions: create pid file, kill process, signal handler) + +Herbert Xu +$Id: README.Debian,v 1.1 1999/11/04 09:42:34 herbert Exp $ --- icmpinfo-1.11.orig/debian/changelog +++ icmpinfo-1.11/debian/changelog @@ -0,0 +1,61 @@ +icmpinfo (1.11-8) unstable; urgency=medium + + * Orphaning package. + * Changed Maintainer address to QA. + * Bump debian/compat to 5. + + -- Alberto Gonzalez Iniesta Wed, 15 Jul 2015 10:58:23 +0000 + +icmpinfo (1.11-7) unstable; urgency=low + + * Fixed segfaults on 64bit arches. (Closes: #473611) + Merged patched by Steffen Wendzel and Andreas Henriksson. + Thanks both for the patches. + * Included new ICMP types for completeness. Thanks Steffen Wendzel + for this too. + * Bumped Standards-Version to 3.7.3. + + -- Alberto Gonzalez Iniesta Thu, 10 Apr 2008 12:44:49 +0200 + +icmpinfo (1.11-6) unstable; urgency=low + + * Moved to DH_COMPAT 4. + * Fixed typos in man page (Closes: #409579) + * Improved output of -vvv (Closes: #401300) + * Bumped Standards-Version to 3.7.2.2, no change. + + -- Alberto Gonzalez Iniesta Sun, 4 Feb 2007 16:27:36 +0100 + +icmpinfo (1.11-5) unstable; urgency=low + + * Changed maintainer email address. + * Bumped Standards-Version to 3.6.1.0, no change. + * debian/copyright: updated ftp site address. + + -- Alberto Gonzalez Iniesta Thu, 24 Mar 2005 19:37:40 +0100 + +icmpinfo (1.11-4) unstable; urgency=low + + * The I-should-have-changed-control-file release. + Now I should really be the maintainer. (Closes: #168398) + + -- Alberto Gonzalez Iniesta Sun, 15 Dec 2002 18:35:16 +0100 + +icmpinfo (1.11-3) unstable; urgency=low + + * New maintainer. (Closes: #168398) + + -- Alberto Gonzalez Iniesta Sat, 14 Dec 2002 09:25:53 +0100 + +icmpinfo (1.11-2) unstable; urgency=low + + * Added build-time dependency on debhelper (closes: #168393). + + -- Herbert Xu Sat, 9 Nov 2002 15:01:42 +1100 + +icmpinfo (1.11-1) unstable; urgency=low + + * Initial release. + + -- Herbert Xu Thu, 4 Nov 1999 20:43:46 +1100 + --- icmpinfo-1.11.orig/debian/compat +++ icmpinfo-1.11/debian/compat @@ -0,0 +1 @@ +5 --- icmpinfo-1.11.orig/debian/control +++ icmpinfo-1.11/debian/control @@ -0,0 +1,15 @@ +Source: icmpinfo +Section: net +Priority: optional +Maintainer: Debian QA Group +Standards-Version: 3.7.3 +Build-Depends: debhelper (>= 5) + +Package: icmpinfo +Architecture: any +Depends: ${shlibs:Depends} +Description: Interpret ICMP messages + Icmpinfo is a tool for looking at the ICMP messages received on the running + host. It can be used to detect and record 'bombs' as well as various network + problems. + --- icmpinfo-1.11.orig/debian/copyright +++ icmpinfo-1.11/debian/copyright @@ -0,0 +1,16 @@ +This package was split from netstd by Herbert Xu herbert@debian.org on +Thu, 4 Nov 1999 20:45:02 +1100. + +netstd was created by Peter Tobias tobias@et-inf.fho-emden.de on +Wed, 20 Jul 1994 17:23:21 +0200. + +It was downloaded from ftp://ftp.demailly.com/pub/ + +Copyright: + +Copyright (c) 1995 Laurent Demailly +Copyright (c) 1987 Regents of the University of California. + +The license can be found in /usr/share/common-licenses/Artistic. + +$Id: copyright,v 1.1 1999/11/04 10:14:50 herbert Exp $ --- icmpinfo-1.11.orig/debian/icmpinfo.dirs +++ icmpinfo-1.11/debian/icmpinfo.dirs @@ -0,0 +1,2 @@ +usr/sbin +usr/share/man/man8 --- icmpinfo-1.11.orig/debian/icmpinfo.docs +++ icmpinfo-1.11/debian/icmpinfo.docs @@ -0,0 +1,3 @@ +DOC +README +TODO --- icmpinfo-1.11.orig/debian/rules +++ icmpinfo-1.11/debian/rules @@ -0,0 +1,73 @@ +#!/usr/bin/make -f +# GNU copyright 1997 to 1999 by Joey Hess. +# Copyright (c) 1999 Herbert Xu +# $Id: rules,v 1.2 2002/04/20 00:05:29 herbert Exp $ + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + + +build: build-stamp +build-stamp: + dh_testdir + + $(MAKE) CFLAGS="-g -O2" LDFLAGS= + + touch build-stamp + +clean: + dh_testdir + dh_testroot + rm -f build-stamp install-stamp + + [ ! -f Makefile ] || $(MAKE) clean + + dh_clean + +install: install-stamp +install-stamp: build-stamp + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs + + install icmpinfo debian/icmpinfo/usr/sbin + cp icmpinfo.man debian/icmpinfo/usr/share/man/man8/icmpinfo.8 + + touch install-stamp + +# Build architecture-independent files here. +binary-indep: build install +# We have nothing to do by default. + +# Build architecture-dependent files here. +binary-arch: build install +# dh_testversion + dh_testdir + dh_testroot +# dh_installdebconf + dh_installdocs + dh_installexamples + dh_installmenu +# dh_installemacsen +# dh_installpam +# dh_installinit + dh_installcron + dh_installman + dh_installinfo +# dh_undocumented + dh_installchangelogs CHANGES + dh_link + dh_strip + dh_compress + dh_fixperms +# dh_makeshlibs + dh_installdeb +# dh_perl + dh_shlibdeps + dh_gencontrol + dh_md5sums + dh_builddeb + +binary: binary-indep binary-arch +.PHONY: build clean binary-indep binary-arch binary install --- icmpinfo-1.11.orig/defs.h +++ icmpinfo-1.11/defs.h @@ -1,12 +1,12 @@ /* * Includes, defines and global variables used between functions. */ - #include +#include #include extern int errno; -#include +#include #include #include #include @@ -24,7 +24,6 @@ #endif #include #include - #include #include @@ -53,6 +52,14 @@ DCLARE int syslogdoutput; /* flag for stdoutput / syslogd output */ DCLARE int noportquery; /* flag for query/noquery of port -> serv name */ +int err_ret(char *); +int pr_pack(char *, int, struct sockaddr_in *); +void pid_file(void); +void pid_kill(void); +int err_quit(char *); +int err_sys(char *); +void recv_ping(void); + /* on some hosts (linux) netinet/ip_icmp.h is missing/empty : */ #ifndef ICMP_MINLEN int bug=You_need_an_non_empty_netinet_ip_icmp_h; --- icmpinfo-1.11.orig/err.c +++ icmpinfo-1.11/err.c @@ -1,4 +1,5 @@ #include +#include extern char *pname; --- icmpinfo-1.11.orig/icmpinfo.c +++ icmpinfo-1.11/icmpinfo.c @@ -62,7 +62,7 @@ * This program has to run SUID to ROOT to access the ICMP socket. */ -char usage[] = "Usage: icmpinfo [-v[v[v]]] [-s] [-n] [-p] [-l]\n -v : more and more info\n -s : show local interface address\n -n : no name query (dot ip only)\n -p : no port -> service name query\n -l : fork + syslog output\nv1.11 - 8/1995 - dl"; +char usage[] = "Usage: icmpinfo [-v[v[v]]] [-s] [-n] [-p] [-l] [-k]\n -v : more and more info\n -s : show local interface address\n -n : no name query (dot ip only)\n -p : no port -> service name query\n -l : fork + syslog output\n -k : kill background process\nv1.11 - 8/1995 - dl"; char *pname; int main(argc, argv) @@ -101,6 +101,11 @@ case 's': showsrcip++; break; + case 'k': + pid_kill(); + exit(0); + /*NOTREACHED*/ + break; case 'h': default : err_quit(usage); @@ -130,6 +135,7 @@ openlog("icmpinfo",0,LOG_DAEMON); syslog(LOG_NOTICE,"started, PID=%d.",getpid()); setsid(); + pid_file(); close(0); close(1); close(2); --- icmpinfo-1.11.orig/icmpinfo.man +++ icmpinfo-1.11/icmpinfo.man @@ -1,12 +1,10 @@ -.TH ICMPINFO 1 "V1.11 - 28 August 1995" "dl's free utilities" +.TH ICMPINFO 8 "V1.11 - 28 August 1995" "dl's free utilities" .SH NAME - icmpinfo \- interpret ICMP messages - .SH SYNOPSIS .B icmpinfo -[\-v[v[v]]] [\-n] [\-p] [\-s] [\-l] +[\-v[v[v]]] [\-n] [\-p] [\-s] [\-l] [\-k] .SH DESCRIPTION .BR Icmpinfo @@ -52,14 +50,21 @@ .TP .I "\-s" -Show the interface ip that received the packet. Usefull only if your +Show the interface ip that received the packet. Useful only if your host has several network interfaces. In this case an '- my_ip [my_name]' is added between the sender and unreach ip and name fields. .TP .I "\-l" -Forks and use the syslog(3) facility to record events (recomended use). +Forks and use the syslog(3) facility to record events (recommended use). (root only option). + +.TP +.I "\-k" +Kills the background process started with the +.I "\-l" +option. + .SH WARNINGS The packet decoding is planned for ICMP Unreachable outputs and might not be significant for all other Icmp types. Output can be shorter --- icmpinfo-1.11.orig/linux_ip_icmp.h +++ icmpinfo-1.11/linux_ip_icmp.h @@ -3,6 +3,8 @@ #ifndef _netinet_ip_icmp_h #define _netinet_ip_icmp_h +#include + struct icmp { u_char icmp_type; /* type of message, see below */ u_char icmp_code; /* type sub code */ @@ -22,6 +24,7 @@ #define icmp_seq icmp_hun.ih_idseq.icd_seq #define icmp_void icmp_hun.ih_void +#if 0 struct ip { u_char ip_hl:4, /* header length */ ip_v:4; /* version */ @@ -36,6 +39,7 @@ u_short ip_sum; /* checksum */ struct in_addr ip_src,ip_dst; /* source and dest address */ }; +#endif union { --- icmpinfo-1.11.orig/pid.c +++ icmpinfo-1.11/pid.c @@ -0,0 +1,52 @@ +#include +#include +#include +#include + +#define PIDFILE "/var/run/icmpinfo.pid" + +extern char *pname; + +void sig_handler(int); + +void pid_file(void) +{ + FILE *fp; + + if ((fp = fopen(PIDFILE, "w")) != (FILE *)NULL) { + fprintf(fp, "%d\n", getpid()); + fclose(fp); + } + else + { + fprintf(stderr, "\n%s: Could not write PID file `%s', terminating.\n", + pname, PIDFILE); + exit(1); + } + signal(SIGHUP, sig_handler); + signal(SIGINT, sig_handler); + signal(SIGTERM, sig_handler); +} + +void sig_handler(int sig) +{ + unlink(PIDFILE); + exit(0); +} + +void pid_kill(void) +{ + FILE *fp; + int pid; + + if ((fp = fopen(PIDFILE, "r")) != (FILE *)NULL) + { + if (fscanf(fp, "%d", &pid) == 1) + { + kill(pid, SIGHUP); + sleep(1); + } + fclose(fp); + } +} + --- icmpinfo-1.11.orig/print.c +++ icmpinfo-1.11/print.c @@ -8,8 +8,11 @@ /* note : the original bsd code was *very* buggy !!! it should be ok, now */ +#include +#include #include "defs.h" + #ifndef ANSI_OFFSETOF #ifndef offsetof # define offsetof(t,m) (int)((&((t *)0L)->m)) @@ -28,6 +31,7 @@ struct sockaddr_in *from; /* address of sender */ { int iphdrlen,doipdecoding=1; + int iplen; struct ip *ip; /* ptr to IP header */ register struct icmp *icp; /* ptr to ICMP header */ struct tcphdr *tp; /* ptr to TCP header */ @@ -35,7 +39,7 @@ char *pr_type(),*pr_subtype(),*strtime; struct hostent *hostent=NULL; struct servent *servent=NULL; - static char prbuf[1024]; /* provide enough room for even the longest hosts*/ + static char prbuf[1024]={'\0'}; /* provide enough room for even the longest hosts*/ /* * We have to look at the IP header, to get its length. @@ -44,17 +48,18 @@ */ ip = (struct ip *) buf; iphdrlen = ip->ip_hl << 2; /* convert # 16-bit words to #bytes */ - if (cc < iphdrlen + ICMP_MINLEN) { + if (cc < (iphdrlen + ICMP_MINLEN)) { sprintf(prbuf,"packet too short (%d bytes) from %s", cc, inet_ntoa(from->sin_addr)); if (syslogdoutput) { syslog(LOG_WARNING,"%s",prbuf); - } else { - puts(prbuf); - fflush(stdout); - } + } else { + puts(prbuf); + fflush(stdout); + } return -1; } + iplen = cc; cc -= iphdrlen; icp = (struct icmp *)(buf + iphdrlen); @@ -113,6 +118,29 @@ inet_ntoa(icp->icmp_ip.ip_dst), hostent?hostent->h_name:NULL); tp = (struct tcphdr *)((char *)&(icp->icmp_dun)+sizeof(struct ip)) ; +#if defined(__GLIBC__) && (__GLIBC__ >= 2) + if (cc>=offsetof(struct icmp,icmp_dun)+sizeof(struct ip)+offsetof(struct tcphdr,seq)+sizeof(tp->seq)) + { + if (noportquery) { + sprintf(prbuf+strlen(prbuf)," sp=%d dp=%d seq=0x%8.8x", + ntohs(tp->source),ntohs(tp->dest), + ntohl(tp->seq)); + } else { + if ((servent=getservbyport(ntohs(tp->source),NULL))) + sprintf(prbuf+strlen(prbuf)," sp=%d [%s]", + ntohs(tp->source),servent->s_name); + else + sprintf(prbuf+strlen(prbuf)," sp=%d",tp->source); + if ((servent=getservbyport(ntohs(tp->dest),NULL))) + sprintf(prbuf+strlen(prbuf)," dp=%d [%s] seq=0x%8.8x", + ntohs(tp->dest),servent->s_name, + ntohl(tp->seq)); + else + sprintf(prbuf+strlen(prbuf)," dp=%d seq=0x%8.8x", + ntohs(tp->dest),ntohl(tp->seq)); + } + } +#else if (cc>=offsetof(struct icmp,icmp_dun)+sizeof(struct ip)+offsetof(struct tcphdr,th_seq)+sizeof(tp->th_seq)) { if (noportquery) { @@ -134,6 +162,7 @@ ntohs(tp->th_dport),ntohl(tp->th_seq)); } } +#endif } } sprintf(prbuf+strlen(prbuf)," sz=%d(+%d)",cc,iphdrlen); @@ -153,7 +182,7 @@ flagNEof = 1; while (flagNEof) { i = j = 0; - while (i < 16 && (flagNEof = cc--)) { + while (i < 16 && (flagNEof = iplen--)) { b= (int)(*(pbuf++)); h[j++] = to_hex(b >> 4); h[j++] = to_hex(b & 0x0F); @@ -193,7 +222,7 @@ "Dest_Unreachable", "Source_Quench", "Redirect", - "6", + "Alternate Host Address", "7", "Echo", "RouterAdvert", @@ -205,7 +234,22 @@ "Info_Request", "Info_Reply", "Mask_Request", - "Mask_Reply" + "Mask_Reply", + "19 (Reserved for Security)", + /* 20-29: reserved for robustness experiment */ + "20","21","22","23","24","25","26","27","28","29", + "Traceroute", + "Datagram Convers. Err.", + "Mobile Host Redir", + "IPv6 Where-Are-You", + "IPv6 I-Am-Here", + "Mobile Registration Request", + "Mobile Registration Reply", + "Domain Name Req", + "Domain Name Reply", + "SKIP", + "Photuris", + "41 (ICMP messages utilized by experimental mobility protocols such as Seamoby)" }; if (t < 0 || t > 18) { --- icmpinfo-1.11.orig/recvping.c +++ icmpinfo-1.11/recvping.c @@ -6,10 +6,14 @@ #include "defs.h" -int recv_ping() +void recv_ping() { register int n; +#if !defined(__GLIBC__) int fromlen; +#else /* __GLIBC__ */ + socklen_t fromlen; +#endif /* __GLIBC__ */ struct sockaddr_in from; for ( ; ; ) {