Lines Matching refs:sc
280 struct gif_softc *sc = ifnet_softc(ifp);
282 sc->tap_mode = mode;
283 sc->tap_callback = callback;
292 struct gif_softc *sc = NULL;
300 sc = _MALLOC(sizeof(struct gif_softc), M_DEVBUF, M_WAITOK);
301 if (sc == NULL) {
305 bzero(sc, sizeof(struct gif_softc));
308 snprintf(sc->gif_ifname, sizeof(sc->gif_ifname), "%s%d",
312 gif_init.uniqueid = sc->gif_ifname;
313 gif_init.uniqueid_len = strlen(sc->gif_ifname);
322 gif_init.softc = sc;
326 result = ifnet_allocate(&gif_init, &sc->gif_if);
329 _FREE(sc, M_DEVBUF);
333 sc->encap_cookie4 = sc->encap_cookie6 = NULL;
335 sc->encap_cookie4 = encap_attach_func(AF_INET, -1,
336 gif_encapcheck, &in_gif_protosw, sc);
337 if (sc->encap_cookie4 == NULL) {
338 printf("%s: unable to attach encap4\n", if_name(sc->gif_if));
339 ifnet_release(sc->gif_if);
340 FREE(sc, M_DEVBUF);
345 sc->encap_cookie6 = encap_attach_func(AF_INET6, -1,
346 gif_encapcheck, (struct protosw*)&in6_gif_protosw, sc);
347 if (sc->encap_cookie6 == NULL) {
348 if (sc->encap_cookie4) {
349 encap_detach(sc->encap_cookie4);
350 sc->encap_cookie4 = NULL;
352 printf("%s: unable to attach encap6\n", if_name(sc->gif_if));
353 ifnet_release(sc->gif_if);
354 FREE(sc, M_DEVBUF);
358 sc->gif_called = 0;
359 ifnet_set_mtu(sc->gif_if, GIF_MTU);
360 ifnet_set_flags(sc->gif_if, IFF_POINTOPOINT | IFF_MULTICAST, 0xffff);
363 sc->gif_if.if_flags |= IFF_LINK2;
365 result = ifnet_attach(sc->gif_if, NULL);
368 ifnet_release(sc->gif_if);
369 if (sc->encap_cookie4) {
370 encap_detach(sc->encap_cookie4);
371 sc->encap_cookie4 = NULL;
373 if (sc->encap_cookie6) {
374 encap_detach(sc->encap_cookie6);
375 sc->encap_cookie6 = NULL;
377 FREE(sc, M_DEVBUF);
381 mac_ifnet_label_init(&sc->gif_if);
383 bpfattach(sc->gif_if, DLT_NULL, sizeof(u_int));
384 TAILQ_INSERT_TAIL(&gifs, sc, gif_link);
395 struct gif_softc *sc = ifp->if_softc;
397 TAILQ_REMOVE(&gifs, sc, gif_link);
399 gif_delete_tunnel(sc);
401 if (sc->encap_cookie6 != NULL) {
402 err = encap_detach(sc->encap_cookie6);
407 if (sc->encap_cookie4 != NULL) {
408 err = encap_detach(sc->encap_cookie4);
420 FREE(sc, M_DEVBUF);
433 struct gif_softc *sc;
435 sc = (struct gif_softc *)arg;
436 if (sc == NULL)
439 if ((ifnet_flags(sc->gif_if) & IFF_UP) == 0)
443 if (!sc->gif_psrc || !sc->gif_pdst)
464 if (sc->gif_psrc->sa_family != AF_INET ||
465 sc->gif_pdst->sa_family != AF_INET)
471 if (sc->gif_psrc->sa_family != AF_INET6 ||
472 sc->gif_pdst->sa_family != AF_INET6)
486 struct gif_softc *sc = ifnet_softc(ifp);
497 sc->gif_psrc == NULL || sc->gif_pdst == NULL) {
504 bpf_tap_out(ifp, 0, m, &sc->gif_proto, sizeof(sc->gif_proto));
511 switch (sc->gif_psrc->sa_family) {
514 error = in_gif_output(ifp, sc->gif_proto, m, NULL);
519 error = in6_gif_output(ifp, sc->gif_proto, m, NULL);
550 struct gif_softc *sc = ifnet_softc(ifp);
552 bpf_tap_in(ifp, 0, m, &sc->gif_proto, sizeof(sc->gif_proto));
582 struct gif_softc *sc = ifnet_softc(ifp);
719 if (sc2 == sc)
762 if (sc->gif_psrc)
763 FREE((caddr_t)sc->gif_psrc, M_IFADDR);
768 sc->gif_psrc = sa;
770 if (sc->gif_pdst)
771 FREE((caddr_t)sc->gif_pdst, M_IFADDR);
776 sc->gif_pdst = sa;
785 if (sc->gif_psrc) {
786 FREE((caddr_t)sc->gif_psrc, M_IFADDR);
787 sc->gif_psrc = NULL;
789 if (sc->gif_pdst) {
790 FREE((caddr_t)sc->gif_pdst, M_IFADDR);
791 sc->gif_pdst = NULL;
801 if (sc->gif_psrc == NULL) {
805 src = sc->gif_psrc;
833 if (sc->gif_pdst == NULL) {
837 src = sc->gif_pdst;
862 if (sc->gif_psrc == NULL || sc->gif_pdst == NULL) {
868 src = sc->gif_psrc;
877 src = sc->gif_pdst;
900 gif_delete_tunnel(sc)
901 struct gif_softc *sc;
905 if (sc->gif_psrc) {
906 FREE((caddr_t)sc->gif_psrc, M_IFADDR);
907 sc->gif_psrc = NULL;
909 if (sc->gif_pdst) {
910 FREE((caddr_t)sc->gif_pdst, M_IFADDR);
911 sc->gif_pdst = NULL;