Example #1
0
static int
natm_usr_disconnect(struct socket *so)
{
    struct natmpcb *npcb;
    struct sockaddr_natm *snatm;
    struct atm_pseudoioctl api;
    struct atm_pseudohdr *aph;
    struct ifnet *ifp;
    int error = 0;
    int s2, s = SPLSOFTNET();
    int proto = so->so_proto->pr_protocol;

    npcb = (struct natmpcb *) so->so_pcb;
    if (npcb == NULL) {
	error = EINVAL;
	goto out;
    }

    if ((npcb->npcb_flags & NPCB_CONNECTED) == 0) {
        printf("natm: disconnected check\n");
        error = EIO;
	goto out;
    }
    ifp = npcb->npcb_ifp;

    /*
     * disable rx
     */

    ATM_PH_FLAGS(&api.aph) = ATM_PH_AAL5;
    ATM_PH_VPI(&api.aph) = npcb->npcb_vpi;
    ATM_PH_SETVCI(&api.aph, npcb->npcb_vci);
    api.rxhand = npcb;
    s2 = splimp();
    if (ifp->if_ioctl != NULL)
	ifp->if_ioctl(ifp, SIOCATMDIS, (caddr_t) &api);
    splx(s2);

    npcb_free(npcb, NPCB_REMOVE);
    soisdisconnected(so);

 out:
    splx(s);
    return (error);
}
Example #2
0
static int
natm_usr_send(struct socket *so, int flags, struct mbuf *m, struct mbuf *nam,
	     struct mbuf *control)
{
    struct natmpcb *npcb;
    struct atm_pseudohdr *aph;
    int error = 0;
    int s = SPLSOFTNET();
    int proto = so->so_proto->pr_protocol;

    npcb = (struct natmpcb *) so->so_pcb;
    if (npcb == NULL) {
	error = EINVAL;
	goto out;
    }

    if (control && control->m_len) {
	m_freem(control);
	m_freem(m);
	error = EINVAL;
	goto out;
    }

    /*
     * send the data.   we must put an atm_pseudohdr on first
     */

    M_PREPEND(m, sizeof(*aph), M_WAITOK);
    if (m == NULL) {
        error = ENOBUFS;
	goto out;
    }
    aph = mtod(m, struct atm_pseudohdr *);
    ATM_PH_VPI(aph) = npcb->npcb_vpi;
    ATM_PH_SETVCI(aph, npcb->npcb_vci);
    ATM_PH_FLAGS(aph) = (proto == PROTO_NATMAAL5) ? ATM_PH_AAL5 : 0;

    error = atm_output(npcb->npcb_ifp, m, NULL, NULL);

 out:
    splx(s);
    return (error);
}
Example #3
0
static int
natm_usr_send(struct socket *so, int flags, struct mbuf *m, 
	struct sockaddr *nam, struct mbuf *control, struct thread *p)
{
	struct natmpcb *npcb;
	struct atm_pseudohdr *aph;
	int error = 0;
	int proto = so->so_proto->pr_protocol;

	npcb = (struct natmpcb *)so->so_pcb;
	KASSERT(npcb != NULL, ("natm_usr_send: npcb == NULL"));

	NATM_LOCK();
	if (control && control->m_len) {
		NATM_UNLOCK();
		m_freem(control);
		m_freem(m);
		return (EINVAL);
	}

	/*
	 * Send the data.  We must put an atm_pseudohdr on first.
	 */
	M_PREPEND(m, sizeof(*aph), M_DONTWAIT);
	if (m == NULL) {
		NATM_UNLOCK();
		m_freem(control);
		return (ENOBUFS);
	}
	aph = mtod(m, struct atm_pseudohdr *);
	ATM_PH_VPI(aph) = npcb->npcb_vpi;
	ATM_PH_SETVCI(aph, npcb->npcb_vci);
	ATM_PH_FLAGS(aph) = (proto == PROTO_NATMAAL5) ? ATM_PH_AAL5 : 0;
	error = atm_output(npcb->npcb_ifp, m, NULL, NULL);
	NATM_UNLOCK();
	return (error);
}
Example #4
0
int natm_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam,
    struct mbuf *control, struct proc *p)
{
  int error = 0, s, s2;
  struct natmpcb *npcb;
  struct sockaddr_natm *snatm;
  struct atm_pseudoioctl api;
  struct atm_pseudohdr *aph;
  struct atm_rawioctl ario;
  struct ifnet *ifp;
  int proto = so->so_proto->pr_protocol;

