[NET] core: whitespace cleanup

Fix whitespace around keywords. Fix indentation especially of switch
statements.

Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Stephen Hemminger 2007-04-10 20:10:33 -07:00 committed by David S. Miller
parent add459aa1a
commit e71a4783aa
7 changed files with 543 additions and 548 deletions

View file

@ -34,11 +34,11 @@ static inline int iov_from_user_compat_to_kern(struct iovec *kiov,
{ {
int tot_len = 0; int tot_len = 0;
while(niov > 0) { while (niov > 0) {
compat_uptr_t buf; compat_uptr_t buf;
compat_size_t len; compat_size_t len;
if(get_user(len, &uiov32->iov_len) || if (get_user(len, &uiov32->iov_len) ||
get_user(buf, &uiov32->iov_base)) { get_user(buf, &uiov32->iov_base)) {
tot_len = -EFAULT; tot_len = -EFAULT;
break; break;
@ -78,12 +78,12 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
{ {
int tot_len; int tot_len;
if(kern_msg->msg_namelen) { if (kern_msg->msg_namelen) {
if(mode==VERIFY_READ) { if (mode==VERIFY_READ) {
int err = move_addr_to_kernel(kern_msg->msg_name, int err = move_addr_to_kernel(kern_msg->msg_name,
kern_msg->msg_namelen, kern_msg->msg_namelen,
kern_address); kern_address);
if(err < 0) if (err < 0)
return err; return err;
} }
kern_msg->msg_name = kern_address; kern_msg->msg_name = kern_address;
@ -93,7 +93,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
tot_len = iov_from_user_compat_to_kern(kern_iov, tot_len = iov_from_user_compat_to_kern(kern_iov,
(struct compat_iovec __user *)kern_msg->msg_iov, (struct compat_iovec __user *)kern_msg->msg_iov,
kern_msg->msg_iovlen); kern_msg->msg_iovlen);
if(tot_len >= 0) if (tot_len >= 0)
kern_msg->msg_iov = kern_iov; kern_msg->msg_iov = kern_iov;
return tot_len; return tot_len;
@ -146,8 +146,8 @@ int cmsghdr_from_user_compat_to_kern(struct msghdr *kmsg, struct sock *sk,
kcmlen = 0; kcmlen = 0;
kcmsg_base = kcmsg = (struct cmsghdr *)stackbuf; kcmsg_base = kcmsg = (struct cmsghdr *)stackbuf;
ucmsg = CMSG_COMPAT_FIRSTHDR(kmsg); ucmsg = CMSG_COMPAT_FIRSTHDR(kmsg);
while(ucmsg != NULL) { while (ucmsg != NULL) {
if(get_user(ucmlen, &ucmsg->cmsg_len)) if (get_user(ucmlen, &ucmsg->cmsg_len))
return -EFAULT; return -EFAULT;
/* Catch bogons. */ /* Catch bogons. */
@ -160,7 +160,7 @@ int cmsghdr_from_user_compat_to_kern(struct msghdr *kmsg, struct sock *sk,
kcmlen += tmp; kcmlen += tmp;
ucmsg = cmsg_compat_nxthdr(kmsg, ucmsg, ucmlen); ucmsg = cmsg_compat_nxthdr(kmsg, ucmsg, ucmlen);
} }
if(kcmlen == 0) if (kcmlen == 0)
return -EINVAL; return -EINVAL;
/* The kcmlen holds the 64-bit version of the control length. /* The kcmlen holds the 64-bit version of the control length.
@ -176,7 +176,7 @@ int cmsghdr_from_user_compat_to_kern(struct msghdr *kmsg, struct sock *sk,
/* Now copy them over neatly. */ /* Now copy them over neatly. */
memset(kcmsg, 0, kcmlen); memset(kcmsg, 0, kcmlen);
ucmsg = CMSG_COMPAT_FIRSTHDR(kmsg); ucmsg = CMSG_COMPAT_FIRSTHDR(kmsg);
while(ucmsg != NULL) { while (ucmsg != NULL) {
if (__get_user(ucmlen, &ucmsg->cmsg_len)) if (__get_user(ucmlen, &ucmsg->cmsg_len))
goto Efault; goto Efault;
if (!CMSG_COMPAT_OK(ucmlen, ucmsg, kmsg)) if (!CMSG_COMPAT_OK(ucmlen, ucmsg, kmsg))
@ -219,7 +219,7 @@ int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *dat
struct compat_cmsghdr cmhdr; struct compat_cmsghdr cmhdr;
int cmlen; int cmlen;
if(cm == NULL || kmsg->msg_controllen < sizeof(*cm)) { if (cm == NULL || kmsg->msg_controllen < sizeof(*cm)) {
kmsg->msg_flags |= MSG_CTRUNC; kmsg->msg_flags |= MSG_CTRUNC;
return 0; /* XXX: return error? check spec. */ return 0; /* XXX: return error? check spec. */
} }
@ -233,7 +233,7 @@ int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *dat
} }
cmlen = CMSG_COMPAT_LEN(len); cmlen = CMSG_COMPAT_LEN(len);
if(kmsg->msg_controllen < cmlen) { if (kmsg->msg_controllen < cmlen) {
kmsg->msg_flags |= MSG_CTRUNC; kmsg->msg_flags |= MSG_CTRUNC;
cmlen = kmsg->msg_controllen; cmlen = kmsg->msg_controllen;
} }
@ -241,9 +241,9 @@ int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *dat
cmhdr.cmsg_type = type; cmhdr.cmsg_type = type;
cmhdr.cmsg_len = cmlen; cmhdr.cmsg_len = cmlen;
if(copy_to_user(cm, &cmhdr, sizeof cmhdr)) if (copy_to_user(cm, &cmhdr, sizeof cmhdr))
return -EFAULT; return -EFAULT;
if(copy_to_user(CMSG_COMPAT_DATA(cm), data, cmlen - sizeof(struct compat_cmsghdr))) if (copy_to_user(CMSG_COMPAT_DATA(cm), data, cmlen - sizeof(struct compat_cmsghdr)))
return -EFAULT; return -EFAULT;
cmlen = CMSG_COMPAT_SPACE(len); cmlen = CMSG_COMPAT_SPACE(len);
kmsg->msg_control += cmlen; kmsg->msg_control += cmlen;
@ -646,7 +646,7 @@ asmlinkage long compat_sys_socketcall(int call, u32 __user *args)
a0 = a[0]; a0 = a[0];
a1 = a[1]; a1 = a[1];
switch(call) { switch (call) {
case SYS_SOCKET: case SYS_SOCKET:
ret = sys_socket(a0, a1, a[2]); ret = sys_socket(a0, a1, a[2]);
break; break;

View file

@ -836,7 +836,7 @@ int dev_ethtool(struct ifreq *ifr)
return -EPERM; return -EPERM;
} }
if(dev->ethtool_ops->begin) if (dev->ethtool_ops->begin)
if ((rc = dev->ethtool_ops->begin(dev)) < 0) if ((rc = dev->ethtool_ops->begin(dev)) < 0)
return rc; return rc;
@ -952,7 +952,7 @@ int dev_ethtool(struct ifreq *ifr)
rc = -EOPNOTSUPP; rc = -EOPNOTSUPP;
} }
if(dev->ethtool_ops->complete) if (dev->ethtool_ops->complete)
dev->ethtool_ops->complete(dev); dev->ethtool_ops->complete(dev);
if (old_features != dev->features) if (old_features != dev->features)

View file

@ -352,8 +352,8 @@ static ssize_t wireless_show(struct device *d, char *buf,
read_lock(&dev_base_lock); read_lock(&dev_base_lock);
if (dev_isalive(dev)) { if (dev_isalive(dev)) {
if(dev->wireless_handlers && if (dev->wireless_handlers &&
dev->wireless_handlers->get_wireless_stats) dev->wireless_handlers->get_wireless_stats)
iw = dev->wireless_handlers->get_wireless_stats(dev); iw = dev->wireless_handlers->get_wireless_stats(dev);
if (iw != NULL) if (iw != NULL)
ret = (*format)(iw, buf); ret = (*format)(iw, buf);

View file

@ -645,7 +645,7 @@ static int pktgen_if_show(struct seq_file *seq, void *v)
if (pkt_dev->nr_labels) { if (pkt_dev->nr_labels) {
unsigned i; unsigned i;
seq_printf(seq, " mpls: "); seq_printf(seq, " mpls: ");
for(i = 0; i < pkt_dev->nr_labels; i++) for (i = 0; i < pkt_dev->nr_labels; i++)
seq_printf(seq, "%08x%s", ntohl(pkt_dev->labels[i]), seq_printf(seq, "%08x%s", ntohl(pkt_dev->labels[i]),
i == pkt_dev->nr_labels-1 ? "\n" : ", "); i == pkt_dev->nr_labels-1 ? "\n" : ", ");
} }
@ -750,7 +750,7 @@ static int hex32_arg(const char __user *user_buffer, unsigned long maxlen, __u32
int i = 0; int i = 0;
*num = 0; *num = 0;
for(; i < maxlen; i++) { for (; i < maxlen; i++) {
char c; char c;
*num <<= 4; *num <<= 4;
if (get_user(c, &user_buffer[i])) if (get_user(c, &user_buffer[i]))
@ -858,7 +858,7 @@ static ssize_t get_labels(const char __user *buffer, struct pktgen_dev *pkt_dev)
n++; n++;
if (n >= MAX_MPLS_LABELS) if (n >= MAX_MPLS_LABELS)
return -E2BIG; return -E2BIG;
} while(c == ','); } while (c == ',');
pkt_dev->nr_labels = n; pkt_dev->nr_labels = n;
return i; return i;
@ -1487,7 +1487,7 @@ static ssize_t pktgen_if_write(struct file *file,
if (len < 0) { return len; } if (len < 0) { return len; }
i += len; i += len;
offset = sprintf(pg_result, "OK: mpls="); offset = sprintf(pg_result, "OK: mpls=");
for(n = 0; n < pkt_dev->nr_labels; n++) for (n = 0; n < pkt_dev->nr_labels; n++)
offset += sprintf(pg_result + offset, offset += sprintf(pg_result + offset,
"%08x%s", ntohl(pkt_dev->labels[n]), "%08x%s", ntohl(pkt_dev->labels[n]),
n == pkt_dev->nr_labels-1 ? "" : ","); n == pkt_dev->nr_labels-1 ? "" : ",");
@ -2148,7 +2148,7 @@ static void mod_cur_headers(struct pktgen_dev *pkt_dev)
if (pkt_dev->flags & F_MPLS_RND) { if (pkt_dev->flags & F_MPLS_RND) {
unsigned i; unsigned i;
for(i = 0; i < pkt_dev->nr_labels; i++) for (i = 0; i < pkt_dev->nr_labels; i++)
if (pkt_dev->labels[i] & MPLS_STACK_BOTTOM) if (pkt_dev->labels[i] & MPLS_STACK_BOTTOM)
pkt_dev->labels[i] = MPLS_STACK_BOTTOM | pkt_dev->labels[i] = MPLS_STACK_BOTTOM |
((__force __be32)random32() & ((__force __be32)random32() &
@ -2281,7 +2281,7 @@ static void mod_cur_headers(struct pktgen_dev *pkt_dev)
static void mpls_push(__be32 *mpls, struct pktgen_dev *pkt_dev) static void mpls_push(__be32 *mpls, struct pktgen_dev *pkt_dev)
{ {
unsigned i; unsigned i;
for(i = 0; i < pkt_dev->nr_labels; i++) { for (i = 0; i < pkt_dev->nr_labels; i++) {
*mpls++ = pkt_dev->labels[i] & ~MPLS_STACK_BOTTOM; *mpls++ = pkt_dev->labels[i] & ~MPLS_STACK_BOTTOM;
} }
mpls--; mpls--;
@ -2341,7 +2341,7 @@ static struct sk_buff *fill_packet_ipv4(struct net_device *odev,
mpls_push(mpls, pkt_dev); mpls_push(mpls, pkt_dev);
if (pkt_dev->vlan_id != 0xffff) { if (pkt_dev->vlan_id != 0xffff) {
if(pkt_dev->svlan_id != 0xffff) { if (pkt_dev->svlan_id != 0xffff) {
svlan_tci = (__be16 *)skb_put(skb, sizeof(__be16)); svlan_tci = (__be16 *)skb_put(skb, sizeof(__be16));
*svlan_tci = build_tci(pkt_dev->svlan_id, *svlan_tci = build_tci(pkt_dev->svlan_id,
pkt_dev->svlan_cfi, pkt_dev->svlan_cfi,
@ -2677,7 +2677,7 @@ static struct sk_buff *fill_packet_ipv6(struct net_device *odev,
mpls_push(mpls, pkt_dev); mpls_push(mpls, pkt_dev);
if (pkt_dev->vlan_id != 0xffff) { if (pkt_dev->vlan_id != 0xffff) {
if(pkt_dev->svlan_id != 0xffff) { if (pkt_dev->svlan_id != 0xffff) {
svlan_tci = (__be16 *)skb_put(skb, sizeof(__be16)); svlan_tci = (__be16 *)skb_put(skb, sizeof(__be16));
*svlan_tci = build_tci(pkt_dev->svlan_id, *svlan_tci = build_tci(pkt_dev->svlan_id,
pkt_dev->svlan_cfi, pkt_dev->svlan_cfi,

View file

@ -361,8 +361,8 @@ int sock_setsockopt(struct socket *sock, int level, int optname,
} }
#endif #endif
if(optlen<sizeof(int)) if (optlen < sizeof(int))
return(-EINVAL); return -EINVAL;
if (get_user(val, (int __user *)optval)) if (get_user(val, (int __user *)optval))
return -EFAULT; return -EFAULT;
@ -371,265 +371,263 @@ int sock_setsockopt(struct socket *sock, int level, int optname,
lock_sock(sk); lock_sock(sk);
switch(optname) switch(optname) {
{ case SO_DEBUG:
case SO_DEBUG: if (val && !capable(CAP_NET_ADMIN)) {
if(val && !capable(CAP_NET_ADMIN)) ret = -EACCES;
{ }
ret = -EACCES; else if (valbool)
} sock_set_flag(sk, SOCK_DBG);
else if (valbool) else
sock_set_flag(sk, SOCK_DBG); sock_reset_flag(sk, SOCK_DBG);
else break;
sock_reset_flag(sk, SOCK_DBG); case SO_REUSEADDR:
break; sk->sk_reuse = valbool;
case SO_REUSEADDR: break;
sk->sk_reuse = valbool; case SO_TYPE:
break; case SO_ERROR:
case SO_TYPE: ret = -ENOPROTOOPT;
case SO_ERROR: break;
ret = -ENOPROTOOPT; case SO_DONTROUTE:
break; if (valbool)
case SO_DONTROUTE: sock_set_flag(sk, SOCK_LOCALROUTE);
if (valbool) else
sock_set_flag(sk, SOCK_LOCALROUTE); sock_reset_flag(sk, SOCK_LOCALROUTE);
else break;
sock_reset_flag(sk, SOCK_LOCALROUTE); case SO_BROADCAST:
break; sock_valbool_flag(sk, SOCK_BROADCAST, valbool);
case SO_BROADCAST: break;
sock_valbool_flag(sk, SOCK_BROADCAST, valbool); case SO_SNDBUF:
break; /* Don't error on this BSD doesn't and if you think
case SO_SNDBUF: about it this is right. Otherwise apps have to
/* Don't error on this BSD doesn't and if you think play 'guess the biggest size' games. RCVBUF/SNDBUF
about it this is right. Otherwise apps have to are treated in BSD as hints */
play 'guess the biggest size' games. RCVBUF/SNDBUF
are treated in BSD as hints */
if (val > sysctl_wmem_max) if (val > sysctl_wmem_max)
val = sysctl_wmem_max; val = sysctl_wmem_max;
set_sndbuf: set_sndbuf:
sk->sk_userlocks |= SOCK_SNDBUF_LOCK; sk->sk_userlocks |= SOCK_SNDBUF_LOCK;
if ((val * 2) < SOCK_MIN_SNDBUF) if ((val * 2) < SOCK_MIN_SNDBUF)
sk->sk_sndbuf = SOCK_MIN_SNDBUF; sk->sk_sndbuf = SOCK_MIN_SNDBUF;
else else
sk->sk_sndbuf = val * 2; sk->sk_sndbuf = val * 2;
/* /*
* Wake up sending tasks if we * Wake up sending tasks if we
* upped the value. * upped the value.
*/ */
sk->sk_write_space(sk); sk->sk_write_space(sk);
break; break;
case SO_SNDBUFFORCE: case SO_SNDBUFFORCE:
if (!capable(CAP_NET_ADMIN)) { if (!capable(CAP_NET_ADMIN)) {
ret = -EPERM; ret = -EPERM;
break;
}
goto set_sndbuf;
case SO_RCVBUF:
/* Don't error on this BSD doesn't and if you think
about it this is right. Otherwise apps have to
play 'guess the biggest size' games. RCVBUF/SNDBUF
are treated in BSD as hints */
if (val > sysctl_rmem_max)
val = sysctl_rmem_max;
set_rcvbuf:
sk->sk_userlocks |= SOCK_RCVBUF_LOCK;
/*
* We double it on the way in to account for
* "struct sk_buff" etc. overhead. Applications
* assume that the SO_RCVBUF setting they make will
* allow that much actual data to be received on that
* socket.
*
* Applications are unaware that "struct sk_buff" and
* other overheads allocate from the receive buffer
* during socket buffer allocation.
*
* And after considering the possible alternatives,
* returning the value we actually used in getsockopt
* is the most desirable behavior.
*/
if ((val * 2) < SOCK_MIN_RCVBUF)
sk->sk_rcvbuf = SOCK_MIN_RCVBUF;
else
sk->sk_rcvbuf = val * 2;
break;
case SO_RCVBUFFORCE:
if (!capable(CAP_NET_ADMIN)) {
ret = -EPERM;
break;
}
goto set_rcvbuf;
case SO_KEEPALIVE:
#ifdef CONFIG_INET
if (sk->sk_protocol == IPPROTO_TCP)
tcp_set_keepalive(sk, valbool);
#endif
sock_valbool_flag(sk, SOCK_KEEPOPEN, valbool);
break;
case SO_OOBINLINE:
sock_valbool_flag(sk, SOCK_URGINLINE, valbool);
break;
case SO_NO_CHECK:
sk->sk_no_check = valbool;
break;
case SO_PRIORITY:
if ((val >= 0 && val <= 6) || capable(CAP_NET_ADMIN))
sk->sk_priority = val;
else
ret = -EPERM;
break;
case SO_LINGER:
if(optlen<sizeof(ling)) {
ret = -EINVAL; /* 1003.1g */
break;
}
if (copy_from_user(&ling,optval,sizeof(ling))) {
ret = -EFAULT;
break;
}
if (!ling.l_onoff)
sock_reset_flag(sk, SOCK_LINGER);
else {
#if (BITS_PER_LONG == 32)
if ((unsigned int)ling.l_linger >= MAX_SCHEDULE_TIMEOUT/HZ)
sk->sk_lingertime = MAX_SCHEDULE_TIMEOUT;
else
#endif
sk->sk_lingertime = (unsigned int)ling.l_linger * HZ;
sock_set_flag(sk, SOCK_LINGER);
}
break;
case SO_BSDCOMPAT:
sock_warn_obsolete_bsdism("setsockopt");
break;
case SO_PASSCRED:
if (valbool)
set_bit(SOCK_PASSCRED, &sock->flags);
else
clear_bit(SOCK_PASSCRED, &sock->flags);
break;
case SO_TIMESTAMP:
if (valbool) {
sock_set_flag(sk, SOCK_RCVTSTAMP);
sock_enable_timestamp(sk);
} else
sock_reset_flag(sk, SOCK_RCVTSTAMP);
break;
case SO_RCVLOWAT:
if (val < 0)
val = INT_MAX;
sk->sk_rcvlowat = val ? : 1;
break;
case SO_RCVTIMEO:
ret = sock_set_timeout(&sk->sk_rcvtimeo, optval, optlen);
break;
case SO_SNDTIMEO:
ret = sock_set_timeout(&sk->sk_sndtimeo, optval, optlen);
break;
#ifdef CONFIG_NETDEVICES
case SO_BINDTODEVICE:
{
char devname[IFNAMSIZ];
/* Sorry... */
if (!capable(CAP_NET_RAW)) {
ret = -EPERM;
break;
}
/* Bind this socket to a particular device like "eth0",
* as specified in the passed interface name. If the
* name is "" or the option length is zero the socket
* is not bound.
*/
if (!valbool) {
sk->sk_bound_dev_if = 0;
} else {
if (optlen > IFNAMSIZ - 1)
optlen = IFNAMSIZ - 1;
memset(devname, 0, sizeof(devname));
if (copy_from_user(devname, optval, optlen)) {
ret = -EFAULT;
break;
}
/* Remove any cached route for this socket. */
sk_dst_reset(sk);
if (devname[0] == '\0') {
sk->sk_bound_dev_if = 0;
} else {
struct net_device *dev = dev_get_by_name(devname);
if (!dev) {
ret = -ENODEV;
break;
}
sk->sk_bound_dev_if = dev->ifindex;
dev_put(dev);
}
}
break; break;
} }
goto set_sndbuf;
case SO_RCVBUF:
/* Don't error on this BSD doesn't and if you think
about it this is right. Otherwise apps have to
play 'guess the biggest size' games. RCVBUF/SNDBUF
are treated in BSD as hints */
if (val > sysctl_rmem_max)
val = sysctl_rmem_max;
set_rcvbuf:
sk->sk_userlocks |= SOCK_RCVBUF_LOCK;
/*
* We double it on the way in to account for
* "struct sk_buff" etc. overhead. Applications
* assume that the SO_RCVBUF setting they make will
* allow that much actual data to be received on that
* socket.
*
* Applications are unaware that "struct sk_buff" and
* other overheads allocate from the receive buffer
* during socket buffer allocation.
*
* And after considering the possible alternatives,
* returning the value we actually used in getsockopt
* is the most desirable behavior.
*/
if ((val * 2) < SOCK_MIN_RCVBUF)
sk->sk_rcvbuf = SOCK_MIN_RCVBUF;
else
sk->sk_rcvbuf = val * 2;
break;
case SO_RCVBUFFORCE:
if (!capable(CAP_NET_ADMIN)) {
ret = -EPERM;
break;
}
goto set_rcvbuf;
case SO_KEEPALIVE:
#ifdef CONFIG_INET
if (sk->sk_protocol == IPPROTO_TCP)
tcp_set_keepalive(sk, valbool);
#endif
sock_valbool_flag(sk, SOCK_KEEPOPEN, valbool);
break;
case SO_OOBINLINE:
sock_valbool_flag(sk, SOCK_URGINLINE, valbool);
break;
case SO_NO_CHECK:
sk->sk_no_check = valbool;
break;
case SO_PRIORITY:
if ((val >= 0 && val <= 6) || capable(CAP_NET_ADMIN))
sk->sk_priority = val;
else
ret = -EPERM;
break;
case SO_LINGER:
if (optlen < sizeof(ling)) {
ret = -EINVAL; /* 1003.1g */
break;
}
if (copy_from_user(&ling,optval,sizeof(ling))) {
ret = -EFAULT;
break;
}
if (!ling.l_onoff)
sock_reset_flag(sk, SOCK_LINGER);
else {
#if (BITS_PER_LONG == 32)
if ((unsigned int)ling.l_linger >= MAX_SCHEDULE_TIMEOUT/HZ)
sk->sk_lingertime = MAX_SCHEDULE_TIMEOUT;
else
#endif
sk->sk_lingertime = (unsigned int)ling.l_linger * HZ;
sock_set_flag(sk, SOCK_LINGER);
}
break;
case SO_BSDCOMPAT:
sock_warn_obsolete_bsdism("setsockopt");
break;
case SO_PASSCRED:
if (valbool)
set_bit(SOCK_PASSCRED, &sock->flags);
else
clear_bit(SOCK_PASSCRED, &sock->flags);
break;
case SO_TIMESTAMP:
if (valbool) {
sock_set_flag(sk, SOCK_RCVTSTAMP);
sock_enable_timestamp(sk);
} else
sock_reset_flag(sk, SOCK_RCVTSTAMP);
break;
case SO_RCVLOWAT:
if (val < 0)
val = INT_MAX;
sk->sk_rcvlowat = val ? : 1;
break;
case SO_RCVTIMEO:
ret = sock_set_timeout(&sk->sk_rcvtimeo, optval, optlen);
break;
case SO_SNDTIMEO:
ret = sock_set_timeout(&sk->sk_sndtimeo, optval, optlen);
break;
#ifdef CONFIG_NETDEVICES
case SO_BINDTODEVICE:
{
char devname[IFNAMSIZ];
/* Sorry... */
if (!capable(CAP_NET_RAW)) {
ret = -EPERM;
break;
}
/* Bind this socket to a particular device like "eth0",
* as specified in the passed interface name. If the
* name is "" or the option length is zero the socket
* is not bound.
*/
if (!valbool) {
sk->sk_bound_dev_if = 0;
} else {
if (optlen > IFNAMSIZ - 1)
optlen = IFNAMSIZ - 1;
memset(devname, 0, sizeof(devname));
if (copy_from_user(devname, optval, optlen)) {
ret = -EFAULT;
break;
}
/* Remove any cached route for this socket. */
sk_dst_reset(sk);
if (devname[0] == '\0') {
sk->sk_bound_dev_if = 0;
} else {
struct net_device *dev = dev_get_by_name(devname);
if (!dev) {
ret = -ENODEV;
break;
}
sk->sk_bound_dev_if = dev->ifindex;
dev_put(dev);
}
}
break;
}
#endif #endif
case SO_ATTACH_FILTER: case SO_ATTACH_FILTER:
ret = -EINVAL; ret = -EINVAL;
if (optlen == sizeof(struct sock_fprog)) { if (optlen == sizeof(struct sock_fprog)) {
struct sock_fprog fprog; struct sock_fprog fprog;
ret = -EFAULT; ret = -EFAULT;
if (copy_from_user(&fprog, optval, sizeof(fprog))) if (copy_from_user(&fprog, optval, sizeof(fprog)))
break;
ret = sk_attach_filter(&fprog, sk);
}
break;
case SO_DETACH_FILTER:
rcu_read_lock_bh();
filter = rcu_dereference(sk->sk_filter);
if (filter) {
rcu_assign_pointer(sk->sk_filter, NULL);
sk_filter_release(sk, filter);
rcu_read_unlock_bh();
break; break;
}
rcu_read_unlock_bh();
ret = -ENONET;
break;
case SO_PASSSEC: ret = sk_attach_filter(&fprog, sk);
if (valbool) }
set_bit(SOCK_PASSSEC, &sock->flags); break;
else
clear_bit(SOCK_PASSSEC, &sock->flags); case SO_DETACH_FILTER:
rcu_read_lock_bh();
filter = rcu_dereference(sk->sk_filter);
if (filter) {
rcu_assign_pointer(sk->sk_filter, NULL);
sk_filter_release(sk, filter);
rcu_read_unlock_bh();
break; break;
}
rcu_read_unlock_bh();
ret = -ENONET;
break;
case SO_PASSSEC:
if (valbool)
set_bit(SOCK_PASSSEC, &sock->flags);
else
clear_bit(SOCK_PASSSEC, &sock->flags);
break;
/* We implement the SO_SNDLOWAT etc to /* We implement the SO_SNDLOWAT etc to
not be settable (1003.1g 5.3) */ not be settable (1003.1g 5.3) */
default: default:
ret = -ENOPROTOOPT; ret = -ENOPROTOOPT;
break; break;
} }
release_sock(sk); release_sock(sk);
return ret; return ret;
@ -641,8 +639,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
{ {
struct sock *sk = sock->sk; struct sock *sk = sock->sk;
union union {
{
int val; int val;
struct linger ling; struct linger ling;
struct timeval tm; struct timeval tm;
@ -651,148 +648,148 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
unsigned int lv = sizeof(int); unsigned int lv = sizeof(int);
int len; int len;
if(get_user(len,optlen)) if (get_user(len, optlen))
return -EFAULT; return -EFAULT;
if(len < 0) if (len < 0)
return -EINVAL; return -EINVAL;
switch(optname) switch(optname) {
{ case SO_DEBUG:
case SO_DEBUG: v.val = sock_flag(sk, SOCK_DBG);
v.val = sock_flag(sk, SOCK_DBG); break;
break;
case SO_DONTROUTE: case SO_DONTROUTE:
v.val = sock_flag(sk, SOCK_LOCALROUTE); v.val = sock_flag(sk, SOCK_LOCALROUTE);
break; break;
case SO_BROADCAST: case SO_BROADCAST:
v.val = !!sock_flag(sk, SOCK_BROADCAST); v.val = !!sock_flag(sk, SOCK_BROADCAST);
break; break;
case SO_SNDBUF: case SO_SNDBUF:
v.val = sk->sk_sndbuf; v.val = sk->sk_sndbuf;
break; break;
case SO_RCVBUF: case SO_RCVBUF:
v.val = sk->sk_rcvbuf; v.val = sk->sk_rcvbuf;
break; break;
case SO_REUSEADDR: case SO_REUSEADDR:
v.val = sk->sk_reuse; v.val = sk->sk_reuse;
break; break;
case SO_KEEPALIVE: case SO_KEEPALIVE:
v.val = !!sock_flag(sk, SOCK_KEEPOPEN); v.val = !!sock_flag(sk, SOCK_KEEPOPEN);
break; break;
case SO_TYPE: case SO_TYPE:
v.val = sk->sk_type; v.val = sk->sk_type;
break; break;
case SO_ERROR: case SO_ERROR:
v.val = -sock_error(sk); v.val = -sock_error(sk);
if(v.val==0) if (v.val==0)
v.val = xchg(&sk->sk_err_soft, 0); v.val = xchg(&sk->sk_err_soft, 0);
break; break;
case SO_OOBINLINE: case SO_OOBINLINE:
v.val = !!sock_flag(sk, SOCK_URGINLINE); v.val = !!sock_flag(sk, SOCK_URGINLINE);
break; break;
case SO_NO_CHECK: case SO_NO_CHECK:
v.val = sk->sk_no_check; v.val = sk->sk_no_check;
break; break;
case SO_PRIORITY: case SO_PRIORITY:
v.val = sk->sk_priority; v.val = sk->sk_priority;
break; break;
case SO_LINGER: case SO_LINGER:
lv = sizeof(v.ling); lv = sizeof(v.ling);
v.ling.l_onoff = !!sock_flag(sk, SOCK_LINGER); v.ling.l_onoff = !!sock_flag(sk, SOCK_LINGER);
v.ling.l_linger = sk->sk_lingertime / HZ; v.ling.l_linger = sk->sk_lingertime / HZ;
break; break;
case SO_BSDCOMPAT: case SO_BSDCOMPAT:
sock_warn_obsolete_bsdism("getsockopt"); sock_warn_obsolete_bsdism("getsockopt");
break; break;
case SO_TIMESTAMP: case SO_TIMESTAMP:
v.val = sock_flag(sk, SOCK_RCVTSTAMP); v.val = sock_flag(sk, SOCK_RCVTSTAMP);
break; break;
case SO_RCVTIMEO: case SO_RCVTIMEO:
lv=sizeof(struct timeval); lv=sizeof(struct timeval);
if (sk->sk_rcvtimeo == MAX_SCHEDULE_TIMEOUT) { if (sk->sk_rcvtimeo == MAX_SCHEDULE_TIMEOUT) {
v.tm.tv_sec = 0; v.tm.tv_sec = 0;
v.tm.tv_usec = 0; v.tm.tv_usec = 0;
} else { } else {
v.tm.tv_sec = sk->sk_rcvtimeo / HZ; v.tm.tv_sec = sk->sk_rcvtimeo / HZ;
v.tm.tv_usec = ((sk->sk_rcvtimeo % HZ) * 1000000) / HZ; v.tm.tv_usec = ((sk->sk_rcvtimeo % HZ) * 1000000) / HZ;
}
break;
case SO_SNDTIMEO:
lv=sizeof(struct timeval);
if (sk->sk_sndtimeo == MAX_SCHEDULE_TIMEOUT) {
v.tm.tv_sec = 0;
v.tm.tv_usec = 0;
} else {
v.tm.tv_sec = sk->sk_sndtimeo / HZ;
v.tm.tv_usec = ((sk->sk_sndtimeo % HZ) * 1000000) / HZ;
}
break;
case SO_RCVLOWAT:
v.val = sk->sk_rcvlowat;
break;
case SO_SNDLOWAT:
v.val=1;
break;
case SO_PASSCRED:
v.val = test_bit(SOCK_PASSCRED, &sock->flags) ? 1 : 0;
break;
case SO_PEERCRED:
if (len > sizeof(sk->sk_peercred))
len = sizeof(sk->sk_peercred);
if (copy_to_user(optval, &sk->sk_peercred, len))
return -EFAULT;
goto lenout;
case SO_PEERNAME:
{
char address[128];
if (sock->ops->getname(sock, (struct sockaddr *)address, &lv, 2))
return -ENOTCONN;
if (lv < len)
return -EINVAL;
if (copy_to_user(optval, address, len))
return -EFAULT;
goto lenout;
} }
break;
/* Dubious BSD thing... Probably nobody even uses it, but case SO_SNDTIMEO:
* the UNIX standard wants it for whatever reason... -DaveM lv=sizeof(struct timeval);
*/ if (sk->sk_sndtimeo == MAX_SCHEDULE_TIMEOUT) {
case SO_ACCEPTCONN: v.tm.tv_sec = 0;
v.val = sk->sk_state == TCP_LISTEN; v.tm.tv_usec = 0;
break; } else {
v.tm.tv_sec = sk->sk_sndtimeo / HZ;
v.tm.tv_usec = ((sk->sk_sndtimeo % HZ) * 1000000) / HZ;
}
break;
case SO_PASSSEC: case SO_RCVLOWAT:
v.val = test_bit(SOCK_PASSSEC, &sock->flags) ? 1 : 0; v.val = sk->sk_rcvlowat;
break; break;
case SO_PEERSEC: case SO_SNDLOWAT:
return security_socket_getpeersec_stream(sock, optval, optlen, len); v.val=1;
break;
default: case SO_PASSCRED:
return(-ENOPROTOOPT); v.val = test_bit(SOCK_PASSCRED, &sock->flags) ? 1 : 0;
break;
case SO_PEERCRED:
if (len > sizeof(sk->sk_peercred))
len = sizeof(sk->sk_peercred);
if (copy_to_user(optval, &sk->sk_peercred, len))
return -EFAULT;
goto lenout;
case SO_PEERNAME:
{
char address[128];
if (sock->ops->getname(sock, (struct sockaddr *)address, &lv, 2))
return -ENOTCONN;
if (lv < len)
return -EINVAL;
if (copy_to_user(optval, address, len))
return -EFAULT;
goto lenout;
} }
/* Dubious BSD thing... Probably nobody even uses it, but
* the UNIX standard wants it for whatever reason... -DaveM
*/
case SO_ACCEPTCONN:
v.val = sk->sk_state == TCP_LISTEN;
break;
case SO_PASSSEC:
v.val = test_bit(SOCK_PASSSEC, &sock->flags) ? 1 : 0;
break;
case SO_PEERSEC:
return security_socket_getpeersec_stream(sock, optval, optlen, len);
default:
return -ENOPROTOOPT;
}
if (len > lv) if (len > lv)
len = lv; len = lv;
if (copy_to_user(optval, &v, len)) if (copy_to_user(optval, &v, len))
@ -1220,13 +1217,13 @@ static void __lock_sock(struct sock *sk)
{ {
DEFINE_WAIT(wait); DEFINE_WAIT(wait);
for(;;) { for (;;) {
prepare_to_wait_exclusive(&sk->sk_lock.wq, &wait, prepare_to_wait_exclusive(&sk->sk_lock.wq, &wait,
TASK_UNINTERRUPTIBLE); TASK_UNINTERRUPTIBLE);
spin_unlock_bh(&sk->sk_lock.slock); spin_unlock_bh(&sk->sk_lock.slock);
schedule(); schedule();
spin_lock_bh(&sk->sk_lock.slock); spin_lock_bh(&sk->sk_lock.slock);
if(!sock_owned_by_user(sk)) if (!sock_owned_by_user(sk))
break; break;
} }
finish_wait(&sk->sk_lock.wq, &wait); finish_wait(&sk->sk_lock.wq, &wait);
@ -1258,7 +1255,7 @@ static void __release_sock(struct sock *sk)
} while (skb != NULL); } while (skb != NULL);
bh_lock_sock(sk); bh_lock_sock(sk);
} while((skb = sk->sk_backlog.head) != NULL); } while ((skb = sk->sk_backlog.head) != NULL);
} }
/** /**
@ -1420,7 +1417,7 @@ static void sock_def_write_space(struct sock *sk)
/* Do not wake up a writer until he can make "significant" /* Do not wake up a writer until he can make "significant"
* progress. --DaveM * progress. --DaveM
*/ */
if((atomic_read(&sk->sk_wmem_alloc) << 1) <= sk->sk_sndbuf) { if ((atomic_read(&sk->sk_wmem_alloc) << 1) <= sk->sk_sndbuf) {
if (sk->sk_sleep && waitqueue_active(sk->sk_sleep)) if (sk->sk_sleep && waitqueue_active(sk->sk_sleep))
wake_up_interruptible(sk->sk_sleep); wake_up_interruptible(sk->sk_sleep);
@ -1482,8 +1479,7 @@ void sock_init_data(struct socket *sock, struct sock *sk)
sock_set_flag(sk, SOCK_ZAPPED); sock_set_flag(sk, SOCK_ZAPPED);
if(sock) if (sock) {
{
sk->sk_type = sock->type; sk->sk_type = sock->type;
sk->sk_sleep = &sock->wait; sk->sk_sleep = &sock->wait;
sock->sk = sk; sock->sk = sk;

View file

@ -463,17 +463,17 @@ static inline iw_handler get_handler(struct net_device *dev,
unsigned int index; /* *MUST* be unsigned */ unsigned int index; /* *MUST* be unsigned */
/* Check if we have some wireless handlers defined */ /* Check if we have some wireless handlers defined */
if(dev->wireless_handlers == NULL) if (dev->wireless_handlers == NULL)
return NULL; return NULL;
/* Try as a standard command */ /* Try as a standard command */
index = cmd - SIOCIWFIRST; index = cmd - SIOCIWFIRST;
if(index < dev->wireless_handlers->num_standard) if (index < dev->wireless_handlers->num_standard)
return dev->wireless_handlers->standard[index]; return dev->wireless_handlers->standard[index];
/* Try as a private command */ /* Try as a private command */
index = cmd - SIOCIWFIRSTPRIV; index = cmd - SIOCIWFIRSTPRIV;
if(index < dev->wireless_handlers->num_private) if (index < dev->wireless_handlers->num_private)
return dev->wireless_handlers->private[index]; return dev->wireless_handlers->private[index];
/* Not found */ /* Not found */
@ -487,7 +487,7 @@ static inline iw_handler get_handler(struct net_device *dev,
static inline struct iw_statistics *get_wireless_stats(struct net_device *dev) static inline struct iw_statistics *get_wireless_stats(struct net_device *dev)
{ {
/* New location */ /* New location */
if((dev->wireless_handlers != NULL) && if ((dev->wireless_handlers != NULL) &&
(dev->wireless_handlers->get_wireless_stats != NULL)) (dev->wireless_handlers->get_wireless_stats != NULL))
return dev->wireless_handlers->get_wireless_stats(dev); return dev->wireless_handlers->get_wireless_stats(dev);
@ -516,7 +516,7 @@ static inline struct iw_statistics *get_wireless_stats(struct net_device *dev)
*/ */
static inline int call_commit_handler(struct net_device * dev) static inline int call_commit_handler(struct net_device * dev)
{ {
if((netif_running(dev)) && if ((netif_running(dev)) &&
(dev->wireless_handlers->standard[0] != NULL)) { (dev->wireless_handlers->standard[0] != NULL)) {
/* Call the commit handler on the driver */ /* Call the commit handler on the driver */
return dev->wireless_handlers->standard[0](dev, NULL, return dev->wireless_handlers->standard[0](dev, NULL,
@ -577,7 +577,7 @@ static int iw_handler_get_iwstats(struct net_device * dev,
wrqu->data.length = sizeof(struct iw_statistics); wrqu->data.length = sizeof(struct iw_statistics);
/* Check if we need to clear the updated flag */ /* Check if we need to clear the updated flag */
if(wrqu->data.flags != 0) if (wrqu->data.flags != 0)
stats->qual.updated &= ~IW_QUAL_ALL_UPDATED; stats->qual.updated &= ~IW_QUAL_ALL_UPDATED;
return 0; return 0;
} else } else
@ -596,12 +596,12 @@ static int iw_handler_get_private(struct net_device * dev,
char * extra) char * extra)
{ {
/* Check if the driver has something to export */ /* Check if the driver has something to export */
if((dev->wireless_handlers->num_private_args == 0) || if ((dev->wireless_handlers->num_private_args == 0) ||
(dev->wireless_handlers->private_args == NULL)) (dev->wireless_handlers->private_args == NULL))
return -EOPNOTSUPP; return -EOPNOTSUPP;
/* Check if there is enough buffer up there */ /* Check if there is enough buffer up there */
if(wrqu->data.length < dev->wireless_handlers->num_private_args) { if (wrqu->data.length < dev->wireless_handlers->num_private_args) {
/* User space can't know in advance how large the buffer /* User space can't know in advance how large the buffer
* needs to be. Give it a hint, so that we can support * needs to be. Give it a hint, so that we can support
* any size buffer we want somewhat efficiently... */ * any size buffer we want somewhat efficiently... */
@ -735,7 +735,7 @@ static int ioctl_standard_call(struct net_device * dev,
int ret = -EINVAL; int ret = -EINVAL;
/* Get the description of the IOCTL */ /* Get the description of the IOCTL */
if((cmd - SIOCIWFIRST) >= standard_ioctl_num) if ((cmd - SIOCIWFIRST) >= standard_ioctl_num)
return -EOPNOTSUPP; return -EOPNOTSUPP;
descr = &(standard_ioctl[cmd - SIOCIWFIRST]); descr = &(standard_ioctl[cmd - SIOCIWFIRST]);
@ -750,14 +750,14 @@ static int ioctl_standard_call(struct net_device * dev,
info.flags = 0; info.flags = 0;
/* Check if we have a pointer to user space data or not */ /* Check if we have a pointer to user space data or not */
if(descr->header_type != IW_HEADER_TYPE_POINT) { if (descr->header_type != IW_HEADER_TYPE_POINT) {
/* No extra arguments. Trivial to handle */ /* No extra arguments. Trivial to handle */
ret = handler(dev, &info, &(iwr->u), NULL); ret = handler(dev, &info, &(iwr->u), NULL);
#ifdef WE_SET_EVENT #ifdef WE_SET_EVENT
/* Generate an event to notify listeners of the change */ /* Generate an event to notify listeners of the change */
if((descr->flags & IW_DESCR_FLAG_EVENT) && if ((descr->flags & IW_DESCR_FLAG_EVENT) &&
((ret == 0) || (ret == -EIWCOMMIT))) ((ret == 0) || (ret == -EIWCOMMIT)))
wireless_send_event(dev, cmd, &(iwr->u), NULL); wireless_send_event(dev, cmd, &(iwr->u), NULL);
#endif /* WE_SET_EVENT */ #endif /* WE_SET_EVENT */
@ -800,19 +800,19 @@ static int ioctl_standard_call(struct net_device * dev,
iwr->u.data.length -= essid_compat; iwr->u.data.length -= essid_compat;
/* Check what user space is giving us */ /* Check what user space is giving us */
if(IW_IS_SET(cmd)) { if (IW_IS_SET(cmd)) {
/* Check NULL pointer */ /* Check NULL pointer */
if((iwr->u.data.pointer == NULL) && if ((iwr->u.data.pointer == NULL) &&
(iwr->u.data.length != 0)) (iwr->u.data.length != 0))
return -EFAULT; return -EFAULT;
/* Check if number of token fits within bounds */ /* Check if number of token fits within bounds */
if(iwr->u.data.length > descr->max_tokens) if (iwr->u.data.length > descr->max_tokens)
return -E2BIG; return -E2BIG;
if(iwr->u.data.length < descr->min_tokens) if (iwr->u.data.length < descr->min_tokens)
return -EINVAL; return -EINVAL;
} else { } else {
/* Check NULL pointer */ /* Check NULL pointer */
if(iwr->u.data.pointer == NULL) if (iwr->u.data.pointer == NULL)
return -EFAULT; return -EFAULT;
/* Save user space buffer size for checking */ /* Save user space buffer size for checking */
user_length = iwr->u.data.length; user_length = iwr->u.data.length;
@ -822,7 +822,7 @@ static int ioctl_standard_call(struct net_device * dev,
* implied by the test at the end. */ * implied by the test at the end. */
/* Support for very large requests */ /* Support for very large requests */
if((descr->flags & IW_DESCR_FLAG_NOMAX) && if ((descr->flags & IW_DESCR_FLAG_NOMAX) &&
(user_length > descr->max_tokens)) { (user_length > descr->max_tokens)) {
/* Allow userspace to GET more than max so /* Allow userspace to GET more than max so
* we can support any size GET requests. * we can support any size GET requests.
@ -848,7 +848,7 @@ static int ioctl_standard_call(struct net_device * dev,
} }
/* If it is a SET, get all the extra data in here */ /* If it is a SET, get all the extra data in here */
if(IW_IS_SET(cmd) && (iwr->u.data.length != 0)) { if (IW_IS_SET(cmd) && (iwr->u.data.length != 0)) {
err = copy_from_user(extra, iwr->u.data.pointer, err = copy_from_user(extra, iwr->u.data.pointer,
iwr->u.data.length * iwr->u.data.length *
descr->token_size); descr->token_size);
@ -871,7 +871,7 @@ static int ioctl_standard_call(struct net_device * dev,
/* If we have something to return to the user */ /* If we have something to return to the user */
if (!ret && IW_IS_GET(cmd)) { if (!ret && IW_IS_GET(cmd)) {
/* Check if there is enough buffer up there */ /* Check if there is enough buffer up there */
if(user_length < iwr->u.data.length) { if (user_length < iwr->u.data.length) {
kfree(extra); kfree(extra);
return -E2BIG; return -E2BIG;
} }
@ -890,9 +890,9 @@ static int ioctl_standard_call(struct net_device * dev,
#ifdef WE_SET_EVENT #ifdef WE_SET_EVENT
/* Generate an event to notify listeners of the change */ /* Generate an event to notify listeners of the change */
if((descr->flags & IW_DESCR_FLAG_EVENT) && if ((descr->flags & IW_DESCR_FLAG_EVENT) &&
((ret == 0) || (ret == -EIWCOMMIT))) { ((ret == 0) || (ret == -EIWCOMMIT))) {
if(descr->flags & IW_DESCR_FLAG_RESTRICT) if (descr->flags & IW_DESCR_FLAG_RESTRICT)
/* If the event is restricted, don't /* If the event is restricted, don't
* export the payload */ * export the payload */
wireless_send_event(dev, cmd, &(iwr->u), NULL); wireless_send_event(dev, cmd, &(iwr->u), NULL);
@ -907,7 +907,7 @@ static int ioctl_standard_call(struct net_device * dev,
} }
/* Call commit handler if needed and defined */ /* Call commit handler if needed and defined */
if(ret == -EIWCOMMIT) if (ret == -EIWCOMMIT)
ret = call_commit_handler(dev); ret = call_commit_handler(dev);
/* Here, we will generate the appropriate event if needed */ /* Here, we will generate the appropriate event if needed */
@ -944,8 +944,8 @@ static inline int ioctl_private_call(struct net_device * dev,
int ret = -EINVAL; int ret = -EINVAL;
/* Get the description of the IOCTL */ /* Get the description of the IOCTL */
for(i = 0; i < dev->wireless_handlers->num_private_args; i++) for (i = 0; i < dev->wireless_handlers->num_private_args; i++)
if(cmd == dev->wireless_handlers->private_args[i].cmd) { if (cmd == dev->wireless_handlers->private_args[i].cmd) {
descr = &(dev->wireless_handlers->private_args[i]); descr = &(dev->wireless_handlers->private_args[i]);
break; break;
} }
@ -953,7 +953,7 @@ static inline int ioctl_private_call(struct net_device * dev,
#ifdef WE_IOCTL_DEBUG #ifdef WE_IOCTL_DEBUG
printk(KERN_DEBUG "%s (WE) : Found private handler for 0x%04X\n", printk(KERN_DEBUG "%s (WE) : Found private handler for 0x%04X\n",
ifr->ifr_name, cmd); ifr->ifr_name, cmd);
if(descr) { if (descr) {
printk(KERN_DEBUG "%s (WE) : Name %s, set %X, get %X\n", printk(KERN_DEBUG "%s (WE) : Name %s, set %X, get %X\n",
dev->name, descr->name, dev->name, descr->name,
descr->set_args, descr->get_args); descr->set_args, descr->get_args);
@ -961,11 +961,11 @@ static inline int ioctl_private_call(struct net_device * dev,
#endif /* WE_IOCTL_DEBUG */ #endif /* WE_IOCTL_DEBUG */
/* Compute the size of the set/get arguments */ /* Compute the size of the set/get arguments */
if(descr != NULL) { if (descr != NULL) {
if(IW_IS_SET(cmd)) { if (IW_IS_SET(cmd)) {
int offset = 0; /* For sub-ioctls */ int offset = 0; /* For sub-ioctls */
/* Check for sub-ioctl handler */ /* Check for sub-ioctl handler */
if(descr->name[0] == '\0') if (descr->name[0] == '\0')
/* Reserve one int for sub-ioctl index */ /* Reserve one int for sub-ioctl index */
offset = sizeof(__u32); offset = sizeof(__u32);
@ -973,7 +973,7 @@ static inline int ioctl_private_call(struct net_device * dev,
extra_size = get_priv_size(descr->set_args); extra_size = get_priv_size(descr->set_args);
/* Does it fits in iwr ? */ /* Does it fits in iwr ? */
if((descr->set_args & IW_PRIV_SIZE_FIXED) && if ((descr->set_args & IW_PRIV_SIZE_FIXED) &&
((extra_size + offset) <= IFNAMSIZ)) ((extra_size + offset) <= IFNAMSIZ))
extra_size = 0; extra_size = 0;
} else { } else {
@ -981,7 +981,7 @@ static inline int ioctl_private_call(struct net_device * dev,
extra_size = get_priv_size(descr->get_args); extra_size = get_priv_size(descr->get_args);
/* Does it fits in iwr ? */ /* Does it fits in iwr ? */
if((descr->get_args & IW_PRIV_SIZE_FIXED) && if ((descr->get_args & IW_PRIV_SIZE_FIXED) &&
(extra_size <= IFNAMSIZ)) (extra_size <= IFNAMSIZ))
extra_size = 0; extra_size = 0;
} }
@ -992,7 +992,7 @@ static inline int ioctl_private_call(struct net_device * dev,
info.flags = 0; info.flags = 0;
/* Check if we have a pointer to user space data or not. */ /* Check if we have a pointer to user space data or not. */
if(extra_size == 0) { if (extra_size == 0) {
/* No extra arguments. Trivial to handle */ /* No extra arguments. Trivial to handle */
ret = handler(dev, &info, &(iwr->u), (char *) &(iwr->u)); ret = handler(dev, &info, &(iwr->u), (char *) &(iwr->u));
} else { } else {
@ -1000,19 +1000,19 @@ static inline int ioctl_private_call(struct net_device * dev,
int err; int err;
/* Check what user space is giving us */ /* Check what user space is giving us */
if(IW_IS_SET(cmd)) { if (IW_IS_SET(cmd)) {
/* Check NULL pointer */ /* Check NULL pointer */
if((iwr->u.data.pointer == NULL) && if ((iwr->u.data.pointer == NULL) &&
(iwr->u.data.length != 0)) (iwr->u.data.length != 0))
return -EFAULT; return -EFAULT;
/* Does it fits within bounds ? */ /* Does it fits within bounds ? */
if(iwr->u.data.length > (descr->set_args & if (iwr->u.data.length > (descr->set_args &
IW_PRIV_SIZE_MASK)) IW_PRIV_SIZE_MASK))
return -E2BIG; return -E2BIG;
} else { } else {
/* Check NULL pointer */ /* Check NULL pointer */
if(iwr->u.data.pointer == NULL) if (iwr->u.data.pointer == NULL)
return -EFAULT; return -EFAULT;
} }
@ -1029,7 +1029,7 @@ static inline int ioctl_private_call(struct net_device * dev,
} }
/* If it is a SET, get all the extra data in here */ /* If it is a SET, get all the extra data in here */
if(IW_IS_SET(cmd) && (iwr->u.data.length != 0)) { if (IW_IS_SET(cmd) && (iwr->u.data.length != 0)) {
err = copy_from_user(extra, iwr->u.data.pointer, err = copy_from_user(extra, iwr->u.data.pointer,
extra_size); extra_size);
if (err) { if (err) {
@ -1071,7 +1071,7 @@ static inline int ioctl_private_call(struct net_device * dev,
/* Call commit handler if needed and defined */ /* Call commit handler if needed and defined */
if(ret == -EIWCOMMIT) if (ret == -EIWCOMMIT)
ret = call_commit_handler(dev); ret = call_commit_handler(dev);
return ret; return ret;
@ -1098,51 +1098,50 @@ int wireless_process_ioctl(struct ifreq *ifr, unsigned int cmd)
/* A bunch of special cases, then the generic case... /* A bunch of special cases, then the generic case...
* Note that 'cmd' is already filtered in dev_ioctl() with * Note that 'cmd' is already filtered in dev_ioctl() with
* (cmd >= SIOCIWFIRST && cmd <= SIOCIWLAST) */ * (cmd >= SIOCIWFIRST && cmd <= SIOCIWLAST) */
switch(cmd) switch (cmd) {
{ case SIOCGIWSTATS:
case SIOCGIWSTATS: /* Get Wireless Stats */
/* Get Wireless Stats */ return ioctl_standard_call(dev,
ifr,
cmd,
&iw_handler_get_iwstats);
case SIOCGIWPRIV:
/* Check if we have some wireless handlers defined */
if (dev->wireless_handlers != NULL) {
/* We export to user space the definition of
* the private handler ourselves */
return ioctl_standard_call(dev, return ioctl_standard_call(dev,
ifr, ifr,
cmd, cmd,
&iw_handler_get_iwstats); &iw_handler_get_private);
}
case SIOCGIWPRIV: // ## Fall-through for old API ##
/* Check if we have some wireless handlers defined */ default:
if(dev->wireless_handlers != NULL) { /* Generic IOCTL */
/* We export to user space the definition of /* Basic check */
* the private handler ourselves */ if (!netif_device_present(dev))
return -ENODEV;
/* New driver API : try to find the handler */
handler = get_handler(dev, cmd);
if (handler != NULL) {
/* Standard and private are not the same */
if (cmd < SIOCIWFIRSTPRIV)
return ioctl_standard_call(dev, return ioctl_standard_call(dev,
ifr, ifr,
cmd, cmd,
&iw_handler_get_private); handler);
} else
// ## Fall-through for old API ## return ioctl_private_call(dev,
default: ifr,
/* Generic IOCTL */ cmd,
/* Basic check */ handler);
if (!netif_device_present(dev)) }
return -ENODEV; /* Old driver API : call driver ioctl handler */
/* New driver API : try to find the handler */ if (dev->do_ioctl) {
handler = get_handler(dev, cmd); return dev->do_ioctl(dev, ifr, cmd);
if(handler != NULL) { }
/* Standard and private are not the same */ return -EOPNOTSUPP;
if(cmd < SIOCIWFIRSTPRIV)
return ioctl_standard_call(dev,
ifr,
cmd,
handler);
else
return ioctl_private_call(dev,
ifr,
cmd,
handler);
}
/* Old driver API : call driver ioctl handler */
if (dev->do_ioctl) {
return dev->do_ioctl(dev, ifr, cmd);
}
return -EOPNOTSUPP;
} }
/* Not reached */ /* Not reached */
return -EINVAL; return -EINVAL;
@ -1196,7 +1195,7 @@ static int rtnetlink_standard_get(struct net_device * dev,
/* Get the description of the Request */ /* Get the description of the Request */
cmd = request->cmd; cmd = request->cmd;
if((cmd - SIOCIWFIRST) >= standard_ioctl_num) if ((cmd - SIOCIWFIRST) >= standard_ioctl_num)
return -EOPNOTSUPP; return -EOPNOTSUPP;
descr = &(standard_ioctl[cmd - SIOCIWFIRST]); descr = &(standard_ioctl[cmd - SIOCIWFIRST]);
@ -1208,7 +1207,7 @@ static int rtnetlink_standard_get(struct net_device * dev,
/* Check if wrqu is complete */ /* Check if wrqu is complete */
hdr_len = event_type_size[descr->header_type]; hdr_len = event_type_size[descr->header_type];
if(request_len < hdr_len) { if (request_len < hdr_len) {
#ifdef WE_RTNETLINK_DEBUG #ifdef WE_RTNETLINK_DEBUG
printk(KERN_DEBUG printk(KERN_DEBUG
"%s (WE.r) : Wireless request too short (%d)\n", "%s (WE.r) : Wireless request too short (%d)\n",
@ -1222,7 +1221,7 @@ static int rtnetlink_standard_get(struct net_device * dev,
info.flags = 0; info.flags = 0;
/* Check if we have extra data in the reply or not */ /* Check if we have extra data in the reply or not */
if(descr->header_type != IW_HEADER_TYPE_POINT) { if (descr->header_type != IW_HEADER_TYPE_POINT) {
/* Create the kernel buffer that we will return. /* Create the kernel buffer that we will return.
* It's at an offset to match the TYPE_POINT case... */ * It's at an offset to match the TYPE_POINT case... */
@ -1254,7 +1253,7 @@ static int rtnetlink_standard_get(struct net_device * dev,
* for max space. Easier, and won't last long... */ * for max space. Easier, and won't last long... */
extra_size = descr->max_tokens * descr->token_size; extra_size = descr->max_tokens * descr->token_size;
/* Support for very large requests */ /* Support for very large requests */
if((descr->flags & IW_DESCR_FLAG_NOMAX) && if ((descr->flags & IW_DESCR_FLAG_NOMAX) &&
(wrqu_point.data.length > descr->max_tokens)) (wrqu_point.data.length > descr->max_tokens))
extra_size = (wrqu_point.data.length extra_size = (wrqu_point.data.length
* descr->token_size); * descr->token_size);
@ -1299,7 +1298,7 @@ static int rtnetlink_standard_get(struct net_device * dev,
#endif /* WE_RTNETLINK_DEBUG */ #endif /* WE_RTNETLINK_DEBUG */
/* Check if there is enough buffer up there */ /* Check if there is enough buffer up there */
if(wrqu_point.data.length < wrqu->data.length) if (wrqu_point.data.length < wrqu->data.length)
ret = -E2BIG; ret = -E2BIG;
} }
@ -1309,7 +1308,7 @@ static int rtnetlink_standard_get(struct net_device * dev,
*p_len = request->len; *p_len = request->len;
} else { } else {
/* Cleanup */ /* Cleanup */
if(buffer) if (buffer)
kfree(buffer); kfree(buffer);
} }
@ -1338,7 +1337,7 @@ static inline int rtnetlink_standard_set(struct net_device * dev,
/* Get the description of the Request */ /* Get the description of the Request */
cmd = request->cmd; cmd = request->cmd;
if((cmd - SIOCIWFIRST) >= standard_ioctl_num) if ((cmd - SIOCIWFIRST) >= standard_ioctl_num)
return -EOPNOTSUPP; return -EOPNOTSUPP;
descr = &(standard_ioctl[cmd - SIOCIWFIRST]); descr = &(standard_ioctl[cmd - SIOCIWFIRST]);
@ -1353,7 +1352,7 @@ static inline int rtnetlink_standard_set(struct net_device * dev,
/* Check if wrqu is complete */ /* Check if wrqu is complete */
hdr_len = event_type_pk_size[descr->header_type]; hdr_len = event_type_pk_size[descr->header_type];
if(request_len < hdr_len) { if (request_len < hdr_len) {
#ifdef WE_RTNETLINK_DEBUG #ifdef WE_RTNETLINK_DEBUG
printk(KERN_DEBUG printk(KERN_DEBUG
"%s (WE.r) : Wireless request too short (%d)\n", "%s (WE.r) : Wireless request too short (%d)\n",
@ -1367,7 +1366,7 @@ static inline int rtnetlink_standard_set(struct net_device * dev,
info.flags = 0; info.flags = 0;
/* Check if we have extra data in the request or not */ /* Check if we have extra data in the request or not */
if(descr->header_type != IW_HEADER_TYPE_POINT) { if (descr->header_type != IW_HEADER_TYPE_POINT) {
/* No extra arguments. Trivial to handle */ /* No extra arguments. Trivial to handle */
ret = handler(dev, &info, wrqu, NULL); ret = handler(dev, &info, wrqu, NULL);
@ -1382,16 +1381,16 @@ static inline int rtnetlink_standard_set(struct net_device * dev,
wrqu = &wrqu_point; wrqu = &wrqu_point;
/* Check if number of token fits within bounds */ /* Check if number of token fits within bounds */
if(wrqu_point.data.length > descr->max_tokens) if (wrqu_point.data.length > descr->max_tokens)
return -E2BIG; return -E2BIG;
if(wrqu_point.data.length < descr->min_tokens) if (wrqu_point.data.length < descr->min_tokens)
return -EINVAL; return -EINVAL;
/* Real length of payload */ /* Real length of payload */
extra_len = wrqu_point.data.length * descr->token_size; extra_len = wrqu_point.data.length * descr->token_size;
/* Check if request is self consistent */ /* Check if request is self consistent */
if((request_len - hdr_len) < extra_len) { if ((request_len - hdr_len) < extra_len) {
#ifdef WE_RTNETLINK_DEBUG #ifdef WE_RTNETLINK_DEBUG
printk(KERN_DEBUG "%s (WE.r) : Wireless request data too short (%d)\n", printk(KERN_DEBUG "%s (WE.r) : Wireless request data too short (%d)\n",
dev->name, extra_size); dev->name, extra_size);
@ -1420,9 +1419,9 @@ static inline int rtnetlink_standard_set(struct net_device * dev,
#ifdef WE_SET_EVENT #ifdef WE_SET_EVENT
/* Generate an event to notify listeners of the change */ /* Generate an event to notify listeners of the change */
if((descr->flags & IW_DESCR_FLAG_EVENT) && if ((descr->flags & IW_DESCR_FLAG_EVENT) &&
((ret == 0) || (ret == -EIWCOMMIT))) { ((ret == 0) || (ret == -EIWCOMMIT))) {
if(descr->flags & IW_DESCR_FLAG_RESTRICT) if (descr->flags & IW_DESCR_FLAG_RESTRICT)
/* If the event is restricted, don't /* If the event is restricted, don't
* export the payload */ * export the payload */
wireless_send_event(dev, cmd, wrqu, NULL); wireless_send_event(dev, cmd, wrqu, NULL);
@ -1432,11 +1431,11 @@ static inline int rtnetlink_standard_set(struct net_device * dev,
#endif /* WE_SET_EVENT */ #endif /* WE_SET_EVENT */
/* Cleanup - I told you it wasn't that long ;-) */ /* Cleanup - I told you it wasn't that long ;-) */
if(extra) if (extra)
kfree(extra); kfree(extra);
/* Call commit handler if needed and defined */ /* Call commit handler if needed and defined */
if(ret == -EIWCOMMIT) if (ret == -EIWCOMMIT)
ret = call_commit_handler(dev); ret = call_commit_handler(dev);
return ret; return ret;
@ -1477,12 +1476,12 @@ static inline int rtnetlink_private_get(struct net_device * dev,
/* Get the description of the Request */ /* Get the description of the Request */
cmd = request->cmd; cmd = request->cmd;
for(i = 0; i < dev->wireless_handlers->num_private_args; i++) for (i = 0; i < dev->wireless_handlers->num_private_args; i++)
if(cmd == dev->wireless_handlers->private_args[i].cmd) { if (cmd == dev->wireless_handlers->private_args[i].cmd) {
descr = &(dev->wireless_handlers->private_args[i]); descr = &(dev->wireless_handlers->private_args[i]);
break; break;
} }
if(descr == NULL) if (descr == NULL)
return -EOPNOTSUPP; return -EOPNOTSUPP;
#ifdef WE_RTNETLINK_DEBUG #ifdef WE_RTNETLINK_DEBUG
@ -1496,7 +1495,7 @@ static inline int rtnetlink_private_get(struct net_device * dev,
extra_size = get_priv_size(descr->get_args); extra_size = get_priv_size(descr->get_args);
/* Does it fits in wrqu ? */ /* Does it fits in wrqu ? */
if((descr->get_args & IW_PRIV_SIZE_FIXED) && if ((descr->get_args & IW_PRIV_SIZE_FIXED) &&
(extra_size <= IFNAMSIZ)) { (extra_size <= IFNAMSIZ)) {
hdr_len = extra_size; hdr_len = extra_size;
extra_size = 0; extra_size = 0;
@ -1505,7 +1504,7 @@ static inline int rtnetlink_private_get(struct net_device * dev,
} }
/* Check if wrqu is complete */ /* Check if wrqu is complete */
if(request_len < hdr_len) { if (request_len < hdr_len) {
#ifdef WE_RTNETLINK_DEBUG #ifdef WE_RTNETLINK_DEBUG
printk(KERN_DEBUG printk(KERN_DEBUG
"%s (WE.r) : Wireless request too short (%d)\n", "%s (WE.r) : Wireless request too short (%d)\n",
@ -1519,7 +1518,7 @@ static inline int rtnetlink_private_get(struct net_device * dev,
info.flags = 0; info.flags = 0;
/* Check if we have a pointer to user space data or not. */ /* Check if we have a pointer to user space data or not. */
if(extra_size == 0) { if (extra_size == 0) {
/* Create the kernel buffer that we will return. /* Create the kernel buffer that we will return.
* It's at an offset to match the TYPE_POINT case... */ * It's at an offset to match the TYPE_POINT case... */
@ -1591,7 +1590,7 @@ static inline int rtnetlink_private_get(struct net_device * dev,
*p_len = request->len; *p_len = request->len;
} else { } else {
/* Cleanup */ /* Cleanup */
if(buffer) if (buffer)
kfree(buffer); kfree(buffer);
} }
@ -1632,12 +1631,12 @@ static inline int rtnetlink_private_set(struct net_device * dev,
/* Get the description of the Request */ /* Get the description of the Request */
cmd = request->cmd; cmd = request->cmd;
for(i = 0; i < dev->wireless_handlers->num_private_args; i++) for (i = 0; i < dev->wireless_handlers->num_private_args; i++)
if(cmd == dev->wireless_handlers->private_args[i].cmd) { if (cmd == dev->wireless_handlers->private_args[i].cmd) {
descr = &(dev->wireless_handlers->private_args[i]); descr = &(dev->wireless_handlers->private_args[i]);
break; break;
} }
if(descr == NULL) if (descr == NULL)
return -EOPNOTSUPP; return -EOPNOTSUPP;
#ifdef WE_RTNETLINK_DEBUG #ifdef WE_RTNETLINK_DEBUG
@ -1649,7 +1648,7 @@ static inline int rtnetlink_private_set(struct net_device * dev,
/* Compute the size of the set arguments */ /* Compute the size of the set arguments */
/* Check for sub-ioctl handler */ /* Check for sub-ioctl handler */
if(descr->name[0] == '\0') if (descr->name[0] == '\0')
/* Reserve one int for sub-ioctl index */ /* Reserve one int for sub-ioctl index */
offset = sizeof(__u32); offset = sizeof(__u32);
@ -1657,7 +1656,7 @@ static inline int rtnetlink_private_set(struct net_device * dev,
extra_size = get_priv_size(descr->set_args); extra_size = get_priv_size(descr->set_args);
/* Does it fits in wrqu ? */ /* Does it fits in wrqu ? */
if((descr->set_args & IW_PRIV_SIZE_FIXED) && if ((descr->set_args & IW_PRIV_SIZE_FIXED) &&
(extra_size <= IFNAMSIZ)) { (extra_size <= IFNAMSIZ)) {
hdr_len = IW_EV_LCP_PK_LEN + extra_size; hdr_len = IW_EV_LCP_PK_LEN + extra_size;
extra_size = 0; extra_size = 0;
@ -1669,7 +1668,7 @@ static inline int rtnetlink_private_set(struct net_device * dev,
wrqu = (union iwreq_data *) (((char *) request) + IW_EV_LCP_PK_LEN); wrqu = (union iwreq_data *) (((char *) request) + IW_EV_LCP_PK_LEN);
/* Check if wrqu is complete */ /* Check if wrqu is complete */
if(request_len < hdr_len) { if (request_len < hdr_len) {
#ifdef WE_RTNETLINK_DEBUG #ifdef WE_RTNETLINK_DEBUG
printk(KERN_DEBUG printk(KERN_DEBUG
"%s (WE.r) : Wireless request too short (%d)\n", "%s (WE.r) : Wireless request too short (%d)\n",
@ -1683,7 +1682,7 @@ static inline int rtnetlink_private_set(struct net_device * dev,
info.flags = 0; info.flags = 0;
/* Check if we have a pointer to user space data or not. */ /* Check if we have a pointer to user space data or not. */
if(extra_size == 0) { if (extra_size == 0) {
/* No extra arguments. Trivial to handle */ /* No extra arguments. Trivial to handle */
ret = handler(dev, &info, wrqu, (char *) wrqu); ret = handler(dev, &info, wrqu, (char *) wrqu);
@ -1696,7 +1695,7 @@ static inline int rtnetlink_private_set(struct net_device * dev,
wrqu, IW_EV_POINT_PK_LEN - IW_EV_LCP_PK_LEN); wrqu, IW_EV_POINT_PK_LEN - IW_EV_LCP_PK_LEN);
/* Does it fits within bounds ? */ /* Does it fits within bounds ? */
if(wrqu_point.data.length > (descr->set_args & if (wrqu_point.data.length > (descr->set_args &
IW_PRIV_SIZE_MASK)) IW_PRIV_SIZE_MASK))
return -E2BIG; return -E2BIG;
@ -1704,7 +1703,7 @@ static inline int rtnetlink_private_set(struct net_device * dev,
extra_len = adjust_priv_size(descr->set_args, &wrqu_point); extra_len = adjust_priv_size(descr->set_args, &wrqu_point);
/* Check if request is self consistent */ /* Check if request is self consistent */
if((request_len - hdr_len) < extra_len) { if ((request_len - hdr_len) < extra_len) {
#ifdef WE_RTNETLINK_DEBUG #ifdef WE_RTNETLINK_DEBUG
printk(KERN_DEBUG "%s (WE.r) : Wireless request data too short (%d)\n", printk(KERN_DEBUG "%s (WE.r) : Wireless request data too short (%d)\n",
dev->name, extra_size); dev->name, extra_size);
@ -1734,7 +1733,7 @@ static inline int rtnetlink_private_set(struct net_device * dev,
} }
/* Call commit handler if needed and defined */ /* Call commit handler if needed and defined */
if(ret == -EIWCOMMIT) if (ret == -EIWCOMMIT)
ret = call_commit_handler(dev); ret = call_commit_handler(dev);
return ret; return ret;
@ -1756,21 +1755,21 @@ int wireless_rtnetlink_get(struct net_device * dev,
iw_handler handler; iw_handler handler;
/* Check length */ /* Check length */
if(len < IW_EV_LCP_PK_LEN) { if (len < IW_EV_LCP_PK_LEN) {
printk(KERN_DEBUG "%s (WE.r) : RtNetlink request too short (%d)\n", printk(KERN_DEBUG "%s (WE.r) : RtNetlink request too short (%d)\n",
dev->name, len); dev->name, len);
return -EINVAL; return -EINVAL;
} }
/* ReCheck length (len may have padding) */ /* ReCheck length (len may have padding) */
if(request->len > len) { if (request->len > len) {
printk(KERN_DEBUG "%s (WE.r) : RtNetlink request len invalid (%d-%d)\n", printk(KERN_DEBUG "%s (WE.r) : RtNetlink request len invalid (%d-%d)\n",
dev->name, request->len, len); dev->name, request->len, len);
return -EINVAL; return -EINVAL;
} }
/* Only accept GET requests in here */ /* Only accept GET requests in here */
if(!IW_IS_GET(request->cmd)) if (!IW_IS_GET(request->cmd))
return -EOPNOTSUPP; return -EOPNOTSUPP;
/* If command is `get the encoding parameters', check if /* If command is `get the encoding parameters', check if
@ -1782,16 +1781,16 @@ int wireless_rtnetlink_get(struct net_device * dev,
} }
/* Special cases */ /* Special cases */
if(request->cmd == SIOCGIWSTATS) if (request->cmd == SIOCGIWSTATS)
/* Get Wireless Stats */ /* Get Wireless Stats */
return rtnetlink_standard_get(dev, return rtnetlink_standard_get(dev,
request, request,
request->len, request->len,
&iw_handler_get_iwstats, &iw_handler_get_iwstats,
p_buf, p_len); p_buf, p_len);
if(request->cmd == SIOCGIWPRIV) { if (request->cmd == SIOCGIWPRIV) {
/* Check if we have some wireless handlers defined */ /* Check if we have some wireless handlers defined */
if(dev->wireless_handlers == NULL) if (dev->wireless_handlers == NULL)
return -EOPNOTSUPP; return -EOPNOTSUPP;
/* Get Wireless Stats */ /* Get Wireless Stats */
return rtnetlink_standard_get(dev, return rtnetlink_standard_get(dev,
@ -1807,9 +1806,9 @@ int wireless_rtnetlink_get(struct net_device * dev,
/* Try to find the handler */ /* Try to find the handler */
handler = get_handler(dev, request->cmd); handler = get_handler(dev, request->cmd);
if(handler != NULL) { if (handler != NULL) {
/* Standard and private are not the same */ /* Standard and private are not the same */
if(request->cmd < SIOCIWFIRSTPRIV) if (request->cmd < SIOCIWFIRSTPRIV)
return rtnetlink_standard_get(dev, return rtnetlink_standard_get(dev,
request, request,
request->len, request->len,
@ -1840,21 +1839,21 @@ int wireless_rtnetlink_set(struct net_device * dev,
iw_handler handler; iw_handler handler;
/* Check length */ /* Check length */
if(len < IW_EV_LCP_PK_LEN) { if (len < IW_EV_LCP_PK_LEN) {
printk(KERN_DEBUG "%s (WE.r) : RtNetlink request too short (%d)\n", printk(KERN_DEBUG "%s (WE.r) : RtNetlink request too short (%d)\n",
dev->name, len); dev->name, len);
return -EINVAL; return -EINVAL;
} }
/* ReCheck length (len may have padding) */ /* ReCheck length (len may have padding) */
if(request->len > len) { if (request->len > len) {
printk(KERN_DEBUG "%s (WE.r) : RtNetlink request len invalid (%d-%d)\n", printk(KERN_DEBUG "%s (WE.r) : RtNetlink request len invalid (%d-%d)\n",
dev->name, request->len, len); dev->name, request->len, len);
return -EINVAL; return -EINVAL;
} }
/* Only accept SET requests in here */ /* Only accept SET requests in here */
if(!IW_IS_SET(request->cmd)) if (!IW_IS_SET(request->cmd))
return -EOPNOTSUPP; return -EOPNOTSUPP;
/* Basic check */ /* Basic check */
@ -1863,9 +1862,9 @@ int wireless_rtnetlink_set(struct net_device * dev,
/* New driver API : try to find the handler */ /* New driver API : try to find the handler */
handler = get_handler(dev, request->cmd); handler = get_handler(dev, request->cmd);
if(handler != NULL) { if (handler != NULL) {
/* Standard and private are not the same */ /* Standard and private are not the same */
if(request->cmd < SIOCIWFIRSTPRIV) if (request->cmd < SIOCIWFIRSTPRIV)
return rtnetlink_standard_set(dev, return rtnetlink_standard_set(dev,
request, request,
request->len, request->len,
@ -2015,17 +2014,17 @@ void wireless_send_event(struct net_device * dev,
unsigned cmd_index; /* *MUST* be unsigned */ unsigned cmd_index; /* *MUST* be unsigned */
/* Get the description of the Event */ /* Get the description of the Event */
if(cmd <= SIOCIWLAST) { if (cmd <= SIOCIWLAST) {
cmd_index = cmd - SIOCIWFIRST; cmd_index = cmd - SIOCIWFIRST;
if(cmd_index < standard_ioctl_num) if (cmd_index < standard_ioctl_num)
descr = &(standard_ioctl[cmd_index]); descr = &(standard_ioctl[cmd_index]);
} else { } else {
cmd_index = cmd - IWEVFIRST; cmd_index = cmd - IWEVFIRST;
if(cmd_index < standard_event_num) if (cmd_index < standard_event_num)
descr = &(standard_event[cmd_index]); descr = &(standard_event[cmd_index]);
} }
/* Don't accept unknown events */ /* Don't accept unknown events */
if(descr == NULL) { if (descr == NULL) {
/* Note : we don't return an error to the driver, because /* Note : we don't return an error to the driver, because
* the driver would not know what to do about it. It can't * the driver would not know what to do about it. It can't
* return an error to the user, because the event is not * return an error to the user, because the event is not
@ -2044,18 +2043,18 @@ void wireless_send_event(struct net_device * dev,
#endif /* WE_EVENT_DEBUG */ #endif /* WE_EVENT_DEBUG */
/* Check extra parameters and set extra_len */ /* Check extra parameters and set extra_len */
if(descr->header_type == IW_HEADER_TYPE_POINT) { if (descr->header_type == IW_HEADER_TYPE_POINT) {
/* Check if number of token fits within bounds */ /* Check if number of token fits within bounds */
if(wrqu->data.length > descr->max_tokens) { if (wrqu->data.length > descr->max_tokens) {
printk(KERN_ERR "%s (WE) : Wireless Event too big (%d)\n", dev->name, wrqu->data.length); printk(KERN_ERR "%s (WE) : Wireless Event too big (%d)\n", dev->name, wrqu->data.length);
return; return;
} }
if(wrqu->data.length < descr->min_tokens) { if (wrqu->data.length < descr->min_tokens) {
printk(KERN_ERR "%s (WE) : Wireless Event too small (%d)\n", dev->name, wrqu->data.length); printk(KERN_ERR "%s (WE) : Wireless Event too small (%d)\n", dev->name, wrqu->data.length);
return; return;
} }
/* Calculate extra_len - extra is NULL for restricted events */ /* Calculate extra_len - extra is NULL for restricted events */
if(extra != NULL) if (extra != NULL)
extra_len = wrqu->data.length * descr->token_size; extra_len = wrqu->data.length * descr->token_size;
/* Always at an offset in wrqu */ /* Always at an offset in wrqu */
wrqu_off = IW_EV_POINT_OFF; wrqu_off = IW_EV_POINT_OFF;
@ -2074,14 +2073,14 @@ void wireless_send_event(struct net_device * dev,
/* Create temporary buffer to hold the event */ /* Create temporary buffer to hold the event */
event = kmalloc(event_len, GFP_ATOMIC); event = kmalloc(event_len, GFP_ATOMIC);
if(event == NULL) if (event == NULL)
return; return;
/* Fill event */ /* Fill event */
event->len = event_len; event->len = event_len;
event->cmd = cmd; event->cmd = cmd;
memcpy(&event->u, ((char *) wrqu) + wrqu_off, hdr_len - IW_EV_LCP_LEN); memcpy(&event->u, ((char *) wrqu) + wrqu_off, hdr_len - IW_EV_LCP_LEN);
if(extra != NULL) if (extra != NULL)
memcpy(((char *) event) + hdr_len, extra, extra_len); memcpy(((char *) event) + hdr_len, extra, extra_len);
#ifdef WE_EVENT_RTNETLINK #ifdef WE_EVENT_RTNETLINK
@ -2116,7 +2115,7 @@ void wireless_send_event(struct net_device * dev,
static inline struct iw_spy_data * get_spydata(struct net_device *dev) static inline struct iw_spy_data * get_spydata(struct net_device *dev)
{ {
/* This is the new way */ /* This is the new way */
if(dev->wireless_data) if (dev->wireless_data)
return(dev->wireless_data->spy_data); return(dev->wireless_data->spy_data);
return NULL; return NULL;
} }
@ -2134,7 +2133,7 @@ int iw_handler_set_spy(struct net_device * dev,
struct sockaddr * address = (struct sockaddr *) extra; struct sockaddr * address = (struct sockaddr *) extra;
/* Make sure driver is not buggy or using the old API */ /* Make sure driver is not buggy or using the old API */
if(!spydata) if (!spydata)
return -EOPNOTSUPP; return -EOPNOTSUPP;
/* Disable spy collection while we copy the addresses. /* Disable spy collection while we copy the addresses.
@ -2151,11 +2150,11 @@ int iw_handler_set_spy(struct net_device * dev,
smp_wmb(); smp_wmb();
/* Are there are addresses to copy? */ /* Are there are addresses to copy? */
if(wrqu->data.length > 0) { if (wrqu->data.length > 0) {
int i; int i;
/* Copy addresses */ /* Copy addresses */
for(i = 0; i < wrqu->data.length; i++) for (i = 0; i < wrqu->data.length; i++)
memcpy(spydata->spy_address[i], address[i].sa_data, memcpy(spydata->spy_address[i], address[i].sa_data,
ETH_ALEN); ETH_ALEN);
/* Reset stats */ /* Reset stats */
@ -2199,23 +2198,23 @@ int iw_handler_get_spy(struct net_device * dev,
int i; int i;
/* Make sure driver is not buggy or using the old API */ /* Make sure driver is not buggy or using the old API */
if(!spydata) if (!spydata)
return -EOPNOTSUPP; return -EOPNOTSUPP;
wrqu->data.length = spydata->spy_number; wrqu->data.length = spydata->spy_number;
/* Copy addresses. */ /* Copy addresses. */
for(i = 0; i < spydata->spy_number; i++) { for (i = 0; i < spydata->spy_number; i++) {
memcpy(address[i].sa_data, spydata->spy_address[i], ETH_ALEN); memcpy(address[i].sa_data, spydata->spy_address[i], ETH_ALEN);
address[i].sa_family = AF_UNIX; address[i].sa_family = AF_UNIX;
} }
/* Copy stats to the user buffer (just after). */ /* Copy stats to the user buffer (just after). */
if(spydata->spy_number > 0) if (spydata->spy_number > 0)
memcpy(extra + (sizeof(struct sockaddr) *spydata->spy_number), memcpy(extra + (sizeof(struct sockaddr) *spydata->spy_number),
spydata->spy_stat, spydata->spy_stat,
sizeof(struct iw_quality) * spydata->spy_number); sizeof(struct iw_quality) * spydata->spy_number);
/* Reset updated flags. */ /* Reset updated flags. */
for(i = 0; i < spydata->spy_number; i++) for (i = 0; i < spydata->spy_number; i++)
spydata->spy_stat[i].updated &= ~IW_QUAL_ALL_UPDATED; spydata->spy_stat[i].updated &= ~IW_QUAL_ALL_UPDATED;
return 0; return 0;
} }
@ -2233,7 +2232,7 @@ int iw_handler_set_thrspy(struct net_device * dev,
struct iw_thrspy * threshold = (struct iw_thrspy *) extra; struct iw_thrspy * threshold = (struct iw_thrspy *) extra;
/* Make sure driver is not buggy or using the old API */ /* Make sure driver is not buggy or using the old API */
if(!spydata) if (!spydata)
return -EOPNOTSUPP; return -EOPNOTSUPP;
/* Just do it */ /* Just do it */
@ -2263,7 +2262,7 @@ int iw_handler_get_thrspy(struct net_device * dev,
struct iw_thrspy * threshold = (struct iw_thrspy *) extra; struct iw_thrspy * threshold = (struct iw_thrspy *) extra;
/* Make sure driver is not buggy or using the old API */ /* Make sure driver is not buggy or using the old API */
if(!spydata) if (!spydata)
return -EOPNOTSUPP; return -EOPNOTSUPP;
/* Just do it */ /* Just do it */
@ -2327,7 +2326,7 @@ void wireless_spy_update(struct net_device * dev,
int match = -1; int match = -1;
/* Make sure driver is not buggy or using the old API */ /* Make sure driver is not buggy or using the old API */
if(!spydata) if (!spydata)
return; return;
#ifdef WE_SPY_DEBUG #ifdef WE_SPY_DEBUG
@ -2335,8 +2334,8 @@ void wireless_spy_update(struct net_device * dev,
#endif /* WE_SPY_DEBUG */ #endif /* WE_SPY_DEBUG */
/* Update all records that match */ /* Update all records that match */
for(i = 0; i < spydata->spy_number; i++) for (i = 0; i < spydata->spy_number; i++)
if(!compare_ether_addr(address, spydata->spy_address[i])) { if (!compare_ether_addr(address, spydata->spy_address[i])) {
memcpy(&(spydata->spy_stat[i]), wstats, memcpy(&(spydata->spy_stat[i]), wstats,
sizeof(struct iw_quality)); sizeof(struct iw_quality));
match = i; match = i;
@ -2346,15 +2345,15 @@ void wireless_spy_update(struct net_device * dev,
* To avoid event storms, we have a simple hysteresis : we generate * To avoid event storms, we have a simple hysteresis : we generate
* event only when we go under the low threshold or above the * event only when we go under the low threshold or above the
* high threshold. */ * high threshold. */
if(match >= 0) { if (match >= 0) {
if(spydata->spy_thr_under[match]) { if (spydata->spy_thr_under[match]) {
if(wstats->level > spydata->spy_thr_high.level) { if (wstats->level > spydata->spy_thr_high.level) {
spydata->spy_thr_under[match] = 0; spydata->spy_thr_under[match] = 0;
iw_send_thrspy_event(dev, spydata, iw_send_thrspy_event(dev, spydata,
address, wstats); address, wstats);
} }
} else { } else {
if(wstats->level < spydata->spy_thr_low.level) { if (wstats->level < spydata->spy_thr_low.level) {
spydata->spy_thr_under[match] = 1; spydata->spy_thr_under[match] = 1;
iw_send_thrspy_event(dev, spydata, iw_send_thrspy_event(dev, spydata,
address, wstats); address, wstats);

View file

@ -1292,7 +1292,7 @@ asmlinkage long sys_bind(int fd, struct sockaddr __user *umyaddr, int addrlen)
int err, fput_needed; int err, fput_needed;
sock = sockfd_lookup_light(fd, &err, &fput_needed); sock = sockfd_lookup_light(fd, &err, &fput_needed);
if(sock) { if (sock) {
err = move_addr_to_kernel(umyaddr, addrlen, address); err = move_addr_to_kernel(umyaddr, addrlen, address);
if (err >= 0) { if (err >= 0) {
err = security_socket_bind(sock, err = security_socket_bind(sock,