00001 /* 00002 * Copyright (c) 1992, 1993, 1994, 1995, 1996 00003 * The Regents of the University of California. All rights reserved. 00004 * 00005 * Redistribution and use in source and binary forms, with or without 00006 * modification, are permitted provided that: (1) source code distributions 00007 * retain the above copyright notice and this paragraph in its entirety, (2) 00008 * distributions including binary code include the above copyright notice and 00009 * this paragraph in its entirety in the documentation or other materials 00010 * provided with the distribution, and (3) all advertising materials mentioning 00011 * features or use of this software display the following acknowledgement: 00012 * ``This product includes software developed by the University of California, 00013 * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 00014 * the University nor the names of its contributors may be used to endorse 00015 * or promote products derived from this software without specific prior 00016 * written permission. 00017 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 00018 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 00019 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 00020 */ 00021 #ifndef lint 00022 static const char rcsid[] =
00023 "@(#) $Header: /tcpdump/master/libpcap/bpf_dump.c,v 1.13 2002/03/24 23:21:51 guy Exp $ (LBL)";
00024 #endif 00025 00026 #ifdef HAVE_CONFIG_H 00027 #include "config.h" 00028 #endif 00029 00030 #include <pcap.h> 00031 #include <stdio.h> 00032 00033 void 00034 bpf_dump(struct bpf_program *p, int option)
00035 {
00036 struct bpf_insn *insn;
00037 int i;
00038 int n = p->bf_len;
00039
00040 insn = p->bf_insns;
00041 if (option > 2) {
00042 printf("%d\n", n);
00043 for (i = 0; i < n; ++insn, ++i) {
00044 printf("%u %u %u %u\n", insn->code,
00045 insn->jt, insn->jf, insn->k);
00046 }
00047 return ;
00048 }
00049 if (option > 1) {
00050 for (i = 0; i < n; ++insn, ++i)
00051 printf("{ 0x%x, %d, %d, 0x%08x },\n",
00052 insn->code, insn->jt, insn->jf, insn->k);
00053 return;
00054 }
00055 for (i = 0; i < n; ++insn, ++i) {
00056 #ifdef BDEBUG 00057 extern int bids[];
00058 printf(bids[i] > 0 ? "[%02d]" : " -- ", bids[i] - 1);
00059 #endif 00060 puts(bpf_image(insn, i));
00061 }
00062 }
documentation.
Copyright (c)
2002-2003 Politecnico di Torino.
2005 translated by Telebusiness,Inc.
All rights reserved.