kernels/linux-2.4.0/drivers/net/ppp_generic.c
/*
 * Connect a PPP channel to a PPP interface unit.
 */
Connect a PPP channel to a PPP interface unit.
Connect a PPP channel to a PPP interface unit .
static int
ppp_connect_channel(struct channel *pch, int unit)
{
	struct ppp *ppp;
	int ret = -ENXIO;
	int hdrlen;
	spin_lock(&all_ppp_lock);
	ppp = ppp_find_unit(unit);
	if (ppp == 0)
		goto out;
	write_lock_bh(&pch->upl);
	ret = -EINVAL;
	if (pch->ppp != 0)
		goto outw;
	ppp_lock(ppp);
	spin_lock_bh(&pch->downl);
	if (pch->chan == 0)		
		goto outr;
	if (pch->file.hdrlen > ppp->file.hdrlen)
		ppp->file.hdrlen = pch->file.hdrlen;
	hdrlen = pch->file.hdrlen + 2;	
	if (ppp->dev && hdrlen > ppp->dev->hard_header_len)
		ppp->dev->hard_header_len = hdrlen;
	list_add_tail(&pch->clist, &ppp->channels);
	++ppp->n_channels;
	pch->ppp = ppp;
	ret = 0;
 outr:
	spin_unlock_bh(&pch->downl);
	ppp_unlock(ppp);
 outw:
	write_unlock_bh(&pch->upl);
 out:
	spin_unlock(&all_ppp_lock);
	return ret;
}
static int ppp_connect_channel ( struct channel * pch , int unit ) { struct ppp * ppp ; int ret = - ENXIO ; int hdrlen ; spin_lock ( & all_ppp_lock ) ; ppp = ppp_find_unit ( unit ) ; if ( ppp == 0 ) goto out ; write_lock_bh ( & pch -> upl ) ; ret = - EINVAL ; if ( pch -> ppp != 0 ) goto outw ; ppp_lock ( ppp ) ; spin_lock_bh ( & pch -> downl ) ; if ( pch -> chan == 0 ) goto outr ; if ( pch -> file . hdrlen > ppp -> file . hdrlen ) ppp -> file . hdrlen = pch -> file . hdrlen ; hdrlen = pch -> file . hdrlen + 2 ; if ( ppp -> dev && hdrlen > ppp -> dev -> hard_header_len ) ppp -> dev -> hard_header_len = hdrlen ; list_add_tail ( & pch -> clist , & ppp -> channels ) ; ++ ppp -> n_channels ; pch -> ppp = ppp ; ret = 0 ; outr : spin_unlock_bh ( & pch -> downl ) ; ppp_unlock ( ppp ) ; outw : write_unlock_bh ( & pch -> upl ) ; out : spin_unlock ( & all_ppp_lock ) ; return ret ; }
Connect a PPP channel to a PPP interface unit.
Connect a PPP channel to a PPP interface unit .
/* need to check this?? */ /* for protocol bytes */