  s = splsoftnet();

  npcb = (struct natmpcb *) so->so_pcb;

  if (npcb == NULL && req != PRU_ATTACH) {
    error = EINVAL;
    goto done;
  }
    

  switch (req) {
    case PRU_ATTACH:			/* attach protocol to up */

      if (npcb) {
	error = EISCONN;
	break;
      }

      if (so->so_snd.sb_hiwat == 0 || so->so_rcv.sb_hiwat == 0) {
	if (proto == PROTO_NATMAAL5) 
          error = soreserve(so, natm5_sendspace, natm5_recvspace);
	else
          error = soreserve(so, natm0_sendspace, natm0_recvspace);
        if (error)
          break;
      }

      so->so_pcb = (caddr_t) (npcb = npcb_alloc(M_WAITOK));
      npcb->npcb_socket = so;

      break;

    case PRU_DETACH:			/* detach protocol from up */

      /*
       * we turn on 'drain' *before* we sofree.
       */

      npcb_free(npcb, NPCB_DESTROY);	/* drain */
      so->so_pcb = NULL;
      sofree(so);

      break;

    case PRU_CONNECT:			/* establish connection to peer */

      /*
       * validate nam and npcb
       */

      if (nam->m_len != sizeof(*snatm)) {
        error = EINVAL;
	break;
      }
      snatm = mtod(nam, struct sockaddr_natm *);
      if (snatm->snatm_len != sizeof(*snatm) ||
		(npcb->npcb_flags & NPCB_FREE) == 0) {
	error = EINVAL;
	break;
      }
      if (snatm->snatm_family != AF_NATM) {
	error = EAFNOSUPPORT;
	break;
      }

      snatm->snatm_if[IFNAMSIZ-1] = '\0';  /* XXX ensure null termination
						since ifunit() uses strcmp */

      /*
       * convert interface string to ifp, validate.
       */

      ifp = ifunit(snatm->snatm_if);
      if (ifp == NULL || (ifp->if_flags & IFF_RUNNING) == 0) {
	error = ENXIO;
	break;
      }
      if (ifp->if_output != atm_output) {
	error = EAFNOSUPPORT;
	break;
      }


      /*
       * register us with the NATM PCB layer
       */

      if (npcb_add(npcb, ifp, snatm->snatm_vci, snatm->snatm_vpi) != npcb) {
        error = EADDRINUSE;
        break;
      }

      /*
       * enable rx
       */

      ATM_PH_FLAGS(&api.aph) = (proto == PROTO_NATMAAL5) ? ATM_PH_AAL5 : 0;
      ATM_PH_VPI(&api.aph) = npcb->npcb_vpi;
      ATM_PH_SETVCI(&api.aph, npcb->npcb_vci);
      api.rxhand = npcb;
      s2 = splnet();
      if (ifp->if_ioctl == NULL || 
	  ifp->if_ioctl(ifp, SIOCATMENA, (caddr_t) &api) != 0) {
	splx(s2);
	npcb_free(npcb, NPCB_REMOVE);
        error = EIO;
	break;
      }
      splx(s2);

      soisconnected(so);

      break;

    case PRU_DISCONNECT:		/* disconnect from peer */

      if ((npcb->npcb_flags & NPCB_CONNECTED) == 0) {
        printf("natm: disconnected check\n");
        error = EIO;
	break;
      }
      ifp = npcb->npcb_ifp;

      /*
       * disable rx
       */

      ATM_PH_FLAGS(&api.aph) = ATM_PH_AAL5;
      ATM_PH_VPI(&api.aph) = npcb->npcb_vpi;
      ATM_PH_SETVCI(&api.aph, npcb->npcb_vci);
      api.rxhand = npcb;
      s2 = splnet();
      if (ifp->if_ioctl != NULL)
	  ifp->if_ioctl(ifp, SIOCATMDIS, (caddr_t) &api);
      splx(s2);

      npcb_free(npcb, NPCB_REMOVE);
      soisdisconnected(so);

      break;

    case PRU_SHUTDOWN:			/* won't send any more data */
      socantsendmore(so);
      break;

    case PRU_SEND:			/* send this data */
      if (control && control->m_len) {
	m_freem(control);
	m_freem(m);
	error = EINVAL;
	break;
      }

      /*
       * send the data.   we must put an atm_pseudohdr on first
       */

      M_PREPEND(m, sizeof(*aph), M_WAITOK);
      aph = mtod(m, struct atm_pseudohdr *);
      ATM_PH_VPI(aph) = npcb->npcb_vpi;
      ATM_PH_SETVCI(aph, npcb->npcb_vci);
      ATM_PH_FLAGS(aph) = (proto == PROTO_NATMAAL5) ? ATM_PH_AAL5 : 0;

      error = atm_output(npcb->npcb_ifp, m, NULL, NULL);

      break;

    case PRU_SENSE:			/* return status into m */
      /* return zero? */
      break;

    case PRU_PEERADDR:			/* fetch peer's address */
      snatm = mtod(nam, struct sockaddr_natm *);
      bzero(snatm, sizeof(*snatm));
      nam->m_len = snatm->snatm_len = sizeof(*snatm);
      snatm->snatm_family = AF_NATM;
#if defined(__NetBSD__) || defined(__OpenBSD__)
      bcopy(npcb->npcb_ifp->if_xname, snatm->snatm_if, sizeof(snatm->snatm_if));
#elif defined(__FreeBSD__)
      sprintf(snatm->snatm_if, "%s%d", npcb->npcb_ifp->if_name,
	npcb->npcb_ifp->if_unit);
#endif
      snatm->snatm_vci = npcb->npcb_vci;
      snatm->snatm_vpi = npcb->npcb_vpi;
      break;

    case PRU_CONTROL:			/* control operations on protocol */
      /*
       * raw atm ioctl.   comes in as a SIOCRAWATM.   we convert it to
       * SIOCXRAWATM and pass it to the driver.
       */
      if ((u_long)m == SIOCRAWATM) {
        if (npcb->npcb_ifp == NULL) {
          error = ENOTCONN;
          break;
        }
        ario.npcb = npcb;
        ario.rawvalue = *((int *)nam);
        error = npcb->npcb_ifp->if_ioctl(npcb->npcb_ifp, 
				SIOCXRAWATM, (caddr_t) &ario);
	if (!error) {
          if (ario.rawvalue) 
	    npcb->npcb_flags |= NPCB_RAW;
	  else
	    npcb->npcb_flags &= ~(NPCB_RAW);
	}

        break;
      }

      error = EOPNOTSUPP;
      break;

    case PRU_BIND:			/* bind socket to address */
    case PRU_LISTEN:			/* listen for connection */
    case PRU_ACCEPT:			/* accept connection from peer */
    case PRU_CONNECT2:			/* connect two sockets */
    case PRU_ABORT:			/* abort (fast DISCONNECT, DETACH) */
					/* (only happens if LISTEN socket) */
    case PRU_RCVD:			/* have taken data; more room now */
    case PRU_FASTTIMO:			/* 200ms timeout */
    case PRU_SLOWTIMO:			/* 500ms timeout */
    case PRU_RCVOOB:			/* retrieve out of band data */
    case PRU_SENDOOB:			/* send out of band data */
    case PRU_PROTORCV:			/* receive from below */
    case PRU_PROTOSEND:			/* send to below */
    case PRU_SOCKADDR:			/* fetch socket's address */
#ifdef DIAGNOSTIC
      printf("natm: PRU #%d unsupported\n", req);
#endif
      error = EOPNOTSUPP;
      break;
   
    default: panic("natm usrreq");
  }

done:
  splx(s);
  return(error);
}
Example #5
0
void
hatm_rx(struct hatm_softc *sc, u_int cid, u_int flags, struct mbuf *m0,
    u_int len)
{
	struct hevcc *vcc;
	struct atm_pseudohdr aph;
	struct mbuf *m, *m1;
	u_int vpi, vci;
	u_char *ptr;

	DBG(sc, RX, ("cid=%#x flags=%#x len=%u mbuf=%p", cid, flags, len, m0));

	vcc = sc->vccs[cid];
	if (vcc == NULL)
		goto drop;

	if (flags & HE_REGM_RBRQ_CON_CLOSED) {
		if (vcc->vflags & HE_VCC_RX_CLOSING) {
			vcc->vflags &= ~HE_VCC_RX_CLOSING;
			if (vcc->param.flags & ATMIO_FLAG_ASYNC) {
				if (!(vcc->vflags & HE_VCC_OPEN))
					hatm_vcc_closed(sc, cid);
			} else
				cv_signal(&sc->vcc_cv);
		}
		goto drop;
	}

	if (!(vcc->vflags & HE_VCC_RX_OPEN))
		goto drop;

	if (flags & HE_REGM_RBRQ_HBUF_ERROR) {
		sc->istats.hbuf_error++;
		if (vcc->chain != NULL) {
			m_freem(vcc->chain);
			vcc->chain = vcc->last = NULL;
		}
		goto drop;
	}
	if (m0 == NULL) {
		sc->istats.no_rcv_mbuf++;
		return;
	}

	if ((m0->m_len = len) == 0) {
		sc->istats.empty_hbuf++;
		m_free(m0);

	} else if (vcc->chain == NULL) {
		sc->istats.rx_seg++;
		vcc->chain = vcc->last = m0;
		vcc->last->m_next = NULL;
		vcc->chain->m_pkthdr.len = m0->m_len;
		vcc->chain->m_pkthdr.rcvif = sc->ifp;

	} else {
		sc->istats.rx_seg++;
		vcc->last->m_next = m0;
		vcc->last = m0;
		vcc->last->m_next = NULL;
		vcc->chain->m_pkthdr.len += m0->m_len;
	}

	if (!(flags & HE_REGM_RBRQ_END_PDU))
		return;

	if (flags & HE_REGM_RBRQ_CRC_ERROR) {
		if (vcc->chain)
			m_freem(vcc->chain);
		vcc->chain = vcc->last = NULL;
		sc->istats.crc_error++;
		sc->ifp->if_ierrors++;
		return;
	}
	if (flags & HE_REGM_RBRQ_LEN_ERROR) {
		if (vcc->chain)
			m_freem(vcc->chain);
		vcc->chain = vcc->last = NULL;
		sc->istats.len_error++;
		sc->ifp->if_ierrors++;
		return;
	}

#ifdef HATM_DEBUG
	if (sc->debug & DBG_DUMP) {
		struct mbuf *tmp;

		for (tmp = vcc->chain; tmp != NULL; tmp = tmp->m_next) {
			printf("mbuf %p: len=%u\n", tmp, tmp->m_len);
			for (ptr = mtod(tmp, u_char *);
			    ptr < mtod(tmp, u_char *) + tmp->m_len; ptr++)
				printf("%02x ", *ptr);
			printf("\n");
		}
	}
#endif

	if (vcc->param.aal == ATMIO_AAL_5) {
		/*
		 * Need to remove padding and the trailer. The trailer
		 * may be split accross buffers according to 2.10.1.2
		 * Assume that mbufs sizes are even (buffer sizes and cell
		 * payload sizes are) and that there are no empty mbufs.
		 */
		m = vcc->last;
		if (m->m_len == 2) {
			/* Ah, oh, only part of CRC */
			if (m == vcc->chain) {
				/* ups */
				sc->istats.short_aal5++;
				m_freem(vcc->chain);
				vcc->chain = vcc->last = NULL;
				return;
			}
			for (m1 = vcc->chain; m1->m_next != m; m1 = m1->m_next)
				;
			ptr = (u_char *)m1->m_data + m1->m_len - 4;

		} else if (m->m_len == 4) {
			/* Ah, oh, only CRC */
			if (m == vcc->chain) {
				/* ups */
				sc->istats.short_aal5++;
				m_freem(vcc->chain);
				vcc->chain = vcc->last = NULL;
				return;
			}
			for (m1 = vcc->chain; m1->m_next != m; m1 = m1->m_next)
				;
			ptr = (u_char *)m1->m_data + m1->m_len - 2;

		} else if (m->m_len >= 6) {
			ptr = (u_char *)m->m_data + m->m_len - 6;
		} else
			panic("hatm_rx: bad mbuf len %d", m->m_len);

		len = (ptr[0] << 8) + ptr[1];
		if (len > (u_int)vcc->chain->m_pkthdr.len - 4) {
			sc->istats.badlen_aal5++;
			m_freem(vcc->chain);
			vcc->chain = vcc->last = NULL;
			return;
		}
		m_adj(vcc->chain, -(vcc->chain->m_pkthdr.len - len));
	}
	m = vcc->chain;
	vcc->chain = vcc->last = NULL;

#ifdef ENABLE_BPF
	if (!(vcc->param.flags & ATMIO_FLAG_NG) &&
	    (vcc->param.aal == ATMIO_AAL_5) &&
	    (vcc->param.flags & ATM_PH_LLCSNAP))
		BPF_MTAP(sc->ifp, m);
#endif

	vpi = HE_VPI(cid);
	vci = HE_VCI(cid);

	ATM_PH_FLAGS(&aph) = vcc->param.flags & 0xff;
	ATM_PH_VPI(&aph) = vpi;
	ATM_PH_SETVCI(&aph, vci);

	sc->ifp->if_ipackets++;
	/* this is in if_atmsubr.c */
	/* sc->ifp->if_ibytes += len; */

	vcc->ibytes += len;
	vcc->ipackets++;

#if 0
	{
		struct mbuf *tmp;

		for (tmp = m; tmp != NULL; tmp = tmp->m_next) {
			printf("mbuf %p: len=%u\n", tmp, tmp->m_len);
			for (ptr = mtod(tmp, u_char *);
			    ptr < mtod(tmp, u_char *) + tmp->m_len; ptr++)
				printf("%02x ", *ptr);
			printf("\n");
		}
	}
#endif

	atm_input(sc->ifp, &aph, m, vcc->rxhand);

	return;

  drop:
	if (m0 != NULL)
		m_free(m0);
}
Example #6
0
int
main(int argc, char **argv)
{
	struct pvctxreq pvcreq;
	int s, ch;
	long bandwidth;
	char *if_name, *cp;
	int vpi = 0;
	int vci = 0;
	int joint_vpi = 0;
	int joint_vci = 0;
	int pcr = 0;
	int llcsnap = ATM_PH_LLCSNAP;
	int getinfo = 1;
	int subinterface = 0;
	int verbose = 1;

	if (argc < 2)
		usage();

	if_name = argv[1];
	if (argc > 2 && isdigit((unsigned char)argv[2][0]))
		str2vc(argv[2], &vpi, &vci);

	optind = 3;
	while ((ch = getopt(argc, argv, "p:b:j:snv")) != -1) {
		switch (ch) {
		case 'p':
			pcr = strtol(optarg, NULL, 0);
			getinfo = 0;
			break;
		case 'b':
			cp = NULL;
			bandwidth = strtol(optarg, &cp, 0);
			if (cp != NULL) {
				if (*cp == 'K' || *cp == 'k')
					bandwidth *= 1000;
				if (*cp == 'M' || *cp == 'm')
					bandwidth *= 1000000;
			}
			pcr = bandwidth / 8 / 48;
			getinfo = 0;
			break;
		case 'j':
			str2vc(optarg, &joint_vpi, &joint_vci);
			break;
		case 'n':
			llcsnap = 0;
			break;
		case 'v':
			verbose = 1;
			break;
		default:
			usage();
		}
	}

	if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
		err(1, "can't open socket");

	pvcreq.pvc_ifname[IFNAMSIZ-1] = '\0';
	strncpy(pvcreq.pvc_ifname, if_name, IFNAMSIZ-1);

	if (strncmp(if_name, "pvc", 3) == 0)
		/* pvc subinterface */
		subinterface = 1;
	
	ATM_PH_FLAGS(&pvcreq.pvc_aph) = ATM_PH_AAL5 | llcsnap;
	ATM_PH_VPI(&pvcreq.pvc_aph) = vpi;
	ATM_PH_SETVCI(&pvcreq.pvc_aph, vci);

	ATM_PH_FLAGS(&pvcreq.pvc_joint) = 0;
	ATM_PH_VPI(&pvcreq.pvc_joint) = joint_vpi;
	ATM_PH_SETVCI(&pvcreq.pvc_joint, joint_vci);
	
	pvcreq.pvc_pcr = pcr;

	if (getinfo) {
		if (ioctl(s, SIOCGPVCTX, &pvcreq) < 0)
			err(1, "SIOCSPVCTX");
	}
	else {
		if (verbose) {
		    printf("setting pvc tx: interface:%s vc:%d:%d ph=0x%x\n",
			   if_name, vpi, vci, ATM_PH_FLAGS(&pvcreq.pvc_aph));
		    printf("  joint:%d:%d, setting pcr:%d\n",
			   joint_vpi, joint_vci, pcr);
	        }

		if (ioctl(s, SIOCSPVCTX, &pvcreq) < 0)
				err(1, "SIOCSPVCTX");
	}

	pcr = pvcreq.pvc_pcr;

	/*
	 * print info
	 */
	printf("  %s", if_name);
	if (subinterface)
		printf(" (bound to %s)", pvcreq.pvc_ifname);
	printf(": vci:[%d:%d] (",
	       ATM_PH_VPI(&pvcreq.pvc_aph), ATM_PH_VCI(&pvcreq.pvc_aph));
	if (ATM_PH_FLAGS(&pvcreq.pvc_aph) & ATM_PH_AAL5)
		printf("AAL5");
	if (ATM_PH_FLAGS(&pvcreq.pvc_aph) & ATM_PH_LLCSNAP)
		printf("/LLCSNAP");
	printf(") ");
	if (pcr < 0)
		printf("(invalid)\n");
	else if (pcr == 0)
		printf("pcr:%d(full speed)\n", pcr);
	else if (pcr < 1000)
		printf("pcr:%d(%dbps)\n", pcr, pcr * 48 * 8);
	else if (pcr < 1000000)
		printf("pcr:%d(%dKbps)\n", pcr, pcr * 48 * 8 / 1000);
	else
		printf("pcr:%d(%dMbps)\n", pcr, pcr * 48 * 8 / 1000000);

	close(s);

	if (getinfo && pcr < 0) {
		fprintf(stderr, "can't get pvc info for vci:%d\n", vci);
		fprintf(stderr, "to setup a vci, use -p or -b option\n");
	}

	return (0);
}
Example #7
0
static int
natm_usr_connect(struct socket *so, struct mbuf *nam)
{
    struct natmpcb *npcb;
    struct sockaddr_natm *snatm;
    struct atm_pseudoioctl api;
    struct atm_pseudohdr *aph;
    struct ifnet *ifp;
    int error = 0;
    int s2, s = SPLSOFTNET();
    int proto = so->so_proto->pr_protocol;

    npcb = (struct natmpcb *) so->so_pcb;
    if (npcb == NULL) {
	error = EINVAL;
	goto out;
    }

    /*
     * validate nam and npcb
     */

    if (nam->m_len != sizeof(*snatm)) {
        error = EINVAL;
	goto out;
    }
    snatm = mtod(nam, struct sockaddr_natm *);
    if (snatm->snatm_len != sizeof(*snatm) ||
	(npcb->npcb_flags & NPCB_FREE) == 0) {
	error = EINVAL;
	goto out;
    }
    if (snatm->snatm_family != AF_NATM) {
	error = EAFNOSUPPORT;
	goto out;
    }

    snatm->snatm_if[IFNAMSIZ-1] = '\0';  /* XXX ensure null termination
					    since ifunit() uses strcmp */

    /*
     * convert interface string to ifp, validate.
     */

    ifp = ifunit(snatm->snatm_if);
    if (ifp == NULL || (ifp->if_flags & IFF_RUNNING) == 0) {
	error = ENXIO;
	goto out;
    }
    if (ifp->if_output != atm_output) {
	error = EAFNOSUPPORT;
	goto out;
    }

    /*
     * register us with the NATM PCB layer
     */

    if (npcb_add(npcb, ifp, snatm->snatm_vci, snatm->snatm_vpi) != npcb) {
        error = EADDRINUSE;
        goto out;
    }

    /*
     * enable rx
     */

    ATM_PH_FLAGS(&api.aph) = (proto == PROTO_NATMAAL5) ? ATM_PH_AAL5 : 0;
    ATM_PH_VPI(&api.aph) = npcb->npcb_vpi;
    ATM_PH_SETVCI(&api.aph, npcb->npcb_vci);
    api.rxhand = npcb;
    s2 = splimp();
    if (ifp->if_ioctl == NULL || 
	ifp->if_ioctl(ifp, SIOCATMENA, (caddr_t) &api) != 0) {
	splx(s2);
	npcb_free(npcb, NPCB_REMOVE);
        error = EIO;
	goto out;
    }
    splx(s2);

    soisconnected(so);

 out:
    splx(s);
    return (error);
}