• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.10/xnu-2782.1.97/bsd/net/

Lines Matching refs:sc

182 	struct gif_softc *sc = ifnet_softc(ifp);
184 GIF_LOCK(sc);
186 *protocol_family = sc->gif_proto;
187 GIF_UNLOCK(sc);
200 struct gif_softc *sc = ifnet_softc(ifp);
202 GIF_LOCK(sc);
203 if (sc->gif_proto != 0)
207 sc->gif_proto = protocol_family;
208 GIF_UNLOCK(sc);
218 struct gif_softc *sc = ifnet_softc(ifp);
220 GIF_LOCK(sc);
221 if (sc->gif_proto == protocol_family)
222 sc->gif_proto = 0;
223 GIF_UNLOCK(sc);
298 struct gif_softc *sc = ifnet_softc(ifp);
300 GIF_LOCK(sc);
301 sc->tap_mode = mode;
302 sc->tap_callback = callback;
303 GIF_UNLOCK(sc);
311 struct gif_softc *sc = ifp->if_softc;
312 lck_mtx_destroy(&sc->gif_lock, gif_mtx_grp);
321 struct gif_softc *sc = NULL;
333 sc = _MALLOC(sizeof (struct gif_softc), M_DEVBUF, M_WAITOK);
334 if (sc == NULL) {
340 bzero(sc, sizeof (struct gif_softc));
343 snprintf(sc->gif_ifname, sizeof (sc->gif_ifname), "%s%d",
346 lck_mtx_init(&sc->gif_lock, gif_mtx_grp, gif_mtx_attr);
349 gif_init_params.uniqueid = sc->gif_ifname;
350 gif_init_params.uniqueid_len = strlen(sc->gif_ifname);
359 gif_init_params.softc = sc;
364 error = ifnet_allocate(&gif_init_params, &sc->gif_if);
367 _FREE(sc, M_DEVBUF);
372 sc->encap_cookie4 = sc->encap_cookie6 = NULL;
374 sc->encap_cookie4 = encap_attach_func(AF_INET, -1,
375 gif_encapcheck, &in_gif_protosw, sc);
376 if (sc->encap_cookie4 == NULL) {
377 printf("%s: unable to attach encap4\n", if_name(sc->gif_if));
378 ifnet_release(sc->gif_if);
379 FREE(sc, M_DEVBUF);
385 sc->encap_cookie6 = encap_attach_func(AF_INET6, -1,
386 gif_encapcheck, (struct protosw *)&in6_gif_protosw, sc);
387 if (sc->encap_cookie6 == NULL) {
388 if (sc->encap_cookie4) {
389 encap_detach(sc->encap_cookie4);
390 sc->encap_cookie4 = NULL;
392 printf("%s: unable to attach encap6\n", if_name(sc->gif_if));
393 ifnet_release(sc->gif_if);
394 FREE(sc, M_DEVBUF);
399 sc->gif_called = 0;
400 ifnet_set_mtu(sc->gif_if, GIF_MTU);
401 ifnet_set_flags(sc->gif_if, IFF_POINTOPOINT | IFF_MULTICAST, 0xffff);
404 sc->gif_if.if_flags |= IFF_LINK2;
406 error = ifnet_attach(sc->gif_if, NULL);
409 ifnet_release(sc->gif_if);
410 if (sc->encap_cookie4) {
411 encap_detach(sc->encap_cookie4);
412 sc->encap_cookie4 = NULL;
414 if (sc->encap_cookie6) {
415 encap_detach(sc->encap_cookie6);
416 sc->encap_cookie6 = NULL;
418 FREE(sc, M_DEVBUF);
422 mac_ifnet_label_init(&sc->gif_if);
424 bpfattach(sc->gif_if, DLT_NULL, sizeof (u_int));
425 TAILQ_INSERT_TAIL(&gifs, sc, gif_link);
439 struct gif_softc *sc = ifp->if_softc;
442 TAILQ_REMOVE(&gifs, sc, gif_link);
445 GIF_LOCK(sc);
446 gif_delete_tunnel(sc);
448 if (sc->encap_cookie6 != NULL) {
449 error = encap_detach(sc->encap_cookie6);
455 if (sc->encap_cookie4 != NULL) {
456 error = encap_detach(sc->encap_cookie4);
471 GIF_UNLOCK(sc);
486 struct gif_softc *sc;
488 sc = (struct gif_softc *)arg;
489 if (sc == NULL)
492 GIF_LOCK(sc);
493 if ((ifnet_flags(sc->gif_if) & IFF_UP) == 0)
497 if (!sc->gif_psrc || !sc->gif_pdst)
518 if (sc->gif_psrc->sa_family != AF_INET ||
519 sc->gif_pdst->sa_family != AF_INET)
525 if (sc->gif_psrc->sa_family != AF_INET6 ||
526 sc->gif_pdst->sa_family != AF_INET6)
534 GIF_UNLOCK(sc);
543 struct gif_softc *sc = ifnet_softc(ifp);
548 GIF_LOCK(sc);
549 gif_psrc = sc->gif_psrc;
550 gif_pdst = sc->gif_pdst;
551 GIF_UNLOCK(sc);
567 bpf_tap_out(ifp, 0, m, &sc->gif_proto, sizeof (sc->gif_proto));
569 GIF_LOCK(sc);
576 switch (sc->gif_psrc->sa_family) {
579 error = in_gif_output(ifp, sc->gif_proto, m, NULL);
584 error = in6_gif_output(ifp, sc->gif_proto, m, NULL);
592 GIF_UNLOCK(sc);
615 struct gif_softc *sc = ifnet_softc(ifp);
617 bpf_tap_in(ifp, 0, m, &sc->gif_proto, sizeof (sc->gif_proto));
647 struct gif_softc *sc = ifnet_softc(ifp);
770 #define GIF_ORDERED_LOCK(sc, sc2) \
771 if (sc < sc2) { \
772 GIF_LOCK(sc); \
776 GIF_LOCK(sc); \
779 #define GIF_ORDERED_UNLOCK(sc, sc2) \
780 if (sc > sc2) { \
781 GIF_UNLOCK(sc); \
785 GIF_UNLOCK(sc); \
793 if (sc2 == sc)
795 /* lock sc and sc2 in increasing order of ifnet index */
796 GIF_ORDERED_LOCK(sc, sc2);
798 GIF_ORDERED_UNLOCK(sc, sc2);
805 GIF_ORDERED_UNLOCK(sc, sc2);
812 GIF_ORDERED_UNLOCK(sc, sc2);
829 GIF_ORDERED_UNLOCK(sc, sc2);
837 GIF_ORDERED_UNLOCK(sc, sc2);
843 GIF_ORDERED_UNLOCK(sc, sc2);
847 GIF_LOCK(sc);
848 if (sc->gif_psrc)
849 FREE((caddr_t)sc->gif_psrc, M_IFADDR);
853 GIF_UNLOCK(sc);
857 sc->gif_psrc = sa;
859 if (sc->gif_pdst)
860 FREE((caddr_t)sc->gif_pdst, M_IFADDR);
864 GIF_UNLOCK(sc);
868 sc->gif_pdst = sa;
869 GIF_UNLOCK(sc);
879 GIF_LOCK(sc);
880 if (sc->gif_psrc) {
881 FREE((caddr_t)sc->gif_psrc, M_IFADDR);
882 sc->gif_psrc = NULL;
884 if (sc->gif_pdst) {
885 FREE((caddr_t)sc->gif_pdst, M_IFADDR);
886 sc->gif_pdst = NULL;
888 GIF_UNLOCK(sc);
897 GIF_LOCK(sc);
898 if (sc->gif_psrc == NULL) {
899 GIF_UNLOCK(sc);
903 src = sc->gif_psrc;
919 GIF_UNLOCK(sc);
924 GIF_UNLOCK(sc);
928 GIF_UNLOCK(sc);
935 GIF_LOCK(sc);
936 if (sc->gif_pdst == NULL) {
937 GIF_UNLOCK(sc);
941 src = sc->gif_pdst;
958 GIF_UNLOCK(sc);
962 GIF_UNLOCK(sc);
966 GIF_UNLOCK(sc);
982 gif_delete_tunnel(struct gif_softc *sc)
984 GIF_LOCK_ASSERT(sc);
985 if (sc->gif_psrc) {
986 FREE((caddr_t)sc->gif_psrc, M_IFADDR);
987 sc->gif_psrc = NULL;
989 if (sc->gif_pdst) {
990 FREE((caddr_t)sc->gif_pdst, M_IFADDR);
991 sc->gif_pdst = NULL;
993 ROUTE_RELEASE(&sc->gif_ro);