* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-#ifndef lint
-static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/libpcap/bpf_image.c,v 1.22 1999-10-07 23:46:40 mcr Exp $ (LBL)";
+#ifdef HAVE_CONFIG_H
+#include "config.h"
#endif
+#ifdef _WIN32
+#include <pcap-stdinc.h>
+#else /* _WIN32 */
+#if HAVE_INTTYPES_H
+#include <inttypes.h>
+#elif HAVE_STDINT_H
+#include <stdint.h>
+#endif
+#ifdef HAVE_SYS_BITYPES_H
+#include <sys/bitypes.h>
+#endif
#include <sys/types.h>
-#include <sys/time.h>
+#endif /* _WIN32 */
#include <stdio.h>
#include <string.h>
#include "pcap-int.h"
-#include "gnuc.h"
#ifdef HAVE_OS_PROTO_H
#include "os-proto.h"
#endif
char *
bpf_image(p, n)
- struct bpf_insn *p;
+ const struct bpf_insn *p;
int n;
{
int v;
- char *fmt, *op;
+ const char *fmt, *op;
static char image[256];
char operand[64];
fmt = "x";
break;
+ case BPF_ALU|BPF_MOD|BPF_X:
+ op = "mod";
+ fmt = "x";
+ break;
+
case BPF_ALU|BPF_AND|BPF_X:
op = "and";
fmt = "x";
fmt = "x";
break;
+ case BPF_ALU|BPF_XOR|BPF_X:
+ op = "xor";
+ fmt = "x";
+ break;
+
case BPF_ALU|BPF_LSH|BPF_X:
op = "lsh";
fmt = "x";
fmt = "#%d";
break;
+ case BPF_ALU|BPF_MOD|BPF_K:
+ op = "mod";
+ fmt = "#%d";
+ break;
+
case BPF_ALU|BPF_AND|BPF_K:
op = "and";
fmt = "#0x%x";
fmt = "#0x%x";
break;
+ case BPF_ALU|BPF_XOR|BPF_K:
+ op = "xor";
+ fmt = "#0x%x";
+ break;
+
case BPF_ALU|BPF_LSH|BPF_K:
op = "lsh";
fmt = "#%d";
fmt = "";
break;
}
- (void)sprintf(operand, fmt, v);
- (void)sprintf(image,
- (BPF_CLASS(p->code) == BPF_JMP &&
- BPF_OP(p->code) != BPF_JA) ?
- "(%03d) %-8s %-16s jt %d\tjf %d"
- : "(%03d) %-8s %s",
- n, op, operand, n + 1 + p->jt, n + 1 + p->jf);
+ (void)pcap_snprintf(operand, sizeof operand, fmt, v);
+ if (BPF_CLASS(p->code) == BPF_JMP && BPF_OP(p->code) != BPF_JA) {
+ (void)pcap_snprintf(image, sizeof image,
+ "(%03d) %-8s %-16s jt %d\tjf %d",
+ n, op, operand, n + 1 + p->jt, n + 1 + p->jf);
+ } else {
+ (void)pcap_snprintf(image, sizeof image,
+ "(%03d) %-8s %s",
+ n, op, operand);
+ }
return image;
}