summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--interface.h5
-rw-r--r--print-icmp6.c13
-rw-r--r--print-telnet.c18
-rw-r--r--util.c133
4 files changed, 86 insertions, 83 deletions
diff --git a/interface.h b/interface.h
index a45186d0..a0313d7f 100644
--- a/interface.h
+++ b/interface.h
@@ -18,7 +18,7 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.126 2000-06-01 01:14:43 assar Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.127 2000-06-03 16:40:35 itojun Exp $ (LBL)
*/
#ifndef tcpdump_interface_h
@@ -209,6 +209,9 @@ extern void warning(const char *, ...) __attribute__ ((format (printf, 1, 2)));
extern char *read_infile(char *);
extern char *copy_argv(char **);
+extern void safeputchar(int);
+extern void safeputs(const char *);
+
extern char *isonsap_string(const u_char *);
extern char *llcsap_string(u_char);
extern char *protoid_string(const u_char *);
diff --git a/print-icmp6.c b/print-icmp6.c
index 0222fd59..972e8e72 100644
--- a/print-icmp6.c
+++ b/print-icmp6.c
@@ -21,7 +21,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-icmp6.c,v 1.15 2000-05-28 04:23:14 itojun Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-icmp6.c,v 1.16 2000-06-03 16:40:35 itojun Exp $";
#endif
#ifdef HAVE_CONFIG_H
@@ -578,10 +578,6 @@ mld6_print(register const u_char *bp)
#endif
#ifdef HAVE_STRUCT_ICMP6_NODEINFO
-#define safeputc(c) \
- printf((((unsigned char)c) < 0x80 && isprint((c)) ? "%c" : "\\%03o"), \
- ((unsigned char)c) & 0xff)
-
static void
dnsname_print(const u_char *cp, const u_char *ep)
{
@@ -597,7 +593,7 @@ dnsname_print(const u_char *cp, const u_char *ep)
break;
}
while (i-- && cp < ep) {
- safeputc(*cp);
+ safeputchar(*cp);
cp++;
}
if (cp + 1 < ep && *cp)
@@ -717,7 +713,7 @@ icmp6_nodeinfo_print(int icmp6len, const u_char *bp, const u_char *ep)
cp++;
printf(", \"");
while (cp < ep) {
- safeputc(*cp);
+ safeputchar(*cp);
cp++;
}
printf("\"");
@@ -800,7 +796,7 @@ icmp6_nodeinfo_print(int icmp6len, const u_char *bp, const u_char *ep)
cp++;
printf(", \"");
while (cp < ep) {
- safeputc(*cp);
+ safeputchar(*cp);
cp++;
}
printf("\"");
@@ -842,7 +838,6 @@ icmp6_nodeinfo_print(int icmp6len, const u_char *bp, const u_char *ep)
trunc:
fputs("[|icmp6]", stdout);
}
-#undef safeputc
#endif
#endif /* INET6 */
diff --git a/print-telnet.c b/print-telnet.c
index ab8351f2..e0db8ee9 100644
--- a/print-telnet.c
+++ b/print-telnet.c
@@ -51,7 +51,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-telnet.c,v 1.7 2000-05-28 04:23:14 itojun Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-telnet.c,v 1.8 2000-06-03 16:40:35 itojun Exp $";
#endif
#include <sys/param.h>
@@ -83,22 +83,6 @@ static const char rcsid[] =
# define TELCMD_FIRST SE
#endif
-static void safeputs __P((const char *));
-
-#define safeputc(c) \
- printf((((unsigned char)c) < 0x80 && isprint((c)) ? "%c" : "\\%03o"), \
- ((unsigned char)c) & 0xff)
-
-static void
-safeputs(s)
- const char *s;
-{
- while (*s) {
- safeputc(*s);
- s++;
- }
-}
-
void
telnet_print(register const u_char *sp, u_int length)
{
diff --git a/util.c b/util.c
index fd8843c3..efb6b0e9 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.64 2000-06-01 01:13:53 assar Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/util.c,v 1.65 2000-06-03 16:40:36 itojun Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -134,47 +134,46 @@ ts_print(register const struct timeval *tvp)
static unsigned b_sec;
static unsigned b_usec;
- switch(tflag)
- {
- case 1: /* Default */
- s = (tvp->tv_sec + thiszone) % 86400;
- (void)printf("%02d:%02d:%02d.%06u ",
- s / 3600, (s % 3600) / 60, s % 60,
- (unsigned)tvp->tv_usec);
- break;
- case -1: /* Unix timeval style */
- (void)printf("%u.%06u ",
- (unsigned)tvp->tv_sec,
- (unsigned)tvp->tv_usec);
- break;
- case -2:
- if (b_sec == 0) {
- printf("000000 ");
- } else {
- int d_usec = tvp->tv_usec - b_usec;
- int d_sec = tvp->tv_sec - b_sec;
-
- while (d_usec < 0) {
- d_usec += 1000000;
- d_sec--;
- }
- if (d_sec)
- printf("%d. ", d_sec);
- printf("%06d ", d_usec);
+ switch(tflag) {
+ case 1: /* Default */
+ s = (tvp->tv_sec + thiszone) % 86400;
+ (void)printf("%02d:%02d:%02d.%06u ",
+ s / 3600, (s % 3600) / 60, s % 60,
+ (unsigned)tvp->tv_usec);
+ break;
+ case -1: /* Unix timeval style */
+ (void)printf("%u.%06u ",
+ (unsigned)tvp->tv_sec,
+ (unsigned)tvp->tv_usec);
+ break;
+ case -2:
+ if (b_sec == 0) {
+ printf("000000 ");
+ } else {
+ int d_usec = tvp->tv_usec - b_usec;
+ int d_sec = tvp->tv_sec - b_sec;
+
+ while (d_usec < 0) {
+ d_usec += 1000000;
+ d_sec--;
}
- b_sec = tvp->tv_sec;
- b_usec = tvp->tv_usec;
- break;
- case -3: /* Default + Date*/
- s = (tvp->tv_sec + thiszone) % 86400;
- time(&Time);
- tm = localtime(&Time);
- (void)printf("%02d/%02d/%04d %02d:%02d:%02d.%06u ",
- tm->tm_mon+1, tm->tm_mday,
- tm->tm_year+1900,
- s / 3600, (s % 3600) / 60,
- s % 60, (unsigned)tvp->tv_usec);
- break;
+ if (d_sec)
+ printf("%d. ", d_sec);
+ printf("%06d ", d_usec);
+ }
+ b_sec = tvp->tv_sec;
+ b_usec = tvp->tv_usec;
+ break;
+ case -3: /* Default + Date*/
+ s = (tvp->tv_sec + thiszone) % 86400;
+ time(&Time);
+ tm = localtime(&Time);
+ (void)printf("%02d/%02d/%04d %02d:%02d:%02d.%06u ",
+ tm->tm_mon+1, tm->tm_mday,
+ tm->tm_year+1900,
+ s / 3600, (s % 3600) / 60,
+ s % 60, (unsigned)tvp->tv_usec);
+ break;
}
}
@@ -186,22 +185,23 @@ ts_print(register const struct timeval *tvp)
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;
-
- if (secs == 0) {
- (void)printf("0s");
- return;
- }
- while (secs) {
- if (secs >= *s) {
- (void)printf("%d%s", secs / *s, *l);
- secs -= (secs / *s) * *s;
+ static char *lengths[] = {"y", "w", "d", "h", "m", "s"};
+ static int seconds[] = {31536000, 604800, 86400, 3600, 60, 1};
+ char **l = lengths;
+ int *s = seconds;
+
+ if (secs <= 0) {
+ (void)printf("0s");
+ return;
+ }
+ while (secs > 0) {
+ if (secs >= *s) {
+ (void)printf("%d%s", secs / *s, *l);
+ secs -= (secs / *s) * *s;
+ }
+ s++;
+ l++;
}
- s++; l++;
- }
}
/*
@@ -339,3 +339,24 @@ read_infile(char *fname)
return (cp);
}
+
+void
+safeputs(const char *s)
+{
+ while (*s) {
+ safeputchar(*s);
+ s++;
+ }
+}
+
+void
+safeputchar(int c)
+{
+ unsigned char ch;
+
+ ch = (unsigned char)(c & 0xff);
+ if (c < 0x80 && isprint(c))
+ printf("\\%03o", c & 0xff);
+ else
+ printf("%c", c & 0xff);
+}