+ if(!iw_ignore_version)
+ {
+ /* For new versions, we can check the version directly, for old versions
+ * we use magic. 300 bytes is a also magic number, don't touch... */
+ if((WIRELESS_EXT > 10) && (wrq.u.data.length >= 300))
+ {
+#if WIRELESS_EXT > 10
+ /* Version verification - for new versions */
+ if(range->we_version_compiled != WIRELESS_EXT)
+ {
+ fprintf(stderr, "Warning: Driver for device %s has been compiled with version %d\n", ifname, range->we_version_compiled);
+ fprintf(stderr, "of Wireless Extension, while this program is using version %d.\n", WIRELESS_EXT);
+ fprintf(stderr, "Some things may be broken...\n\n");
+ }
+ /* Driver version verification */
+ if(range->we_version_compiled < range->we_version_source)
+ {
+ fprintf(stderr, "Warning: Driver for device %s recommend version %d of Wireless Extension,\n", ifname, range->we_version_source);
+ fprintf(stderr, "but has been compiled with version %d, therefore some driver features\n", range->we_version_compiled);
+ fprintf(stderr, "may not be available...\n\n");
+ }
+#endif /* WIRELESS_EXT > 10 */
+ }
+ else
+ {
+ /* Version verification - for old versions */
+ if(wrq.u.data.length != sizeof(iwrange))
+ {
+ fprintf(stderr, "Warning: Driver for device %s has been compiled with an ancient version\n", ifname);
+ fprintf(stderr, "of Wireless Extension, while this program is using version %d.\n", WIRELESS_EXT);
+ fprintf(stderr, "Some things may be broken...\n\n");
+ }
+ }
+ }
+ /* Don't complain twice.
+ * In theory, the test apply to each individual driver, but usually
+ * all drivers are compiled from the same kernel, and most often
+ * problem is the system/glibc headers. */
+ iw_ignore_version = 1;
+
+ /* Note : we are only trying to catch compile difference, not source.
+ * If the driver source has not been updated to the latest, it doesn't
+ * matter because the new fields are set to zero */
+
+ return(0);
+}
+
+/*------------------------------------------------------------------*/
+/*
+ * Print the WE versions of the interface.
+ */
+static int
+print_iface_version_info(int skfd,
+ char * ifname,
+ char * args[], /* Command line args */
+ int count) /* Args count */
+{
+ struct iwreq wrq;
+ char buffer[sizeof(iwrange) * 2]; /* Large enough */
+ struct iw_range * range;
+
+ /* Avoid "Unused parameter" warning */
+ args = args; count = count;
+
+ /* Cleanup */
+ memset(buffer, 0, sizeof(buffer));
+
+ wrq.u.data.pointer = (caddr_t) buffer;
+ wrq.u.data.length = sizeof(buffer);
+ wrq.u.data.flags = 0;
+ if(iw_get_ext(skfd, ifname, SIOCGIWRANGE, &wrq) < 0)
+ return(-1);
+
+ /* Copy stuff at the right place, ignore extra */
+ range = (struct iw_range *) buffer;