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);
> 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