Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Easy Problem with ioctl

122 views
Skip to first unread message

Orome

unread,
Apr 27, 2011, 11:11:05 AM4/27/11
to
Hi Guys,

I use VxWorks 6.8, my problem: I want to utilize the ioctl()-function
with a socket, so I can make an invocation of the network driver ioctl-
function. But the ioctl-function always returned -1.

Please help me.

Thank you in advance Orome.

Here is the code:

char * add;
*add = 0;
int sock = socket(AF_INET,SOCK_DGRAM,0);
int test = ioctl(sock,EIOCGADDR, add);


Jeremy

unread,
Apr 28, 2011, 6:08:50 AM4/28/11
to
Orome <andreas....@fh-landshut.de> wrote:
> Hi Guys,

> I use VxWorks 6.8, my problem: I want to utilize the ioctl()-function
> with a socket, so I can make an invocation of the network driver ioctl-
> function. But the ioctl-function always returned -1.

> Please help me.

> Thank you in advance Orome.

> Here is the code:

> char * add;
> *add = 0;

The value of add hasn't been initialized, so this assignment may be attempting to write
to an address that is invalid for the RTP or kernel. That may or may not corrupt something,
leading to unexpected behavior.

> int sock = socket(AF_INET,SOCK_DGRAM,0);
> int test = ioctl(sock,EIOCGADDR, add);

vxWorks may be detecting that the value of add isn't valid, or it may be indicating another
error. Check the value of errno.

I suspect what you want is closer to:

int add = 0;
int sock = socket(AF_INET,SOCK_DGRAM,0);
int test = ioctl(sock,EIOCGADDR, &add);
if (test == -1) {
switch(errno) {
case EINVAL:
...

Happy to help,
Jeremy

0 new messages