Deleted Added
sdiff udiff text old ( 135196 ) new ( 141584 )
full compact
1/* $FreeBSD: head/sys/contrib/pf/net/if_pflog.c 141584 2005-02-09 19:29:13Z mlaier $ */
2/* $OpenBSD: if_pflog.c,v 1.11 2003/12/31 11:18:25 cedric Exp $ */
3/*
4 * The authors of this code are John Ioannidis (ji@tla.org),
5 * Angelos D. Keromytis (kermit@csd.uch.gr) and
6 * Niels Provos (provos@physnet.uni-hamburg.de).
7 *
8 * This code was written by John Ioannidis for BSD/OS in Athens, Greece,
9 * in November 1995.

--- 111 unchanged lines hidden (view full) ---

121
122#ifndef __FreeBSD__
123extern int ifqmaxlen;
124#endif
125
126#ifdef __FreeBSD__
127static MALLOC_DEFINE(M_PFLOG, PFLOGNAME, "Packet Filter Logging Interface");
128static LIST_HEAD(pflog_list, pflog_softc) pflog_list;
129#define SCP2IFP(sc) (&(sc)->sc_if)
130IFC_SIMPLE_DECLARE(pflog, 1);
131
132static void
133pflog_clone_destroy(struct ifnet *ifp)
134{
135 struct pflog_softc *sc;
136
137 sc = ifp->if_softc;

--- 8 unchanged lines hidden (view full) ---

146 LIST_REMOVE(sc, sc_next);
147 free(sc, M_PFLOG);
148}
149
150static int
151pflog_clone_create(struct if_clone *ifc, int unit)
152{
153 struct pflog_softc *sc;
154 struct ifnet *ifp;
155
156 MALLOC(sc, struct pflog_softc *, sizeof(*sc), M_PFLOG, M_WAITOK|M_ZERO);
157
158 ifp = SCP2IFP(sc);
159 if_initname(ifp, ifc->ifc_name, unit);
160 ifp->if_mtu = PFLOGMTU;
161 ifp->if_ioctl = pflogioctl;
162 ifp->if_output = pflogoutput;
163 ifp->if_start = pflogstart;
164 ifp->if_type = IFT_PFLOG;
165 ifp->if_snd.ifq_maxlen = ifqmaxlen;
166 ifp->if_hdrlen = PFLOG_HDRLEN;
167 ifp->if_softc = sc;
168 if_attach(ifp);
169
170 LIST_INSERT_HEAD(&pflog_list, sc, sc_next);
171#if NBPFILTER > 0
172 bpfattach(ifp, DLT_PFLOG, PFLOG_HDRLEN);
173#endif
174
175 return (0);
176}
177#else /* !__FreeBSD__ */
178void
179pflogattach(int npflog)
180{
181 struct ifnet *ifp;
182 int i;
183

--- 143 unchanged lines hidden (view full) ---

327#ifndef __FreeBSD__
328 m1.m_next = m;
329 m1.m_len = PFLOG_HDRLEN;
330 m1.m_data = (char *) &hdr;
331#endif
332
333#ifdef __FreeBSD__
334 KASSERT((!LIST_EMPTY(&pflog_list)), ("pflog: no interface"));
335 ifn = SCP2IFP(LIST_FIRST(&pflog_list));
336 BPF_MTAP2(ifn, &hdr, sizeof(hdr), m);
337#else
338 ifn = &(pflogif[0].sc_if);
339
340 if (ifn->if_bpf)
341 bpf_mtap(ifn->if_bpf, &m1);
342#endif
343#endif

--- 11 unchanged lines hidden (view full) ---

355 case MOD_LOAD:
356 LIST_INIT(&pflog_list);
357 if_clone_attach(&pflog_cloner);
358 break;
359
360 case MOD_UNLOAD:
361 if_clone_detach(&pflog_cloner);
362 while (!LIST_EMPTY(&pflog_list))
363 pflog_clone_destroy(SCP2IFP(LIST_FIRST(&pflog_list)));
364 break;
365
366 default:
367 error = EINVAL;
368 break;
369 }
370
371 return error;

--- 13 unchanged lines hidden ---