R
raj
Hi,
I am a beginner and need help with the following:
'ifr_data' is (char *)
'args' is unsigned long args[4]
((unsigned long *)(&ifr.ifr_data))[0] = (unsigned long)args;
What does the above statement do.?
Why should we type cast args again it is already of type 'unsigned
long.'
Why do we need to pass the address of ifr_data and later dereference,
if
I understood corrctly, using [].
Cant we do something like:
(unsigned long *) ifr.ifr_data = args
COMPLETE CODE: (remember 'ifr.ifr_data' is char *)
---------------
int br_device_ioctl32(struct bridge *br, unsigned long arg0, unsigned
long arg1, unsigned long arg2, unsigned long arg3)
{
unsigned long args[4];
struct ifreq ifr;
args[0] = arg0;
args[1] = arg1;
args[2] = arg2;
args[3] = arg3;
memcpy(ifr.ifr_name, br->ifname, IFNAMSIZ);
((unsigned long *)(&ifr.ifr_data))[0] = (unsigned long)args;
return ioctl(br_socket_fd, SIOCDEVPRIVATE, &ifr);
}
I am a beginner and need help with the following:
'ifr_data' is (char *)
'args' is unsigned long args[4]
((unsigned long *)(&ifr.ifr_data))[0] = (unsigned long)args;
What does the above statement do.?
Why should we type cast args again it is already of type 'unsigned
long.'
Why do we need to pass the address of ifr_data and later dereference,
if
I understood corrctly, using [].
Cant we do something like:
(unsigned long *) ifr.ifr_data = args
COMPLETE CODE: (remember 'ifr.ifr_data' is char *)
---------------
int br_device_ioctl32(struct bridge *br, unsigned long arg0, unsigned
long arg1, unsigned long arg2, unsigned long arg3)
{
unsigned long args[4];
struct ifreq ifr;
args[0] = arg0;
args[1] = arg1;
args[2] = arg2;
args[3] = arg3;
memcpy(ifr.ifr_name, br->ifname, IFNAMSIZ);
((unsigned long *)(&ifr.ifr_data))[0] = (unsigned long)args;
return ioctl(br_socket_fd, SIOCDEVPRIVATE, &ifr);
}