|
ADC Home > Reference Library > Reference > Darwin > Kernel Framework Reference
|
bpf.h |
| Includes: |
bpf_attach |
errno_t bpf_attach( ifnet_t interface, u_int32_t data_link_type, u_int32_t header_length, bpf_send_func send, bpf_tap_func tap);
interfaceThe interface to register with BPF.
data_link_typeThe data link type of the interface. See the DLT_* defines in bpf.h.
header_lengthThe length, in bytes, of the data link header.
Registers an interface with BPF. This allows bpf devices to attach to your interface to capture and transmit packets. Your interface will be unregistered automatically when your interface is detached. You may register multiple times with different data link types. An 802.11 interface would use this to allow clients to pick whether they want just an ethernet style frame or the 802.11 wireless headers as well. The first dlt you register will be considered the default. Any bpf device attaches that do not specify a data link type will use the default.
bpf_tap_in |
void bpf_tap_in( ifnet_t interface, u_int32_t dlt, mbuf_t packet, void *header, size_t header_len);
interfaceThe interface the packet was received on.
dltThe data link type of the packet.
packetThe packet received.
headerAn optional pointer to a header that will be prepended.
headerlenIf the header was specified, the length of the header.
Call this function when your interface receives a packet. This function will check if any bpf devices need a a copy of the packet.
bpf_tap_out |
void bpf_tap_out( ifnet_t interface, u_int32_t dlt, mbuf_t packet, void *header, size_t header_len);
interfaceThe interface the packet was or will be transmitted on.
dltThe data link type of the packet.
packetThe packet received.
headerAn optional pointer to a header that will be prepended.
headerlenIf the header was specified, the length of the header.
Call this function when your interface trasmits a packet. This function will check if any bpf devices need a a copy of the packet.
bpfattach |
void bpfattach( ifnet_t interface, u_int data_link_type, u_int header_length);
interfaceThe interface to register with BPF.
data_link_typeThe data link type of the interface. See the DLT_* defines in bpf.h.
header_lengthThe length, in bytes, of the data link header.
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.
bpf_send_func |
typedef errno_t ( *bpf_send_func)( ifnet_t interface, u_int32_t data_link_type, mbuf_t packet);
interfaceThe interface the packet is being sent on.
dltThe data link type the bpf device is attached to.
packetThe packet to be sent.
bpf_send_func is called when a bpf file descriptor is used to send a raw packet on the interface. The mbuf and data link type are specified. The callback is responsible for releasing the mbuf whether or not it returns an error.
bpf_tap_func |
typedef errno_t ( *bpf_tap_func)( ifnet_t interface, u_int32_t data_link_type, bpf_tap_mode direction);
interfaceThe interface being tapped.
dltThe data link type being tapped.
directionThe direction of the tap.
bpf_tap_func is called when the tap state of the interface changes. This happens when a bpf device attaches to an interface or detaches from an interface. The tap mode will join together (bit or) the modes of all bpf devices using that interface for that dlt. If you return an error from this function, the bpf device attach attempt that triggered the tap will fail. If this function was called bacuse the tap state was decreasing (tap in or out is stopping), the error will be ignored.
bpf_tap_mode |
Mode for tapping. BPF_MODE_DISABLED/BPF_MODE_INPUT_OUTPUT etc.
typedef u_int32_t bpf_tap_mode;
BPF |
Constants defining interface families.
enum { BPF_MODE_DISABLED = 0, BPF_MODE_INPUT = 1, BPF_MODE_OUTPUT = 2, BPF_MODE_INPUT_OUTPUT = 3 };
BPF_MODE_DISABLEDDisable bpf.
BPF_MODE_INPUTEnable input only.
BPF_MODE_OUTPUTEnable output only.
BPF_MODE_INPUT_OUTPUTEnable input and output.
|
Last Updated: 2008-12-19