diff options
author | Stephen Hemminger <shemminger@linux-foundation.org> | 2007-04-10 23:10:33 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-04-26 01:24:09 -0400 |
commit | e71a4783aae059931f63b2d4e7013e36529badef (patch) | |
tree | d9c2bad69b8d0512e12c8ff786237319990fbd00 /net/core/wireless.c | |
parent | add459aa1afe05472abc96f6a29aefd0c84e73d6 (diff) |
[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>
Diffstat (limited to 'net/core/wireless.c')
-rw-r--r-- | net/core/wireless.c | 297 |
1 files changed, 148 insertions, 149 deletions
diff --git a/net/core/wireless.c b/net/core/wireless.c index b07fe270a5..8f7f3abdb2 100644 --- a/net/core/wireless.c +++ b/net/core/wireless.c | |||
@@ -463,17 +463,17 @@ static inline iw_handler get_handler(struct net_device *dev, | |||
463 | unsigned int index; /* *MUST* be unsigned */ | 463 | unsigned int index; /* *MUST* be unsigned */ |
464 | 464 | ||
465 | /* Check if we have some wireless handlers defined */ | 465 | /* Check if we have some wireless handlers defined */ |
466 | if(dev->wireless_handlers == NULL) | 466 | if (dev->wireless_handlers == NULL) |
467 | return NULL; | 467 | return NULL; |
468 | 468 | ||
469 | /* Try as a standard command */ | 469 | /* Try as a standard command */ |
470 | index = cmd - SIOCIWFIRST; | 470 | index = cmd - SIOCIWFIRST; |
471 | if(index < dev->wireless_handlers->num_standard) | 471 | if (index < dev->wireless_handlers->num_standard) |
472 | return dev->wireless_handlers->standard[index]; | 472 | return dev->wireless_handlers->standard[index]; |
473 | 473 | ||
474 | /* Try as a private command */ | 474 | /* Try as a private command */ |
475 | index = cmd - SIOCIWFIRSTPRIV; | 475 | index = cmd - SIOCIWFIRSTPRIV; |
476 | if(index < dev->wireless_handlers->num_private) | 476 | if (index < dev->wireless_handlers->num_private) |
477 | return dev->wireless_handlers->private[index]; | 477 | return dev->wireless_handlers->private[index]; |
478 | 478 | ||
479 | /* Not found */ | 479 | /* Not found */ |
@@ -487,7 +487,7 @@ static inline iw_handler get_handler(struct net_device *dev, | |||
487 | static inline struct iw_statistics *get_wireless_stats(struct net_device *dev) | 487 | static inline struct iw_statistics *get_wireless_stats(struct net_device *dev) |
488 | { | 488 | { |
489 | /* New location */ | 489 | /* New location */ |
490 | if((dev->wireless_handlers != NULL) && | 490 | if ((dev->wireless_handlers != NULL) && |
491 | (dev->wireless_handlers->get_wireless_stats != NULL)) | 491 | (dev->wireless_handlers->get_wireless_stats != NULL)) |
492 | return dev->wireless_handlers->get_wireless_stats(dev); | 492 | return dev->wireless_handlers->get_wireless_stats(dev); |
493 | 493 | ||
@@ -516,7 +516,7 @@ static inline struct iw_statistics *get_wireless_stats(struct net_device *dev) | |||
516 | */ | 516 | */ |
517 | static inline int call_commit_handler(struct net_device * dev) | 517 | static inline int call_commit_handler(struct net_device * dev) |
518 | { | 518 | { |
519 | if((netif_running(dev)) && | 519 | if ((netif_running(dev)) && |
520 | (dev->wireless_handlers->standard[0] != NULL)) { | 520 | (dev->wireless_handlers->standard[0] != NULL)) { |
521 | /* Call the commit handler on the driver */ | 521 | /* Call the commit handler on the driver */ |
522 | return dev->wireless_handlers->standard[0](dev, NULL, | 522 | return dev->wireless_handlers->standard[0](dev, NULL, |
@@ -577,7 +577,7 @@ static int iw_handler_get_iwstats(struct net_device * dev, | |||
577 | wrqu->data.length = sizeof(struct iw_statistics); | 577 | wrqu->data.length = sizeof(struct iw_statistics); |
578 | 578 | ||
579 | /* Check if we need to clear the updated flag */ | 579 | /* Check if we need to clear the updated flag */ |
580 | if(wrqu->data.flags != 0) | 580 | if (wrqu->data.flags != 0) |
581 | stats->qual.updated &= ~IW_QUAL_ALL_UPDATED; | 581 | stats->qual.updated &= ~IW_QUAL_ALL_UPDATED; |
582 | return 0; | 582 | return 0; |
583 | } else | 583 | } else |
@@ -596,12 +596,12 @@ static int iw_handler_get_private(struct net_device * dev, | |||
596 | char * extra) | 596 | char * extra) |
597 | { | 597 | { |
598 | /* Check if the driver has something to export */ | 598 | /* Check if the driver has something to export */ |
599 | if((dev->wireless_handlers->num_private_args == 0) || | 599 | if ((dev->wireless_handlers->num_private_args == 0) || |
600 | (dev->wireless_handlers->private_args == NULL)) | 600 | (dev->wireless_handlers->private_args == NULL)) |
601 | return -EOPNOTSUPP; | 601 | return -EOPNOTSUPP; |
602 | 602 | ||
603 | /* Check if there is enough buffer up there */ | 603 | /* Check if there is enough buffer up there */ |
604 | if(wrqu->data.length < dev->wireless_handlers->num_private_args) { | 604 | if (wrqu->data.length < dev->wireless_handlers->num_private_args) { |
605 | /* User space can't know in advance how large the buffer | 605 | /* User space can't know in advance how large the buffer |
606 | * needs to be. Give it a hint, so that we can support | 606 | * needs to be. Give it a hint, so that we can support |
607 | * any size buffer we want somewhat efficiently... */ | 607 | * any size buffer we want somewhat efficiently... */ |
@@ -735,7 +735,7 @@ static int ioctl_standard_call(struct net_device * dev, | |||
735 | int ret = -EINVAL; | 735 | int ret = -EINVAL; |
736 | 736 | ||
737 | /* Get the description of the IOCTL */ | 737 | /* Get the description of the IOCTL */ |
738 | if((cmd - SIOCIWFIRST) >= standard_ioctl_num) | 738 | if ((cmd - SIOCIWFIRST) >= standard_ioctl_num) |
739 | return -EOPNOTSUPP; | 739 | return -EOPNOTSUPP; |
740 | descr = &(standard_ioctl[cmd - SIOCIWFIRST]); | 740 | descr = &(standard_ioctl[cmd - SIOCIWFIRST]); |
741 | 741 | ||
@@ -750,14 +750,14 @@ static int ioctl_standard_call(struct net_device * dev, | |||
750 | info.flags = 0; | 750 | info.flags = 0; |
751 | 751 | ||
752 | /* Check if we have a pointer to user space data or not */ | 752 | /* Check if we have a pointer to user space data or not */ |
753 | if(descr->header_type != IW_HEADER_TYPE_POINT) { | 753 | if (descr->header_type != IW_HEADER_TYPE_POINT) { |
754 | 754 | ||
755 | /* No extra arguments. Trivial to handle */ | 755 | /* No extra arguments. Trivial to handle */ |
756 | ret = handler(dev, &info, &(iwr->u), NULL); | 756 | ret = handler(dev, &info, &(iwr->u), NULL); |
757 | 757 | ||
758 | #ifdef WE_SET_EVENT | 758 | #ifdef WE_SET_EVENT |
759 | /* Generate an event to notify listeners of the change */ | 759 | /* Generate an event to notify listeners of the change */ |
760 | if((descr->flags & IW_DESCR_FLAG_EVENT) && | 760 | if ((descr->flags & IW_DESCR_FLAG_EVENT) && |
761 | ((ret == 0) || (ret == -EIWCOMMIT))) | 761 | ((ret == 0) || (ret == -EIWCOMMIT))) |
762 | wireless_send_event(dev, cmd, &(iwr->u), NULL); | 762 | wireless_send_event(dev, cmd, &(iwr->u), NULL); |
763 | #endif /* WE_SET_EVENT */ | 763 | #endif /* WE_SET_EVENT */ |
@@ -800,19 +800,19 @@ static int ioctl_standard_call(struct net_device * dev, | |||
800 | iwr->u.data.length -= essid_compat; | 800 | iwr->u.data.length -= essid_compat; |
801 | 801 | ||
802 | /* Check what user space is giving us */ | 802 | /* Check what user space is giving us */ |
803 | if(IW_IS_SET(cmd)) { | 803 | if (IW_IS_SET(cmd)) { |
804 | /* Check NULL pointer */ | 804 | /* Check NULL pointer */ |
805 | if((iwr->u.data.pointer == NULL) && | 805 | if ((iwr->u.data.pointer == NULL) && |
806 | (iwr->u.data.length != 0)) | 806 | (iwr->u.data.length != 0)) |
807 | return -EFAULT; | 807 | return -EFAULT; |
808 | /* Check if number of token fits within bounds */ | 808 | /* Check if number of token fits within bounds */ |
809 | if(iwr->u.data.length > descr->max_tokens) | 809 | if (iwr->u.data.length > descr->max_tokens) |
810 | return -E2BIG; | 810 | return -E2BIG; |
811 | if(iwr->u.data.length < descr->min_tokens) | 811 | if (iwr->u.data.length < descr->min_tokens) |
812 | return -EINVAL; | 812 | return -EINVAL; |
813 | } else { | 813 | } else { |
814 | /* Check NULL pointer */ | 814 | /* Check NULL pointer */ |
815 | if(iwr->u.data.pointer == NULL) | 815 | if (iwr->u.data.pointer == NULL) |
816 | return -EFAULT; | 816 | return -EFAULT; |
817 | /* Save user space buffer size for checking */ | 817 | /* Save user space buffer size for checking */ |
818 | user_length = iwr->u.data.length; | 818 | user_length = iwr->u.data.length; |
@@ -822,7 +822,7 @@ static int ioctl_standard_call(struct net_device * dev, | |||
822 | * implied by the test at the end. */ | 822 | * implied by the test at the end. */ |
823 | 823 | ||
824 | /* Support for very large requests */ | 824 | /* Support for very large requests */ |
825 | if((descr->flags & IW_DESCR_FLAG_NOMAX) && | 825 | if ((descr->flags & IW_DESCR_FLAG_NOMAX) && |
826 | (user_length > descr->max_tokens)) { | 826 | (user_length > descr->max_tokens)) { |
827 | /* Allow userspace to GET more than max so | 827 | /* Allow userspace to GET more than max so |
828 | * we can support any size GET requests. | 828 | * we can support any size GET requests. |
@@ -848,7 +848,7 @@ static int ioctl_standard_call(struct net_device * dev, | |||
848 | } | 848 | } |
849 | 849 | ||
850 | /* If it is a SET, get all the extra data in here */ | 850 | /* If it is a SET, get all the extra data in here */ |
851 | if(IW_IS_SET(cmd) && (iwr->u.data.length != 0)) { | 851 | if (IW_IS_SET(cmd) && (iwr->u.data.length != 0)) { |
852 | err = copy_from_user(extra, iwr->u.data.pointer, | 852 | err = copy_from_user(extra, iwr->u.data.pointer, |
853 | iwr->u.data.length * | 853 | iwr->u.data.length * |
854 | descr->token_size); | 854 | descr->token_size); |
@@ -871,7 +871,7 @@ static int ioctl_standard_call(struct net_device * dev, | |||
871 | /* If we have something to return to the user */ | 871 | /* If we have something to return to the user */ |
872 | if (!ret && IW_IS_GET(cmd)) { | 872 | if (!ret && IW_IS_GET(cmd)) { |
873 | /* Check if there is enough buffer up there */ | 873 | /* Check if there is enough buffer up there */ |
874 | if(user_length < iwr->u.data.length) { | 874 | if (user_length < iwr->u.data.length) { |
875 | kfree(extra); | 875 | kfree(extra); |
876 | return -E2BIG; | 876 | return -E2BIG; |
877 | } | 877 | } |
@@ -890,9 +890,9 @@ static int ioctl_standard_call(struct net_device * dev, | |||
890 | 890 | ||
891 | #ifdef WE_SET_EVENT | 891 | #ifdef WE_SET_EVENT |
892 | /* Generate an event to notify listeners of the change */ | 892 | /* Generate an event to notify listeners of the change */ |
893 | if((descr->flags & IW_DESCR_FLAG_EVENT) && | 893 | if ((descr->flags & IW_DESCR_FLAG_EVENT) && |
894 | ((ret == 0) || (ret == -EIWCOMMIT))) { | 894 | ((ret == 0) || (ret == -EIWCOMMIT))) { |
895 | if(descr->flags & IW_DESCR_FLAG_RESTRICT) | 895 | if (descr->flags & IW_DESCR_FLAG_RESTRICT) |
896 | /* If the event is restricted, don't | 896 | /* If the event is restricted, don't |
897 | * export the payload */ | 897 | * export the payload */ |
898 | wireless_send_event(dev, cmd, &(iwr->u), NULL); | 898 | wireless_send_event(dev, cmd, &(iwr->u), NULL); |
@@ -907,7 +907,7 @@ static int ioctl_standard_call(struct net_device * dev, | |||
907 | } | 907 | } |
908 | 908 | ||
909 | /* Call commit handler if needed and defined */ | 909 | /* Call commit handler if needed and defined */ |
910 | if(ret == -EIWCOMMIT) | 910 | if (ret == -EIWCOMMIT) |
911 | ret = call_commit_handler(dev); | 911 | ret = call_commit_handler(dev); |
912 | 912 | ||
913 | /* Here, we will generate the appropriate event if needed */ | 913 | /* Here, we will generate the appropriate event if needed */ |
@@ -944,8 +944,8 @@ static inline int ioctl_private_call(struct net_device * dev, | |||
944 | int ret = -EINVAL; | 944 | int ret = -EINVAL; |
945 | 945 | ||
946 | /* Get the description of the IOCTL */ | 946 | /* Get the description of the IOCTL */ |
947 | for(i = 0; i < dev->wireless_handlers->num_private_args; i++) | 947 | for (i = 0; i < dev->wireless_handlers->num_private_args; i++) |
948 | if(cmd == dev->wireless_handlers->private_args[i].cmd) { | 948 | if (cmd == dev->wireless_handlers->private_args[i].cmd) { |
949 | descr = &(dev->wireless_handlers->private_args[i]); | 949 | descr = &(dev->wireless_handlers->private_args[i]); |
950 | break; | 950 | break; |
951 | } | 951 | } |
@@ -953,7 +953,7 @@ static inline int ioctl_private_call(struct net_device * dev, | |||
953 | #ifdef WE_IOCTL_DEBUG | 953 | #ifdef WE_IOCTL_DEBUG |
954 | printk(KERN_DEBUG "%s (WE) : Found private handler for 0x%04X\n", | 954 | printk(KERN_DEBUG "%s (WE) : Found private handler for 0x%04X\n", |
955 | ifr->ifr_name, cmd); | 955 | ifr->ifr_name, cmd); |
956 | if(descr) { | 956 | if (descr) { |
957 | printk(KERN_DEBUG "%s (WE) : Name %s, set %X, get %X\n", | 957 | printk(KERN_DEBUG "%s (WE) : Name %s, set %X, get %X\n", |
958 | dev->name, descr->name, | 958 | dev->name, descr->name, |
959 | descr->set_args, descr->get_args); | 959 | descr->set_args, descr->get_args); |
@@ -961,11 +961,11 @@ static inline int ioctl_private_call(struct net_device * dev, | |||
961 | #endif /* WE_IOCTL_DEBUG */ | 961 | #endif /* WE_IOCTL_DEBUG */ |
962 | 962 | ||
963 | /* Compute the size of the set/get arguments */ | 963 | /* Compute the size of the set/get arguments */ |
964 | if(descr != NULL) { | 964 | if (descr != NULL) { |
965 | if(IW_IS_SET(cmd)) { | 965 | if (IW_IS_SET(cmd)) { |
966 | int offset = 0; /* For sub-ioctls */ | 966 | int offset = 0; /* For sub-ioctls */ |
967 | /* Check for sub-ioctl handler */ | 967 | /* Check for sub-ioctl handler */ |
968 | if(descr->name[0] == '\0') | 968 | if (descr->name[0] == '\0') |
969 | /* Reserve one int for sub-ioctl index */ | 969 | /* Reserve one int for sub-ioctl index */ |
970 | offset = sizeof(__u32); | 970 | offset = sizeof(__u32); |
971 | 971 | ||
@@ -973,7 +973,7 @@ static inline int ioctl_private_call(struct net_device * dev, | |||
973 | extra_size = get_priv_size(descr->set_args); | 973 | extra_size = get_priv_size(descr->set_args); |
974 | 974 | ||
975 | /* Does it fits in iwr ? */ | 975 | /* Does it fits in iwr ? */ |
976 | if((descr->set_args & IW_PRIV_SIZE_FIXED) && | 976 | if ((descr->set_args & IW_PRIV_SIZE_FIXED) && |
977 | ((extra_size + offset) <= IFNAMSIZ)) | 977 | ((extra_size + offset) <= IFNAMSIZ)) |
978 | extra_size = 0; | 978 | extra_size = 0; |
979 | } else { | 979 | } else { |
@@ -981,7 +981,7 @@ static inline int ioctl_private_call(struct net_device * dev, | |||
981 | extra_size = get_priv_size(descr->get_args); | 981 | extra_size = get_priv_size(descr->get_args); |
982 | 982 | ||
983 | /* Does it fits in iwr ? */ | 983 | /* Does it fits in iwr ? */ |
984 | if((descr->get_args & IW_PRIV_SIZE_FIXED) && | 984 | if ((descr->get_args & IW_PRIV_SIZE_FIXED) && |
985 | (extra_size <= IFNAMSIZ)) | 985 | (extra_size <= IFNAMSIZ)) |
986 | extra_size = 0; | 986 | extra_size = 0; |
987 | } | 987 | } |
@@ -992,7 +992,7 @@ static inline int ioctl_private_call(struct net_device * dev, | |||
992 | info.flags = 0; | 992 | info.flags = 0; |
993 | 993 | ||
994 | /* Check if we have a pointer to user space data or not. */ | 994 | /* Check if we have a pointer to user space data or not. */ |
995 | if(extra_size == 0) { | 995 | if (extra_size == 0) { |
996 | /* No extra arguments. Trivial to handle */ | 996 | /* No extra arguments. Trivial to handle */ |
997 | ret = handler(dev, &info, &(iwr->u), (char *) &(iwr->u)); | 997 | ret = handler(dev, &info, &(iwr->u), (char *) &(iwr->u)); |
998 | } else { | 998 | } else { |
@@ -1000,19 +1000,19 @@ static inline int ioctl_private_call(struct net_device * dev, | |||
1000 | int err; | 1000 | int err; |
1001 | 1001 | ||
1002 | /* Check what user space is giving us */ | 1002 | /* Check what user space is giving us */ |
1003 | if(IW_IS_SET(cmd)) { | 1003 | if (IW_IS_SET(cmd)) { |
1004 | /* Check NULL pointer */ | 1004 | /* Check NULL pointer */ |
1005 | if((iwr->u.data.pointer == NULL) && | 1005 | if ((iwr->u.data.pointer == NULL) && |
1006 | (iwr->u.data.length != 0)) | 1006 | (iwr->u.data.length != 0)) |
1007 | return -EFAULT; | 1007 | return -EFAULT; |
1008 | 1008 | ||
1009 | /* Does it fits within bounds ? */ | 1009 | /* Does it fits within bounds ? */ |
1010 | if(iwr->u.data.length > (descr->set_args & | 1010 | if (iwr->u.data.length > (descr->set_args & |
1011 | IW_PRIV_SIZE_MASK)) | 1011 | IW_PRIV_SIZE_MASK)) |
1012 | return -E2BIG; | 1012 | return -E2BIG; |
1013 | } else { | 1013 | } else { |
1014 | /* Check NULL pointer */ | 1014 | /* Check NULL pointer */ |
1015 | if(iwr->u.data.pointer == NULL) | 1015 | if (iwr->u.data.pointer == NULL) |
1016 | return -EFAULT; | 1016 | return -EFAULT; |
1017 | } | 1017 | } |
1018 | 1018 | ||
@@ -1029,7 +1029,7 @@ static inline int ioctl_private_call(struct net_device * dev, | |||
1029 | } | 1029 | } |
1030 | 1030 | ||
1031 | /* If it is a SET, get all the extra data in here */ | 1031 | /* If it is a SET, get all the extra data in here */ |
1032 | if(IW_IS_SET(cmd) && (iwr->u.data.length != 0)) { | 1032 | if (IW_IS_SET(cmd) && (iwr->u.data.length != 0)) { |
1033 | err = copy_from_user(extra, iwr->u.data.pointer, | 1033 | err = copy_from_user(extra, iwr->u.data.pointer, |
1034 | extra_size); | 1034 | extra_size); |
1035 | if (err) { | 1035 | if (err) { |
@@ -1071,7 +1071,7 @@ static inline int ioctl_private_call(struct net_device * dev, | |||
1071 | 1071 | ||
1072 | 1072 | ||
1073 | /* Call commit handler if needed and defined */ | 1073 | /* Call commit handler if needed and defined */ |
1074 | if(ret == -EIWCOMMIT) | 1074 | if (ret == -EIWCOMMIT) |
1075 | ret = call_commit_handler(dev); | 1075 | ret = call_commit_handler(dev); |
1076 | 1076 | ||
1077 | return ret; | 1077 | return ret; |
@@ -1098,51 +1098,50 @@ int wireless_process_ioctl(struct ifreq *ifr, unsigned int cmd) | |||
1098 | /* A bunch of special cases, then the generic case... | 1098 | /* A bunch of special cases, then the generic case... |
1099 | * Note that 'cmd' is already filtered in dev_ioctl() with | 1099 | * Note that 'cmd' is already filtered in dev_ioctl() with |
1100 | * (cmd >= SIOCIWFIRST && cmd <= SIOCIWLAST) */ | 1100 | * (cmd >= SIOCIWFIRST && cmd <= SIOCIWLAST) */ |
1101 | switch(cmd) | 1101 | switch (cmd) { |
1102 | { | 1102 | case SIOCGIWSTATS: |
1103 | case SIOCGIWSTATS: | 1103 | /* Get Wireless Stats */ |
1104 | /* Get Wireless Stats */ | 1104 | return ioctl_standard_call(dev, |
1105 | ifr, | ||
1106 | cmd, | ||
1107 | &iw_handler_get_iwstats); | ||
1108 | |||
1109 | case SIOCGIWPRIV: | ||
1110 | /* Check if we have some wireless handlers defined */ | ||
1111 | if (dev->wireless_handlers != NULL) { | ||
1112 | /* We export to user space the definition of | ||
1113 | * the private handler ourselves */ | ||
1105 | return ioctl_standard_call(dev, | 1114 | return ioctl_standard_call(dev, |
1106 | ifr, | 1115 | ifr, |
1107 | cmd, | 1116 | cmd, |
1108 | &iw_handler_get_iwstats); | 1117 | &iw_handler_get_private); |
1109 | 1118 | } | |
1110 | case SIOCGIWPRIV: | 1119 | // ## Fall-through for old API ## |
1111 | /* Check if we have some wireless handlers defined */ | 1120 | default: |
1112 | if(dev->wireless_handlers != NULL) { | 1121 | /* Generic IOCTL */ |
1113 | /* We export to user space the definition of | 1122 | /* Basic check */ |
1114 | * the private handler ourselves */ | 1123 | if (!netif_device_present(dev)) |
1124 | return -ENODEV; | ||
1125 | /* New driver API : try to find the handler */ | ||
1126 | handler = get_handler(dev, cmd); | ||
1127 | if (handler != NULL) { | ||
1128 | /* Standard and private are not the same */ | ||
1129 | if (cmd < SIOCIWFIRSTPRIV) | ||
1115 | return ioctl_standard_call(dev, | 1130 | return ioctl_standard_call(dev, |
1116 | ifr, | 1131 | ifr, |
1117 | cmd, | 1132 | cmd, |
1118 | &iw_handler_get_private); | 1133 | handler); |
1119 | } | 1134 | else |
1120 | // ## Fall-through for old API ## | 1135 | return ioctl_private_call(dev, |
1121 | default: | 1136 | ifr, |
1122 | /* Generic IOCTL */ | 1137 | cmd, |
1123 | /* Basic check */ | 1138 | handler); |
1124 | if (!netif_device_present(dev)) | 1139 | } |
1125 | return -ENODEV; | 1140 | /* Old driver API : call driver ioctl handler */ |
1126 | /* New driver API : try to find the handler */ | 1141 | if (dev->do_ioctl) { |
1127 | handler = get_handler(dev, cmd); | 1142 | return dev->do_ioctl(dev, ifr, cmd); |
1128 | if(handler != NULL) { | 1143 | } |
1129 | /* Standard and private are not the same */ | 1144 | return -EOPNOTSUPP; |
1130 | if(cmd < SIOCIWFIRSTPRIV) | ||
1131 | return ioctl_standard_call(dev, | ||
1132 | ifr, | ||
1133 | cmd, | ||
1134 | handler); | ||
1135 | else | ||
1136 | return ioctl_private_call(dev, | ||
1137 | ifr, | ||
1138 | cmd, | ||
1139 | handler); | ||
1140 | } | ||
1141 | /* Old driver API : call driver ioctl handler */ | ||
1142 | if (dev->do_ioctl) { | ||
1143 | return dev->do_ioctl(dev, ifr, cmd); | ||
1144 | } | ||
1145 | return -EOPNOTSUPP; | ||
1146 | } | 1145 | } |
1147 | /* Not reached */ | 1146 | /* Not reached */ |
1148 | return -EINVAL; | 1147 | return -EINVAL; |
@@ -1196,7 +1195,7 @@ static int rtnetlink_standard_get(struct net_device * dev, | |||
1196 | 1195 | ||
1197 | /* Get the description of the Request */ | 1196 | /* Get the description of the Request */ |
1198 | cmd = request->cmd; | 1197 | cmd = request->cmd; |
1199 | if((cmd - SIOCIWFIRST) >= standard_ioctl_num) | 1198 | if ((cmd - SIOCIWFIRST) >= standard_ioctl_num) |
1200 | return -EOPNOTSUPP; | 1199 | return -EOPNOTSUPP; |
1201 | descr = &(standard_ioctl[cmd - SIOCIWFIRST]); | 1200 | descr = &(standard_ioctl[cmd - SIOCIWFIRST]); |
1202 | 1201 | ||
@@ -1208,7 +1207,7 @@ static int rtnetlink_standard_get(struct net_device * dev, | |||
1208 | 1207 | ||
1209 | /* Check if wrqu is complete */ | 1208 | /* Check if wrqu is complete */ |
1210 | hdr_len = event_type_size[descr->header_type]; | 1209 | hdr_len = event_type_size[descr->header_type]; |
1211 | if(request_len < hdr_len) { | 1210 | if (request_len < hdr_len) { |
1212 | #ifdef WE_RTNETLINK_DEBUG | 1211 | #ifdef WE_RTNETLINK_DEBUG |
1213 | printk(KERN_DEBUG | 1212 | printk(KERN_DEBUG |
1214 | "%s (WE.r) : Wireless request too short (%d)\n", | 1213 | "%s (WE.r) : Wireless request too short (%d)\n", |
@@ -1222,7 +1221,7 @@ static int rtnetlink_standard_get(struct net_device * dev, | |||
1222 | info.flags = 0; | 1221 | info.flags = 0; |
1223 | 1222 | ||
1224 | /* Check if we have extra data in the reply or not */ | 1223 | /* Check if we have extra data in the reply or not */ |
1225 | if(descr->header_type != IW_HEADER_TYPE_POINT) { | 1224 | if (descr->header_type != IW_HEADER_TYPE_POINT) { |
1226 | 1225 | ||
1227 | /* Create the kernel buffer that we will return. | 1226 | /* Create the kernel buffer that we will return. |
1228 | * It's at an offset to match the TYPE_POINT case... */ | 1227 | * It's at an offset to match the TYPE_POINT case... */ |
@@ -1254,7 +1253,7 @@ static int rtnetlink_standard_get(struct net_device * dev, | |||
1254 | * for max space. Easier, and won't last long... */ | 1253 | * for max space. Easier, and won't last long... */ |
1255 | extra_size = descr->max_tokens * descr->token_size; | 1254 | extra_size = descr->max_tokens * descr->token_size; |
1256 | /* Support for very large requests */ | 1255 | /* Support for very large requests */ |
1257 | if((descr->flags & IW_DESCR_FLAG_NOMAX) && | 1256 | if ((descr->flags & IW_DESCR_FLAG_NOMAX) && |
1258 | (wrqu_point.data.length > descr->max_tokens)) | 1257 | (wrqu_point.data.length > descr->max_tokens)) |
1259 | extra_size = (wrqu_point.data.length | 1258 | extra_size = (wrqu_point.data.length |
1260 | * descr->token_size); | 1259 | * descr->token_size); |
@@ -1299,7 +1298,7 @@ static int rtnetlink_standard_get(struct net_device * dev, | |||
1299 | #endif /* WE_RTNETLINK_DEBUG */ | 1298 | #endif /* WE_RTNETLINK_DEBUG */ |
1300 | 1299 | ||
1301 | /* Check if there is enough buffer up there */ | 1300 | /* Check if there is enough buffer up there */ |
1302 | if(wrqu_point.data.length < wrqu->data.length) | 1301 | if (wrqu_point.data.length < wrqu->data.length) |
1303 | ret = -E2BIG; | 1302 | ret = -E2BIG; |
1304 | } | 1303 | } |
1305 | 1304 | ||
@@ -1309,7 +1308,7 @@ static int rtnetlink_standard_get(struct net_device * dev, | |||
1309 | *p_len = request->len; | 1308 | *p_len = request->len; |
1310 | } else { | 1309 | } else { |
1311 | /* Cleanup */ | 1310 | /* Cleanup */ |
1312 | if(buffer) | 1311 | if (buffer) |
1313 | kfree(buffer); | 1312 | kfree(buffer); |
1314 | } | 1313 | } |
1315 | 1314 | ||
@@ -1338,7 +1337,7 @@ static inline int rtnetlink_standard_set(struct net_device * dev, | |||
1338 | 1337 | ||
1339 | /* Get the description of the Request */ | 1338 | /* Get the description of the Request */ |
1340 | cmd = request->cmd; | 1339 | cmd = request->cmd; |
1341 | if((cmd - SIOCIWFIRST) >= standard_ioctl_num) | 1340 | if ((cmd - SIOCIWFIRST) >= standard_ioctl_num) |
1342 | return -EOPNOTSUPP; | 1341 | return -EOPNOTSUPP; |
1343 | descr = &(standard_ioctl[cmd - SIOCIWFIRST]); | 1342 | descr = &(standard_ioctl[cmd - SIOCIWFIRST]); |
1344 | 1343 | ||
@@ -1353,7 +1352,7 @@ static inline int rtnetlink_standard_set(struct net_device * dev, | |||
1353 | 1352 | ||
1354 | /* Check if wrqu is complete */ | 1353 | /* Check if wrqu is complete */ |
1355 | hdr_len = event_type_pk_size[descr->header_type]; | 1354 | hdr_len = event_type_pk_size[descr->header_type]; |
1356 | if(request_len < hdr_len) { | 1355 | if (request_len < hdr_len) { |
1357 | #ifdef WE_RTNETLINK_DEBUG | 1356 | #ifdef WE_RTNETLINK_DEBUG |
1358 | printk(KERN_DEBUG | 1357 | printk(KERN_DEBUG |
1359 | "%s (WE.r) : Wireless request too short (%d)\n", | 1358 | "%s (WE.r) : Wireless request too short (%d)\n", |
@@ -1367,7 +1366,7 @@ static inline int rtnetlink_standard_set(struct net_device * dev, | |||
1367 | info.flags = 0; | 1366 | info.flags = 0; |
1368 | 1367 | ||
1369 | /* Check if we have extra data in the request or not */ | 1368 | /* Check if we have extra data in the request or not */ |
1370 | if(descr->header_type != IW_HEADER_TYPE_POINT) { | 1369 | if (descr->header_type != IW_HEADER_TYPE_POINT) { |
1371 | 1370 | ||
1372 | /* No extra arguments. Trivial to handle */ | 1371 | /* No extra arguments. Trivial to handle */ |
1373 | ret = handler(dev, &info, wrqu, NULL); | 1372 | ret = handler(dev, &info, wrqu, NULL); |
@@ -1382,16 +1381,16 @@ static inline int rtnetlink_standard_set(struct net_device * dev, | |||
1382 | wrqu = &wrqu_point; | 1381 | wrqu = &wrqu_point; |
1383 | 1382 | ||
1384 | /* Check if number of token fits within bounds */ | 1383 | /* Check if number of token fits within bounds */ |
1385 | if(wrqu_point.data.length > descr->max_tokens) | 1384 | if (wrqu_point.data.length > descr->max_tokens) |
1386 | return -E2BIG; | 1385 | return -E2BIG; |
1387 | if(wrqu_point.data.length < descr->min_tokens) | 1386 | if (wrqu_point.data.length < descr->min_tokens) |
1388 | return -EINVAL; | 1387 | return -EINVAL; |
1389 | 1388 | ||
1390 | /* Real length of payload */ | 1389 | /* Real length of payload */ |
1391 | extra_len = wrqu_point.data.length * descr->token_size; | 1390 | extra_len = wrqu_point.data.length * descr->token_size; |
1392 | 1391 | ||
1393 | /* Check if request is self consistent */ | 1392 | /* Check if request is self consistent */ |
1394 | if((request_len - hdr_len) < extra_len) { | 1393 | if ((request_len - hdr_len) < extra_len) { |
1395 | #ifdef WE_RTNETLINK_DEBUG | 1394 | #ifdef WE_RTNETLINK_DEBUG |
1396 | printk(KERN_DEBUG "%s (WE.r) : Wireless request data too short (%d)\n", | 1395 | printk(KERN_DEBUG "%s (WE.r) : Wireless request data too short (%d)\n", |
1397 | dev->name, extra_size); | 1396 | dev->name, extra_size); |
@@ -1420,9 +1419,9 @@ static inline int rtnetlink_standard_set(struct net_device * dev, | |||
1420 | 1419 | ||
1421 | #ifdef WE_SET_EVENT | 1420 | #ifdef WE_SET_EVENT |
1422 | /* Generate an event to notify listeners of the change */ | 1421 | /* Generate an event to notify listeners of the change */ |
1423 | if((descr->flags & IW_DESCR_FLAG_EVENT) && | 1422 | if ((descr->flags & IW_DESCR_FLAG_EVENT) && |
1424 | ((ret == 0) || (ret == -EIWCOMMIT))) { | 1423 | ((ret == 0) || (ret == -EIWCOMMIT))) { |
1425 | if(descr->flags & IW_DESCR_FLAG_RESTRICT) | 1424 | if (descr->flags & IW_DESCR_FLAG_RESTRICT) |
1426 | /* If the event is restricted, don't | 1425 | /* If the event is restricted, don't |
1427 | * export the payload */ | 1426 | * export the payload */ |
1428 | wireless_send_event(dev, cmd, wrqu, NULL); | 1427 | wireless_send_event(dev, cmd, wrqu, NULL); |
@@ -1432,11 +1431,11 @@ static inline int rtnetlink_standard_set(struct net_device * dev, | |||
1432 | #endif /* WE_SET_EVENT */ | 1431 | #endif /* WE_SET_EVENT */ |
1433 | 1432 | ||
1434 | /* Cleanup - I told you it wasn't that long ;-) */ | 1433 | /* Cleanup - I told you it wasn't that long ;-) */ |
1435 | if(extra) | 1434 | if (extra) |
1436 | kfree(extra); | 1435 | kfree(extra); |
1437 | 1436 | ||
1438 | /* Call commit handler if needed and defined */ | 1437 | /* Call commit handler if needed and defined */ |
1439 | if(ret == -EIWCOMMIT) | 1438 | if (ret == -EIWCOMMIT) |
1440 | ret = call_commit_handler(dev); | 1439 | ret = call_commit_handler(dev); |
1441 | 1440 | ||
1442 | return ret; | 1441 | return ret; |
@@ -1477,12 +1476,12 @@ static inline int rtnetlink_private_get(struct net_device * dev, | |||
1477 | 1476 | ||
1478 | /* Get the description of the Request */ | 1477 | /* Get the description of the Request */ |
1479 | cmd = request->cmd; | 1478 | cmd = request->cmd; |
1480 | for(i = 0; i < dev->wireless_handlers->num_private_args; i++) | 1479 | for (i = 0; i < dev->wireless_handlers->num_private_args; i++) |
1481 | if(cmd == dev->wireless_handlers->private_args[i].cmd) { | 1480 | if (cmd == dev->wireless_handlers->private_args[i].cmd) { |
1482 | descr = &(dev->wireless_handlers->private_args[i]); | 1481 | descr = &(dev->wireless_handlers->private_args[i]); |
1483 | break; | 1482 | break; |
1484 | } | 1483 | } |
1485 | if(descr == NULL) | 1484 | if (descr == NULL) |
1486 | return -EOPNOTSUPP; | 1485 | return -EOPNOTSUPP; |
1487 | 1486 | ||
1488 | #ifdef WE_RTNETLINK_DEBUG | 1487 | #ifdef WE_RTNETLINK_DEBUG |
@@ -1496,7 +1495,7 @@ static inline int rtnetlink_private_get(struct net_device * dev, | |||
1496 | extra_size = get_priv_size(descr->get_args); | 1495 | extra_size = get_priv_size(descr->get_args); |
1497 | 1496 | ||
1498 | /* Does it fits in wrqu ? */ | 1497 | /* Does it fits in wrqu ? */ |
1499 | if((descr->get_args & IW_PRIV_SIZE_FIXED) && | 1498 | if ((descr->get_args & IW_PRIV_SIZE_FIXED) && |
1500 | (extra_size <= IFNAMSIZ)) { | 1499 | (extra_size <= IFNAMSIZ)) { |
1501 | hdr_len = extra_size; | 1500 | hdr_len = extra_size; |
1502 | extra_size = 0; | 1501 | extra_size = 0; |
@@ -1505,7 +1504,7 @@ static inline int rtnetlink_private_get(struct net_device * dev, | |||
1505 | } | 1504 | } |
1506 | 1505 | ||
1507 | /* Check if wrqu is complete */ | 1506 | /* Check if wrqu is complete */ |
1508 | if(request_len < hdr_len) { | 1507 | if (request_len < hdr_len) { |
1509 | #ifdef WE_RTNETLINK_DEBUG | 1508 | #ifdef WE_RTNETLINK_DEBUG |
1510 | printk(KERN_DEBUG | 1509 | printk(KERN_DEBUG |
1511 | "%s (WE.r) : Wireless request too short (%d)\n", | 1510 | "%s (WE.r) : Wireless request too short (%d)\n", |
@@ -1519,7 +1518,7 @@ static inline int rtnetlink_private_get(struct net_device * dev, | |||
1519 | info.flags = 0; | 1518 | info.flags = 0; |
1520 | 1519 | ||
1521 | /* Check if we have a pointer to user space data or not. */ | 1520 | /* Check if we have a pointer to user space data or not. */ |
1522 | if(extra_size == 0) { | 1521 | if (extra_size == 0) { |
1523 | 1522 | ||
1524 | /* Create the kernel buffer that we will return. | 1523 | /* Create the kernel buffer that we will return. |
1525 | * It's at an offset to match the TYPE_POINT case... */ | 1524 | * 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, | |||
1591 | *p_len = request->len; | 1590 | *p_len = request->len; |
1592 | } else { | 1591 | } else { |
1593 | /* Cleanup */ | 1592 | /* Cleanup */ |
1594 | if(buffer) | 1593 | if (buffer) |
1595 | kfree(buffer); | 1594 | kfree(buffer); |
1596 | } | 1595 | } |
1597 | 1596 | ||
@@ -1632,12 +1631,12 @@ static inline int rtnetlink_private_set(struct net_device * dev, | |||
1632 | 1631 | ||
1633 | /* Get the description of the Request */ | 1632 | /* Get the description of the Request */ |
1634 | cmd = request->cmd; | 1633 | cmd = request->cmd; |
1635 | for(i = 0; i < dev->wireless_handlers->num_private_args; i++) | 1634 | for (i = 0; i < dev->wireless_handlers->num_private_args; i++) |
1636 | if(cmd == dev->wireless_handlers->private_args[i].cmd) { | 1635 | if (cmd == dev->wireless_handlers->private_args[i].cmd) { |
1637 | descr = &(dev->wireless_handlers->private_args[i]); | 1636 | descr = &(dev->wireless_handlers->private_args[i]); |
1638 | break; | 1637 | break; |
1639 | } | 1638 | } |
1640 | if(descr == NULL) | 1639 | if (descr == NULL) |
1641 | return -EOPNOTSUPP; | 1640 | return -EOPNOTSUPP; |
1642 | 1641 | ||
1643 | #ifdef WE_RTNETLINK_DEBUG | 1642 | #ifdef WE_RTNETLINK_DEBUG |
@@ -1649,7 +1648,7 @@ static inline int rtnetlink_private_set(struct net_device * dev, | |||
1649 | 1648 | ||
1650 | /* Compute the size of the set arguments */ | 1649 | /* Compute the size of the set arguments */ |
1651 | /* Check for sub-ioctl handler */ | 1650 | /* Check for sub-ioctl handler */ |
1652 | if(descr->name[0] == '\0') | 1651 | if (descr->name[0] == '\0') |
1653 | /* Reserve one int for sub-ioctl index */ | 1652 | /* Reserve one int for sub-ioctl index */ |
1654 | offset = sizeof(__u32); | 1653 | offset = sizeof(__u32); |
1655 | 1654 | ||
@@ -1657,7 +1656,7 @@ static inline int rtnetlink_private_set(struct net_device * dev, | |||
1657 | extra_size = get_priv_size(descr->set_args); | 1656 | extra_size = get_priv_size(descr->set_args); |
1658 | 1657 | ||
1659 | /* Does it fits in wrqu ? */ | 1658 | /* Does it fits in wrqu ? */ |
1660 | if((descr->set_args & IW_PRIV_SIZE_FIXED) && | 1659 | if ((descr->set_args & IW_PRIV_SIZE_FIXED) && |
1661 | (extra_size <= IFNAMSIZ)) { | 1660 | (extra_size <= IFNAMSIZ)) { |
1662 | hdr_len = IW_EV_LCP_PK_LEN + extra_size; | 1661 | hdr_len = IW_EV_LCP_PK_LEN + extra_size; |
1663 | extra_size = 0; | 1662 | extra_size = 0; |
@@ -1669,7 +1668,7 @@ static inline int rtnetlink_private_set(struct net_device * dev, | |||
1669 | wrqu = (union iwreq_data *) (((char *) request) + IW_EV_LCP_PK_LEN); | 1668 | wrqu = (union iwreq_data *) (((char *) request) + IW_EV_LCP_PK_LEN); |
1670 | 1669 | ||
1671 | /* Check if wrqu is complete */ | 1670 | /* Check if wrqu is complete */ |
1672 | if(request_len < hdr_len) { | 1671 | if (request_len < hdr_len) { |
1673 | #ifdef WE_RTNETLINK_DEBUG | 1672 | #ifdef WE_RTNETLINK_DEBUG |
1674 | printk(KERN_DEBUG | 1673 | printk(KERN_DEBUG |
1675 | "%s (WE.r) : Wireless request too short (%d)\n", | 1674 | "%s (WE.r) : Wireless request too short (%d)\n", |
@@ -1683,7 +1682,7 @@ static inline int rtnetlink_private_set(struct net_device * dev, | |||
1683 | info.flags = 0; | 1682 | info.flags = 0; |
1684 | 1683 | ||
1685 | /* Check if we have a pointer to user space data or not. */ | 1684 | /* Check if we have a pointer to user space data or not. */ |
1686 | if(extra_size == 0) { | 1685 | if (extra_size == 0) { |
1687 | 1686 | ||
1688 | /* No extra arguments. Trivial to handle */ | 1687 | /* No extra arguments. Trivial to handle */ |
1689 | ret = handler(dev, &info, wrqu, (char *) wrqu); | 1688 | ret = handler(dev, &info, wrqu, (char *) wrqu); |
@@ -1696,7 +1695,7 @@ static inline int rtnetlink_private_set(struct net_device * dev, | |||
1696 | wrqu, IW_EV_POINT_PK_LEN - IW_EV_LCP_PK_LEN); | 1695 | wrqu, IW_EV_POINT_PK_LEN - IW_EV_LCP_PK_LEN); |
1697 | 1696 | ||
1698 | /* Does it fits within bounds ? */ | 1697 | /* Does it fits within bounds ? */ |
1699 | if(wrqu_point.data.length > (descr->set_args & | 1698 | if (wrqu_point.data.length > (descr->set_args & |
1700 | IW_PRIV_SIZE_MASK)) | 1699 | IW_PRIV_SIZE_MASK)) |
1701 | return -E2BIG; | 1700 | return -E2BIG; |
1702 | 1701 | ||
@@ -1704,7 +1703,7 @@ static inline int rtnetlink_private_set(struct net_device * dev, | |||
1704 | extra_len = adjust_priv_size(descr->set_args, &wrqu_point); | 1703 | extra_len = adjust_priv_size(descr->set_args, &wrqu_point); |
1705 | 1704 | ||
1706 | /* Check if request is self consistent */ | 1705 | /* Check if request is self consistent */ |
1707 | if((request_len - hdr_len) < extra_len) { | 1706 | if ((request_len - hdr_len) < extra_len) { |
1708 | #ifdef WE_RTNETLINK_DEBUG | 1707 | #ifdef WE_RTNETLINK_DEBUG |
1709 | printk(KERN_DEBUG "%s (WE.r) : Wireless request data too short (%d)\n", | 1708 | printk(KERN_DEBUG "%s (WE.r) : Wireless request data too short (%d)\n", |
1710 | dev->name, extra_size); | 1709 | dev->name, extra_size); |
@@ -1734,7 +1733,7 @@ static inline int rtnetlink_private_set(struct net_device * dev, | |||
1734 | } | 1733 | } |
1735 | 1734 | ||
1736 | /* Call commit handler if needed and defined */ | 1735 | /* Call commit handler if needed and defined */ |
1737 | if(ret == -EIWCOMMIT) | 1736 | if (ret == -EIWCOMMIT) |
1738 | ret = call_commit_handler(dev); | 1737 | ret = call_commit_handler(dev); |
1739 | 1738 | ||
1740 | return ret; | 1739 | return ret; |
@@ -1756,21 +1755,21 @@ int wireless_rtnetlink_get(struct net_device * dev, | |||
1756 | iw_handler handler; | 1755 | iw_handler handler; |
1757 | 1756 | ||
1758 | /* Check length */ | 1757 | /* Check length */ |
1759 | if(len < IW_EV_LCP_PK_LEN) { | 1758 | if (len < IW_EV_LCP_PK_LEN) { |
1760 | printk(KERN_DEBUG "%s (WE.r) : RtNetlink request too short (%d)\n", | 1759 | printk(KERN_DEBUG "%s (WE.r) : RtNetlink request too short (%d)\n", |
1761 | dev->name, len); | 1760 | dev->name, len); |
1762 | return -EINVAL; | 1761 | return -EINVAL; |
1763 | } | 1762 | } |
1764 | 1763 | ||
1765 | /* ReCheck length (len may have padding) */ | 1764 | /* ReCheck length (len may have padding) */ |
1766 | if(request->len > len) { | 1765 | if (request->len > len) { |
1767 | printk(KERN_DEBUG "%s (WE.r) : RtNetlink request len invalid (%d-%d)\n", | 1766 | printk(KERN_DEBUG "%s (WE.r) : RtNetlink request len invalid (%d-%d)\n", |
1768 | dev->name, request->len, len); | 1767 | dev->name, request->len, len); |
1769 | return -EINVAL; | 1768 | return -EINVAL; |
1770 | } | 1769 | } |
1771 | 1770 | ||
1772 | /* Only accept GET requests in here */ | 1771 | /* Only accept GET requests in here */ |
1773 | if(!IW_IS_GET(request->cmd)) | 1772 | if (!IW_IS_GET(request->cmd)) |
1774 | return -EOPNOTSUPP; | 1773 | return -EOPNOTSUPP; |
1775 | 1774 | ||
1776 | /* If command is `get the encoding parameters', check if | 1775 | /* If command is `get the encoding parameters', check if |
@@ -1782,16 +1781,16 @@ int wireless_rtnetlink_get(struct net_device * dev, | |||
1782 | } | 1781 | } |
1783 | 1782 | ||
1784 | /* Special cases */ | 1783 | /* Special cases */ |
1785 | if(request->cmd == SIOCGIWSTATS) | 1784 | if (request->cmd == SIOCGIWSTATS) |
1786 | /* Get Wireless Stats */ | 1785 | /* Get Wireless Stats */ |
1787 | return rtnetlink_standard_get(dev, | 1786 | return rtnetlink_standard_get(dev, |
1788 | request, | 1787 | request, |
1789 | request->len, | 1788 | request->len, |
1790 | &iw_handler_get_iwstats, | 1789 | &iw_handler_get_iwstats, |
1791 | p_buf, p_len); | 1790 | p_buf, p_len); |
1792 | if(request->cmd == SIOCGIWPRIV) { | 1791 | if (request->cmd == SIOCGIWPRIV) { |
1793 | /* Check if we have some wireless handlers defined */ | 1792 | /* Check if we have some wireless handlers defined */ |
1794 | if(dev->wireless_handlers == NULL) | 1793 | if (dev->wireless_handlers == NULL) |
1795 | return -EOPNOTSUPP; | 1794 | return -EOPNOTSUPP; |
1796 | /* Get Wireless Stats */ | 1795 | /* Get Wireless Stats */ |
1797 | return rtnetlink_standard_get(dev, | 1796 | return rtnetlink_standard_get(dev, |
@@ -1807,9 +1806,9 @@ int wireless_rtnetlink_get(struct net_device * dev, | |||
1807 | 1806 | ||
1808 | /* Try to find the handler */ | 1807 | /* Try to find the handler */ |
1809 | handler = get_handler(dev, request->cmd); | 1808 | handler = get_handler(dev, request->cmd); |
1810 | if(handler != NULL) { | 1809 | if (handler != NULL) { |
1811 | /* Standard and private are not the same */ | 1810 | /* Standard and private are not the same */ |
1812 | if(request->cmd < SIOCIWFIRSTPRIV) | 1811 | if (request->cmd < SIOCIWFIRSTPRIV) |
1813 | return rtnetlink_standard_get(dev, | 1812 | return rtnetlink_standard_get(dev, |
1814 | request, | 1813 | request, |
1815 | request->len, | 1814 | request->len, |
@@ -1840,21 +1839,21 @@ int wireless_rtnetlink_set(struct net_device * dev, | |||
1840 | iw_handler handler; | 1839 | iw_handler handler; |
1841 | 1840 | ||
1842 | /* Check length */ | 1841 | /* Check length */ |
1843 | if(len < IW_EV_LCP_PK_LEN) { | 1842 | if (len < IW_EV_LCP_PK_LEN) { |
1844 | printk(KERN_DEBUG "%s (WE.r) : RtNetlink request too short (%d)\n", | 1843 | printk(KERN_DEBUG "%s (WE.r) : RtNetlink request too short (%d)\n", |
1845 | dev->name, len); | 1844 | dev->name, len); |
1846 | return -EINVAL; | 1845 | return -EINVAL; |
1847 | } | 1846 | } |
1848 | 1847 | ||
1849 | /* ReCheck length (len may have padding) */ | 1848 | /* ReCheck length (len may have padding) */ |
1850 | if(request->len > len) { | 1849 | if (request->len > len) { |
1851 | printk(KERN_DEBUG "%s (WE.r) : RtNetlink request len invalid (%d-%d)\n", | 1850 | printk(KERN_DEBUG "%s (WE.r) : RtNetlink request len invalid (%d-%d)\n", |
1852 | dev->name, request->len, len); | 1851 | dev->name, request->len, len); |
1853 | return -EINVAL; | 1852 | return -EINVAL; |
1854 | } | 1853 | } |
1855 | 1854 | ||
1856 | /* Only accept SET requests in here */ | 1855 | /* Only accept SET requests in here */ |
1857 | if(!IW_IS_SET(request->cmd)) | 1856 | if (!IW_IS_SET(request->cmd)) |
1858 | return -EOPNOTSUPP; | 1857 | return -EOPNOTSUPP; |
1859 | 1858 | ||
1860 | /* Basic check */ | 1859 | /* Basic check */ |
@@ -1863,9 +1862,9 @@ int wireless_rtnetlink_set(struct net_device * dev, | |||
1863 | 1862 | ||
1864 | /* New driver API : try to find the handler */ | 1863 | /* New driver API : try to find the handler */ |
1865 | handler = get_handler(dev, request->cmd); | 1864 | handler = get_handler(dev, request->cmd); |
1866 | if(handler != NULL) { | 1865 | if (handler != NULL) { |
1867 | /* Standard and private are not the same */ | 1866 | /* Standard and private are not the same */ |
1868 | if(request->cmd < SIOCIWFIRSTPRIV) | 1867 | if (request->cmd < SIOCIWFIRSTPRIV) |
1869 | return rtnetlink_standard_set(dev, | 1868 | return rtnetlink_standard_set(dev, |
1870 | request, | 1869 | request, |
1871 | request->len, | 1870 | request->len, |
@@ -2015,17 +2014,17 @@ void wireless_send_event(struct net_device * dev, | |||
2015 | unsigned cmd_index; /* *MUST* be unsigned */ | 2014 | unsigned cmd_index; /* *MUST* be unsigned */ |
2016 | 2015 | ||
2017 | /* Get the description of the Event */ | 2016 | /* Get the description of the Event */ |
2018 | if(cmd <= SIOCIWLAST) { | 2017 | if (cmd <= SIOCIWLAST) { |
2019 | cmd_index = cmd - SIOCIWFIRST; | 2018 | cmd_index = cmd - SIOCIWFIRST; |
2020 | if(cmd_index < standard_ioctl_num) | 2019 | if (cmd_index < standard_ioctl_num) |
2021 | descr = &(standard_ioctl[cmd_index]); | 2020 | descr = &(standard_ioctl[cmd_index]); |
2022 | } else { | 2021 | } else { |
2023 | cmd_index = cmd - IWEVFIRST; | 2022 | cmd_index = cmd - IWEVFIRST; |
2024 | if(cmd_index < standard_event_num) | 2023 | if (cmd_index < standard_event_num) |
2025 | descr = &(standard_event[cmd_index]); | 2024 | descr = &(standard_event[cmd_index]); |
2026 | } | 2025 | } |
2027 | /* Don't accept unknown events */ | 2026 | /* Don't accept unknown events */ |
2028 | if(descr == NULL) { | 2027 | if (descr == NULL) { |
2029 | /* Note : we don't return an error to the driver, because | 2028 | /* Note : we don't return an error to the driver, because |
2030 | * the driver would not know what to do about it. It can't | 2029 | * the driver would not know what to do about it. It can't |
2031 | * return an error to the user, because the event is not | 2030 | * return an error to the user, because the event is not |
@@ -2044,18 +2043,18 @@ void wireless_send_event(struct net_device * dev, | |||
2044 | #endif /* WE_EVENT_DEBUG */ | 2043 | #endif /* WE_EVENT_DEBUG */ |
2045 | 2044 | ||
2046 | /* Check extra parameters and set extra_len */ | 2045 | /* Check extra parameters and set extra_len */ |
2047 | if(descr->header_type == IW_HEADER_TYPE_POINT) { | 2046 | if (descr->header_type == IW_HEADER_TYPE_POINT) { |
2048 | /* Check if number of token fits within bounds */ | 2047 | /* Check if number of token fits within bounds */ |
2049 | if(wrqu->data.length > descr->max_tokens) { | 2048 | if (wrqu->data.length > descr->max_tokens) { |
2050 | printk(KERN_ERR "%s (WE) : Wireless Event too big (%d)\n", dev->name, wrqu->data.length); | 2049 | printk(KERN_ERR "%s (WE) : Wireless Event too big (%d)\n", dev->name, wrqu->data.length); |
2051 | return; | 2050 | return; |
2052 | } | 2051 | } |
2053 | if(wrqu->data.length < descr->min_tokens) { | 2052 | if (wrqu->data.length < descr->min_tokens) { |
2054 | printk(KERN_ERR "%s (WE) : Wireless Event too small (%d)\n", dev->name, wrqu->data.length); | 2053 | printk(KERN_ERR "%s (WE) : Wireless Event too small (%d)\n", dev->name, wrqu->data.length); |
2055 | return; | 2054 | return; |
2056 | } | 2055 | } |
2057 | /* Calculate extra_len - extra is NULL for restricted events */ | 2056 | /* Calculate extra_len - extra is NULL for restricted events */ |
2058 | if(extra != NULL) | 2057 | if (extra != NULL) |
2059 | extra_len = wrqu->data.length * descr->token_size; | 2058 | extra_len = wrqu->data.length * descr->token_size; |
2060 | /* Always at an offset in wrqu */ | 2059 | /* Always at an offset in wrqu */ |
2061 | wrqu_off = IW_EV_POINT_OFF; | 2060 | wrqu_off = IW_EV_POINT_OFF; |
@@ -2074,14 +2073,14 @@ void wireless_send_event(struct net_device * dev, | |||
2074 | 2073 | ||
2075 | /* Create temporary buffer to hold the event */ | 2074 | /* Create temporary buffer to hold the event */ |
2076 | event = kmalloc(event_len, GFP_ATOMIC); | 2075 | event = kmalloc(event_len, GFP_ATOMIC); |
2077 | if(event == NULL) | 2076 | if (event == NULL) |
2078 | return; | 2077 | return; |
2079 | 2078 | ||
2080 | /* Fill event */ | 2079 | /* Fill event */ |
2081 | event->len = event_len; | 2080 | event->len = event_len; |
2082 | event->cmd = cmd; | 2081 | event->cmd = cmd; |
2083 | memcpy(&event->u, ((char *) wrqu) + wrqu_off, hdr_len - IW_EV_LCP_LEN); | 2082 | memcpy(&event->u, ((char *) wrqu) + wrqu_off, hdr_len - IW_EV_LCP_LEN); |
2084 | if(extra != NULL) | 2083 | if (extra != NULL) |
2085 | memcpy(((char *) event) + hdr_len, extra, extra_len); | 2084 | memcpy(((char *) event) + hdr_len, extra, extra_len); |
2086 | 2085 | ||
2087 | #ifdef WE_EVENT_RTNETLINK | 2086 | #ifdef WE_EVENT_RTNETLINK |
@@ -2116,7 +2115,7 @@ void wireless_send_event(struct net_device * dev, | |||
2116 | static inline struct iw_spy_data * get_spydata(struct net_device *dev) | 2115 | static inline struct iw_spy_data * get_spydata(struct net_device *dev) |
2117 | { | 2116 | { |
2118 | /* This is the new way */ | 2117 | /* This is the new way */ |
2119 | if(dev->wireless_data) | 2118 | if (dev->wireless_data) |
2120 | return(dev->wireless_data->spy_data); | 2119 | return(dev->wireless_data->spy_data); |
2121 | return NULL; | 2120 | return NULL; |
2122 | } | 2121 | } |
@@ -2134,7 +2133,7 @@ int iw_handler_set_spy(struct net_device * dev, | |||
2134 | struct sockaddr * address = (struct sockaddr *) extra; | 2133 | struct sockaddr * address = (struct sockaddr *) extra; |
2135 | 2134 | ||
2136 | /* Make sure driver is not buggy or using the old API */ | 2135 | /* Make sure driver is not buggy or using the old API */ |
2137 | if(!spydata) | 2136 | if (!spydata) |
2138 | return -EOPNOTSUPP; | 2137 | return -EOPNOTSUPP; |
2139 | 2138 | ||
2140 | /* Disable spy collection while we copy the addresses. | 2139 | /* Disable spy collection while we copy the addresses. |
@@ -2151,11 +2150,11 @@ int iw_handler_set_spy(struct net_device * dev, | |||
2151 | smp_wmb(); | 2150 | smp_wmb(); |
2152 | 2151 | ||
2153 | /* Are there are addresses to copy? */ | 2152 | /* Are there are addresses to copy? */ |
2154 | if(wrqu->data.length > 0) { | 2153 | if (wrqu->data.length > 0) { |
2155 | int i; | 2154 | int i; |
2156 | 2155 | ||
2157 | /* Copy addresses */ | 2156 | /* Copy addresses */ |
2158 | for(i = 0; i < wrqu->data.length; i++) | 2157 | for (i = 0; i < wrqu->data.length; i++) |
2159 | memcpy(spydata->spy_address[i], address[i].sa_data, | 2158 | memcpy(spydata->spy_address[i], address[i].sa_data, |
2160 | ETH_ALEN); | 2159 | ETH_ALEN); |
2161 | /* Reset stats */ | 2160 | /* Reset stats */ |
@@ -2199,23 +2198,23 @@ int iw_handler_get_spy(struct net_device * dev, | |||
2199 | int i; | 2198 | int i; |
2200 | 2199 | ||
2201 | /* Make sure driver is not buggy or using the old API */ | 2200 | /* Make sure driver is not buggy or using the old API */ |
2202 | if(!spydata) | 2201 | if (!spydata) |
2203 | return -EOPNOTSUPP; | 2202 | return -EOPNOTSUPP; |
2204 | 2203 | ||
2205 | wrqu->data.length = spydata->spy_number; | 2204 | wrqu->data.length = spydata->spy_number; |
2206 | 2205 | ||
2207 | /* Copy addresses. */ | 2206 | /* Copy addresses. */ |
2208 | for(i = 0; i < spydata->spy_number; i++) { | 2207 | for (i = 0; i < spydata->spy_number; i++) { |
2209 | memcpy(address[i].sa_data, spydata->spy_address[i], ETH_ALEN); | 2208 | memcpy(address[i].sa_data, spydata->spy_address[i], ETH_ALEN); |
2210 | address[i].sa_family = AF_UNIX; | 2209 | address[i].sa_family = AF_UNIX; |
2211 | } | 2210 | } |
2212 | /* Copy stats to the user buffer (just after). */ | 2211 | /* Copy stats to the user buffer (just after). */ |
2213 | if(spydata->spy_number > 0) | 2212 | if (spydata->spy_number > 0) |
2214 | memcpy(extra + (sizeof(struct sockaddr) *spydata->spy_number), | 2213 | memcpy(extra + (sizeof(struct sockaddr) *spydata->spy_number), |
2215 | spydata->spy_stat, | 2214 | spydata->spy_stat, |
2216 | sizeof(struct iw_quality) * spydata->spy_number); | 2215 | sizeof(struct iw_quality) * spydata->spy_number); |
2217 | /* Reset updated flags. */ | 2216 | /* Reset updated flags. */ |
2218 | for(i = 0; i < spydata->spy_number; i++) | 2217 | for (i = 0; i < spydata->spy_number; i++) |
2219 | spydata->spy_stat[i].updated &= ~IW_QUAL_ALL_UPDATED; | 2218 | spydata->spy_stat[i].updated &= ~IW_QUAL_ALL_UPDATED; |
2220 | return 0; | 2219 | return 0; |
2221 | } | 2220 | } |
@@ -2233,7 +2232,7 @@ int iw_handler_set_thrspy(struct net_device * dev, | |||
2233 | struct iw_thrspy * threshold = (struct iw_thrspy *) extra; | 2232 | struct iw_thrspy * threshold = (struct iw_thrspy *) extra; |
2234 | 2233 | ||
2235 | /* Make sure driver is not buggy or using the old API */ | 2234 | /* Make sure driver is not buggy or using the old API */ |
2236 | if(!spydata) | 2235 | if (!spydata) |
2237 | return -EOPNOTSUPP; | 2236 | return -EOPNOTSUPP; |
2238 | 2237 | ||
2239 | /* Just do it */ | 2238 | /* Just do it */ |
@@ -2263,7 +2262,7 @@ int iw_handler_get_thrspy(struct net_device * dev, | |||
2263 | struct iw_thrspy * threshold = (struct iw_thrspy *) extra; | 2262 | struct iw_thrspy * threshold = (struct iw_thrspy *) extra; |
2264 | 2263 | ||
2265 | /* Make sure driver is not buggy or using the old API */ | 2264 | /* Make sure driver is not buggy or using the old API */ |
2266 | if(!spydata) | 2265 | if (!spydata) |
2267 | return -EOPNOTSUPP; | 2266 | return -EOPNOTSUPP; |
2268 | 2267 | ||
2269 | /* Just do it */ | 2268 | /* Just do it */ |
@@ -2327,7 +2326,7 @@ void wireless_spy_update(struct net_device * dev, | |||
2327 | int match = -1; | 2326 | int match = -1; |
2328 | 2327 | ||
2329 | /* Make sure driver is not buggy or using the old API */ | 2328 | /* Make sure driver is not buggy or using the old API */ |
2330 | if(!spydata) | 2329 | if (!spydata) |
2331 | return; | 2330 | return; |
2332 | 2331 | ||
2333 | #ifdef WE_SPY_DEBUG | 2332 | #ifdef WE_SPY_DEBUG |
@@ -2335,8 +2334,8 @@ void wireless_spy_update(struct net_device * dev, | |||
2335 | #endif /* WE_SPY_DEBUG */ | 2334 | #endif /* WE_SPY_DEBUG */ |
2336 | 2335 | ||
2337 | /* Update all records that match */ | 2336 | /* Update all records that match */ |
2338 | for(i = 0; i < spydata->spy_number; i++) | 2337 | for (i = 0; i < spydata->spy_number; i++) |
2339 | if(!compare_ether_addr(address, spydata->spy_address[i])) { | 2338 | if (!compare_ether_addr(address, spydata->spy_address[i])) { |
2340 | memcpy(&(spydata->spy_stat[i]), wstats, | 2339 | memcpy(&(spydata->spy_stat[i]), wstats, |
2341 | sizeof(struct iw_quality)); | 2340 | sizeof(struct iw_quality)); |
2342 | match = i; | 2341 | match = i; |
@@ -2346,15 +2345,15 @@ void wireless_spy_update(struct net_device * dev, | |||
2346 | * To avoid event storms, we have a simple hysteresis : we generate | 2345 | * To avoid event storms, we have a simple hysteresis : we generate |
2347 | * event only when we go under the low threshold or above the | 2346 | * event only when we go under the low threshold or above the |
2348 | * high threshold. */ | 2347 | * high threshold. */ |
2349 | if(match >= 0) { | 2348 | if (match >= 0) { |
2350 | if(spydata->spy_thr_under[match]) { | 2349 | if (spydata->spy_thr_under[match]) { |
2351 | if(wstats->level > spydata->spy_thr_high.level) { | 2350 | if (wstats->level > spydata->spy_thr_high.level) { |
2352 | spydata->spy_thr_under[match] = 0; | 2351 | spydata->spy_thr_under[match] = 0; |
2353 | iw_send_thrspy_event(dev, spydata, | 2352 | iw_send_thrspy_event(dev, spydata, |
2354 | address, wstats); | 2353 | address, wstats); |
2355 | } | 2354 | } |
2356 | } else { | 2355 | } else { |
2357 | if(wstats->level < spydata->spy_thr_low.level) { | 2356 | if (wstats->level < spydata->spy_thr_low.level) { |
2358 | spydata->spy_thr_under[match] = 1; | 2357 | spydata->spy_thr_under[match] = 1; |
2359 | iw_send_thrspy_event(dev, spydata, | 2358 | iw_send_thrspy_event(dev, spydata, |
2360 | address, wstats); | 2359 | address, wstats); |