/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved.
*
- * @APPLE_LICENSE_HEADER_START@
+ * @APPLE_OSREFERENCE_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. The rights granted to you under the License
+ * may not be used to create, or enable the creation or redistribution of,
+ * unlawful or unlicensed copies of an Apple operating system, or to
+ * circumvent, violate, or enable the circumvention or violation of, any
+ * terms of an Apple operating system software license agreement.
*
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this file.
+ *
+ * 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@
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* Copyright (c) 1990, 1991, 1993
#include <sys/appleapiopts.h>
#include <sys/types.h>
#include <sys/time.h>
+#include <sys/cdefs.h>
+
+#ifdef KERNEL
+#include <sys/kernel_types.h>
+#endif
/* BSD style release date */
#define BPF_RELEASE 199606
#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
/*
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
+ */
+struct user_bpf_program {
+ u_int bf_len;
+ user_addr_t bf_insns __attribute__((aligned(8)));
+};
+
+#endif // KERNEL
+
/*
* Struct returned by BIOCGSTATS.
*/
#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 bpfilterattach __P((int));
-u_int bpf_filter __P((const struct bpf_insn *, u_char *, u_int, u_int));
+void bpfdetach(struct ifnet *);
+
+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 */
/*