kernels/linux-2.4.0/drivers/net/pppoe.c
/***********************************************************************
 *
 * Initialize a new struct sock.
 *
 **********************************************************************/
Initialize a new struct sock.
Initialize a new struct sock .
static int pppoe_create(struct socket *sock)
{
	int error = 0;
	struct sock *sk;
	MOD_INC_USE_COUNT;
	sk = sk_alloc(PF_PPPOX, GFP_KERNEL, 1);
	if (!sk)
		return -ENOMEM;
	sock_init_data(sock, sk);
	sock->state = SS_UNCONNECTED;
	sock->ops   = &pppoe_ops;
	sk->protocol = PX_PROTO_OE;
	sk->family = PF_PPPOX;
	sk->backlog_rcv = pppoe_backlog_rcv;
	sk->next = NULL;
	sk->pprev = NULL;
	sk->state = PPPOX_NONE;
	sk->type = SOCK_STREAM;
	sk->destruct = pppoe_sock_destruct;
	sk->protinfo.pppox = kmalloc(sizeof(struct pppox_opt), GFP_KERNEL);
	if (!sk->protinfo.pppox) {
		error = -ENOMEM;
		goto free_sk;
	}
	memset((void *) sk->protinfo.pppox, 0, sizeof(struct pppox_opt));
	sk->protinfo.pppox->sk = sk;
	sk->protinfo.destruct_hook = sk->protinfo.pppox;
	sock->sk = sk;
	return 0;
free_sk:
	sk_free(sk);
	return error;
}
static int pppoe_create ( struct socket * sock ) { int error = 0 ; struct sock * sk ; MOD_INC_USE_COUNT ; sk = sk_alloc ( PF_PPPOX , GFP_KERNEL , 1 ) ; if ( ! sk ) return - ENOMEM ; sock_init_data ( sock , sk ) ; sock -> state = SS_UNCONNECTED ; sock -> ops = & pppoe_ops ; sk -> protocol = PX_PROTO_OE ; sk -> family = PF_PPPOX ; sk -> backlog_rcv = pppoe_backlog_rcv ; sk -> next = NULL ; sk -> pprev = NULL ; sk -> state = PPPOX_NONE ; sk -> type = SOCK_STREAM ; sk -> destruct = pppoe_sock_destruct ; sk -> protinfo . pppox = kmalloc ( sizeof ( struct pppox_opt ) , GFP_KERNEL ) ; if ( ! sk -> protinfo . pppox ) { error = - ENOMEM ; goto free_sk ; } memset ( ( void * ) sk -> protinfo . pppox , 0 , sizeof ( struct pppox_opt ) ) ; sk -> protinfo . pppox -> sk = sk ; sk -> protinfo . destruct_hook = sk -> protinfo . pppox ; sock -> sk = sk ; return 0 ; free_sk : sk_free ( sk ) ; return error ; }
Initialize a new struct sock.
Initialize a new struct sock .
/* Delete the protinfo when it is time to do so. */