All of lore.kernel.org
 help / color / mirror / Atom feed
* Network Byte order not reached reading from a sock RAW
@ 2012-10-12 16:04 Pietro Paolini
  2012-10-13  3:30 ` Mandeep Sandhu
  0 siblings, 1 reply; 7+ messages in thread
From: Pietro Paolini @ 2012-10-12 16:04 UTC (permalink / raw)
  To: kernelnewbies

Hello,

I am struggling with the byte order question on a x86_32 arch, I am doing some modifications on a program which actually works fine on a MIPS arch.

I do a reading from a RAW socket in this way:

	/* Configure socket */
        if ((fd = socket(AF_INET, SOCK_RAW, IPPROTO_IGMP)) < 0) {
                perror("Error on socket creation, exit");
                exit(1);
        }
	  ....
        if (setsockopt(fd, IPPROTO_IP, IP_PKTINFO, (void *)&va, sizeof(va))) {
                perror("Error on setsockopt, exit");
                exit(1);
        }
        va = 0;
	....
	....
	struct msghdr mhdr;
	struct __in_pktinfo *pktinfo = NULL;
	...
	...
	nrd = recvmsg(env->mrouter_fd, &mhdr, 0);	
	...
	ip = (struct iphdr *)iov.iov_base;

When I print the saddr (or daddr) of the received ip packet it is printed as host byte order instead of what I am expecting, the network byte order. I can just use the htonl() family functions for solve the problem but I would like understand if it is the normal behavior or if there is an issues on my code, or if the device driver of my NIC can influence the question.
Many thanks,
Pietro.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2012-10-17  5:18 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-12 16:04 Network Byte order not reached reading from a sock RAW Pietro Paolini
2012-10-13  3:30 ` Mandeep Sandhu
2012-10-15  7:46   ` Pietro Paolini
2012-10-15  8:28     ` Kumar amit mehta
2012-10-15  8:32     ` Mandeep Sandhu
2012-10-16 13:12       ` Pietro Paolini
2012-10-17  5:18         ` Mandeep Sandhu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.