1/* $FreeBSD: head/sys/net/if_stf.c 241610 2012-10-16 13:37:54Z glebius $ */ |
2/* $KAME: if_stf.c,v 1.73 2001/12/03 11:08:30 keiichi Exp $ */ 3 4/*- 5 * Copyright (C) 2000 WIDE Project. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions --- 112 unchanged lines hidden (view full) --- 122 123SYSCTL_DECL(_net_link); 124static SYSCTL_NODE(_net_link, IFT_STF, stf, CTLFLAG_RW, 0, "6to4 Interface"); 125 126static int stf_route_cache = 1; 127SYSCTL_INT(_net_link_stf, OID_AUTO, route_cache, CTLFLAG_RW, 128 &stf_route_cache, 0, "Caching of IPv4 routes for 6to4 Output"); 129 |
130#define STFUNIT 0 131 132#define IN6_IS_ADDR_6TO4(x) (ntohs((x)->s6_addr16[0]) == 0x2002) 133 134/* 135 * XXX: Return a pointer with 16-bit aligned. Don't cast it to 136 * struct in_addr *; use bcopy() instead. 137 */ --- 7 unchanged lines hidden (view full) --- 145 } __sc_ro46; 146#define sc_ro __sc_ro46.__sc_ro4 147 struct mtx sc_ro_mtx; 148 u_int sc_fibnum; 149 const struct encaptab *encap_cookie; 150}; 151#define STF2IFP(sc) ((sc)->sc_ifp) 152 |
153static const char stfname[] = "stf"; 154 |
155/* 156 * Note that mutable fields in the softc are not currently locked. 157 * We do lock sc_ro in stf_output though. 158 */ |
159static MALLOC_DEFINE(M_STF, stfname, "6to4 Tunnel Interface"); |
160static const int ip_stf_ttl = 40; 161 162extern struct domain inetdomain; 163struct protosw in_stf_protosw = { 164 .pr_type = SOCK_RAW, 165 .pr_domain = &inetdomain, 166 .pr_protocol = IPPROTO_IPV6, 167 .pr_flags = PR_ATOMIC|PR_ADDR, --- 16 unchanged lines hidden (view full) --- 184static int stf_checkaddr6(struct stf_softc *, struct in6_addr *, 185 struct ifnet *); 186static void stf_rtrequest(int, struct rtentry *, struct rt_addrinfo *); 187static int stf_ioctl(struct ifnet *, u_long, caddr_t); 188 189static int stf_clone_match(struct if_clone *, const char *); 190static int stf_clone_create(struct if_clone *, char *, size_t, caddr_t); 191static int stf_clone_destroy(struct if_clone *, struct ifnet *); |
192static struct if_clone *stf_cloner; |
193 194static int 195stf_clone_match(struct if_clone *ifc, const char *name) 196{ 197 int i; 198 199 for(i = 0; stfnames[i] != NULL; i++) { 200 if (strcmp(stfnames[i], name) == 0) --- 30 unchanged lines hidden (view full) --- 231 ifp->if_softc = sc; 232 sc->sc_fibnum = curthread->td_proc->p_fibnum; 233 234 /* 235 * Set the name manually rather then using if_initname because 236 * we don't conform to the default naming convention for interfaces. 237 */ 238 strlcpy(ifp->if_xname, name, IFNAMSIZ); |
239 ifp->if_dname = stfname; |
240 ifp->if_dunit = IF_DUNIT_NONE; 241 242 mtx_init(&(sc)->sc_ro_mtx, "stf ro", NULL, MTX_DEF); 243 sc->encap_cookie = encap_attach_func(AF_INET, IPPROTO_IPV6, 244 stf_encapcheck, &in_stf_protosw, sc); 245 if (sc->encap_cookie == NULL) { 246 if_printf(ifp, "attach failed\n"); 247 free(sc, M_STF); --- 33 unchanged lines hidden (view full) --- 281stfmodevent(mod, type, data) 282 module_t mod; 283 int type; 284 void *data; 285{ 286 287 switch (type) { 288 case MOD_LOAD: |
289 stf_cloner = if_clone_advanced(stfname, 0, stf_clone_match, 290 stf_clone_create, stf_clone_destroy); |
291 break; 292 case MOD_UNLOAD: |
293 if_clone_detach(stf_cloner); |
294 break; 295 default: 296 return (EOPNOTSUPP); 297 } 298 299 return (0); 300} 301 --- 558 unchanged lines hidden --- |