/*1* Copyright (c) 1992, 1993, 1994, 1995, 19962* The Regents of the University of California. All rights reserved.3*4* Redistribution and use in source and binary forms, with or without5* modification, are permitted provided that: (1) source code distributions6* retain the above copyright notice and this paragraph in its entirety, (2)7* distributions including binary code include the above copyright notice and8* this paragraph in its entirety in the documentation or other materials9* provided with the distribution, and (3) all advertising materials mentioning10* features or use of this software display the following acknowledgement:11* ``This product includes software developed by the University of California,12* Lawrence Berkeley Laboratory and its contributors.'' Neither the name of13* the University nor the names of its contributors may be used to endorse14* or promote products derived from this software without specific prior15* written permission.16* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED17* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF18* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.19*/2021#include <config.h>2223#include <pcap.h>24#include <stdio.h>2526#include "optimize.h"2728void29bpf_dump(const struct bpf_program *p, int option)30{31const struct bpf_insn *insn;32int i;33int n = p->bf_len;3435insn = p->bf_insns;36if (option > 2) {37printf("%d\n", n);38for (i = 0; i < n; ++insn, ++i) {39printf("%u %u %u %u\n", insn->code,40insn->jt, insn->jf, insn->k);41}42return ;43}44if (option > 1) {45for (i = 0; i < n; ++insn, ++i)46printf("{ 0x%x, %d, %d, 0x%08x },\n",47insn->code, insn->jt, insn->jf, insn->k);48return;49}50for (i = 0; i < n; ++insn, ++i) {51#ifdef BDEBUG52if (i < NBIDS && bids[i] > 0)53printf("[%02d]", bids[i] - 1);54else55printf(" -- ");56#endif57puts(bpf_image(insn, i));58}59}606162