static void	catchpacket __P((struct bpf_d *, u_char *, size_t, size_t, void (*)(const void *, void *, size_t))); static void	reset_d __P((struct bpf_d *));
void	bpf_catchpacket __P((struct bpf_d *, u_char *, size_t, size_t, void (*)(const void *, void *, size_t))); void	bpf_reset_d __P((struct bpf_d *));
static void	catchpacket __P((struct bpf_d *, u_char *, size_t, size_t,				 void (*)(const void *, void *, size_t)));static void	reset_d __P((struct bpf_d *));static intbpf_movein(uio, linktype, mp, sockp)	register struct uio *uio;	int linktype;	register struct mbuf **mp;	register struct sockaddr *sockp;{	struct mbuf *m;	int error;	int len;	int hlen;	/*	 * Build a sockaddr based on the data link layer type.	 * We do this at this level because the ethernet header	 * is copied directly into the data field of the sockaddr.	 * In the case of SLIP, there is no header and the packet	 * is forwarded as is.	 * Also, we are careful to leave room at the front of the mbuf	 * for the link level header.	 */	switch (linktype) {	case DLT_SLIP:		sockp->sa_family = AF_INET;		hlen = 0;		break;	case DLT_PPP:		sockp->sa_family = AF_UNSPEC;		hlen = 0;		break;	case DLT_EN10MB:		sockp->sa_family = AF_UNSPEC;		/* XXX Would MAXLINKHDR be better? */		hlen = sizeof(struct ether_header);		break;	case DLT_ARCNET:		sockp->sa_family = AF_UNSPEC;		hlen = ARC_HDRLEN;		break;	case DLT_FDDI:		sockp->sa_family = AF_UNSPEC;		/* XXX 4(FORMAC)+6(dst)+6(src)+3(LLC)+5(SNAP) */		hlen = 24;		break;	case DLT_NULL:		sockp->sa_family = AF_UNSPEC;		hlen = 0;		break;	default:		return (EIO);	}	len = uio->uio_resid;	if ((unsigned)len > MCLBYTES)		return (EIO);	MGETHDR(m, M_WAIT, MT_DATA);	if (m == 0)		return (ENOBUFS);	m->m_pkthdr.rcvif = 0;	m->m_pkthdr.len = len - hlen;	if (len > MHLEN) {#if BSD >= 199103		MCLGET(m, M_WAIT);		if ((m->m_flags & M_EXT) == 0) {#else		MCLGET(m);		if (m->m_len != MCLBYTES) {#endif			error = ENOBUFS;			goto bad;		}	}	m->m_len = len;	*mp = m;	/*	 * Make room for link header.	 */	if (hlen != 0) {		m->m_len -= hlen;#if BSD >= 199103		m->m_data += hlen; /* XXX */#else		m->m_off += hlen;#endif		error = UIOMOVE((caddr_t)sockp->sa_data, hlen, UIO_WRITE, uio);		if (error)			goto bad;	}	error = UIOMOVE(mtod(m, caddr_t), len - hlen, UIO_WRITE, uio);	if (!error)		return (0); bad:	m_freem(m);	return (error);}