Deleted Added
full compact
1c1
< /* $FreeBSD: head/sys/net/if_stf.c 78701 2001-06-24 14:52:55Z ume $ */
---
> /* $FreeBSD: head/sys/net/if_stf.c 79106 2001-07-02 21:02:09Z brooks $ */
100a101
> #include <netinet/ipprotosw.h>
106d106
< #include <netinet6/in6_gif.h>
116,121d115
< #include "bpf.h"
< #define NBPFILTER NBPF
< #include "stf.h"
< #include "gif.h" /*XXX*/
<
< #if NBPFILTER > 0
123d116
< #endif
125,133d117
< #if NGIF > 0
< #include <net/if_gif.h>
< #endif
<
< #if NSTF > 0
< #if NSTF != 1
< # error only single stf interface allowed
< #endif
<
148d131
< static int nstf;
150,154c133,134
< #if NGIF > 0
< extern int ip_gif_ttl; /*XXX*/
< #else
< static int ip_gif_ttl = 40; /*XXX*/
< #endif
---
> static MALLOC_DEFINE(M_STF, "stf", "6to4 Tunnel Interface");
> static int ip_stf_ttl = 40;
156c136,143
< extern struct protosw in_stf_protosw;
---
> extern struct domain inetdomain;
> struct ipprotosw in_stf_protosw =
> { SOCK_RAW, &inetdomain, IPPROTO_IPV6, PR_ATOMIC|PR_ADDR,
> in_stf_input, rip_output, 0, rip_ctloutput,
> 0,
> 0, 0, 0, 0,
> &rip_usrreqs
> };
158c145
< void stfattach __P((void *));
---
> static int stfmodevent __P((module_t, int, void *));
170,172c157,161
< void
< stfattach(dummy)
< void *dummy;
---
> static int
> stfmodevent(mod, type, data)
> module_t mod;
> int type;
> void *data;
175c164
< int i;
---
> int err;
178,181c167,171
< nstf = NSTF;
< stf = malloc(nstf * sizeof(struct stf_softc), M_DEVBUF, M_WAITOK);
< bzero(stf, nstf * sizeof(struct stf_softc));
< sc = stf;
---
> switch (type) {
> case MOD_LOAD:
> stf = malloc(sizeof(struct stf_softc), M_STF, M_WAITOK);
> bzero(stf, sizeof(struct stf_softc));
> sc = stf;
183,185d172
< /* XXX just in case... */
< for (i = 0; i < nstf; i++) {
< sc = &stf[i];
188c175
< sc->sc_if.if_unit = i;
---
> sc->sc_if.if_unit = 0;
194c181
< continue;
---
> return (ENOMEM);
209d195
< #if NBPFILTER > 0
215c201,209
< #endif
---
> break;
> case MOD_UNLOAD:
> sc = stf;
> bpfdetach(&sc->sc_if);
> if_detach(&sc->sc_if);
> err = encap_detach(sc->encap_cookie);
> KASSERT(err == 0, ("Unexpected error detaching encap_cookie"));
> free(sc, M_STF);
> break;
216a211,212
>
> return (0);
219c215,219
< PSEUDO_SET(stfattach, if_stf);
---
> static moduledata_t stf_mod = {
> "if_stf",
> stfmodevent,
> 0
> };
220a221,222
> DECLARE_MODULE(if_stf, stf_mod, SI_SUB_PSEUDO, SI_ORDER_ANY);
>
416c418
< ip->ip_ttl = ip_gif_ttl; /*XXX*/
---
> ip->ip_ttl = ip_stf_ttl;
610d611
< #if NBPFILTER > 0
632d632
< #endif /*NBPFILTER > 0*/
706,707d705
<
< #endif /* NSTF > 0 */