/* $OpenBSD: misc.c,v 1.12 2000/03/13 23:40:20 kjell Exp $ */ /* * Copyright (C) 1993-1998 by Darren Reed. * * Redistribution and use in source and binary forms are permitted * provided that this notice is preserved and due credit is given * to the original author and the contributors. */ #if (SOLARIS2 >= 7) # define _SYS_VARARGS_H # define _VARARGS_H #endif #if defined(__STDC__) # include #else # include #endif #include #include #include #include #if !defined(__SVR4) && !defined(__svr4__) #include #else #include #endif #include #include #include #include #include #include #include #include #include #include #ifndef linux #include #endif #include #include #include #include #include #include #include #include #include #include #include #include "ipf.h" #include "ipt.h" #if !defined(lint) static const char sccsid[] = "@(#)misc.c 1.3 2/4/96 (C) 1995 Darren Reed"; static const char rcsid[] = "@(#)$IPFilter: misc.c,v 2.1 1999/08/04 17:30:11 darrenr Exp $"; #endif extern int opts; void printpacket(ip) ip_t *ip; { tcphdr_t *tcp; tcp = (struct tcphdr *)((char *)ip + (ip->ip_hl << 2)); printf("ip %d(%d) %d", ip->ip_len, ip->ip_hl << 2, ip->ip_p); if (ip->ip_off & IP_OFFMASK) printf(" @%d", ip->ip_off << 3); (void)printf(" %s", inet_ntoa(ip->ip_src)); if (!(ip->ip_off & IP_OFFMASK)) if (ip->ip_p == IPPROTO_TCP || ip->ip_p == IPPROTO_UDP) (void)printf(",%d", ntohs(tcp->th_sport)); (void)printf(" > "); (void)printf("%s", inet_ntoa(ip->ip_dst)); if (!(ip->ip_off & IP_OFFMASK)) if (ip->ip_p == IPPROTO_TCP || ip->ip_p == IPPROTO_UDP) (void)printf(",%d", ntohs(tcp->th_dport)); putchar('\n'); } #if defined(__STDC__) void verbose(char *fmt, ...) #else void verbose(fmt, va_alist) char *fmt; va_dcl #endif { va_list pvar; va_start(pvar, fmt); if (opts & OPT_VERBOSE) vprintf(fmt, pvar); va_end(pvar); } #ifdef __STDC__ void debug(char *fmt, ...) #else void debug(fmt, va_alist) char *fmt; va_dcl #endif { va_list pvar; va_start(pvar, fmt); if (opts & OPT_DEBUG) vprintf(fmt, pvar); va_end(pvar); }