X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/de355530ae67247cbd0da700edb3a2a1dae884c2..ff6e181ae92fc6f1e89841290f461d1f2f9badd9:/bsd/net/bpf.h diff --git a/bsd/net/bpf.h b/bsd/net/bpf.h index 6f3afea4d..a9dcb8c0e 100644 --- a/bsd/net/bpf.h +++ b/bsd/net/bpf.h @@ -1,21 +1,22 @@ /* - * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * - * The contents of this file constitute Original Code as defined in and - * are subject to the Apple Public Source License Version 1.1 (the - * "License"). You may not use this file except in compliance with the - * License. Please obtain a copy of the License at - * http://www.apple.com/publicsource and read it before using this file. + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. * - * This Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ @@ -67,6 +68,11 @@ #include #include #include +#include + +#ifdef KERNEL +#include +#endif /* BSD style release date */ #define BPF_RELEASE 199606 @@ -82,7 +88,7 @@ typedef u_int32_t bpf_u_int32; #define BPF_WORDALIGN(x) (((x)+(BPF_ALIGNMENT-1))&~(BPF_ALIGNMENT-1)) #define BPF_MAXINSNS 512 -#define BPF_MAXBUFSIZE 0x8000 +#define BPF_MAXBUFSIZE 0x80000 #define BPF_MINBUFSIZE 32 /* @@ -93,6 +99,26 @@ struct bpf_program { struct bpf_insn *bf_insns; }; +#ifdef KERNEL +/* LP64 version of bpf_program. all pointers + * grow when we're dealing with a 64-bit process. + * WARNING - keep in sync with bpf_program + */ +#if __DARWIN_ALIGN_NATURAL +#pragma options align=natural +#endif + +struct user_bpf_program { + u_int bf_len; + user_addr_t bf_insns; +}; + +#if __DARWIN_ALIGN_NATURAL +#pragma options align=reset +#endif + +#endif // KERNEL + /* * Struct returned by BIOCGSTATS. */ @@ -176,6 +202,7 @@ struct bpf_hdr { #define DLT_FDDI 10 /* FDDI */ #define DLT_ATM_RFC1483 11 /* LLC/SNAP encapsulated atm */ #define DLT_RAW 12 /* raw IP */ +#define DLT_APPLE_IP_OVER_IEEE1394 138 /* * These are values from BSD/OS's "bpf.h". @@ -331,26 +358,40 @@ struct bpf_insn { #define BPF_STMT(code, k) { (u_short)(code), 0, 0, k } #define BPF_JUMP(code, k, jt, jf) { (u_short)(code), jt, jf, k } +#ifdef KERNEL_PRIVATE /* Forward declerations */ struct ifnet; struct mbuf; -#ifdef KERNEL -#ifdef __APPLE_API_UNSTABLE -int bpf_validate __P((const struct bpf_insn *, int)); -void bpf_tap __P((struct ifnet *, u_char *, u_int)); -void bpf_mtap __P((struct ifnet *, struct mbuf *)); -void bpfattach __P((struct ifnet *, u_int, u_int)); -void bpfdetach __P((struct ifnet *)); +int bpf_validate(const struct bpf_insn *, int); +void bpf_tap(struct ifnet *, u_char *, u_int); +void bpf_mtap(struct ifnet *, struct mbuf *); + +void bpfdetach(struct ifnet *); -void bpfilterattach __P((int)); -u_int bpf_filter __P((const struct bpf_insn *, u_char *, u_int, u_int)); +void bpfilterattach(int); +u_int bpf_filter(const struct bpf_insn *, u_char *, u_int, u_int); #ifdef __APPLE__ #define BPF_TAP(x, y, z) bpf_tap(x,y,z) #define BPF_MTAP(x, y) bpf_mtap(x, y) #endif /* __APPLE__ */ -#endif /* __APPLE_API_UNSTABLE */ + +#endif /* KERNEL_PRIVATE */ + +#ifdef KERNEL +/*! + @function bpfattach + @discussion Registers an interface with BPF. This allows bpf devices + to attach to your interface to capture packets. Your interface + will be unregistered automatically when your interface is + detached. + @param interface The interface to register with BPF. + @param data_link_type The data link type of the interface. See the + DLT_* defines in bpf.h. + @param header_length The length, in bytes, of the data link header. + */ +void bpfattach(ifnet_t interface, u_int data_link_type, u_int header_length); #endif /* KERNEL */ /*