---
title: bpfattach
framework: Kernel
role: symbol
role_heading: Function
platforms: [macOS 10.4+]
path: kernel/1589467-bpfattach
---

# bpfattach

## Declaration

```occ
void bpfattach(ifnet_t interface, u_int data_link_type, u_int header_length);
```

## Parameters

- `interface`: The interface to register with BPF.
- `data_link_type`: The data link type of the interface. See the DLT_* defines in bpf.h.
- `header_length`: The length, in bytes, of the data link header.

## Discussion

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.

## See Also

### bpf

- [bpf_attach](kernel/1589700-bpf_attach.md)
- [bpf_tap_in](kernel/1589470-bpf_tap_in.md)
- [bpf_tap_out](kernel/1589576-bpf_tap_out.md)
