struct sock->inet_sock convert question

hu jun duanshuidao at hotmail.com
Thu Feb 2 07:44:00 EST 2012


in kernel linux-2.6.16.60-0.54.5  code:
static int inet_create(struct socket *sock, int protocol){struct sock *sk;struct inet_sock *inet;....
sk = sk_alloc(PF_INET, GFP_KERNEL, answer_prot, 1);	if (sk == NULL)		goto out;
inet = inet_sk(sk);inet->is_icsk = (INET_PROTOSW_ICSK & answer_flags) == INET_PROTOSW_ICSK;
	if (SOCK_RAW == sock->type) {		inet->num = protocol;		if (IPPROTO_RAW == protocol)			inet->hdrincl = 1;	}
	if (ipv4_config.no_pmtu_disc)		inet->pmtudisc = IP_PMTUDISC_DONT;	else		inet->pmtudisc = IP_PMTUDISC_WANT;
	inet->id = 0;....}
my question is in the red line ,  why can convert  like that?
thanks! 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20120202/acddbb43/attachment.html 


More information about the Kernelnewbies mailing list