if_pflog.c (135196) | if_pflog.c (141584) |
---|---|
1/* $FreeBSD: head/sys/contrib/pf/net/if_pflog.c 135196 2004-09-14 03:12:01Z mlaier $ */ | 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; | 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) |
|
129IFC_SIMPLE_DECLARE(pflog, 1); 130 131static void 132pflog_clone_destroy(struct ifnet *ifp) 133{ 134 struct pflog_softc *sc; 135 136 sc = ifp->if_softc; --- 8 unchanged lines hidden (view full) --- 145 LIST_REMOVE(sc, sc_next); 146 free(sc, M_PFLOG); 147} 148 149static int 150pflog_clone_create(struct if_clone *ifc, int unit) 151{ 152 struct pflog_softc *sc; | 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; |
|
153 154 MALLOC(sc, struct pflog_softc *, sizeof(*sc), M_PFLOG, M_WAITOK|M_ZERO); 155 | 155 156 MALLOC(sc, struct pflog_softc *, sizeof(*sc), M_PFLOG, M_WAITOK|M_ZERO); 157 |
156 if_initname(&sc->sc_if, ifc->ifc_name, unit); 157 sc->sc_if.if_mtu = PFLOGMTU; 158 sc->sc_if.if_ioctl = pflogioctl; 159 sc->sc_if.if_output = pflogoutput; 160 sc->sc_if.if_start = pflogstart; 161 sc->sc_if.if_type = IFT_PFLOG; 162 sc->sc_if.if_snd.ifq_maxlen = ifqmaxlen; 163 sc->sc_if.if_hdrlen = PFLOG_HDRLEN; 164 sc->sc_if.if_softc = sc; 165 if_attach(&sc->sc_if); | 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); |
166 | 169 |
167 LIST_INSERT_HEAD(&pflog_list, sc, sc_next); | 170 LIST_INSERT_HEAD(&pflog_list, sc, sc_next); |
168#if NBPFILTER > 0 | 171#if NBPFILTER > 0 |
169 bpfattach(&sc->sc_if, DLT_PFLOG, PFLOG_HDRLEN); | 172 bpfattach(ifp, DLT_PFLOG, PFLOG_HDRLEN); |
170#endif 171 | 173#endif 174 |
172 return (0); | 175 return (0); |
173} 174#else /* !__FreeBSD__ */ 175void 176pflogattach(int npflog) 177{ 178 struct ifnet *ifp; 179 int i; 180 --- 143 unchanged lines hidden (view full) --- 324#ifndef __FreeBSD__ 325 m1.m_next = m; 326 m1.m_len = PFLOG_HDRLEN; 327 m1.m_data = (char *) &hdr; 328#endif 329 330#ifdef __FreeBSD__ 331 KASSERT((!LIST_EMPTY(&pflog_list)), ("pflog: no interface")); | 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")); |
332 ifn = &LIST_FIRST(&pflog_list)->sc_if; | 335 ifn = SCP2IFP(LIST_FIRST(&pflog_list)); |
333 BPF_MTAP2(ifn, &hdr, sizeof(hdr), m); 334#else 335 ifn = &(pflogif[0].sc_if); 336 337 if (ifn->if_bpf) 338 bpf_mtap(ifn->if_bpf, &m1); 339#endif 340#endif --- 11 unchanged lines hidden (view full) --- 352 case MOD_LOAD: 353 LIST_INIT(&pflog_list); 354 if_clone_attach(&pflog_cloner); 355 break; 356 357 case MOD_UNLOAD: 358 if_clone_detach(&pflog_cloner); 359 while (!LIST_EMPTY(&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)) |
360 pflog_clone_destroy( 361 &LIST_FIRST(&pflog_list)->sc_if); | 363 pflog_clone_destroy(SCP2IFP(LIST_FIRST(&pflog_list))); |
362 break; 363 364 default: 365 error = EINVAL; 366 break; 367 } 368 369 return error; --- 13 unchanged lines hidden --- | 364 break; 365 366 default: 367 error = EINVAL; 368 break; 369 } 370 371 return error; --- 13 unchanged lines hidden --- |