diff -ur mtr-0.56/Makefile.in mtr-0.57/Makefile.in --- mtr-0.56/Makefile.in Mon Apr 5 13:45:47 2004 +++ mtr-0.57/Makefile.in Mon Apr 5 14:04:56 2004 @@ -113,9 +113,6 @@ TAR = tar GZIP_ENV = --best -DEP_FILES = .deps/curses.P .deps/display.P .deps/dns.P .deps/getopt.P \ -.deps/getopt1.P .deps/gtk.P .deps/mtr.P .deps/net.P .deps/raw.P \ -.deps/report.P .deps/select.P .deps/split.P SOURCES = $(mtr_SOURCES) $(EXTRA_mtr_SOURCES) OBJECTS = $(mtr_OBJECTS) @@ -123,9 +120,9 @@ .SUFFIXES: .SUFFIXES: .S .c .o .s $(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) - cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile + cd $(top_srcdir) && $(AUTOMAKE) --foreign --include-deps Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES) +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status cd $(top_builddir) \ && CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status @@ -190,6 +187,9 @@ rm -f $(DESTDIR)$(sbindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \ done +.c.o: + $(COMPILE) -c $< + .s.o: $(COMPILE) -c $< @@ -376,11 +376,6 @@ -rm -rf $(distdir) mkdir $(distdir) -chmod 777 $(distdir) - here=`cd $(top_builddir) && pwd`; \ - top_distdir=`cd $(distdir) && pwd`; \ - distdir=`cd $(distdir) && pwd`; \ - cd $(top_srcdir) \ - && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu Makefile @for file in $(DISTFILES); do \ d=$(srcdir); \ if test -d $$d/$$file; then \ @@ -401,38 +396,6 @@ || exit 1; \ fi; \ done - -DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :) - --include $(DEP_FILES) - -mostlyclean-depend: - -clean-depend: - -distclean-depend: - -rm -rf .deps - -maintainer-clean-depend: - -%.o: %.c - @echo '$(COMPILE) -c $<'; \ - $(COMPILE) -Wp,-MD,.deps/$(*F).pp -c $< - @-cp .deps/$(*F).pp .deps/$(*F).P; \ - tr ' ' '\012' < .deps/$(*F).pp \ - | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \ - >> .deps/$(*F).P; \ - rm .deps/$(*F).pp - -%.lo: %.c - @echo '$(LTCOMPILE) -c $<'; \ - $(LTCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $< - @-sed -e 's/^\([^:]*\)\.o[ ]*:/\1.lo \1.o :/' \ - < .deps/$(*F).pp > .deps/$(*F).P; \ - tr ' ' '\012' < .deps/$(*F).pp \ - | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \ - >> .deps/$(*F).P; \ - rm -f .deps/$(*F).pp info-am: info: info-recursive dvi-am: @@ -475,27 +438,26 @@ maintainer-clean-generic: mostlyclean-am: mostlyclean-hdr mostlyclean-sbinPROGRAMS \ - mostlyclean-compile mostlyclean-tags mostlyclean-depend \ + mostlyclean-compile mostlyclean-tags \ mostlyclean-generic mostlyclean: mostlyclean-recursive clean-am: clean-hdr clean-sbinPROGRAMS clean-compile clean-tags \ - clean-depend clean-generic mostlyclean-am + clean-generic mostlyclean-am clean: clean-recursive distclean-am: distclean-hdr distclean-sbinPROGRAMS distclean-compile \ - distclean-tags distclean-depend distclean-generic \ - clean-am distclean-local + distclean-tags distclean-generic clean-am \ + distclean-local distclean: distclean-recursive -rm -f config.status maintainer-clean-am: maintainer-clean-hdr maintainer-clean-sbinPROGRAMS \ maintainer-clean-compile maintainer-clean-tags \ - maintainer-clean-depend maintainer-clean-generic \ - distclean-am + maintainer-clean-generic distclean-am @echo "This command is intended for maintainers to use;" @echo "it deletes files that may require special tools to rebuild." @@ -513,12 +475,10 @@ all-recursive check-recursive installcheck-recursive info-recursive \ dvi-recursive mostlyclean-recursive distclean-recursive clean-recursive \ maintainer-clean-recursive tags tags-recursive mostlyclean-tags \ -distclean-tags clean-tags maintainer-clean-tags distdir \ -mostlyclean-depend distclean-depend clean-depend \ -maintainer-clean-depend info-am info dvi-am dvi check check-am \ -installcheck-am installcheck all-recursive-am install-exec-am \ -install-exec install-data-am install-data install-am install \ -uninstall-am uninstall all-redirect all-am all installdirs-am \ +distclean-tags clean-tags maintainer-clean-tags distdir info-am info \ +dvi-am dvi check check-am installcheck-am installcheck all-recursive-am \ +install-exec-am install-exec install-data-am install-data install-am \ +install uninstall-am uninstall all-redirect all-am all installdirs-am \ installdirs mostlyclean-generic distclean-generic clean-generic \ maintainer-clean-generic clean mostlyclean distclean maintainer-clean diff -ur mtr-0.56/NEWS mtr-0.57/NEWS --- mtr-0.56/NEWS Mon Apr 5 14:02:55 2004 +++ mtr-0.57/NEWS Wed Apr 7 11:50:40 2004 @@ -1,11 +1,14 @@ WHAT'S NEW? + v0.57 Lots of whitespace cleanups. And a DNS fix: Don't do DNS + lookups in raw mode with -n specified. + v0.56 Fixed compile warnings. Now compiles with -Wall. If your - compiler finds things mine didn't feel free to shout. + compiler finds things mine didn't feel free to shout. v0.55 Cleanup patch. I'm going to do some maintenance on MTR, but I want to be able to say: Can you see which version - fixed/broke things for you, so you're going to see a - bunch of new releases soon. + fixed/broke things for you, so you're going to see a + bunch of new releases soon. v0.54 Added "scrolling" patch from Roland Illig, to allow scrolling in text mode. I've always wanted this...... diff -ur mtr-0.56/configure mtr-0.57/configure --- mtr-0.56/configure Mon Apr 5 13:45:59 2004 +++ mtr-0.57/configure Mon Apr 5 14:04:57 2004 @@ -699,7 +699,7 @@ PACKAGE=mtr -VERSION=0.56 +VERSION=0.57 if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then { echo "configure: error: source directory already configured; run "make distclean" there first" 1>&2; exit 1; } diff -ur mtr-0.56/configure.in mtr-0.57/configure.in --- mtr-0.56/configure.in Mon Apr 5 13:45:42 2004 +++ mtr-0.57/configure.in Mon Apr 5 14:04:56 2004 @@ -1,5 +1,5 @@ AC_INIT(mtr.c) -AM_INIT_AUTOMAKE(mtr, 0.56) +AM_INIT_AUTOMAKE(mtr, 0.57) AC_SUBST(GTK_OBJ) diff -ur mtr-0.56/curses.c mtr-0.57/curses.c --- mtr-0.56/curses.c Mon Apr 5 14:01:28 2004 +++ mtr-0.57/curses.c Mon Apr 5 15:57:35 2004 @@ -102,7 +102,8 @@ }; -void pwcenter(char *str) { +void pwcenter(char *str) +{ int maxx, maxy; int cx; @@ -113,7 +114,8 @@ printw(str); } -int mtr_curses_keyaction() { +int mtr_curses_keyaction() +{ int c = getch(); int i=0; char buf[MAXFLD]; @@ -295,7 +297,8 @@ return ActionNone; /* ignore unknown input */ } -void mtr_curses_hosts(int startstat) { +void mtr_curses_hosts(int startstat) +{ int max; int at; int addr, addrs; @@ -389,7 +392,8 @@ static int scale[8]; static int low_ms, high_ms; -void mtr_gen_scale(void) { +void mtr_gen_scale(void) +{ int *saved, i, max, at; int range; @@ -420,7 +424,8 @@ static const char* block_map = ".123abc>"; -void mtr_print_scaled(int ms) { +void mtr_print_scaled(int ms) +{ int i; for (i = 0; i < 8; i++) { @@ -432,7 +437,8 @@ printw(">"); } -void mtr_fill_graph(int at, int cols) { +void mtr_fill_graph(int at, int cols) +{ int* saved; int i; @@ -458,7 +464,8 @@ } } -void mtr_curses_graph(int startstat, int cols) { +void mtr_curses_graph(int startstat, int cols) +{ int max, at, addr, y, x; char* name; @@ -492,7 +499,8 @@ } } -void mtr_curses_redraw() { +void mtr_curses_redraw() +{ int maxx, maxy; int startstat; int rowstat; @@ -513,7 +521,7 @@ pwcenter("My traceroute [v" VERSION "]"); attroff(A_BOLD); - mvprintw(1,0, "%s", LocalHostname); + mvprintw(1, 0, "%s", LocalHostname); printw("(tos=0x%X ", tos); printw("psize=%d ", abs(packetsize) ); printw("bitpattern=0x%02X)", (unsigned char)(abs(bitpattern))); @@ -597,7 +605,8 @@ refresh(); } -void mtr_curses_open() { +void mtr_curses_open() +{ initscr(); raw(); noecho(); @@ -605,12 +614,14 @@ mtr_curses_redraw(); } -void mtr_curses_close() { +void mtr_curses_close() +{ printw("\n"); endwin(); } -void mtr_curses_clear() { +void mtr_curses_clear() +{ mtr_curses_close(); mtr_curses_open(); } diff -ur mtr-0.56/dns.c mtr-0.57/dns.c --- mtr-0.56/dns.c Mon Apr 5 13:58:22 2004 +++ mtr-0.57/dns.c Mon Apr 5 15:45:09 2004 @@ -308,7 +308,8 @@ #endif -void *statmalloc(size_t size){ +void *statmalloc(size_t size) +{ void *p; size_t mallocsize; mem+= size; @@ -333,14 +334,15 @@ return p; } -void statfree(void *p){ - if (p){ - if (*((dword *)p - HEAD_SLACK) == 0){ +void statfree(void *p) +{ + if (p) { + if (*((dword *)p - HEAD_SLACK) == 0) { fprintf(stderr,"ERROR: Attempt to free pointer twice.\n"); *(int*)0=0; exit(-1); } else { - if (*((dword *)p - HEAD_SLACK) > 8192){ + if (*((dword *)p - HEAD_SLACK) > 8192) { fprintf(stderr,"ERROR: Corrupted free() buffer. (header)\n"); *(int*)0=0; exit(-1); @@ -349,7 +351,7 @@ if ((*(byte *)((char *)p + (*((dword *)p - 1)) + sizeof(byte) * 0) != 0xde) || (*(byte *)((char *)p + (*((dword *)p - 1)) + sizeof(byte) * 1) != 0xad) || (*(byte *)((char *)p + (*((dword *)p - 1)) + sizeof(byte) * 2) != 0xbe) || - (*(byte *)((char *)p + (*((dword *)p - 1)) + sizeof(byte) * 3) != 0xef)){ + (*(byte *)((char *)p + (*((dword *)p - 1)) + sizeof(byte) * 3) != 0xef)) { fprintf(stderr,"ERROR: Corrupted free() buffer. (footer)\n"); *(int*)0=0; exit(-1); @@ -365,11 +367,12 @@ } } -char *strtdiff(char *d,long signeddiff){ +char *strtdiff(char *d,long signeddiff) +{ dword diff; dword seconds,minutes,hours; long days; - if ((diff = labs(signeddiff))){ + if ((diff = labs(signeddiff))) { seconds = diff % 60; diff/= 60; minutes = diff % 60; diff/= 60; hours = diff % 24; @@ -389,33 +392,40 @@ return d; } -int issetfd(fd_set *set,int fd){ +int issetfd(fd_set *set,int fd) +{ return (int)((FD_ISSET(fd,set)) && 1); } -void setfd(fd_set *set,int fd){ +void setfd(fd_set *set,int fd) +{ FD_SET(fd,set); } -void clearfd(fd_set *set,int fd){ +void clearfd(fd_set *set,int fd) +{ FD_CLR(fd,set); } -void clearset(fd_set *set){ +void clearset(fd_set *set) +{ FD_ZERO(set); } -char *strlongip(ip_t ip){ +char *strlongip(ip_t ip) +{ struct in_addr a; a.s_addr = htonl(ip); return inet_ntoa(a); } -ip_t longipstr(char *s){ +ip_t longipstr(char *s) +{ return inet_addr(s); } -int dns_forward(char *name){ +int dns_forward(char *name) +{ struct hostent *host; if ((host = gethostbyname(name))) return *(int *)host->h_addr; @@ -423,14 +433,17 @@ return 0; } -int dns_waitfd(){ +int dns_waitfd(void) +{ return resfd; } -void dns_open(){ +void dns_open(void) +{ int option,i; + res_init(); - if (!_res.nscount){ + if (!_res.nscount) { fprintf(stderr,"No nameservers defined.\n"); exit(-1); } @@ -438,29 +451,30 @@ for (i = 0;i < _res.nscount;i++) _res.nsaddr_list[i].sin_family = AF_INET; resfd = socket(AF_INET, SOCK_DGRAM, 0); - if (resfd == -1){ + if (resfd == -1) { fprintf(stderr,"Unable to allocate socket for nameserver communication: %s\n", strerror(errno)); exit(-1); } option = 1; - if (setsockopt(resfd,SOL_SOCKET,SO_BROADCAST,(char *)&option,sizeof(option))){ + if (setsockopt(resfd,SOL_SOCKET,SO_BROADCAST,(char *)&option,sizeof(option))) { fprintf(stderr,"Unable to setsockopt() on nameserver communication socket: %s\n", strerror(errno)); exit(-1); } localhost = longipstr("127.0.0.1"); aseed = time(NULL) ^ (time(NULL) << 3) ^ (dword)getpid(); - for (i = 0;i < BashSize;i++){ + for (i = 0;i < BashSize;i++) { idbash[i] = NULL; hostbash[i] = NULL; } } -struct resolve *allocresolve(){ +struct resolve *allocresolve(void) +{ struct resolve *rp; rp = (struct resolve *)statmalloc(sizeof(struct resolve)); - if (!rp){ + if (!rp) { fprintf(stderr,"statmalloc() failed: %s\n",strerror(errno)); exit(-1); } @@ -468,34 +482,38 @@ return rp; } -dword getidbash(word id){ +dword getidbash(word id) +{ return (dword)BashModulo(id); } -dword getipbash(ip_t ip){ +dword getipbash(ip_t ip) +{ return (dword)BashModulo(ip); } -dword gethostbash(char *host){ +dword gethostbash(char *host) +{ dword bashvalue = 0; - for (;*host;host++){ + for (;*host;host++) { bashvalue^= *host; bashvalue+= (*host >> 1) + (bashvalue >> 1); } return BashModulo(bashvalue); } -void linkresolveid(struct resolve *addrp){ +void linkresolveid(struct resolve *addrp) +{ struct resolve *rp; dword bashnum; bashnum = getidbash(addrp->id); rp = idbash[bashnum]; - if (rp){ + if (rp) { while ((rp->nextid) && (addrp->id > rp->nextid->id)) rp = rp->nextid; while ((rp->previousid) && (addrp->id < rp->previousid->id)) rp = rp->previousid; - if (rp->id < addrp->id){ + if (rp->id < addrp->id) { addrp->previousid = rp; addrp->nextid = rp->nextid; if (rp->nextid) @@ -513,7 +531,8 @@ idbash[bashnum] = addrp; } -void unlinkresolveid(struct resolve *rp){ +void unlinkresolveid(struct resolve *rp) +{ dword bashnum; bashnum = getidbash(rp->id); if (idbash[bashnum] == rp) @@ -524,17 +543,18 @@ rp->previousid->nextid = rp->nextid; } -void linkresolvehost(struct resolve *addrp){ +void linkresolvehost(struct resolve *addrp) +{ struct resolve *rp; dword bashnum; bashnum = gethostbash(addrp->hostname); rp = hostbash[bashnum]; - if (rp){ + if (rp) { while ((rp->nexthost) && (strcasecmp(addrp->hostname,rp->nexthost->hostname) < 0)) rp = rp->nexthost; while ((rp->previoushost) && (strcasecmp(addrp->hostname,rp->previoushost->hostname) > 0)) rp = rp->previoushost; - if (strcasecmp(addrp->hostname,rp->hostname) < 0){ + if (strcasecmp(addrp->hostname,rp->hostname) < 0) { addrp->previoushost = rp; addrp->nexthost = rp->nexthost; if (rp->nexthost) @@ -552,7 +572,8 @@ hostbash[bashnum] = addrp; } -void unlinkresolvehost(struct resolve *rp){ +void unlinkresolvehost(struct resolve *rp) +{ dword bashnum; bashnum = gethostbash(rp->hostname); if (hostbash[bashnum] == rp) @@ -564,17 +585,18 @@ statfree(rp->hostname); } -void linkresolveip(struct resolve *addrp){ +void linkresolveip(struct resolve *addrp) +{ struct resolve *rp; dword bashnum; bashnum = getipbash(addrp->ip); rp = ipbash[bashnum]; - if (rp){ + if (rp) { while ((rp->nextip) && (addrp->ip > rp->nextip->ip)) rp = rp->nextip; while ((rp->previousip) && (addrp->ip < rp->previousip->ip)) rp = rp->previousip; - if (rp->ip < addrp->ip){ + if (rp->ip < addrp->ip) { addrp->previousip = rp; addrp->nextip = rp->nextip; if (rp->nextip) @@ -592,7 +614,8 @@ ipbash[bashnum] = addrp; } -void unlinkresolveip(struct resolve *rp){ +void unlinkresolveip(struct resolve *rp) +{ dword bashnum; bashnum = getipbash(rp->ip); if (ipbash[bashnum] == rp) @@ -603,12 +626,13 @@ rp->previousip->nextip = rp->nextip; } -void linkresolve(struct resolve *rp){ +void linkresolve(struct resolve *rp) +{ struct resolve *irp; - if (expireresolves){ + if (expireresolves) { irp = expireresolves; while ((irp->next) && (rp->expiretime >= irp->expiretime)) irp = irp->next; - if (rp->expiretime >= irp->expiretime){ + if (rp->expiretime >= irp->expiretime) { rp->next = NULL; rp->previous = irp; irp->next = rp; @@ -630,13 +654,14 @@ resolvecount++; } -void lastlinkresolve(struct resolve *rp){ +void lastlinkresolve(struct resolve *rp) +{ struct resolve *irp; - if (lastresolve){ + if (lastresolve) { irp = lastresolve; while ((irp->previous) && (rp->expiretime < irp->expiretime)) irp = irp->previous; while ((irp->next) && (rp->expiretime >= irp->expiretime)) irp = irp->next; - if (rp->expiretime >= irp->expiretime){ + if (rp->expiretime >= irp->expiretime) { rp->next = NULL; rp->previous = irp; irp->next = rp; @@ -658,7 +683,8 @@ resolvecount++; } -void untieresolve(struct resolve *rp){ +void untieresolve(struct resolve *rp) +{ if (rp->previous) rp->previous->next = rp->next; else @@ -670,7 +696,8 @@ resolvecount--; } -void unlinkresolve(struct resolve *rp){ +void unlinkresolve(struct resolve *rp) +{ untieresolve(rp); unlinkresolveid(rp); unlinkresolveip(rp); @@ -678,17 +705,18 @@ unlinkresolvehost(rp); } -struct resolve *findid(word id){ +struct resolve *findid(word id) +{ struct resolve *rp; int bashnum; bashnum = getidbash(id); rp = idbash[bashnum]; - if (rp){ + if (rp) { while ((rp->nextid) && (id >= rp->nextid->id)) rp = rp->nextid; while ((rp->previousid) && (id <= rp->previousid->id)) rp = rp->previousid; - if (id == rp->id){ + if (id == rp->id) { idbash[bashnum] = rp; return rp; } else @@ -697,12 +725,13 @@ return rp; /* NULL */ } -struct resolve *findhost(char *hostname){ +struct resolve *findhost(char *hostname) +{ struct resolve *rp; int bashnum; bashnum = gethostbash(hostname); rp = hostbash[bashnum]; - if (rp){ + if (rp) { while ((rp->nexthost) && (strcasecmp(hostname,rp->nexthost->hostname) >= 0)) rp = rp->nexthost; while ((rp->previoushost) && (strcasecmp(hostname,rp->nexthost->hostname) <= 0)) @@ -717,17 +746,18 @@ return rp; /* NULL */ } -struct resolve *findip(ip_t ip){ +struct resolve *findip(ip_t ip) +{ struct resolve *rp; dword bashnum; bashnum = getipbash(ip); rp = ipbash[bashnum]; - if (rp){ + if (rp) { while ((rp->nextip) && (ip >= rp->nextip->ip)) rp = rp->nextip; while ((rp->previousip) && (ip <= rp->previousip->ip)) rp = rp->previousip; - if (ip == rp->ip){ + if (ip == rp->ip) { ipbash[bashnum] = rp; return rp; } else @@ -736,17 +766,19 @@ return rp; /* NULL */ } -void restell(char *s){ +void restell(char *s) +{ fputs(s,stderr); fputs("\r",stderr); } -void dorequest(char *s,int type,word id){ +void dorequest(char *s,int type,word id) +{ packetheader *hp; int r,i; int buf[(MaxPacketsize/sizeof (int))+1]; r = res_mkquery(QUERY,s,C_IN,type,NULL,0,NULL,(unsigned char*)buf,MaxPacketsize); - if (r == -1){ + if (r == -1) { restell("Resolver error: Query too large."); return; } @@ -757,22 +789,23 @@ sizeof(struct sockaddr)); } -void resendrequest(struct resolve *rp,int type){ - if (type == T_A){ +void resendrequest(struct resolve *rp,int type) +{ + if (type == T_A) { dorequest(rp->hostname,type,rp->id); - if (debug){ + if (debug) { sprintf(tempstring,"Resolver: Sent reverse authentication request for \"%s\".", rp->hostname); restell(tempstring); } - } else if (type == T_PTR){ + } else if (type == T_PTR) { sprintf(tempstring,"%u.%u.%u.%u.in-addr.arpa", ((byte *)&rp->ip)[3], ((byte *)&rp->ip)[2], ((byte *)&rp->ip)[1], ((byte *)&rp->ip)[0]); dorequest(tempstring,type,rp->id); - if (debug){ + if (debug) { sprintf(tempstring,"Resolver: Sent domain lookup request for \"%s\".", strlongip(rp->ip)); restell(tempstring); @@ -780,7 +813,8 @@ } } -void sendrequest(struct resolve *rp,int type){ +void sendrequest(struct resolve *rp,int type) +{ do { idseed = (((idseed + idseed) | (long)time(NULL)) + idseed - 0x54bad4a) ^ aseed; aseed^= idseed; @@ -790,7 +824,8 @@ resendrequest(rp,type); } -void failrp(struct resolve *rp){ +void failrp(struct resolve *rp) +{ if (rp->state == STATE_FINISHED) return; rp->state = STATE_FAILED; @@ -799,17 +834,19 @@ restell("Resolver: Lookup failed.\n"); } -void passrp(struct resolve *rp,long ttl){ +void passrp(struct resolve *rp,long ttl) +{ rp->state = STATE_FINISHED; rp->expiretime = sweeptime + (double)ttl; untieresolve(rp); - if (debug){ + if (debug) { sprintf(tempstring,"Resolver: Lookup successful: %s\n",rp->hostname); restell(tempstring); } } -void parserespacket(byte *s,int l){ +void parserespacket(byte *s,int l) +{ struct resolve *rp; packetheader *hp; byte *eob; @@ -818,11 +855,11 @@ int r,usefulanswer; word rr,datatype,class,qdatatype,qclass; byte rdatalength; - if (l < sizeof(packetheader)){ + if (l < sizeof(packetheader)) { restell("Resolver error: Packet smaller than standard header size."); return; } - if (l == sizeof(packetheader)){ + if (l == sizeof(packetheader)) { restell("Resolver error: Packet has empty body."); return; } @@ -830,7 +867,7 @@ /* Convert data to host byte order */ /* hp->id does not need to be redundantly byte-order flipped, it is only echoed by nameserver */ rp = findid(hp->id); - if (!rp){ + if (!rp) { res_unknownid++; return; } @@ -840,37 +877,37 @@ hp->ancount = ntohs(hp->ancount); hp->nscount = ntohs(hp->nscount); hp->arcount = ntohs(hp->arcount); - if (getheader_tc(hp)){ /* Packet truncated */ + if (getheader_tc(hp)) { /* Packet truncated */ restell("Resolver error: Nameserver packet truncated."); return; } - if (!getheader_qr(hp)){ /* Not a reply */ + if (!getheader_qr(hp)) { /* Not a reply */ restell("Resolver error: Query packet received on nameserver communication socket."); return; } - if (getheader_opcode(hp)){ /* Not opcode 0 (standard query) */ + if (getheader_opcode(hp)) { /* Not opcode 0 (standard query) */ restell("Resolver error: Invalid opcode in response packet."); return; } eob = s + l; c = s + HFIXEDSZ; - switch (getheader_rcode(hp)){ + switch (getheader_rcode(hp)) { case NOERROR: - if (hp->ancount){ - if (debug){ + if (hp->ancount) { + if (debug) { sprintf(tempstring,"Resolver: Received nameserver reply. (qd:%u an:%u ns:%u ar:%u)", hp->qdcount,hp->ancount,hp->nscount,hp->arcount); restell(tempstring); } - if (hp->qdcount != 1){ + if (hp->qdcount != 1) { restell("Resolver error: Reply does not contain one query."); return; } - if (c > eob){ + if (c > eob) { restell("Resolver error: Reply too short."); return; } - switch (rp->state){ /* Construct expected query reply */ + switch (rp->state) { /* Construct expected query reply */ case STATE_PTRREQ1: case STATE_PTRREQ2: case STATE_PTRREQ3: @@ -883,40 +920,40 @@ } *namestring = '\0'; r = dn_expand(s,s + l,c,namestring,MAXDNAME); - if (r == -1){ + if (r == -1) { restell("Resolver error: dn_expand() failed while expanding query domain."); return; } namestring[strlen(stackstring)] = '\0'; - if (strcasecmp(stackstring,namestring)){ - if (debug){ + if (strcasecmp(stackstring,namestring)) { + if (debug) { sprintf(tempstring,"Resolver: Unknown query packet dropped. (\"%s\" does not match \"%s\")", stackstring,namestring); restell(tempstring); } return; } - if (debug){ + if (debug) { sprintf(tempstring,"Resolver: Queried domain name: \"%s\"",namestring); restell(tempstring); } c+= r; - if (c + 4 > eob){ + if (c + 4 > eob) { restell("Resolver error: Query resource record truncated."); return; } qdatatype = sucknetword(c); qclass = sucknetword(c); - if (qclass != C_IN){ + if (qclass != C_IN) { sprintf(tempstring,"Resolver error: Received unsupported query class: %u (%s)", qclass,qclass < ClasstypeCount ? classtypes[qclass] : classtypes[ClasstypeCount]); restell(tempstring); } - switch (qdatatype){ + switch (qdatatype) { case T_PTR: if (!Is_PTR(rp)) - if (debug){ + if (debug) { restell("Resolver warning: Ignoring response with unexpected query type \"PTR\"."); return; } @@ -927,14 +964,14 @@ resourcetypes[qdatatype] : resourcetypes[ResourcetypeCount]); restell(tempstring); } - for (rr = hp->ancount + hp->nscount + hp->arcount;rr;rr--){ - if (c > eob){ + for (rr = hp->ancount + hp->nscount + hp->arcount;rr;rr--) { + if (c > eob) { restell("Resolver error: Packet does not contain all specified resouce records."); return; } *namestring = '\0'; r = dn_expand(s,s + l,c,namestring,MAXDNAME); - if (r == -1){ + if (r == -1) { restell("Resolver error: dn_expand() failed while expanding answer domain."); return; } @@ -943,12 +980,12 @@ usefulanswer = 0; else usefulanswer = 1; - if (debug){ + if (debug) { sprintf(tempstring,"Resolver: answered domain query: \"%s\"",namestring); restell(tempstring); } c+= r; - if (c + 10 > eob){ + if (c + 10 > eob) { restell("Resolver error: Resource record truncated."); return; } @@ -956,7 +993,7 @@ class = sucknetword(c); ttl = sucknetlong(c); rdatalength = sucknetword(c); - if (class != qclass){ + if (class != qclass) { sprintf(tempstring,"query class: %u (%s)",qclass,qclass < ClasstypeCount ? classtypes[qclass] : classtypes[ClasstypeCount]); restell(tempstring); @@ -966,29 +1003,29 @@ restell("Resolver error: Answered class does not match queried class."); return; } - if (!rdatalength){ + if (!rdatalength) { restell("Resolver error: Zero size rdata."); return; } - if (c + rdatalength > eob){ + if (c + rdatalength > eob) { restell("Resolver error: Specified rdata length exceeds packet size."); return; } - if (datatype == qdatatype || datatype == T_CNAME){ - if (debug){ + if (datatype == qdatatype || datatype == T_CNAME) { + if (debug) { sprintf(tempstring,"Resolver: TTL: %s",strtdiff(sendstring,ttl)); restell(tempstring); } if (usefulanswer) - switch (datatype){ + switch (datatype) { case T_A: - if (rdatalength != 4){ + if (rdatalength != 4) { sprintf(tempstring,"Resolver error: Unsupported rdata format for \"A\" type. (%u bytes)", rdatalength); restell(tempstring); return; } - if (memcmp(&rp->ip,(ip_t *)c,sizeof(ip_t))){ + if (memcmp(&rp->ip,(ip_t *)c,sizeof(ip_t))) { sprintf(tempstring,"Resolver: Reverse authentication failed: %s != ", strlongip(rp->ip)); memcpy(&alignedip,(ip_t *)c,sizeof(ip_t)); @@ -1009,26 +1046,26 @@ case T_CNAME: *namestring = '\0'; r = dn_expand(s,s + l,c,namestring,MAXDNAME); - if (r == -1){ + if (r == -1) { restell("Resolver error: dn_expand() failed while expanding domain in rdata."); return; } - if (debug){ + if (debug) { sprintf(tempstring,"Resolver: Answered domain: \"%s\"",namestring); restell(tempstring); } - if (r > HostnameLength){ + if (r > HostnameLength) { restell("Resolver error: Domain name too long."); failrp(rp); return; } - if (datatype == T_CNAME){ + if (datatype == T_CNAME) { strcpy(stackstring,namestring); break; } - if (!rp->hostname){ + if (!rp->hostname) { rp->hostname = (char *)statmalloc(strlen(namestring) + 1); - if (!rp->hostname){ + if (!rp->hostname) { fprintf(stderr,"statmalloc() error: %s\n",strerror(errno)); exit(-1); } @@ -1045,7 +1082,7 @@ restell(tempstring); } } else { - if (debug){ + if (debug) { sprintf(tempstring,"Resolver: Ignoring resource type %u. (%s)", datatype,datatype < ResourcetypeCount ? resourcetypes[datatype] : resourcetypes[ResourcetypeCount]); @@ -1072,12 +1109,13 @@ } } -void dns_ack(){ +void dns_ack(void) +{ int r,i; r = recvfrom(resfd,(byte *)resrecvbuf,MaxPacketsize,0,(struct sockaddr *)&from,&fromlen); - if (r > 0){ + if (r > 0) { /* Check to see if this server is actually one we sent to */ - if (from.sin_addr.s_addr == localhost){ + if (from.sin_addr.s_addr == localhost) { for (i = 0;i < _res.nscount;i++) if ((_res.nsaddr_list[i].sin_addr.s_addr == from.sin_addr.s_addr) || (!_res.nsaddr_list[i].sin_addr.s_addr)) /* 0.0.0.0 replies as 127.0.0.1 */ @@ -1086,7 +1124,7 @@ for (i = 0;i < _res.nscount;i++) if (_res.nsaddr_list[i].sin_addr.s_addr == from.sin_addr.s_addr) break; - if (i == _res.nscount){ + if (i == _res.nscount) { sprintf(tempstring,"Resolver error: Received reply from unknown source: %s", inet_ntoa(from.sin_addr)); restell(tempstring); @@ -1098,7 +1136,8 @@ } } -int istime(double x,double *sinterval){ +int istime(double x,double *sinterval) +{ if (x) { if (x > sweeptime) { if (*sinterval > x - sweeptime) @@ -1109,14 +1148,15 @@ return 0; } -void dns_events(double *sinterval){ +void dns_events(double *sinterval) +{ struct resolve *rp,*nextrp; - for (rp = expireresolves;(rp) && (sweeptime >= rp->expiretime);rp = nextrp){ + for (rp = expireresolves;(rp) && (sweeptime >= rp->expiretime);rp = nextrp) { nextrp = rp->next; - switch (rp->state){ + switch (rp->state) { case STATE_FINISHED: /* TTL has expired */ case STATE_FAILED: /* Fake TTL has expired */ - if (debug){ + if (debug) { sprintf(tempstring,"Resolver: Cache record for \"%s\" (%s) has expired. (state: %u) Marked for expire at: %g, time: %g.", nonull(rp->hostname),strlongip(rp->ip),rp->state,rp->expiretime,sweeptime); restell(tempstring); @@ -1151,20 +1191,21 @@ (void)istime(expireresolves->expiretime,sinterval); } -char *dns_lookup2(ip_t ip){ +char *dns_lookup2(ip_t ip) +{ struct resolve *rp; ip = htonl(ip); - if ((rp = findip(ip))){ - if ((rp->state == STATE_FINISHED) || (rp->state == STATE_FAILED)){ - if ((rp->state == STATE_FINISHED) && (rp->hostname)){ - if (debug){ + if ((rp = findip(ip))) { + if ((rp->state == STATE_FINISHED) || (rp->state == STATE_FAILED)) { + if ((rp->state == STATE_FINISHED) && (rp->hostname)) { + if (debug) { sprintf(tempstring,"Resolver: Used cached record: %s == \"%s\".\n", strlongip(ip),rp->hostname); restell(tempstring); } return rp->hostname; } else { - if (debug){ + if (debug) { sprintf(tempstring,"Resolver: Used failed record: %s == ???\n", strlongip(ip)); restell(tempstring); @@ -1189,7 +1230,8 @@ int use_dns = 1; -char *dns_lookup(ip_t ip){ +char *dns_lookup(ip_t ip) +{ char *t; if (!dns) return strlongip (ip); diff -ur mtr-0.56/gtk.c mtr-0.57/gtk.c --- mtr-0.56/gtk.c Mon Apr 5 14:00:15 2004 +++ mtr-0.57/gtk.c Mon Apr 5 15:52:16 2004 @@ -56,7 +56,8 @@ } -void gtk_do_init(int *argc, char ***argv) { +void gtk_do_init(int *argc, char ***argv) +{ static int done = 0; if(!done) { @@ -66,7 +67,8 @@ } } -int gtk_detect(int *argc, char ***argv) { +int gtk_detect(int *argc, char ***argv) +{ if(getenv("DISPLAY") != NULL) { /* If we do this here, gtk_init exits on an error. This happens BEFORE the user has had a chance to tell us not to use the @@ -77,13 +79,15 @@ } } -gint Window_destroy(GtkWidget *Window, gpointer data) { +gint Window_destroy(GtkWidget *Window, gpointer data) +{ gtk_main_quit(); return FALSE; } -gint Restart_clicked(GtkWidget *Button, gpointer data) { +gint Restart_clicked(GtkWidget *Button, gpointer data) +{ net_reset(); gtk_redraw(); @@ -91,7 +95,8 @@ } -gint Pause_clicked(GtkWidget *Button, gpointer data) { +gint Pause_clicked(GtkWidget *Button, gpointer data) +{ static int paused = 0; if (paused) { @@ -114,7 +119,8 @@ * What's the problem with this? (-> "I don't think so) -- REW */ -gint WaitTime_changed(GtkAdjustment *Adj, GtkWidget *Button) { +gint WaitTime_changed(GtkAdjustment *Adj, GtkWidget *Button) +{ WaitTime = gtk_spin_button_get_value_as_float(GTK_SPIN_BUTTON(Button)); gtk_timeout_remove (tag); gtk_add_ping_timeout (); @@ -123,7 +129,8 @@ return FALSE; } -gint Host_activate(GtkWidget *Entry, gpointer data) { +gint Host_activate(GtkWidget *Entry, gpointer data) +{ int addr; addr = dns_forward(gtk_entry_get_text(GTK_ENTRY(Entry))); @@ -140,13 +147,15 @@ return FALSE; } -GdkPixmap *gtk_load_pixmap(char **pixmap) { +GdkPixmap *gtk_load_pixmap(char **pixmap) +{ return gdk_pixmap_colormap_create_from_xpm_d(NULL, gdk_colormap_get_system(), NULL, NULL, pixmap); } -void Toolbar_fill(GtkWidget *Toolbar) { +void Toolbar_fill(GtkWidget *Toolbar) +{ GtkWidget *Button; GtkWidget *Label; GtkWidget *Entry; @@ -203,7 +212,8 @@ GtkWidget *Report; GtkWidget *ReportBody; -GtkWidget *GetRow(int index) { +GtkWidget *GetRow(int index) +{ int addr; char *name; GtkWidget *Row, *Label; @@ -228,7 +238,8 @@ return Row; } -GtkWidget *Scrollarea_create() { +GtkWidget *Scrollarea_create() +{ GtkWidget *List; GtkWidget *scroll; int count; @@ -254,7 +265,8 @@ return scroll; } -void gtk_add_row(GtkWidget *List) { +void gtk_add_row(GtkWidget *List) +{ int at; GtkWidget *Row, *Label; @@ -280,14 +292,16 @@ //void gtk_set_field_num(GtkCList *List, int row, int ix, char *format, int num) { // changed int to dobule byMin -void gtk_set_field_num(GtkCList *List, int row, int ix, char *format, double num) { +void gtk_set_field_num(GtkCList *List, int row, int ix, char *format, double num) +{ char str[32]; sprintf(str, format, num); gtk_set_field(List, row, ix, str); } -void gtk_update_row(GtkCList *List, int row) { +void gtk_update_row(GtkCList *List, int row) +{ int addr; char str[256], *name; GdkColor color; @@ -331,7 +345,8 @@ } -void gtk_redraw() { +void gtk_redraw() +{ int at = net_min(); // changed from 0 to net_min for TTL stuff byMin int max = net_max(); @@ -353,7 +368,8 @@ gtk_clist_thaw(GTK_CLIST(ReportBody)); } -void Window_fill(GtkWidget *Window) { +void Window_fill(GtkWidget *Window) +{ GtkWidget *VBox; GtkWidget *Toolbar; GtkWidget *List; @@ -377,7 +393,8 @@ gtk_widget_show(VBox); } -void gtk_open() { +void gtk_open() +{ GtkWidget *Window; GdkPixmap *icon; @@ -406,14 +423,17 @@ gdk_window_set_icon_name(Window->window, "mtr"); } -void gtk_close() { +void gtk_close() +{ } -int gtk_keyaction() { +int gtk_keyaction() +{ return 0; } -gint gtk_ping(gpointer data) { +gint gtk_ping(gpointer data) +{ gtk_redraw(); net_send_batch(); gtk_timeout_remove (tag); @@ -421,18 +441,21 @@ return TRUE; } -void gtk_net_data(gpointer data, gint fd, GdkInputCondition cond) { +void gtk_net_data(gpointer data, gint fd, GdkInputCondition cond) +{ net_process_return(); } -void gtk_dns_data(gpointer data, gint fd, GdkInputCondition cond) { +void gtk_dns_data(gpointer data, gint fd, GdkInputCondition cond) +{ dns_ack(); gtk_redraw(); } -void gtk_loop() { +void gtk_loop() +{ gtk_add_ping_timeout (); gdk_input_add(net_waitfd(), GDK_INPUT_READ, gtk_net_data, NULL); gdk_input_add(dns_waitfd(), GDK_INPUT_READ, gtk_dns_data, NULL); diff -ur mtr-0.56/raw.c mtr-0.57/raw.c --- mtr-0.56/raw.c Mon Apr 5 13:57:17 2004 +++ mtr-0.57/raw.c Wed Apr 7 11:47:29 2004 @@ -51,7 +51,7 @@ { char *name; - if (!havename[host]) { + if (dns && !havename[host]) { name = dns_lookup2(net_addr(host)); if (name) { havename[host]++; diff -ur mtr-0.56/select.c mtr-0.57/select.c --- mtr-0.56/select.c Mon Apr 5 13:58:51 2004 +++ mtr-0.57/select.c Mon Apr 5 16:12:15 2004 @@ -70,9 +70,12 @@ maxfd = 1; } - dnsfd = dns_waitfd(); - FD_SET(dnsfd, &readfd); - if(dnsfd >= maxfd) maxfd = dnsfd + 1; + if (dns) { + dnsfd = dns_waitfd(); + FD_SET(dnsfd, &readfd); + if(dnsfd >= maxfd) maxfd = dnsfd + 1; + } else + dnsfd = 0; netfd = net_waitfd(); FD_SET(netfd, &readfd); @@ -136,12 +139,14 @@ anyset = 1; } - /* Handle any pending resolver events */ - dnsinterval = WaitTime; - dns_events(&dnsinterval); + if (dns) { + /* Handle any pending resolver events */ + dnsinterval = WaitTime; + dns_events(&dnsinterval); + } /* Have we finished a nameservice lookup? */ - if(FD_ISSET(dnsfd, &readfd)) { + if(dns && FD_ISSET(dnsfd, &readfd)) { dns_ack(); anyset = 1; } .