Lines Matching refs:sc
265 struct gif_softc *sc = ifnet_softc(ifp);
267 sc->tap_mode = mode;
268 sc->tap_callback = callback;
277 struct gif_softc *sc;
287 TAILQ_FOREACH(sc, &gifs, gif_link) {
289 if ((ifnet_flags(sc->gif_if) & IFF_RUNNING) == 0)
293 sc = _MALLOC(sizeof(struct gif_softc), M_DEVBUF, M_WAITOK);
294 if (sc == NULL) {
308 gif_init.softc = sc;
312 bzero(sc, sizeof(struct gif_softc));
313 result = ifnet_allocate(&gif_init, &sc->gif_if);
316 _FREE(sc, M_DEVBUF);
319 sc->encap_cookie4 = sc->encap_cookie6 = NULL;
321 sc->encap_cookie4 = encap_attach_func(AF_INET, -1,
322 gif_encapcheck, &in_gif_protosw, sc);
323 if (sc->encap_cookie4 == NULL) {
324 printf("%s: unable to attach encap4\n", if_name(sc->gif_if));
325 ifnet_release(sc->gif_if);
326 FREE(sc, M_DEVBUF);
331 sc->encap_cookie6 = encap_attach_func(AF_INET6, -1,
332 gif_encapcheck, (struct protosw*)&in6_gif_protosw, sc);
333 if (sc->encap_cookie6 == NULL) {
334 if (sc->encap_cookie4) {
335 encap_detach(sc->encap_cookie4);
336 sc->encap_cookie4 = NULL;
338 printf("%s: unable to attach encap6\n", if_name(sc->gif_if));
339 ifnet_release(sc->gif_if);
340 FREE(sc, M_DEVBUF);
344 sc->gif_called = 0;
345 ifnet_set_mtu(sc->gif_if, GIF_MTU);
346 ifnet_set_flags(sc->gif_if, IFF_POINTOPOINT | IFF_MULTICAST, 0xffff);
349 sc->gif_if.if_flags |= IFF_LINK2;
351 result = ifnet_attach(sc->gif_if, NULL);
354 ifnet_release(sc->gif_if);
355 FREE(sc, M_DEVBUF);
359 mac_ifnet_label_init(&sc->gif_if);
361 bpfattach(sc->gif_if, DLT_NULL, sizeof(u_int));
362 TAILQ_INSERT_TAIL(&gifs, sc, gif_link);
374 struct gif_softc *sc;
376 sc = (struct gif_softc *)arg;
377 if (sc == NULL)
380 if ((ifnet_flags(sc->gif_if) & IFF_UP) == 0)
384 if (!sc->gif_psrc || !sc->gif_pdst)
405 if (sc->gif_psrc->sa_family != AF_INET ||
406 sc->gif_pdst->sa_family != AF_INET)
412 if (sc->gif_psrc->sa_family != AF_INET6 ||
413 sc->gif_pdst->sa_family != AF_INET6)
427 struct gif_softc *sc = ifnet_softc(ifp);
438 sc->gif_psrc == NULL || sc->gif_pdst == NULL) {
445 bpf_tap_out(ifp, 0, m, &sc->gif_proto, sizeof(sc->gif_proto));
452 switch (sc->gif_psrc->sa_family) {
455 error = in_gif_output(ifp, sc->gif_proto, m, NULL);
460 error = in6_gif_output(ifp, sc->gif_proto, m, NULL);
492 struct gif_softc *sc = ifnet_softc(ifp);
494 bpf_tap_in(ifp, 0, m, &sc->gif_proto, sizeof(sc->gif_proto));
521 struct gif_softc *sc = ifnet_softc(ifp);
645 if (sc2 == sc)
688 if (sc->gif_psrc)
689 FREE((caddr_t)sc->gif_psrc, M_IFADDR);
692 sc->gif_psrc = sa;
694 if (sc->gif_pdst)
695 FREE((caddr_t)sc->gif_pdst, M_IFADDR);
698 sc->gif_pdst = sa;
712 if (sc->gif_psrc) {
713 FREE((caddr_t)sc->gif_psrc, M_IFADDR);
714 sc->gif_psrc = NULL;
716 if (sc->gif_pdst) {
717 FREE((caddr_t)sc->gif_pdst, M_IFADDR);
718 sc->gif_pdst = NULL;
728 if (sc->gif_psrc == NULL) {
732 src = sc->gif_psrc;
760 if (sc->gif_pdst == NULL) {
764 src = sc->gif_pdst;
789 if (sc->gif_psrc == NULL || sc->gif_pdst == NULL) {
795 src = sc->gif_psrc;
804 src = sc->gif_pdst;
828 gif_delete_tunnel(sc)
829 struct gif_softc *sc;
833 if (sc->gif_psrc) {
834 FREE((caddr_t)sc->gif_psrc, M_IFADDR);
835 sc->gif_psrc = NULL;
837 if (sc->gif_pdst) {
838 FREE((caddr_t)sc->gif_pdst, M_IFADDR);
839 sc->gif_pdst = NULL;