inject outgoing packet to bpf. KAME PR 358.

This commit is contained in:
itojun 2001-06-08 00:17:05 +00:00
parent 75a27eccff
commit 7f6ce64273
1 changed files with 26 additions and 2 deletions

View File

@ -1,5 +1,5 @@
/* $NetBSD: if_stf.c,v 1.15 2001/05/10 01:37:42 itojun Exp $ */
/* $KAME: if_stf.c,v 1.60 2001/05/03 14:51:47 itojun Exp $ */
/* $NetBSD: if_stf.c,v 1.16 2001/06/08 00:17:05 itojun Exp $ */
/* $KAME: if_stf.c,v 1.62 2001/06/07 22:32:16 itojun Exp $ */
/*
* Copyright (C) 2000 WIDE Project.
@ -442,6 +442,30 @@ stf_output(ifp, m, dst, rt)
return ENETUNREACH;
}
#if NBPFILTER > 0
if (ifp->if_bpf) {
/*
* We need to prepend the address family as
* a four byte field. Cons up a dummy header
* to pacify bpf. This is safe because bpf
* will only read from the mbuf (i.e., it won't
* try to free it or keep a pointer a to it).
*/
struct mbuf m0;
u_int32_t af = AF_INET6;
m0.m_next = m;
m0.m_len = 4;
m0.m_data = (char *)⁡
#ifdef HAVE_OLD_BPF
bpf_mtap(ifp, &m0);
#else
bpf_mtap(ifp->if_bpf, &m0);
#endif
}
#endif /*NBPFILTER > 0*/
M_PREPEND(m, sizeof(struct ip), M_DONTWAIT);
if (m && m->m_len < sizeof(struct ip))
m = m_pullup(m, sizeof(struct ip));