/*
- * Copyright (c) 2000-2013 Apple Inc. All rights reserved.
+ * Copyright (c) 2000-2017 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
#define BIOCSETFNR64 _IOW('B',126, struct bpf_program64)
#define BIOCSETFNR32 _IOW('B',126, struct bpf_program32)
#endif /* KERNEL_PRIVATE */
-
+#ifdef PRIVATE
+#define BIOCGWANTPKTAP _IOR('B', 127, u_int)
+#define BIOCSWANTPKTAP _IOWR('B', 127, u_int)
+#define BIOCSHEADDROP _IOW('B', 128, int)
+#define BIOCGHEADDROP _IOR('B', 128, int)
+#endif /* PRIVATE */
/*
* Structure prepended to each packet.
*/
#define BPF_HDR_EXT_FLAGS_DIR_OUT 0x0001
pid_t bh_pid; /* process PID */
char bh_comm[MAXCOMLEN+1]; /* process command */
- u_char _bh_pad2[2];
+ u_char _bh_pad2[1];
+ u_char bh_pktflags;
+#define BPF_PKTFLAGS_TCP_REXMT 0x0001
+#define BPF_PKTFLAGS_START_SEQ 0x0002
+#define BPF_PKTFLAGS_LAST_PKT 0x0004
u_char bh_proto; /* kernel reserved; 0 in userland */
bpf_u_int32 bh_svc; /* service class */
bpf_u_int32 bh_flowid; /* kernel reserved; 0 in userland */
+ bpf_u_int32 bh_unsent_bytes; /* unsent bytes at interface */
+ bpf_u_int32 bh_unsent_snd; /* unsent bytes at socket buffer */
};
#define BPF_CONTROL_NAME "com.apple.net.bpf"
/*
* For Apple private usage
*/
+#define DLT_USER0_APPLE_INTERNAL DLT_USER0 /* rdar://12019509 */
+#define DLT_USER1_APPLE_INTERNAL DLT_USER1 /* rdar://12019509 */
#define DLT_PKTAP DLT_USER2 /* rdar://11779467 */
+#define DLT_USER3_APPLE_INTERNAL DLT_USER3 /* rdar://19614531 */
+#define DLT_USER4_APPLE_INTERNAL DLT_USER4 /* rdar://19614531 */
#endif /* PRIVATE */
/*
*/
#define DLT_NFC_LLCP 245
+/*
+ * USB packets, beginning with a Darwin (macOS, etc.) USB header.
+ */
+#define DLT_USB_DARWIN 266
-#define DLT_MATCHING_MAX 245 /* highest value in the "matching" range */
+#define DLT_MATCHING_MAX 266 /* highest value in the "matching" range */
/*
* The instruction encodings.
struct ifnet;
struct mbuf;
+#define BPF_PACKET_TYPE_MBUF 0
+
+struct bpf_packet {
+ int bpfp_type;
+ void * bpfp_header; /* optional */
+ size_t bpfp_header_length;
+ union {
+ struct mbuf *bpfpu_mbuf;
+ void * bpfpu_ptr;
+ } bpfp_u;
+#define bpfp_mbuf bpfp_u.bpfpu_mbuf
+#define bpfp_ptr bpfp_u.bpfpu_ptr
+ size_t bpfp_total_length; /* length including optional header */
+};
+
extern int bpf_validate(const struct bpf_insn *, int);
extern void bpfdetach(struct ifnet *);
extern void bpfilterattach(int);
link type are specified. The callback is responsible for
releasing the mbuf whether or not it returns an error.
@param interface The interface the packet is being sent on.
- @param dlt The data link type the bpf device is attached to.
+ @param data_link_type The data link type the bpf device is attached to.
@param packet The packet to be sent.
*/
typedef errno_t (*bpf_send_func)(ifnet_t interface, u_int32_t data_link_type,
- mbuf_t packet);
+ mbuf_t packet);
/*!
@typedef bpf_tap_func
decreasing (tap in or out is stopping), the error will be
ignored.
@param interface The interface being tapped.
- @param dlt The data link type being tapped.
+ @param data_link_type The data link type being tapped.
@param direction The direction of the tap.
*/
typedef errno_t (*bpf_tap_func)(ifnet_t interface, u_int32_t data_link_type,
- bpf_tap_mode direction);
+ bpf_tap_mode direction);
/*!
@function bpfattach
@param dlt The data link type of the packet.
@param packet The packet received.
@param header An optional pointer to a header that will be prepended.
- @param headerlen If the header was specified, the length of the header.
+ @param header_len If the header was specified, the length of the header.
*/
extern void bpf_tap_in(ifnet_t interface, u_int32_t dlt, mbuf_t packet,
void *header, size_t header_len);
/*!
@function bpf_tap_out
- @discussion Call this function when your interface trasmits a
+ @discussion Call this function when your interface transmits a
packet. This function will check if any bpf devices need a
a copy of the packet.
@param interface The interface the packet was or will be transmitted on.
@param dlt The data link type of the packet.
@param packet The packet received.
@param header An optional pointer to a header that will be prepended.
- @param headerlen If the header was specified, the length of the header.
+ @param header_len If the header was specified, the length of the header.
*/
extern void bpf_tap_out(ifnet_t interface, u_int32_t dlt, mbuf_t packet,
void *header, size_t header_len);