]>
git.saurik.com Git - apple/network_cmds.git/blob - pcap/bpf_image.c
f5177d9d7d920e3f046b59c76f3562e1d31b754c
2 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
7 * Reserved. This file contains Original Code and/or Modifications of
8 * Original Code as defined in and that are subject to the Apple Public
9 * Source License Version 1.0 (the 'License'). You may not use this file
10 * except in compliance with the License. Please obtain a copy of the
11 * License at http://www.apple.com/publicsource and read it before using
14 * The Original Code and all software distributed under the License are
15 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
19 * License for the specific language governing rights and limitations
22 * @APPLE_LICENSE_HEADER_END@
27 * Copyright (c) 1990, 1991, 1992, 1994, 1995
28 * The Regents of the University of California. All rights reserved.
30 * Redistribution and use in source and binary forms, with or without
31 * modification, are permitted provided that: (1) source code distributions
32 * retain the above copyright notice and this paragraph in its entirety, (2)
33 * distributions including binary code include the above copyright notice and
34 * this paragraph in its entirety in the documentation or other materials
35 * provided with the distribution, and (3) all advertising materials mentioning
36 * features or use of this software display the following acknowledgement:
37 * ``This product includes software developed by the University of California,
38 * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
39 * the University nor the names of its contributors may be used to endorse
40 * or promote products derived from this software without specific prior
42 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
43 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
44 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
49 "@(#) Header: bpf_image.c,v 1.19 95/11/26 14:02:36 leres Exp (LBL)";
52 #include <sys/types.h>
61 #ifdef HAVE_OS_PROTO_H
74 static char image
[256];
96 case BPF_LD
|BPF_W
|BPF_ABS
:
101 case BPF_LD
|BPF_H
|BPF_ABS
:
106 case BPF_LD
|BPF_B
|BPF_ABS
:
111 case BPF_LD
|BPF_W
|BPF_LEN
:
116 case BPF_LD
|BPF_W
|BPF_IND
:
121 case BPF_LD
|BPF_H
|BPF_IND
:
126 case BPF_LD
|BPF_B
|BPF_IND
:
136 case BPF_LDX
|BPF_IMM
:
141 case BPF_LDX
|BPF_MSH
|BPF_B
:
143 fmt
= "4*([%d]&0xf)";
151 case BPF_LDX
|BPF_MEM
:
172 case BPF_JMP
|BPF_JGT
|BPF_K
:
177 case BPF_JMP
|BPF_JGE
|BPF_K
:
182 case BPF_JMP
|BPF_JEQ
|BPF_K
:
187 case BPF_JMP
|BPF_JSET
|BPF_K
:
192 case BPF_JMP
|BPF_JGT
|BPF_X
:
197 case BPF_JMP
|BPF_JGE
|BPF_X
:
202 case BPF_JMP
|BPF_JEQ
|BPF_X
:
207 case BPF_JMP
|BPF_JSET
|BPF_X
:
212 case BPF_ALU
|BPF_ADD
|BPF_X
:
217 case BPF_ALU
|BPF_SUB
|BPF_X
:
222 case BPF_ALU
|BPF_MUL
|BPF_X
:
227 case BPF_ALU
|BPF_DIV
|BPF_X
:
232 case BPF_ALU
|BPF_AND
|BPF_X
:
237 case BPF_ALU
|BPF_OR
|BPF_X
:
242 case BPF_ALU
|BPF_LSH
|BPF_X
:
247 case BPF_ALU
|BPF_RSH
|BPF_X
:
252 case BPF_ALU
|BPF_ADD
|BPF_K
:
257 case BPF_ALU
|BPF_SUB
|BPF_K
:
262 case BPF_ALU
|BPF_MUL
|BPF_K
:
267 case BPF_ALU
|BPF_DIV
|BPF_K
:
272 case BPF_ALU
|BPF_AND
|BPF_K
:
277 case BPF_ALU
|BPF_OR
|BPF_K
:
282 case BPF_ALU
|BPF_LSH
|BPF_K
:
287 case BPF_ALU
|BPF_RSH
|BPF_K
:
292 case BPF_ALU
|BPF_NEG
:
297 case BPF_MISC
|BPF_TAX
:
302 case BPF_MISC
|BPF_TXA
:
307 (void)sprintf(operand
, fmt
, v
);
309 (BPF_CLASS(p
->code
) == BPF_JMP
&&
310 BPF_OP(p
->code
) != BPF_JA
) ?
311 "(%03d) %-8s %-16s jt %d\tjf %d"
313 n
, op
, operand
, n
+ 1 + p
->jt
, n
+ 1 + p
->jf
);