X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/115ce6fc62e5935398afb764182bcaff0aa59d04..f78c60f54a9beb04f1409712ec95b46f2d52a0ab:/print-syslog.c diff --git a/print-syslog.c b/print-syslog.c old mode 100755 new mode 100644 index 3685d620..d332f67f --- a/print-syslog.c +++ b/print-syslog.c @@ -14,11 +14,6 @@ * FOR A PARTICULAR PURPOSE. */ -#ifndef lint -static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-syslog.c,v 1.1 2004-10-29 11:42:53 hannes Exp $"; -#endif - #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -30,9 +25,10 @@ static const char rcsid[] _U_ = #include "interface.h" #include "extract.h" -#include "addrtoname.h" -/* +static const char tstr[] = "[|syslog]"; + +/* * tokenlists and #defines taken from Ethereal - Network traffic analyzer * by Gerald Combs */ @@ -94,40 +90,30 @@ syslog_print(register const u_char *pptr, register u_int len) * severity and facility values */ - if (!TTEST2(*pptr, 1)) - goto trunc; - + TCHECK2(*pptr, 1); if (*(pptr+msg_off) == '<') { msg_off++; - - if (!TTEST2(*(pptr+msg_off), 1)) - goto trunc; - + TCHECK2(*(pptr+msg_off), 1); while ( *(pptr+msg_off) >= '0' && *(pptr+msg_off) <= '9' && msg_off <= SYSLOG_MAX_DIGITS) { - - if (!TTEST2(*(pptr+msg_off), 1)) - goto trunc; - pri = pri * 10 + (*(pptr+msg_off) - '0'); msg_off++; - - if (!TTEST2(*(pptr+msg_off), 1)) - goto trunc; - - if (*(pptr+msg_off) == '>') - msg_off++; + TCHECK2(*(pptr+msg_off), 1); } + if (*(pptr+msg_off) != '>') { + printf("%s", tstr); + return; + } + msg_off++; } else { - printf("[|syslog]"); + printf("%s", tstr); return; } facility = (pri & SYSLOG_FACILITY_MASK) >> 3; severity = pri & SYSLOG_SEVERITY_MASK; - if (vflag < 1 ) { printf("SYSLOG %s.%s, length: %u", @@ -136,7 +122,7 @@ syslog_print(register const u_char *pptr, register u_int len) len); return; } - + printf("SYSLOG, length: %u\n\tFacility %s (%u), Severity %s (%u)\n\tMsg: ", len, tok2str(syslog_facility_values, "unknown (%u)", facility), @@ -146,18 +132,15 @@ syslog_print(register const u_char *pptr, register u_int len) /* print the syslog text in verbose mode */ for (; msg_off < len; msg_off++) { - if (!TTEST2(*(pptr+msg_off), 1)) - goto trunc; - safeputchar(*(pptr+msg_off)); + TCHECK2(*(pptr+msg_off), 1); + safeputchar(gndo, *(pptr + msg_off)); } - if (vflag > 1) { - if(!print_unknown_data(pptr,"\n\t",len)) - return; - } - + if (vflag > 1) + print_unknown_data(gndo,pptr,"\n\t",len); + return; trunc: - printf("[|syslog]"); + printf("%s", tstr); }