Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:dirkmueller:acdc:as_python3_module
icmpinfo
icmpinfo-1.11.dif
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File icmpinfo-1.11.dif of Package icmpinfo
Index: Makefile =================================================================== --- Makefile.orig +++ Makefile @@ -13,21 +13,32 @@ VERS = 1.11 #LDLIBS= -lsocket -lnsl # To override default compiler flags : -#CFLAGS=-O2 -s +CFLAGS=-Wall -O2 -pipe -D_BSD_SOURCE # To change default compiler -#CC=gcc +CC=gcc RM = rm -f LDFLAGS= $(CFLAGS) -OBJECTS= recvping.o print.o err.o icmpinfo.o +OBJECTS= recvping.o print.o err.o icmpinfo.o pid.o TARGET = icmpinfo +DESTDIR= +MANDIR=/usr/share/man + +all: $(TARGET) + $(TARGET): $(OBJECTS) $(CC) $(LDFLAGS) -o $@ $(OBJECTS) $(LDLIBS) +install: $(TARGET) + install -d -m 755 $(DESTDIR)/usr/sbin + install -d -m 755 $(DESTDIR)/$(MANDIR)/man1 + install icmpinfo $(DESTDIR)/usr/sbin + install -m 0644 icmpinfo.man $(DESTDIR)/$(MANDIR)/man1/icmpinfo.1 + tgz: clean rm -f CHECKSUMS.asc md5sum * > ../CHECKSUMS @@ -38,4 +49,3 @@ tgz: clean clean: $(RM) $(OBJECTS) $(TARGET) core *~ - Index: defs.h =================================================================== --- defs.h.orig +++ defs.h @@ -4,24 +4,17 @@ #include <stdio.h> #include <errno.h> -extern int errno; +#include <string.h> #include <sys/time.h> #include <sys/param.h> #include <sys/socket.h> #include <sys/file.h> -/* On Linux you might also need to symlink /usr/include/netinet/in_system.h - to /usr/src/linux/include/linux/in_system.h */ #include <netinet/in_systm.h> #include <netinet/in.h> #include <netinet/ip.h> -/* maybe change this when linux will include a complete include tree : */ -#ifdef linux -#include "linux_ip_icmp.h" -#else #include <netinet/ip_icmp.h> -#endif #include <netinet/tcp.h> #include <netdb.h> Index: icmpinfo.c =================================================================== --- icmpinfo.c.orig +++ icmpinfo.c @@ -26,20 +26,27 @@ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ +#include <stdlib.h> #ifndef lint -char copyright[] = +char const copyright[] = "@(#) Copyright (c) 1987 Regents of the University of California.\n\ All rights reserved.\n augmented 4/94 by dl\n"; #endif /* not lint */ #ifndef lint -static char sccsid[] = "@(#)ping.c 4.10 (Berkeley) 10/10/88 - $Author: icmpinfo-1.11- Laurent Demailly <dl@hplyot.obspm.fr>$"; +static const char sccsid[] = "@(#)ping.c 4.10 (Berkeley) 10/10/88 - $Author: icmpinfo-1.11- Laurent Demailly <dl@hplyot.obspm.fr>$"; #endif /* not lint */ #define DCLARE /* def : */ #include "defs.h" +void pid_kill (void); +void pid_file (void); +int recv_ping (void); +int err_quit(char*); +int err_sys(char*); + /* * P I N G . C * @@ -60,7 +67,7 @@ static char sccsid[] = "@(#)ping.c 4.10 * 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) @@ -99,6 +106,10 @@ char **argv; case 's': showsrcip++; break; + case 'k': + pid_kill(); + exit(0); + break; case 'h': default : err_quit(usage); @@ -128,6 +139,7 @@ char **argv; openlog("icmpinfo",0,LOG_DAEMON); syslog(LOG_NOTICE,"started, PID=%d.",getpid()); setsid(); + pid_file(); close(0); close(1); close(2); Index: icmpinfo.man =================================================================== --- icmpinfo.man.orig +++ icmpinfo.man @@ -6,7 +6,7 @@ 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 @@ -60,6 +60,13 @@ host has several network interfaces. In .I "\-l" Forks and use the syslog(3) facility to record events (recomended 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 Index: pid.c =================================================================== --- /dev/null +++ pid.c @@ -0,0 +1,54 @@ +#include <stdio.h> +#include <signal.h> +#include <unistd.h> +#include <stdlib.h> + +#define PIDFILE "/var/run/icmpinfo.pid" + +extern char *pname; + +void sig_handler(int); +void pid_file(void); +void pid_kill(void); + +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); + } +} + Index: print.c =================================================================== --- print.c.orig +++ print.c @@ -15,12 +15,8 @@ */ #include "defs.h" - -#ifndef ANSI_OFFSETOF -#ifndef offsetof -# define offsetof(t,m) (int)((&((t *)0L)->m)) -#endif -#endif +#include <time.h> +#include <stddef.h> char to_hex(a) int a; @@ -42,7 +38,7 @@ struct sockaddr_in *from; /* address of struct hostent *hostent=NULL; struct servent *servent=NULL; static char prbuf[1024]; /* provide enough room for even the longest hosts*/ - + /* * We have to look at the IP header, to get its length. * We also verify that what follows the IP header contains at @@ -64,14 +60,14 @@ struct sockaddr_in *from; /* address of cc -= iphdrlen; icp = (struct icmp *)(buf + iphdrlen); - switch (icp->icmp_type) + switch (icp->icmp_type) { case ICMP_ECHO : case ICMP_ECHOREPLY : doipdecoding=0; if (verbose<2) break; case ICMP_SOURCEQUENCH : - case ICMP_TIMXCEED : + case ICMP_TIMXCEED : case ICMP_REDIRECT : if (!verbose) break; default : @@ -92,10 +88,10 @@ struct sockaddr_in *from; /* address of inet_ntoa(from->sin_addr), hostent?hostent->h_name:NULL ); - if ( doipdecoding && + if ( doipdecoding && ( cc >= offsetof(struct icmp,icmp_ip.ip_src)+sizeof(icp->icmp_ip.ip_dst) ) ) { - if (showsrcip) + if (showsrcip) { /* icp->icmp_ip.ip_src.s_addr == local host, show it only if requested (might be usefull for host with several interfaces */ @@ -126,12 +122,12 @@ struct sockaddr_in *from; /* address of ntohs(tp->th_sport),ntohs(tp->th_dport), ntohl(tp->th_seq)); } else { - if ((servent=getservbyport(ntohs(tp->th_sport),NULL))) + if ((servent=getservbyport(ntohs(tp->th_sport),NULL))) sprintf(prbuf+strlen(prbuf)," sp=%d [%s]", ntohs(tp->th_sport),servent->s_name); else sprintf(prbuf+strlen(prbuf)," sp=%d",tp->th_sport); - if ((servent=getservbyport(ntohs(tp->th_dport),NULL))) + if ((servent=getservbyport(ntohs(tp->th_dport),NULL))) sprintf(prbuf+strlen(prbuf)," dp=%d [%s] seq=0x%8.8x", ntohs(tp->th_dport),servent->s_name, ntohl(tp->th_seq)); @@ -154,7 +150,7 @@ struct sockaddr_in *from; /* address of static char a[] = " "; int i,j,b,n, flagNEof; unsigned char *pbuf=(unsigned char *)buf; - + n = 0; flagNEof = 1; while (flagNEof) { @@ -249,7 +245,7 @@ register int t; "PrecdCut" }; static char buf[80]; - + if (t < 0 || t > 15) { sprintf(buf,"[OUT_OF_RANGE(%d)]",t); } else { @@ -257,4 +253,3 @@ register int t; } return(buf); } - Index: recvping.c =================================================================== --- recvping.c.orig +++ recvping.c @@ -6,6 +6,9 @@ #include "defs.h" +int err_ret(char *); +int pr_pack(char *, int, struct sockaddr_in *); + int recv_ping() { register int n; Index: err.c =================================================================== --- err.c.orig +++ err.c @@ -1,4 +1,5 @@ #include <stdio.h> +#include <stdlib.h> extern char *pname;
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor