X-Git-Url: http://dolda2000.com/gitweb/?a=blobdiff_plain;f=idnlookup.c;h=d47b7de75eb1f84815a0b19eec4562a6ace2bc5f;hb=f0df8f66ac34f08e871eaf4bd1e04303d97df032;hp=27b26fdef4dbd50d60d034f724d180fcce06cc1d;hpb=bfd59ca08b91d279b7646d00c209e4bb527f32c6;p=icmp-dn.git diff --git a/idnlookup.c b/idnlookup.c index 27b26fd..d47b7de 100644 --- a/idnlookup.c +++ b/idnlookup.c @@ -136,14 +136,19 @@ int main(int argc, char **argv) struct pollfd pfd; struct timeval tvb, tvc; struct sockaddr_storage name; - int timeout, elapsed; + int timeout, dispttl; + int elapsed; timeout = 3000; - while((c = getopt(argc, argv, "ht:")) != -1) { + dispttl = 0; + while((c = getopt(argc, argv, "hTt:")) != -1) { switch(c) { case 't': timeout = atoi(optarg); break; + case 'T': + dispttl = 1; + break; case 'h': case '?': case ':': @@ -191,7 +196,7 @@ int main(int argc, char **argv) pfd.events = POLLIN; gettimeofday(&tvc, NULL); elapsed = ((tvc.tv_sec - tvb.tv_sec) * 1000) + ((tvc.tv_usec - tvb.tv_usec) / 1000); - if(elapsed > timeout) { + if(elapsed >= timeout) { fprintf(stderr, "idnlookup: timeout\n"); exit(1); } @@ -236,6 +241,8 @@ int main(int argc, char **argv) } } + if(dispttl) + printf("%i\n", ntohl(rep.ttl)); printdn(stdout, buf + sizeof(iphdr) + sizeof(rep), ret - sizeof(iphdr) - sizeof(rep)); close(s);