{(s)->sb_mb = m->m_act; m->m_act = 0; sbfree((s), m); f;}
{ \ (s)->sb_mb = m->m_nextpkt; \ SB_EMPTY_FIXUP((s)); \ m->m_nextpkt = 0; \ sbfree((s), m); \ f; \ }
pk_rtattach(so, m0)	register struct socket *so;	struct mbuf    *m0;{	register struct pklcd *lcp = (struct pklcd *) so->so_pcb;	register struct mbuf *m = m0;	struct sockaddr *dst = mtod(m, struct sockaddr *);	register struct rtentry *rt = rtalloc1(dst, 0);	register struct llinfo_x25 *lx;	caddr_t         cp;#define ROUNDUP(a) \	((a) > 0 ? (1 + (((a) - 1) | (sizeof(long) - 1))) : sizeof(long))#define transfer_sockbuf(s, f, l) \	while ((m = (s)->sb_mb) != NULL) \		{(s)->sb_mb = m->m_act; m->m_act = 0; sbfree((s), m); f;}	if (rt)		rt->rt_refcnt--;	cp = (dst->sa_len < m->m_len) ? ROUNDUP(dst->sa_len) + (caddr_t) dst : 0;	while (rt &&	       ((cp == 0 && rt_mask(rt) != 0) ||		(cp != 0 && (rt_mask(rt) == 0 ||			 Bcmp(cp, rt_mask(rt), rt_mask(rt)->sa_len)) != 0)))		rt = (struct rtentry *) rt->rt_nodes->rn_dupedkey;	if (rt == 0 || (rt->rt_flags & RTF_GATEWAY) ||	    (lx = (struct llinfo_x25 *) rt->rt_llinfo) == 0)		return ESRCH;	if (lcp == 0)		return ENOTCONN;	switch (lcp->lcd_state) {	default:		return ENOTCONN;	case READY:		/* Detach VC from rtentry */		if (lx->lx_lcd == 0)			return ENOTCONN;		lcp->lcd_so = 0;		pk_close(lcp);		lcp = lx->lx_lcd;		if (lx->lx_list.le_next->lx_rt == rt)			x25_lxfree(lx);		lcp->lcd_so = so;		lcp->lcd_upper = 0;		lcp->lcd_upnext = 0;		transfer_sockbuf(&lcp->lcd_sb, sbappendrecord(&so->so_snd, m),				 &so->so_snd);		soisconnected(so);		return 0;	case DATA_TRANSFER:		/* Add VC to rtentry */		lcp->lcd_so = 0;		lcp->lcd_sb = so->so_snd;	/* structure copy */		bzero((caddr_t) & so->so_snd, sizeof(so->so_snd));	/* XXXXXX */		so->so_pcb = 0;		x25_rtattach(lcp, rt);		transfer_sockbuf(&so->so_rcv, x25_ifinput(m, lcp), lcp);		soisdisconnected(so);	}	return 0;}