summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorfenner <fenner>1999-11-22 07:25:26 +0000
committerfenner <fenner>1999-11-22 07:25:26 +0000
commit814765d31c7cf9bf8753cdb2c908f516608c72ee (patch)
tree3d4b7155185deb9ecc8ced336615a11fa8789a3c /util.c
parentdedd2e68e500e3fc1b8427cb04d9347c4a78d373 (diff)
downloadtcpdump-814765d31c7cf9bf8753cdb2c908f516608c72ee.tar.gz
Enhanced PIMv1 support.
Cisco Auto-RP support.
Diffstat (limited to 'util.c')
-rw-r--r--util.c30
1 files changed, 29 insertions, 1 deletions
diff --git a/util.c b/util.c
index e830a084..326eae49 100644
--- a/util.c
+++ b/util.c
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/util.c,v 1.60 1999-11-21 09:37:05 fenner Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/util.c,v 1.61 1999-11-22 07:25:27 fenner Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -164,6 +164,34 @@ ts_print(register const struct timeval *tvp)
}
/*
+ * Print a relative number of seconds (e.g. hold time, prune timer)
+ * in the form 5m1s. This does no truncation, so 32230861 seconds
+ * is represented as 1y1w1d1h1m1s.
+ */
+void
+relts_print(int secs)
+{
+ static char *lengths[]={"y","w","d","h","m","s"};
+ static int seconds[]={31536000,604800,86400,3600,60,1};
+ char **l = lengths;
+ int *s = seconds;
+ int len;
+ int i;
+
+ if (secs == 0) {
+ (void)printf("0s");
+ return;
+ }
+ while (secs) {
+ if (secs >= *s) {
+ (void)printf("%d%s", secs / *s, *l);
+ secs -= (secs / *s) * *s;
+ }
+ s++; l++;
+ }
+}
+
+/*
* Convert a token value to a string; use "fmt" if not found.
*/
const char *