This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Still need help - issue unresolved.


Hello,
Please bear with me here. My last posting about the ioctl() and gdb
seems to have misled a lot of people, maybe, I did not word it
correctly.
So at the expense of redundancy, let me state the problem again.

I am trying to port an application from UNIX to NT.
One of the things that needs to be done is to get the IP address of the
network interface depending on which one is up.
To do this, the following call is used:
	
	ioctl(fd, SIOCGIFFLAGS, (char*)&ifr);

	fd ----> socket handle
	ifr ---> is a struct:   struct ifr { 
				    union
				    {
				     char ifrn_name[16];
				     }
				     union
				     {
				       struct sockaddr interfc_addr;
				       struct sockaddr interfc_brodaddr;
				       struct sockaddr interfc_netmask;
				       short  interfc_flags;
				       int interfc_metric;
				       int interfc_mtu;
				     } 
				}
The value of the flags is interpreted (very simply) as follows:
	  0x34 - interface down
	  0x99 - interface up

The call gets the value of the interface flags in the member
"interfc_flags". The value that it should return is 0x99 (which it does
inside the gdb) but the value that it returns outside is 0x34.
I printed the value in ifr byte by byte to see what gdb put inside but
the values were totally random.
So when I cleared the struct ifr to contain all zeroes, the program
began to return 0x34 (the wrong flags) inside the gdb as well.
Which is strange ! 
So what I did was find out the random values that ifr (in the gdb)
and copied them bytewise into ifr.
So the program now returns 0x99 in both the places !! ??
I am lost. This behaviour is inexplicable.
Can someone please help me out ?
Thank you for your time.


Regards,
Ashish

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]