* RE: [PATCH] cfg80211/nl80211: Add support to report unsafe frequency ranges(s)
From: Chauhan, Rajesh @ 2013-10-28 18:08 UTC (permalink / raw)
To: Rodriguez, Luis
Cc: Dan Williams, Johannes Berg, linux-wireless@vger.kernel.org,
Malinen, Jouni, Bahini, Henri, Chang, Leo, Luo, Xun,
Chauhan, Rajesh
In-Reply-To: <CAB=NE6UkKuSzH4x2SjkE0pRTVCVa3k7g=_ZeU_JE+t2OovRoEg@mail.gmail.com>
SGkgTHVpcywNCg0KRm9yICJlbm91Z2ggaW5mb3JtYXRpb24gZm9yIHByb3BlciB1c2FnZSIgLSBo
b3cgYWJvdXQgaWYgSSBhZGQgYW4gYXR0cmlidXRlIGZvciB0aGUgc291cmNlIG9mIGludGVyZmVy
ZW5jZSAoc2F5LCBmb3IgZXhhbXBsZSwgImNlbGx1bGFyIikgZm9yIGVhY2ggb2YgdGhvc2UgZnJl
cXVlbmN5IHJhbmdlPw0KDQpSZWdhcmRzLA0KUmFqZXNoIENoYXVoYW4NCg0KLS0tLS1PcmlnaW5h
bCBNZXNzYWdlLS0tLS0NCkZyb206IG1jZ3JvZkBnbWFpbC5jb20gW21haWx0bzptY2dyb2ZAZ21h
aWwuY29tXSBPbiBCZWhhbGYgT2YgTHVpcyBSLiBSb2RyaWd1ZXoNClNlbnQ6IFN1bmRheSwgT2N0
b2JlciAyMCwgMjAxMyAzOjM5IEFNDQpUbzogQ2hhdWhhbiwgUmFqZXNoDQpDYzogRGFuIFdpbGxp
YW1zOyBKb2hhbm5lcyBCZXJnOyBsaW51eC13aXJlbGVzc0B2Z2VyLmtlcm5lbC5vcmc7IE1hbGlu
ZW4sIEpvdW5pOyBCYWhpbmksIEhlbnJpOyBDaGFuZywgTGVvOyBMdW8sIFh1bg0KU3ViamVjdDog
UmU6IFtQQVRDSF0gY2ZnODAyMTEvbmw4MDIxMTogQWRkIHN1cHBvcnQgdG8gcmVwb3J0IHVuc2Fm
ZSBmcmVxdWVuY3kgcmFuZ2VzKHMpDQoNCk9uIFRodSwgT2N0IDE3LCAyMDEzIGF0IDk6NTEgUE0s
IENoYXVoYW4sIFJhamVzaCA8cmFqZXNoY0BxY2EucXVhbGNvbW0uY29tPiB3cm90ZToNCj4gSGkg
RGFuLA0KPg0KPiBUaGFua3MgZm9yIHlvdXIgY29tbWVudHMuDQo+DQo+IEN1cnJlbnQgcGF0Y2gg
aXMgdG8gcmVwb3J0IGV2ZW50IGFzeW5jaHJvbm91c2x5IGFuZCB0aGF0IHdvdWxkIGJlIG5lZWRl
ZCBldmVuIGlmIHdlIGhhdmUgeW91ciBzdWdnZXN0ZWQgaW50ZXJmYWNlIG9mIGNsaWVudCBjb2xs
ZWN0aW5nIHRoYXQgaW5mb3JtYXRpb24gdXBmcm9udCwgd2hpY2ggc2VlbXMgbGlrZSB5b3UgYWxz
byBraW5kIG9mIGFncmVlLCBiZWNhdXNlIFJGIGVudmlyb25tZW50IG1heSBjaGFuZ2UgbGF0ZXIg
YW5kIGdlbmVyYXRpbmcgYW4gZXZlbnQgYXQgdGhhdCB0aW1lIHdpdGggZnJlcXVlbmN5IGRldGFp
bHMgd291bGQgaGVscC4gU28geW91ciBzdWdnZXN0ZWQgYXBwcm9hY2ggb2YgIm1lY2hhbmlzbSBm
b3IgdGhlIGNsaWVudCB0byBnZXQgdGhpcyBpbmZvcm1hdGlvbiIgaW4gaXRzZWxmIHNlZW1zIGxp
a2UgYSBjYW5kaWRhdGUgZm9yIGEgc2VwYXJhdGUgcGF0Y2guDQoNClRoZSBpbmZyYXN0cnVjdHVy
ZSBmb3IgdGhpcyBzb3J0IG9mIHRoaW5nIHRoYXQgbWUsIEluYWt5IGFuZCBNYXJjZWwgaGFkIHBy
b3Bvc2VkIGluIDIwMDcgaXMgdGhlIEZyZXF1ZW5jeSBCcm9rZXI6DQoNCmh0dHA6Ly93aXJlbGVz
cy5rZXJuZWwub3JnL2VuL2RldmVsb3BlcnMvRnJlcXVlbmN5QnJva2VyDQoNCj4gT24gdGhlIHJh
Y2UgY29uZGl0aW9uIHdoaWNoIHlvdSBkZXNjcmliZWQgLSB0aGFua3MhLCBidXQgaXQgaXMgc29t
ZXRoaW5nIHdoaWNoIGltcGxlbWVudGF0aW9uIG9mIGRyaXZlciB3b3VsZCBuZWVkIHRvIHRha2Ug
Y2FyZS4gU2ltaWxhcmx5LCB1c2VyIHNwYWNlIGNhbiBoYXZlIGltcGxlbWVudGF0aW9uIHRvIGNh
Y2hlIGluZm9ybWF0aW9uIG9uIHJlY2VpcHQgb2YgdGhlIGV2ZW50IHRvIHVzZSBpdCBsYXRlci4N
Cg0KVGhpcyBwYXRjaCBpcyB2YWd1ZS4gT25jZSB3ZSBzZXQgc29tZXRoaW5nIGFzIEFQSSB3ZSBo
YXZlIHRvIGxpdmUgd2l0aCBpdCwgSSBhbSBub3QgY29tZm9ydGFibGUgd2l0aCB0aGlzIHBhdGNo
IGhhdmluZyBlbm91Z2ggaW5mb3JtYXRpb24gZm9yIHByb3BlciB1c2FnZSBieSBkaWZmZXJlbnQg
ZHJpdmVycyBmb3IgdGhlIHNhbWUgcHVycG9zZSBvciBpbnRlbnQuIFRoZSBvbmx5IHJlYWwgcG9z
aXRpdmUgYXJndW1lbnQgdGhhdCBjb3VsZCBiZSB1c2VkIGhlcmUgaXMgd2hlcmUgc29tZXRoaW5n
IGxpa2UgQW5kcm9pZCBtaWdodCBoYXZlIGFscmVhZHkgZW1icmFjZWQgc29tZSBzaW1pbGFyIEFQ
SSBidXQgYXJlIHdlIGdvaW5nIHRvIGFsd2F5cyBqdXN0IGVuYWJsZSBBUEkgb24gTGludXgganVz
dCBiZWNhdXNlIEFuZHJvaWQgZGlkIGl0IHdpdGhvdXQgdGhpbmtpbmcgYWJvdXQgcHJvcGVyIGxv
bmcgdGVybSBhcmNoaXRlY3R1cmU/IEkgZG9uJ3QgdGhpbmsgc28uDQoNCiBMdWlzDQo=
^ permalink raw reply
* Re: I always need a miracle to connect with iwlwifi
From: Felipe Contreras @ 2013-10-28 18:00 UTC (permalink / raw)
To: Oleksij Rempel; +Cc: linux-wireless Mailing List, ilw, hostap@lists.shmoo.com
In-Reply-To: <526E20EA.9090203@rempel-privat.de>
On Mon, Oct 28, 2013 at 2:31 AM, Oleksij Rempel <linux@rempel-privat.de> wrote:
> Take wireshark and capture working and not working associational request.
All right, so what I did is take a working and non-working on the same
Linux machine. I have never done that, and didn't find much
information about how to do that so I used kismet.
I don't know exactly how I should export these logs for you to browse
them but I gave a shot at interpreting them.
What I can see is that in both cases the authentication request is
exactly the same, except for the sequence number. Yet in good case
there's an acknowledgement, and in the bad case there isn't.
The authentication response does come back in both cases though, it's
just the acknowledgement that is missing. Unfortunately I cannot
figure out for which message it's the ack.
Also, I notice the sequence number received from the router doesn't
seem to change. All the authentication requests received have the same
number (256). Another peculiar thing is that in the failed case the SN
we send starts with 0.
I suppose since the authentication ack never arrives, the next steps
are never completed.
Does that help?
--
Felipe Contreras
^ permalink raw reply
* Re: [PATCH 2/4] wl1251: move power GPIO handling into the driver
From: Grazvydas Ignotas @ 2013-10-28 17:29 UTC (permalink / raw)
To: Alexander Shiyan, Luciano Coelho, Mark Rutland, devicetree,
Russell King, Pawel Moll, Ian Campbell, Tony Lindgren,
Greg Kroah-Hartman, Stephen Warren, linux-doc, John W. Linville,
Rob Herring, linux-kernel@vger.kernel.org, Sachin Kamat,
Bill Pemberton, Felipe Balbi, Rob Landley, netdev,
linux-wireless@vger.kernel.org, linux-omap@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, Mark Brown
In-Reply-To: <20131027201218.GA4414@earth.universe>
On Sun, Oct 27, 2013 at 10:12 PM, Sebastian Reichel <sre@debian.org> wrote:
> On Sun, Oct 27, 2013 at 08:24:16PM +0400, Alexander Shiyan wrote:
>> > Move the power GPIO handling from the board code into
>> > the driver. This is a dependency for device tree support.
>> >
>> > Signed-off-by: Sebastian Reichel <sre@debian.org>
>> > ---
>> > arch/arm/mach-omap2/board-omap3pandora.c | 2 ++
>> > arch/arm/mach-omap2/board-rx51-peripherals.c | 11 ++--------
>> > drivers/net/wireless/ti/wl1251/sdio.c | 21 +++++++++++++-----
>> > drivers/net/wireless/ti/wl1251/spi.c | 33 ++++++++++++++++++----------
>> > drivers/net/wireless/ti/wl1251/wl1251.h | 2 +-
>> > include/linux/wl12xx.h | 2 +-
>> > 6 files changed, 43 insertions(+), 28 deletions(-)
>> ...
>> > diff --git a/include/linux/wl12xx.h b/include/linux/wl12xx.h
>> > index b516b4f..a9c723b 100644
>> > --- a/include/linux/wl12xx.h
>> > +++ b/include/linux/wl12xx.h
>> > @@ -49,7 +49,7 @@ enum {
>> > };
>> >
>> > struct wl1251_platform_data {
>> > - void (*set_power)(bool enable);
>> > + int power_gpio;
>> > /* SDIO only: IRQ number if WLAN_IRQ line is used, 0 for SDIO IRQs */
>> > int irq;
>> > bool use_eeprom;
>> > --
>>
>> What a reason for not using regulator API here with GPIO-based
>> regulator?
>
> I think this pin is not used as power supply, but like an enable pin
> for low power states. Of course the regulator API could still be
> (mis?)used for this, but I think it would be the first linux device
> driver doing this.
>
> Note: I don't have wl1251 documentation.
When wl12xx family of chips is connected through SDIO, we already have
that pin set up as a regulator controlled with the help of mmc
subsystem. When time comes to communicate with the chip, mmc subsystem
sees this as yet another SD card and looks for associated regulator
for it, and the board file has that set up as a fixed regulator
controlling that pin (see pandora_vmmc3 in
arch/arm/mach-omap2/board-omap3pandora.c). To prevent poweroff after
first SDIO communications are over, pm_runtime calls are used in
drivers/net/wireless/ti/wl1251/sdio.c .
I don't know if something similar can be done done in SPI case, but
I'm sure this is not the first your-so-called regulator misuse.
Gražvydas
^ permalink raw reply
* Re: [PATCH 4/4] wl1251: spi: add device tree support
From: Grazvydas Ignotas @ 2013-10-28 17:15 UTC (permalink / raw)
To: Kumar Gala
Cc: Sebastian Reichel, Mark Rutland, linux-doc, Tony Lindgren,
Russell King, Sachin Kamat, Ian Campbell, Sebastian Reichel,
Luciano Coelho, devicetree, Pawel Moll, Stephen Warren,
John W. Linville, Rob Herring, Bill Pemberton,
linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
Greg Kroah-Hartman, linux-wireless@vger.kernel.org,
linux-kernel@vger.kernel.org, Felipe Balbi, Rob Landley, netdev
In-Reply-To: <FF34C626-4A49-43B1-B0AD-DC6146ABBB11@codeaurora.org>
On Mon, Oct 28, 2013 at 8:37 AM, Kumar Gala <galak@codeaurora.org> wrote:
> On Oct 27, 2013, at 11:14 AM, Sebastian Reichel wrote:
> > +++ b/Documentation/devicetree/bindings/net/wireless/ti,wl1251.txt
> > @@ -0,0 +1,36 @@
> > +* Texas Instruments wl1251 controller
> > +
> > +The wl1251 chip can be connected via SPI or via SDIO. The linux
> > +kernel currently only supports device tree for the SPI variant.
> > +
>
> From the binding I have no idea what this chip actually does, also we don't normally reference linux kernel support in bindings specs (so please remove it).
>
> However, what would expect the SDIO binding to look like? Or more specifically, how would you distinguish the SPI vs SDIO binding/connection? I'm wondering if the compatible should be something like "ti,wl1251-spi" and than the sdio can be "ti,wl1251-sdio"
When connected to SDIO, it doesn't act as standard SDIO device and
can't be probed (standard SDIO registers missing), so information has
to come some other way. That used to partially come through
platform_data and partially through a callback from mmc subsystem (see
pandora_wl1251_init_card() in
arch/arm/mach-omap2/board-omap3pandora.c). I don't know much about DT,
but maybe the information that comes from SDIO registers on "normal"
SDIO devices should come through DT in this case too? I don't really
know how that should be integrated with mmc subsystem though..
> > +Required properties:
> > +- compatible : Should be "ti,wl1251"
>
> reg is not listed as a required prop.
>
> > +- interrupts : Should contain interrupt line
> > +- interrupt-parent : Should be the phandle for the interrupt
> > + controller that services interrupts for this device
> > +- vio-supply : phandle to regulator providing VIO
> > +- power-gpio : GPIO connected to chip's PMEN pin
>
> should be vendor prefixed: ti,power-gpio
>
> > +- For additional required properties on SPI, please consult
> > + Documentation/devicetree/bindings/spi/spi-bus.txt
> > +
> > +Optional properties:
> > +- ti,use-eeprom : If found, configuration will be loaded from eeprom.
>
> can you be a bit more specific on what cfg will be loaded. Also, is this property a boolean, if so how do I know which eeprom the cfg is loaded from (is it one that is directly connected to the wl1251?
wl1251 is a wifi chip that can have an optional eeprom connected to it
to store things like calibration stuff and MAC address, and that
eeprom is usually inside a single module with some additional radio
related chips. If the eeprom is connected (like the module on pandora
board has), the driver can issue command to the firmware running on
chip to load that data on it's startup, alternatively the driver can
load calibration from other storage (like it happens on N900).
Gražvydas
^ permalink raw reply
* Re: [PATCH 3.12] cfg80211: fix ibss wext chandef creation
From: Dirk Gouders @ 2013-10-28 17:14 UTC (permalink / raw)
To: Johannes Berg
Cc: Simon Wunderlich, linux-wireless, Mathias Kretschmer,
Linux Kernel
In-Reply-To: <1382970069.17956.23.camel@jlt4.sipsolutions.net>
Johannes Berg <johannes@sipsolutions.net> writes:
> On Tue, 2013-10-22 at 22:02 +0200, Simon Wunderlich wrote:
>> The wext internal chandefs for ibss should be created using the
>> cfg80211_chandef_create() functions. Otherwise the center_freq1 field
>> will not be set and cfg80211_chandef_valid() will spit a warning and
>> report the chandef as invalid when it should be used.
>
> I think
>
> commit f478f33a93f9353dcd1fe55445343d76b1c3f84a
> Author: Bruno Randolf <br1@einfach.org>
> Date: Thu Sep 26 16:55:28 2013 +0100
>
> cfg80211: fix warning when using WEXT for IBSS
>
>
> already fixed this. Your patch doesn't apply, but feel free to send me a
> new one (for -next) converting to the creation helpers.
I tested the above commit and it also fixes the problems I noticed here.
Best regards,
Dirk
^ permalink raw reply
* Re: I always need a miracle to connect with iwlwifi
From: Felipe Contreras @ 2013-10-28 17:12 UTC (permalink / raw)
To: Oleksij Rempel; +Cc: linux-wireless Mailing List, ilw, hostap@lists.shmoo.com
In-Reply-To: <526E9093.6020409@rempel-privat.de>
On Mon, Oct 28, 2013 at 10:28 AM, Oleksij Rempel <linux@rempel-privat.de> wrote:
> Am 28.10.2013 16:44, schrieb Felipe Contreras:
>> And BTW, the devices we are talking about are very varied: Wii U,
>> Windows 7, Windows 8.1, Nokia N9, Android phone, iPhone, iMac, Amazon
>> Kindle. Yet the only device that seems to have a problem is my Linux
>> machine, I think it's pretty clear where the problem is.
>
> Do any of listed devices use mac80211?
Yes, my Nokia N900, which works flawlessly. I didn't list that, but I
just tried it.
> If not, you still have fallowing
> options: wpa_supplicant, mac80211, iwlwifi driver, iwlwifi firmware. In
> you arguments you even didn't tried to eliminate any of them. So, no. It
> is not clear where problem is.
All of these things run in the Linux laptop, so to me it is clearly
not in the router. Sure, the router might be buggy, but it's very
conspicuous that only this machine reproduces that bug.
>> And sure, it does not necessarily means that other people have the
>> same problem, but it is very unlikely that I'm the only one.
>
> what is your hardware?
Intel Corporation Centrino Advanced-N 6235
> Did you tired to disable power save mode?
modinfo shows this:
parm: power_save:enable WiFi power management (default:
disable) (bool)
So I guessed power saving was disabled by default.
But yeah, to be sure I did try it:
sudo modprobe iwlwifi power_save=0 power_level=1
> I have "Intel Centrino Advanced-N 6235", it use same driver and works
> with three of my APs. I say just to show, that list of working hardware
> is not helpful.
Of course it is helpful, it tells us that the problem is very likely
on this machine, not on the AP.
> what is you AP?
ZNID-GPON-2516
> Mode it is running?
I don't know, it's a wireless router.
> Do changing settings of this AP makes some difference?
I don't have access to the settings. I'm going to ask for access, but
I'm not too hopeful.
--
Felipe Contreras
^ permalink raw reply
* Re: [PATCH 3.12] cfg80211: fix ibss wext chandef creation
From: Dirk Gouders @ 2013-10-28 17:05 UTC (permalink / raw)
To: Johannes Berg
Cc: Simon Wunderlich, linux-wireless, Mathias Kretschmer,
Linux Kernel
In-Reply-To: <1382970069.17956.23.camel@jlt4.sipsolutions.net>
Johannes Berg <johannes@sipsolutions.net> writes:
> On Tue, 2013-10-22 at 22:02 +0200, Simon Wunderlich wrote:
>> The wext internal chandefs for ibss should be created using the
>> cfg80211_chandef_create() functions. Otherwise the center_freq1 field
>> will not be set and cfg80211_chandef_valid() will spit a warning and
>> report the chandef as invalid when it should be used.
>
> I think
>
> commit f478f33a93f9353dcd1fe55445343d76b1c3f84a
> Author: Bruno Randolf <br1@einfach.org>
> Date: Thu Sep 26 16:55:28 2013 +0100
>
> cfg80211: fix warning when using WEXT for IBSS
>
>
> already fixed this. Your patch doesn't apply, but feel free to send me a
> new one (for -next) converting to the creation helpers.
I tested the above commit and it also fixes the problems I noticed here.
Dirk
^ permalink raw reply
* [PATCH v2 6/6] crda: make reglib a shared library
From: Luis R. Rodriguez @ 2013-10-28 16:42 UTC (permalink / raw)
To: linux-wireless; +Cc: wireless-regdb, Luis R. Rodriguez
In-Reply-To: <1382978526-23929-1-git-send-email-mcgrof@do-not-panic.com>
Now that we have quite a few helpers this puts the more
valuable helpers into a library.
Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
---
Makefile | 48 ++++++++++++++++++++++++++++++++++++------------
1 file changed, 36 insertions(+), 12 deletions(-)
diff --git a/Makefile b/Makefile
index 9e37ccd..4a351c6 100644
--- a/Makefile
+++ b/Makefile
@@ -5,6 +5,8 @@ REG_GIT?=git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless-regdb.g
PREFIX ?= /usr/
MANDIR ?= $(PREFIX)/share/man/
+INCLUDE_DIR ?= $(PREFIX)/include/reglib/
+LIBDIR ?= $(PREFIX)/lib
SBINDIR ?= /sbin/
@@ -23,24 +25,29 @@ UDEV_RULE_DIR?=/lib/udev/rules.d/
PUBKEY_DIR?=pubkeys
RUNTIME_PUBKEY_DIR?=/etc/wireless-regdb/pubkeys
+CFLAGS += -O2 -fpic
+CFLAGS += -std=gnu99 -Wall -Werror -pedantic
CFLAGS += -Wall -g
LDLIBS += -lm
+LDLIBREG += -lreg
+LIBREG += libreg.so
+LDFLAGS += -L ./ $(LDLIBREG)
all: all_noverify verify
-all_noverify: crda intersect regdbdump db2rd optimize
+all_noverify: $(LIBREG) crda intersect regdbdump db2rd optimize
ifeq ($(USE_OPENSSL),1)
CFLAGS += -DUSE_OPENSSL -DPUBKEY_DIR=\"$(RUNTIME_PUBKEY_DIR)\" `pkg-config --cflags openssl`
LDLIBS += `pkg-config --libs openssl`
-reglib.o: keys-ssl.c
+$(LIBREG): keys-ssl.c
else
CFLAGS += -DUSE_GCRYPT
LDLIBS += -lgcrypt
-reglib.o: keys-gcrypt.c
+$(LIBREG): keys-gcrypt.c
endif
MKDIR ?= mkdir -p
@@ -106,39 +113,56 @@ keys-%.c: utils/key2pub.py $(wildcard $(PUBKEY_DIR)/*.pem)
$(NQ) ' Trusted pubkeys:' $(wildcard $(PUBKEY_DIR)/*.pem)
$(Q)./utils/key2pub.py --$* $(wildcard $(PUBKEY_DIR)/*.pem) $@
-%.o: %.c regdb.h reglib.h
+$(LIBREG): regdb.h reglib.h reglib.c
+ $(NQ) ' CC ' $@
+ $(Q)$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ -shared -Wl,-soname,$(LIBREG) $^
+
+install-libreg-headers:
+ $(NQ) ' INSTALL libreg-headers'
+ $(Q)mkdir -p $(INCLUDE_DIR)
+ $(Q)cp *.h $(INCLUDE_DIR)/
+
+install-libreg:
+ $(NQ) ' INSTALL libreg'
+ $(Q)mkdir -p $(LIBDIR)
+ $(Q)cp $(LIBREG) $(LIBDIR)/
+ $(Q)ldconfig
+
+%.o: %.c regdb.h $(LIBREG)
$(NQ) ' CC ' $@
$(Q)$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
-crda: reglib.o crda.o
+crda: crda.o
$(NQ) ' LD ' $@
$(Q)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LDLIBS) $(NLLIBS)
-regdbdump: reglib.o regdbdump.o
+regdbdump: regdbdump.o
$(NQ) ' LD ' $@
$(Q)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LDLIBS)
-intersect: reglib.o intersect.o
+intersect: intersect.o
$(NQ) ' LD ' $@
$(Q)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LDLIBS)
-db2rd: reglib.o db2rd.o
+db2rd: db2rd.o
$(NQ) ' LD ' $@
$(Q)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LDLIBS)
-optimize: reglib.o optimize.o
+optimize: optimize.o
$(NQ) ' LD ' $@
$(Q)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LDLIBS)
verify: $(REG_BIN) regdbdump
$(NQ) ' CHK $(REG_BIN)'
- $(Q)./regdbdump $(REG_BIN) >/dev/null
+ $(Q)\
+ LD_LIBRARY_PATH=.:$(LD_LIBRARY_PATH) \
+ ./regdbdump $(REG_BIN) >/dev/null
%.gz: %
@$(NQ) ' GZIP' $<
$(Q)gzip < $< > $@
-install: crda crda.8.gz regdbdump.8.gz
+install: install-libreg install-libreg-headers crda crda.8.gz regdbdump.8.gz
$(NQ) ' INSTALL crda'
$(Q)$(MKDIR) $(DESTDIR)/$(SBINDIR)
$(Q)$(INSTALL) -m 755 -t $(DESTDIR)/$(SBINDIR) crda
@@ -161,6 +185,6 @@ install: crda crda.8.gz regdbdump.8.gz
$(Q)$(INSTALL) -m 644 -t $(DESTDIR)/$(MANDIR)/man8/ regdbdump.8.gz
clean:
- $(Q)rm -f crda regdbdump intersect db2rd optimize \
+ $(Q)rm -f $(LIBREG) crda regdbdump intersect db2rd optimize \
*.o *~ *.pyc keys-*.c *.gz \
udev/$(UDEV_LEVEL)regulatory.rules udev/regulatory.rules.parsed
--
1.8.4.rc3
^ permalink raw reply related
* [PATCH v2 5/6] crda: make ssl keys include stdint.h
From: Luis R. Rodriguez @ 2013-10-28 16:42 UTC (permalink / raw)
To: linux-wireless; +Cc: wireless-regdb, Luis R. Rodriguez
In-Reply-To: <1382978526-23929-1-git-send-email-mcgrof@do-not-panic.com>
This is required to fix compilation if we
move reglig to its own library.
Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
---
utils/key2pub.py | 2 ++
1 file changed, 2 insertions(+)
diff --git a/utils/key2pub.py b/utils/key2pub.py
index 4d85369..3e84cd2 100755
--- a/utils/key2pub.py
+++ b/utils/key2pub.py
@@ -59,6 +59,7 @@ def print_ssl_32(output, name, val):
def print_ssl(output, name, val):
import struct
+ output.write('#include <stdint.h>\n')
if len(struct.pack('@L', 0)) == 8:
return print_ssl_64(output, name, val)
else:
@@ -85,6 +86,7 @@ static struct pubkey keys[] = {
pass
def print_gcrypt(output, name, val):
+ output.write('#include <stdint.h>\n')
while val[0] == '\0':
val = val[1:]
output.write('static const uint8_t %s[%d] = {\n' % (name, len(val)))
--
1.8.4.rc3
^ permalink raw reply related
* [PATCH v2 4/6] crda: add regulatory domain optimizer
From: Luis R. Rodriguez @ 2013-10-28 16:42 UTC (permalink / raw)
To: linux-wireless; +Cc: wireless-regdb, Luis R. Rodriguez
In-Reply-To: <1382978526-23929-1-git-send-email-mcgrof@do-not-panic.com>
This adds a regulatory domain optimizer which can be
used with information of a regulatory domain in db.txt
format in stdin. It makes use of the new shiny regulatory
domain stream parser.
The way this works is it iterates over the regulatory domain
computing unions between each frequency, starting from each
frequency as a pivot. If a union leads to a valid regulatory
rule we verify that the pivot and othre frequency rules that
provided that valid union can fit into that union regulatory
rule by computing an intersection. If an intersection is
possible it means two rules can be optimized out. We do
this repetitively.
Note: cfg80211's nl80211.h API has:
#define NL80211_MAX_SUPP_REG_RULES 32
Our tools, both the stream parser and the optimizer are not
limited to these artificial limits ! We can work on extending
the kernel's limit but so far we have had no needs. A few
notes below though on the existing reasoning for the limit
and possible future enhancements.
This is used nl80211_set_reg() upon intercept of a regulatory
domain being sent from userspace to it. We picked a limitation
to at least have a stopping gap to avoid userpace flooding the
kernel with a denial of service requests on memory from userspace.
This means that userspace can only request at most a kmalloc
of up to 32 regulatory rules for processing for the regulatory
data that we are copying from userspace. There's a Linux kernel
enhancement that will be made soon so that we invalidate bogus
requests, by checking to see if the incomming regulatory domain
alpha2 was not expected upon a regulatory hint initiator (even
if userspace first tells the kernel it is waiting for a response
from kernel space), and if its invalid then we drop the userspace
supplied request, therefore avoiding some form of flooding on
memory to the kernel.
Note that we can still get flooding if the userspace API is used
to *request* to the kernel for a regulatory domain to be sent
from userspace, in that case the kernel will properly expect the
regulatory data for the alpha2. To prevent flooding there perhaps
its a good idea for us to check whether a userspace pending request
is pendingg and if so deny new updates until the last one triggers
a timeout.
Screenshot for a US file with 40 rules:
mcgrof@frijol ~/devel/xlreg (git::master)$ cat us | grep --"(" | wc -l
40
mcgrof@frijol ~/devel/crda (git::master)$ cat us
country US: DFS-FCC
(2402.000 - 2422.000 @ 20.000), (30.00)
(2407.000 - 2427.000 @ 20.000), (30.00)
(2412.000 - 2432.000 @ 20.000), (30.00)
(2417.000 - 2437.000 @ 20.000), (30.00)
(2422.000 - 2442.000 @ 20.000), (30.00)
(2427.000 - 2447.000 @ 20.000), (30.00)
(2432.000 - 2452.000 @ 20.000), (30.00)
(2437.000 - 2457.000 @ 20.000), (30.00)
(2442.000 - 2462.000 @ 20.000), (30.00)
(2447.000 - 2467.000 @ 20.000), (30.00)
(2452.000 - 2472.000 @ 20.000), (30.00)
(2402.000 - 2442.000 @ 40.000), (30.00)
(2407.000 - 2447.000 @ 40.000), (30.00)
(2412.000 - 2452.000 @ 40.000), (30.00)
(2417.000 - 2457.000 @ 40.000), (30.00)
(2422.000 - 2462.000 @ 40.000), (30.00)
(2427.000 - 2467.000 @ 40.000), (30.00)
(2432.000 - 2472.000 @ 40.000), (30.00)
(5170.000 - 5190.000 @ 20.000), (17.00)
(5190.000 - 5210.000 @ 20.000), (17.00)
(5210.000 - 5230.000 @ 20.000), (17.00)
(5230.000 - 5250.000 @ 20.000), (17.00)
(5250.000 - 5270.000 @ 20.000), (23.00), DFS
(5270.000 - 5290.000 @ 20.000), (23.00), DFS
(5290.000 - 5310.000 @ 20.000), (23.00), DFS
(5310.000 - 5330.000 @ 20.000), (23.00), DFS
(5735.000 - 5755.000 @ 20.000), (30.00)
(5755.000 - 5775.000 @ 20.000), (30.00)
(5775.000 - 5795.000 @ 20.000), (30.00)
(5795.000 - 5815.000 @ 20.000), (30.00)
(5815.000 - 5835.000 @ 20.000), (30.00)
(5170.000 - 5210.000 @ 40.000), (17.00)
(5210.000 - 5250.000 @ 40.000), (17.00)
(5250.000 - 5290.000 @ 40.000), (23.00), DFS
(5290.000 - 5330.000 @ 40.000), (23.00), DFS
(5735.000 - 5775.000 @ 40.000), (30.00)
(5775.000 - 5815.000 @ 40.000), (30.00)
(5170.000 - 5250.000 @ 80.000), (17.00)
(5250.000 - 5330.000 @ 80.000), (23.00), DFS
(5735.000 - 5815.000 @ 80.000), (30.00)
mcgrof@frijol ~/devel/crda (git::master)$ cat us | ./optimize
country US: DFS-FCC
(2402.000 - 2472.000 @ 40.000), (30.00)
(5170.000 - 5250.000 @ 80.000), (17.00)
(5250.000 - 5330.000 @ 80.000), (23.00), DFS
(5735.000 - 5835.000 @ 80.000), (30.00)
I've also tested this with the current db.txt from wireless-regdb
and get real optimiziations which I will post later.
Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
---
Makefile | 8 +-
optimize.c | 40 +++++++++
reglib.c | 300 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
reglib.h | 16 ++++
4 files changed, 360 insertions(+), 4 deletions(-)
create mode 100644 optimize.c
diff --git a/Makefile b/Makefile
index bd9c220..9e37ccd 100644
--- a/Makefile
+++ b/Makefile
@@ -28,7 +28,7 @@ LDLIBS += -lm
all: all_noverify verify
-all_noverify: crda intersect regdbdump db2rd
+all_noverify: crda intersect regdbdump db2rd optimize
ifeq ($(USE_OPENSSL),1)
CFLAGS += -DUSE_OPENSSL -DPUBKEY_DIR=\"$(RUNTIME_PUBKEY_DIR)\" `pkg-config --cflags openssl`
@@ -126,6 +126,10 @@ db2rd: reglib.o db2rd.o
$(NQ) ' LD ' $@
$(Q)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LDLIBS)
+optimize: reglib.o optimize.o
+ $(NQ) ' LD ' $@
+ $(Q)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LDLIBS)
+
verify: $(REG_BIN) regdbdump
$(NQ) ' CHK $(REG_BIN)'
$(Q)./regdbdump $(REG_BIN) >/dev/null
@@ -157,6 +161,6 @@ install: crda crda.8.gz regdbdump.8.gz
$(Q)$(INSTALL) -m 644 -t $(DESTDIR)/$(MANDIR)/man8/ regdbdump.8.gz
clean:
- $(Q)rm -f crda regdbdump intersect db2rd \
+ $(Q)rm -f crda regdbdump intersect db2rd optimize \
*.o *~ *.pyc keys-*.c *.gz \
udev/$(UDEV_LEVEL)regulatory.rules udev/regulatory.rules.parsed
diff --git a/optimize.c b/optimize.c
new file mode 100644
index 0000000..89d714b
--- /dev/null
+++ b/optimize.c
@@ -0,0 +1,40 @@
+#include <errno.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <arpa/inet.h> /* ntohl */
+#include <string.h>
+
+#include "nl80211.h"
+#include "reglib.h"
+
+int main(int argc, char **argv)
+{
+ struct ieee80211_regdomain *rd = NULL, *rd_opt = NULL;
+ FILE *fp;
+
+ if (argc != 1) {
+ fprintf(stderr, "Usage: cat db.txt | %s\n", argv[0]);
+ return -EINVAL;
+ }
+
+ fp = reglib_create_parse_stream(stdin);
+ if (!fp)
+ return -EINVAL;
+
+ reglib_for_each_country_stream(fp, rd) {
+ rd_opt = reglib_optimize_regdom(rd);
+ if (!rd_opt){
+ fprintf(stderr, "Unable to optimize %c%c\n",
+ rd->alpha2[0],
+ rd->alpha2[1]);
+ free(rd);
+ continue;
+ }
+ reglib_print_regdom(rd_opt);
+ free(rd);
+ free(rd_opt);
+ }
+
+ fclose(fp);
+ return 0;
+}
diff --git a/reglib.c b/reglib.c
index 6191acd..9577ada 100644
--- a/reglib.c
+++ b/reglib.c
@@ -459,6 +459,49 @@ int reglib_is_valid_rd(const struct ieee80211_regdomain *rd)
return 1;
}
+static int reg_rules_union(const struct ieee80211_reg_rule *rule1,
+ const struct ieee80211_reg_rule *rule2,
+ struct ieee80211_reg_rule *union_rule)
+{
+ const struct ieee80211_freq_range *freq_range1, *freq_range2;
+ struct ieee80211_freq_range *freq_range;
+ const struct ieee80211_power_rule *power_rule1, *power_rule2;
+ struct ieee80211_power_rule *power_rule;
+
+ freq_range1 = &rule1->freq_range;
+ freq_range2 = &rule2->freq_range;
+ freq_range = &union_rule->freq_range;
+
+ power_rule1 = &rule1->power_rule;
+ power_rule2 = &rule2->power_rule;
+ power_rule = &union_rule->power_rule;
+
+
+ if (freq_range1->end_freq_khz < freq_range2->start_freq_khz)
+ return -EINVAL;
+ if (freq_range2->end_freq_khz < freq_range1->start_freq_khz)
+ return -EINVAL;
+
+ freq_range->start_freq_khz = reglib_min(freq_range1->start_freq_khz,
+ freq_range2->start_freq_khz);
+ freq_range->end_freq_khz = reglib_max(freq_range1->end_freq_khz,
+ freq_range2->end_freq_khz);
+ freq_range->max_bandwidth_khz = reglib_max(freq_range1->max_bandwidth_khz,
+ freq_range2->max_bandwidth_khz);
+
+ power_rule->max_eirp = reglib_max(power_rule1->max_eirp,
+ power_rule2->max_eirp);
+ power_rule->max_antenna_gain = reglib_max(power_rule1->max_antenna_gain,
+ power_rule2->max_antenna_gain);
+
+ union_rule->flags = rule1->flags | rule2->flags;
+
+ if (!is_valid_reg_rule(union_rule))
+ return -EINVAL;
+
+ return 0;
+}
+
/*
* Helper for reglib_intersect_rds(), this does the real
* mathematical intersection fun
@@ -971,8 +1014,10 @@ static int reglib_parse_rule(FILE *fp, struct ieee80211_reg_rule *reg_rule)
memset(line, 0, sizeof(line));
line_p = fgets(line, sizeof(line), fp);
- if (line_p != line)
+ if (line_p != line) {
+ free(reglib_rule_parsers);
return -EINVAL;
+ }
for (i = 0; i < reglib_rule_parsers->n_parsers; i++) {
r = reglib_rule_parsers->rule_parsers[i](line, reg_rule);
@@ -980,6 +1025,8 @@ static int reglib_parse_rule(FILE *fp, struct ieee80211_reg_rule *reg_rule)
break;
}
+ free(reglib_rule_parsers);
+
return r;
}
@@ -1151,8 +1198,10 @@ struct ieee80211_regdomain *__reglib_parse_country(FILE *fp)
line_p = fgets(line, sizeof(line), fp);
- if (line_p != line)
+ if (line_p != line) {
+ free(reglib_country_parsers);
return NULL;
+ }
for (i = 0; i < reglib_country_parsers->n_parsers; i++) {
r = reglib_country_parsers->country_parsers[i](line, &tmp_rd);
@@ -1162,11 +1211,14 @@ struct ieee80211_regdomain *__reglib_parse_country(FILE *fp)
if (r != 0) {
fprintf(stderr, "Invalid country line: %s", line);
+ free(reglib_country_parsers);
return NULL;
}
rd = reglib_parse_rules(fp, &tmp_rd);
+ free(reglib_country_parsers);
+
return rd;
}
@@ -1250,3 +1302,247 @@ FILE *reglib_create_parse_stream(FILE *f)
return fp;
}
+
+/*
+ * Just whatever for now, nothing formal, but note that as bands
+ * grow we'll want to make this a bit more formal somehow.
+ */
+static uint32_t reglib_deduce_band(uint32_t start_freq_khz)
+{
+ uint32_t freq_mhz = REGLIB_KHZ_TO_MHZ(start_freq_khz);
+
+ if (freq_mhz >= 4000)
+ return 5;
+ if (freq_mhz > 2000 && freq_mhz < 4000)
+ return 2;
+ if (freq_mhz > 50000)
+ return 60;
+ return 1234;
+}
+
+/*
+ * The idea behind a rule key is that if two rule keys share the
+ * same key they can be merged together if their frequencies overlap.
+ */
+static uint64_t reglib_rule_key(struct ieee80211_reg_rule *reg_rule)
+{
+ struct ieee80211_power_rule *power_rule;
+ struct ieee80211_freq_range *freq_range;
+ uint32_t band;
+ uint32_t key;
+
+ freq_range = ®_rule->freq_range;
+ band = reglib_deduce_band(freq_range->start_freq_khz);
+
+ power_rule = ®_rule->power_rule;
+
+ key = ((power_rule->max_eirp ^ 0) << 0) ^
+ ((reg_rule->flags ^ 8) << 8) ^
+ ((band ^ 16) << 16);
+
+ return key;
+}
+
+struct reglib_optimize_map {
+ bool optimized;
+ uint32_t key;
+};
+
+/* Does the provided rule suffice both of the other two */
+static int reglib_opt_rule_fit(struct ieee80211_reg_rule *rule1,
+ struct ieee80211_reg_rule *rule2,
+ struct ieee80211_reg_rule *opt_rule)
+{
+ struct ieee80211_reg_rule interesected_rule;
+ struct ieee80211_reg_rule *int_rule;
+ int r;
+
+ memset(&interesected_rule, 0, sizeof(struct ieee80211_reg_rule));
+ int_rule = &interesected_rule;
+
+ r = reg_rules_intersect(rule1, opt_rule, int_rule);
+ if (r != 0)
+ return r;
+ r = reg_rules_intersect(rule2, opt_rule, int_rule);
+ if (r != 0)
+ return r;
+
+ return 0;
+}
+
+static int reg_rule_optimize(struct ieee80211_reg_rule *rule1,
+ struct ieee80211_reg_rule *rule2,
+ struct ieee80211_reg_rule *opt_rule)
+{
+ int r;
+
+ r = reg_rules_union(rule1, rule2, opt_rule);
+ if (r != 0)
+ return r;
+ r = reglib_opt_rule_fit(rule1, rule2, opt_rule);
+ if (r != 0)
+ return r;
+
+ return 0;
+}
+
+/*
+ * Here's the math explanation:
+ *
+ * This takes each pivot frequency on the regulatory domain, computes
+ * the union between it each regulatory rule on the regulatory domain
+ * sequentially, and after that it tries to verify that the pivot frequency
+ * fits on it by computing an intersection between it and the union, if
+ * a rule exist as a possible intersection then we know the rule can be
+ * subset of the combination of the two frequency ranges (union) computed.
+ */
+static unsigned int reg_rule_optimize_rd(struct ieee80211_regdomain *rd,
+ unsigned int rule_idx,
+ struct ieee80211_reg_rule *opt_rule,
+ struct reglib_optimize_map *opt_map)
+{
+ unsigned int i;
+ struct ieee80211_reg_rule *rule1;
+ struct ieee80211_reg_rule *rule2;
+
+ struct ieee80211_reg_rule tmp_optimized_rule;
+ struct ieee80211_reg_rule *tmp_opt_rule;
+
+ struct ieee80211_reg_rule *target_rule;
+
+ unsigned int optimized = 0;
+ int r;
+
+ if (rule_idx > rd->n_reg_rules)
+ return 0;
+
+ rule1 = &rd->reg_rules[rule_idx];
+
+ memset(&tmp_optimized_rule, 0, sizeof(struct ieee80211_reg_rule));
+ tmp_opt_rule = &tmp_optimized_rule;
+
+ memset(opt_rule, 0, sizeof(*opt_rule));
+
+ for (i = 0; i < rd->n_reg_rules; i++) {
+ if (rule_idx == i)
+ continue;
+ rule2 = &rd->reg_rules[i];
+ if (opt_map[rule_idx].key != opt_map[i].key)
+ continue;
+
+ target_rule = optimized ? opt_rule : rule1;
+ r = reg_rule_optimize(target_rule, rule2, tmp_opt_rule);
+ if (r != 0)
+ continue;
+ memcpy(opt_rule, tmp_opt_rule, sizeof(*tmp_opt_rule));
+
+ if (!opt_map[i].optimized) {
+ opt_map[i].optimized = true;
+ optimized++;
+ }
+ if (!opt_map[rule_idx].optimized) {
+ opt_map[rule_idx].optimized = true;
+ optimized++;
+ }
+ }
+ return optimized;
+}
+
+struct ieee80211_regdomain *
+reglib_optimize_regdom(struct ieee80211_regdomain *rd)
+{
+ struct ieee80211_regdomain *opt_rd = NULL;
+ struct ieee80211_reg_rule *reg_rule;
+ struct ieee80211_reg_rule *reg_rule_dst;
+ struct ieee80211_reg_rule optimized_reg_rule;
+ struct ieee80211_reg_rule *opt_reg_rule;
+ struct reglib_optimize_map *opt_map;
+ unsigned int i, idx = 0, non_opt = 0, opt = 0;
+ size_t num_rules, size_of_regd, size_of_opt_map;
+ unsigned int num_opts = 0;
+
+ size_of_opt_map = (rd->n_reg_rules + 2) *
+ sizeof(struct reglib_optimize_map);
+ opt_map = malloc(size_of_opt_map);
+ if (!opt_map)
+ return NULL;
+
+ memset(opt_map, 0, size_of_opt_map);
+ memset(&optimized_reg_rule, 0, sizeof(struct ieee80211_reg_rule));
+
+ opt_reg_rule = &optimized_reg_rule;
+
+ for (i = 0; i < rd->n_reg_rules; i++) {
+ reg_rule = &rd->reg_rules[i];
+ opt_map[i].key = reglib_rule_key(reg_rule);
+ }
+ for (i = 0; i < rd->n_reg_rules; i++) {
+ reg_rule = &rd->reg_rules[i];
+ if (opt_map[i].optimized)
+ continue;
+ num_opts = reg_rule_optimize_rd(rd, i, opt_reg_rule, opt_map);
+ if (!num_opts)
+ non_opt++;
+ else
+ opt += (num_opts ? 1 : 0);
+ }
+
+ num_rules = non_opt + opt;
+
+ if (num_rules > rd->n_reg_rules)
+ goto fail_opt_map;
+
+ size_of_regd = reglib_array_len(sizeof(struct ieee80211_regdomain),
+ num_rules + 1,
+ sizeof(struct ieee80211_reg_rule));
+
+ opt_rd = malloc(size_of_regd);
+ if (!opt_rd)
+ goto fail_opt_map;
+ memset(opt_rd, 0, size_of_regd);
+
+ opt_rd->n_reg_rules = num_rules;
+ opt_rd->alpha2[0] = rd->alpha2[0];
+ opt_rd->alpha2[1] = rd->alpha2[1];
+ opt_rd->dfs_region = rd->dfs_region;
+
+ memset(opt_map, 0, size_of_opt_map);
+ memset(&optimized_reg_rule, 0, sizeof(struct ieee80211_reg_rule));
+
+ opt_reg_rule = &optimized_reg_rule;
+
+ for (i = 0; i < rd->n_reg_rules; i++) {
+ reg_rule = &rd->reg_rules[i];
+ opt_map[i].key = reglib_rule_key(reg_rule);
+ }
+
+ for (i = 0; i < rd->n_reg_rules; i++) {
+ reg_rule = &rd->reg_rules[i];
+ reg_rule_dst = &opt_rd->reg_rules[idx];
+ if (opt_map[i].optimized)
+ continue;
+ num_opts = reg_rule_optimize_rd(rd, i, opt_reg_rule, opt_map);
+ if (!num_opts)
+ memcpy(reg_rule_dst, reg_rule, sizeof(struct ieee80211_reg_rule));
+ else
+ memcpy(reg_rule_dst, opt_reg_rule, sizeof(struct ieee80211_reg_rule));
+ idx++;
+ }
+
+ if (idx != num_rules)
+ goto fail;
+
+ for (i = 0; i < opt_rd->n_reg_rules; i++) {
+ reg_rule = &opt_rd->reg_rules[i];
+ if (!is_valid_reg_rule(reg_rule))
+ goto fail;
+ }
+
+ free(opt_map);
+ return opt_rd;
+fail:
+ free(opt_rd);
+fail_opt_map:
+ free(opt_map);
+ return NULL;
+}
diff --git a/reglib.h b/reglib.h
index 885792e..d570c36 100644
--- a/reglib.h
+++ b/reglib.h
@@ -219,6 +219,22 @@ FILE *reglib_create_parse_stream(FILE *fp);
*/
struct ieee80211_regdomain *reglib_parse_country(FILE *fp);
+/**
+ * @reglib_optimize_regdom - optimize a regulatory domain
+ *
+ * @rd: a regulatory domain to be optimized
+ *
+ * A regulatory domain may exist without optimal expressions
+ * over its rules. This will look for regulatory rules that can
+ * be combined together to reduce the size of the regulatory
+ * domain and its expression.
+ *
+ * Regulatory rules will be combined if their max allowed
+ * bandwidth, max EIRP, and flags all match.
+ */
+struct ieee80211_regdomain *
+reglib_optimize_regdom(struct ieee80211_regdomain *rd);
+
#define reglib_for_each_country_stream(__fp, __rd) \
for (__rd = reglib_parse_country(__fp); \
__rd != NULL; \
--
1.8.4.rc3
^ permalink raw reply related
* [PATCH v2 3/6] crda: add regulatory domain stream parser
From: Luis R. Rodriguez @ 2013-10-28 16:42 UTC (permalink / raw)
To: linux-wireless; +Cc: wireless-regdb, Luis R. Rodriguez
In-Reply-To: <1382978526-23929-1-git-send-email-mcgrof@do-not-panic.com>
This adds a stream parser for regulatory domains. This
allows developers to build regulatory domains now using
the db.txt from a stream, either stdin, or a from an
opened file.
This also adds a simple db2rd which for now only uses the
library but with a bit of effort can also be used as a
suitable replacement for the kernel's genregdb.awk.
Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
---
Makefile | 10 +-
db2rd.c | 32 ++++
reglib.c | 543 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
reglib.h | 44 ++++++
4 files changed, 627 insertions(+), 2 deletions(-)
create mode 100644 db2rd.c
diff --git a/Makefile b/Makefile
index 7d2e33f..bd9c220 100644
--- a/Makefile
+++ b/Makefile
@@ -24,10 +24,11 @@ PUBKEY_DIR?=pubkeys
RUNTIME_PUBKEY_DIR?=/etc/wireless-regdb/pubkeys
CFLAGS += -Wall -g
+LDLIBS += -lm
all: all_noverify verify
-all_noverify: crda intersect regdbdump
+all_noverify: crda intersect regdbdump db2rd
ifeq ($(USE_OPENSSL),1)
CFLAGS += -DUSE_OPENSSL -DPUBKEY_DIR=\"$(RUNTIME_PUBKEY_DIR)\" `pkg-config --cflags openssl`
@@ -121,6 +122,10 @@ intersect: reglib.o intersect.o
$(NQ) ' LD ' $@
$(Q)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LDLIBS)
+db2rd: reglib.o db2rd.o
+ $(NQ) ' LD ' $@
+ $(Q)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LDLIBS)
+
verify: $(REG_BIN) regdbdump
$(NQ) ' CHK $(REG_BIN)'
$(Q)./regdbdump $(REG_BIN) >/dev/null
@@ -152,5 +157,6 @@ install: crda crda.8.gz regdbdump.8.gz
$(Q)$(INSTALL) -m 644 -t $(DESTDIR)/$(MANDIR)/man8/ regdbdump.8.gz
clean:
- $(Q)rm -f crda regdbdump intersect *.o *~ *.pyc keys-*.c *.gz \
+ $(Q)rm -f crda regdbdump intersect db2rd \
+ *.o *~ *.pyc keys-*.c *.gz \
udev/$(UDEV_LEVEL)regulatory.rules udev/regulatory.rules.parsed
diff --git a/db2rd.c b/db2rd.c
new file mode 100644
index 0000000..51ec051
--- /dev/null
+++ b/db2rd.c
@@ -0,0 +1,32 @@
+#include <errno.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <arpa/inet.h> /* ntohl */
+#include <string.h>
+
+#include "nl80211.h"
+#include "reglib.h"
+
+int main(int argc, char **argv)
+{
+ struct ieee80211_regdomain *rd = NULL;
+ FILE *fp;
+
+ if (argc != 1) {
+ fprintf(stderr, "Usage: cat db.txt | %s\n", argv[0]);
+ return -EINVAL;
+ }
+
+ fp = reglib_create_parse_stream(stdin);
+ if (!fp)
+ return -EINVAL;
+
+ reglib_for_each_country_stream(fp, rd) {
+ reglib_print_regdom(rd);
+ free(rd);
+ }
+
+ fclose(fp);
+
+ return 0;
+}
diff --git a/reglib.c b/reglib.c
index b0c61e5..6191acd 100644
--- a/reglib.c
+++ b/reglib.c
@@ -38,6 +38,19 @@
#include "keys-gcrypt.c"
#endif
+int debug = 0;
+
+struct reglib_rule_parse_list {
+ int n_parsers;
+ int (*rule_parsers[])(char *line, struct ieee80211_reg_rule *reg_rule);
+};
+
+struct reglib_country_parse_list {
+ int n_parsers;
+ int (*country_parsers[])(char *line, struct ieee80211_regdomain *rd);
+};
+
+
void *
reglib_get_file_ptr(uint8_t *db, size_t dblen, size_t structlen, uint32_t ptr)
{
@@ -707,3 +720,533 @@ void reglib_print_regdom(const struct ieee80211_regdomain *rd)
print_reg_rule(&rd->reg_rules[i]);
printf("\n");
}
+
+static unsigned int reglib_parse_dfs_region(char *dfs_region)
+{
+ if (strncmp(dfs_region, "DFS-FCC", 7) == 0)
+ return REGDB_DFS_FCC;
+ if (strncmp(dfs_region, "DFS-ETSI", 8) == 0)
+ return REGDB_DFS_ETSI;
+ if (strncmp(dfs_region, "DFS-JP", 6) == 0)
+ return REGDB_DFS_JP;
+ return REGDB_DFS_UNSET;
+}
+
+static uint32_t reglib_parse_rule_flag(char *flag_s)
+{
+ if (strncmp(flag_s, "NO-OFDM", 7) == 0)
+ return RRF_NO_OFDM;
+ if (strncmp(flag_s, "NO-CCK", 6) == 0)
+ return RRF_NO_CCK;
+ if (strncmp(flag_s, "NO-INDOOR", 9) == 0)
+ return RRF_NO_INDOOR;
+ if (strncmp(flag_s, "NO-OUTDOOR", 10) == 0)
+ return RRF_NO_OUTDOOR;
+ if (strncmp(flag_s, "DFS", 3) == 0)
+ return RRF_DFS;
+ if (strncmp(flag_s, "PTP-ONLY", 8) == 0)
+ return RRF_PTP_ONLY;
+ if (strncmp(flag_s, "PTMP-ONLY", 9) == 0)
+ return RRF_PTMP_ONLY;
+ if (strncmp(flag_s, "NO-IR", 5) == 0)
+ return RRF_NO_IR;
+
+ return 0;
+}
+
+static int
+reglib_parse_rule_simple(char *line, struct ieee80211_reg_rule *reg_rule)
+{
+ int hits;
+ float start_freq_khz, end_freq_khz, max_bandwidth_khz, max_eirp;
+
+ hits = sscanf(line, "\t(%f - %f @ %f), (%f)\n",
+ &start_freq_khz,
+ &end_freq_khz,
+ &max_bandwidth_khz,
+ &max_eirp);
+
+ if (hits != 4)
+ return -EINVAL;
+
+ reg_rule->freq_range.start_freq_khz =
+ REGLIB_MHZ_TO_KHZ(start_freq_khz);
+ reg_rule->freq_range.end_freq_khz =
+ REGLIB_MHZ_TO_KHZ(end_freq_khz);
+ reg_rule->freq_range.max_bandwidth_khz =
+ REGLIB_MHZ_TO_KHZ(max_bandwidth_khz);
+ reg_rule->power_rule.max_eirp =
+ REGLIB_DBM_TO_MBM(max_eirp);
+
+ reg_rule->flags = 0;
+
+ if (debug)
+ printf("reglib_parse_rule_simple(): %d line: %s", hits, line);
+
+
+ return 0;
+}
+
+static int
+reglib_parse_rule_simple_mw(char *line, struct ieee80211_reg_rule *reg_rule)
+{
+ int hits;
+ float start_freq_khz, end_freq_khz, max_bandwidth_khz, max_eirp;
+ char mw[3];
+
+ hits = sscanf(line, "\t(%f - %f @ %f), (%f %2[mW])\n",
+ &start_freq_khz,
+ &end_freq_khz,
+ &max_bandwidth_khz,
+ &max_eirp, mw);
+
+ if (hits != 4)
+ return -EINVAL;
+
+
+ reg_rule->freq_range.start_freq_khz =
+ REGLIB_MHZ_TO_KHZ(start_freq_khz);
+ reg_rule->freq_range.end_freq_khz =
+ REGLIB_MHZ_TO_KHZ(end_freq_khz);
+ reg_rule->freq_range.max_bandwidth_khz =
+ REGLIB_MHZ_TO_KHZ(max_bandwidth_khz);
+ reg_rule->power_rule.max_eirp =
+ REGLIB_MW_TO_MBM(max_eirp);
+
+ reg_rule->flags = 0;
+
+ if (debug)
+ printf("reglib_parse_rule_simple_mw(): %d line: %s",
+ hits, line);
+
+ return 0;
+}
+
+static int
+reglib_parse_rule_args(char *line, struct ieee80211_reg_rule *reg_rule)
+{
+#define IGNORE_COMMA_OR_SPACE "%*[ ,]"
+ int hits;
+ char flag_list[9][100];
+ unsigned int i = 0;
+ float start_freq_khz, end_freq_khz, max_bandwidth_khz, max_eirp;
+
+ for (i = 0; i < 9; i++)
+ memset(flag_list[i], 0, sizeof(flag_list[i]));
+
+ hits = sscanf(line, "\t(%f - %f @ %f), (%f)"
+ IGNORE_COMMA_OR_SPACE "%s"
+ IGNORE_COMMA_OR_SPACE "%s"
+ IGNORE_COMMA_OR_SPACE "%s"
+ IGNORE_COMMA_OR_SPACE "%s"
+ IGNORE_COMMA_OR_SPACE "%s"
+ IGNORE_COMMA_OR_SPACE "%s"
+ IGNORE_COMMA_OR_SPACE "%s"
+ IGNORE_COMMA_OR_SPACE "%s"
+ IGNORE_COMMA_OR_SPACE "%s",
+ &start_freq_khz,
+ &end_freq_khz,
+ &max_bandwidth_khz,
+ &max_eirp,
+ flag_list[0],
+ flag_list[1],
+ flag_list[2],
+ flag_list[3],
+ flag_list[4],
+ flag_list[5],
+ flag_list[6],
+ flag_list[7],
+ flag_list[8]);
+
+ if (hits < 5)
+ return -EINVAL;
+
+ reg_rule->freq_range.start_freq_khz =
+ REGLIB_MHZ_TO_KHZ(start_freq_khz);
+ reg_rule->freq_range.end_freq_khz =
+ REGLIB_MHZ_TO_KHZ(end_freq_khz);
+ reg_rule->freq_range.max_bandwidth_khz =
+ REGLIB_MHZ_TO_KHZ(max_bandwidth_khz);
+ reg_rule->power_rule.max_eirp =
+ REGLIB_DBM_TO_MBM(max_eirp);
+
+ for (i = 0; i < 8; i++)
+ reg_rule->flags |= reglib_parse_rule_flag(flag_list[i]);
+
+ if (debug)
+ printf("reglib_parse_rule_args(): %d flags: %d, line: %s",
+ hits, reg_rule->flags, line);
+
+ return 0;
+#undef IGNORE_COMMA_OR_SPACE
+}
+
+
+static int
+reglib_parse_rule_args_mw(char *line, struct ieee80211_reg_rule *reg_rule)
+{
+#define IGNORE_COMMA_OR_SPACE "%*[ ,]"
+ int hits;
+ char flag_list[9][100];
+ unsigned int i = 0;
+ char mw[3];
+ float start_freq_khz, end_freq_khz, max_bandwidth_khz, max_eirp;
+
+ for (i = 0; i < 9; i++)
+ memset(flag_list[i], 0, sizeof(flag_list[i]));
+
+ hits = sscanf(line, "\t(%f - %f @ %f), (%f %2[mW])"
+ IGNORE_COMMA_OR_SPACE "%s"
+ IGNORE_COMMA_OR_SPACE "%s"
+ IGNORE_COMMA_OR_SPACE "%s"
+ IGNORE_COMMA_OR_SPACE "%s"
+ IGNORE_COMMA_OR_SPACE "%s"
+ IGNORE_COMMA_OR_SPACE "%s"
+ IGNORE_COMMA_OR_SPACE "%s"
+ IGNORE_COMMA_OR_SPACE "%s"
+ IGNORE_COMMA_OR_SPACE "%s",
+ &start_freq_khz,
+ &end_freq_khz,
+ &max_bandwidth_khz,
+ &max_eirp,
+ mw,
+ flag_list[0],
+ flag_list[1],
+ flag_list[2],
+ flag_list[3],
+ flag_list[4],
+ flag_list[5],
+ flag_list[6],
+ flag_list[7],
+ flag_list[8]);
+
+ if (hits < 5)
+ return -EINVAL;
+
+ reg_rule->freq_range.start_freq_khz =
+ REGLIB_MHZ_TO_KHZ(start_freq_khz);
+ reg_rule->freq_range.end_freq_khz =
+ REGLIB_MHZ_TO_KHZ(end_freq_khz);
+ reg_rule->freq_range.max_bandwidth_khz =
+ REGLIB_MHZ_TO_KHZ(max_bandwidth_khz);
+ reg_rule->power_rule.max_eirp =
+ REGLIB_MW_TO_MBM(max_eirp);
+
+ for (i = 0; i < 8; i++)
+ reg_rule->flags |= reglib_parse_rule_flag(flag_list[i]);
+
+ if (debug)
+ printf("reglib_parse_rule_args_mw(): %d flags: %d, line: %s",
+ hits, reg_rule->flags, line);
+ return 0;
+#undef IGNORE_COMMA_OR_SPACE
+}
+
+static int reglib_parse_rule(FILE *fp, struct ieee80211_reg_rule *reg_rule)
+{
+ char line[1024];
+ char *line_p;
+ unsigned int i;
+ int r = 0;
+ struct reglib_rule_parse_list *reglib_rule_parsers;
+ size_t size_parsers = sizeof(struct reglib_rule_parse_list) +
+ 4 * sizeof(int (*)(char *, struct ieee80211_reg_rule *));
+
+ reglib_rule_parsers = malloc(size_parsers);
+ if (!reglib_rule_parsers)
+ return -EINVAL;
+ memset(reglib_rule_parsers, 0, size_parsers);
+
+ reglib_rule_parsers->n_parsers = 4;
+
+ /*
+ * XXX: sscanf() is a bit odd with picking up mW
+ * case over the simple one, this order however works,
+ * gotta figure out how to be more precise.
+ */
+ reglib_rule_parsers->rule_parsers[0] = reglib_parse_rule_args_mw;
+ reglib_rule_parsers->rule_parsers[1] = reglib_parse_rule_args;
+ reglib_rule_parsers->rule_parsers[2] = reglib_parse_rule_simple;
+ reglib_rule_parsers->rule_parsers[3] = reglib_parse_rule_simple_mw;
+
+ memset(line, 0, sizeof(line));
+ line_p = fgets(line, sizeof(line), fp);
+ if (line_p != line)
+ return -EINVAL;
+
+ for (i = 0; i < reglib_rule_parsers->n_parsers; i++) {
+ r = reglib_rule_parsers->rule_parsers[i](line, reg_rule);
+ if (r == 0)
+ break;
+ }
+
+ return r;
+}
+
+static uint32_t
+reglib_get_n_rules(FILE *fp, struct ieee80211_reg_rule *reg_rule)
+{
+ uint32_t n_rules = 0;
+ int r;
+ bool save_debug = false;
+
+ save_debug = debug;
+ debug = false;
+
+ while (1) {
+ r = reglib_parse_rule(fp, reg_rule);
+ if (r != 0)
+ break;
+ n_rules++;
+ }
+
+ debug = save_debug;
+
+ return n_rules;
+}
+
+static int reglib_parse_reg_rule(FILE *fp, struct ieee80211_reg_rule *reg_rule)
+{
+ int r;
+
+ while (1) {
+ r = reglib_parse_rule(fp, reg_rule);
+ if (r != 0)
+ continue;
+ return 0;
+ }
+}
+
+static struct ieee80211_regdomain *
+reglib_parse_rules(FILE *fp, struct ieee80211_regdomain *trd)
+{
+ struct ieee80211_regdomain *rd;
+ struct ieee80211_reg_rule rule;
+ struct ieee80211_reg_rule *reg_rule;
+ fpos_t pos;
+ unsigned int i;
+ uint32_t size_of_regd = 0, num_rules = 0;
+ int r;
+
+ memset(&rule, 0, sizeof(rule));
+ reg_rule = &rule;
+
+ r = fgetpos(fp, &pos);
+ if (r != 0) {
+ fprintf(stderr, "fgetpos() failed: %s\n",
+ strerror(errno));
+ return NULL;
+ }
+
+ num_rules = reglib_get_n_rules(fp, reg_rule);
+ if (!num_rules)
+ return NULL;
+
+ size_of_regd = reglib_array_len(sizeof(struct ieee80211_regdomain),
+ num_rules + 1,
+ sizeof(struct ieee80211_reg_rule));
+ rd = malloc(size_of_regd);
+ if (!rd)
+ return NULL;
+
+ memset(rd, 0, size_of_regd);
+ memcpy(rd, trd, sizeof(*trd));
+
+ rd->n_reg_rules = num_rules;
+
+ r = fsetpos(fp, &pos);
+ if (r != 0) {
+ fprintf(stderr, "fsetpos() failed: %s\n",
+ strerror(errno));
+ free(rd);
+ return NULL;
+ }
+ for (i = 0; i < num_rules; i++) {
+ struct ieee80211_reg_rule *rrule = &rd->reg_rules[i];
+
+ if (reglib_parse_reg_rule(fp, rrule) != 0) {
+ fprintf(stderr, "rule parse failed\n");
+ free(rd);
+ return NULL;
+ }
+ }
+ return rd;
+}
+
+static int
+reglib_parse_country_simple(char *line, struct ieee80211_regdomain *rd)
+{
+ char dfs_region_alpha[9];
+ char alpha2[2];
+ int hits;
+
+ memset(rd, 0, sizeof(rd));
+ memset(alpha2, 0, sizeof(alpha2));
+ memset(dfs_region_alpha, 0, sizeof(dfs_region_alpha));
+
+ hits = sscanf(line, "country %2[a-zA-Z0-9]:",
+ alpha2);
+
+ if (hits != 1)
+ return -EINVAL;
+
+ rd->alpha2[0] = alpha2[0];
+ rd->alpha2[1] = alpha2[1];
+
+ return 0;
+}
+
+static int reglib_parse_country_dfs(char *line, struct ieee80211_regdomain *rd)
+{
+ char dfs_region_alpha[9];
+ char alpha2[2];
+ int hits;
+
+ memset(rd, 0, sizeof(rd));
+ memset(alpha2, 0, sizeof(alpha2));
+ memset(dfs_region_alpha, 0, sizeof(dfs_region_alpha));
+
+ hits = sscanf(line, "country %2[a-zA-Z0-9]:%*[ ]%s\n",
+ alpha2,
+ dfs_region_alpha);
+ if (hits <= 0)
+ return -EINVAL;
+
+ if (hits != 2)
+ return -EINVAL;
+
+
+ rd->alpha2[0] = alpha2[0];
+ rd->alpha2[1] = alpha2[1];
+ rd->dfs_region = reglib_parse_dfs_region(dfs_region_alpha);
+
+ return 0;
+}
+
+struct ieee80211_regdomain *__reglib_parse_country(FILE *fp)
+{
+ struct ieee80211_regdomain *rd;
+ struct ieee80211_regdomain tmp_rd;
+ char line[1024];
+ char *line_p;
+ unsigned int i;
+ int r = 0;
+ struct reglib_country_parse_list *reglib_country_parsers;
+ size_t size_of_parsers = sizeof(struct reglib_country_parse_list) +
+ 2 * sizeof(int (*)(char *, struct ieee80211_regdomain *));
+
+ reglib_country_parsers = malloc(size_of_parsers);
+ if (!reglib_country_parsers)
+ return NULL;
+ memset(reglib_country_parsers, 0, size_of_parsers);
+
+ reglib_country_parsers->n_parsers = 2;
+ reglib_country_parsers->country_parsers[0] =
+ reglib_parse_country_dfs;
+ reglib_country_parsers->country_parsers[1] =
+ reglib_parse_country_simple;
+
+ memset(&tmp_rd, 0, sizeof(tmp_rd));
+ memset(line, 0, sizeof(line));
+
+ line_p = fgets(line, sizeof(line), fp);
+
+ if (line_p != line)
+ return NULL;
+
+ for (i = 0; i < reglib_country_parsers->n_parsers; i++) {
+ r = reglib_country_parsers->country_parsers[i](line, &tmp_rd);
+ if (r == 0)
+ break;
+ }
+
+ if (r != 0) {
+ fprintf(stderr, "Invalid country line: %s", line);
+ return NULL;
+ }
+
+ rd = reglib_parse_rules(fp, &tmp_rd);
+
+ return rd;
+}
+
+static int reglib_find_next_country_stream(FILE *fp)
+{
+ fpos_t prev_pos;
+ int r;
+ unsigned int i = 0;
+
+ while(1) {
+ char line[1024];
+ char *line_p;
+
+ r = fgetpos(fp, &prev_pos);
+ if (r != 0) {
+ fprintf(stderr, "fgetpos() failed: %s\n",
+ strerror(errno));
+ return r;
+ }
+
+ memset(line, 0, sizeof(line));
+
+ line_p = fgets(line, sizeof(line), fp);
+ if (line_p == line) {
+ if (strspn(line, "\n") == strlen(line)) {
+ i++;
+ continue;
+ }
+ if (strncmp(line, "country", 7) != 0)
+ continue;
+ r = fsetpos(fp, &prev_pos);
+ if (r != 0) {
+ fprintf(stderr, "fsetpos() failed: %s\n",
+ strerror(errno));
+ return r;
+ }
+ return 0;
+ } else
+ return EOF;
+ }
+}
+
+struct ieee80211_regdomain *reglib_parse_country(FILE *fp)
+{
+ int r;
+
+ r = reglib_find_next_country_stream(fp);
+ if (r != 0)
+ return NULL;
+ return __reglib_parse_country(fp);
+}
+
+FILE *reglib_create_parse_stream(FILE *f)
+{
+ unsigned int lines = 0;
+ FILE *fp;
+
+ fp = tmpfile();
+ if (errno) {
+ fprintf(stderr, "%s\n", strerror(errno));
+ return NULL;
+ }
+
+ while(1) {
+ char line[1024];
+ char *line_p;
+
+ line_p = fgets(line, sizeof(line), f);
+ if (line_p == line) {
+ if (strchr(line, '#') == NULL) {
+ fputs(line, fp);
+ lines++;
+ }
+ continue;
+ } else
+ break;
+ }
+
+ rewind(fp);
+ fflush(fp);
+
+ return fp;
+}
diff --git a/reglib.h b/reglib.h
index 7a586a3..885792e 100644
--- a/reglib.h
+++ b/reglib.h
@@ -1,10 +1,12 @@
#ifndef REG_LIB_H
#define REG_LIB_H
+#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <sys/stat.h>
+#include <math.h>
#include "regdb.h"
@@ -35,6 +37,19 @@ struct ieee80211_regdomain {
struct ieee80211_reg_rule reg_rules[];
};
+/* Remove this once upstream nl80211.h gets this */
+#define NL80211_RRF_NO_IR (1<<7)
+
+#define REGLIB_MHZ_TO_KHZ(freq) ((freq) * 1000)
+#define REGLIB_KHZ_TO_MHZ(freq) ((freq) / 1000)
+#define REGLIB_DBI_TO_MBI(gain) ((gain) * 100)
+#define REGLIB_MBI_TO_DBI(gain) ((gain) / 100)
+#define REGLIB_DBM_TO_MBM(gain) ((gain) * 100)
+#define REGLIB_MBM_TO_DBM(gain) ((gain) / 100)
+
+#define REGLIB_MW_TO_DBM(gain) (10 * log10(gain))
+#define REGLIB_MW_TO_MBM(gain) (REGLIB_DBM_TO_MBM(REGLIB_MW_TO_DBM(gain)))
+
/**
* struct reglib_regdb_ctx - reglib regdb context
*
@@ -180,4 +195,33 @@ reglib_intersect_rds(const struct ieee80211_regdomain *rd1,
const struct ieee80211_regdomain *
reglib_intersect_regdb(const struct reglib_regdb_ctx *ctx);
+/**
+ * @reglib_create_parse_stream - provide a clean new stream for processing
+ *
+ * @fp: FILE stream, could be stdin, or a stream from an open file.
+ *
+ * In order to parse a stream we recommend to create a new stream
+ * using this helper. A new stream is preferred in order to work
+ * with stdin, as otherwise we cannot rewind() and move around
+ * the stream. This helper will create new stream using tmpfile()
+ * and also remove all comments. It will be closed and the file
+ * deleted when the process terminates.
+ */
+FILE *reglib_create_parse_stream(FILE *fp);
+
+/**
+ * @reglib_parse_country - parse stream to build a regulatory domain
+ *
+ * @fp: FILE stream, could be stdin, or a stream from an open file.
+ *
+ * Parse stream and return back a built regulatory domain. Returns
+ * NULL if one could not be built.
+ */
+struct ieee80211_regdomain *reglib_parse_country(FILE *fp);
+
+#define reglib_for_each_country_stream(__fp, __rd) \
+ for (__rd = reglib_parse_country(__fp); \
+ __rd != NULL; \
+ __rd = reglib_parse_country(__fp)) \
+
#endif
--
1.8.4.rc3
^ permalink raw reply related
* [PATCH v2 2/6] crda: fix -pedantic gcc compilation
From: Luis R. Rodriguez @ 2013-10-28 16:42 UTC (permalink / raw)
To: linux-wireless; +Cc: wireless-regdb, Luis R. Rodriguez
In-Reply-To: <1382978526-23929-1-git-send-email-mcgrof@do-not-panic.com>
gcc likes to complain about this, fix that as we're
going to get a bit more anal with code here soon as
we're moving towards making a library out of reglib.
Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
---
crda.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/crda.c b/crda.c
index 2a601eb..4751a39 100644
--- a/crda.c
+++ b/crda.c
@@ -141,13 +141,15 @@ int main(int argc, char **argv)
{
int fd = -1;
int i = 0, j, r;
- char alpha2[3] = {}; /* NUL-terminate */
+ char alpha2[3];
char *env_country;
struct nl80211_state nlstate;
struct nl_cb *cb = NULL;
struct nl_msg *msg;
int finished = 0;
+ memset(alpha2, 0, 3);
+
struct nlattr *nl_reg_rules;
const struct ieee80211_regdomain *rd = NULL;
--
1.8.4.rc3
^ permalink raw reply related
* [PATCH v2 1/6] crda: relicense under copyleft-next-0.3.0
From: Luis R. Rodriguez @ 2013-10-28 16:42 UTC (permalink / raw)
To: linux-wireless; +Cc: wireless-regdb, Luis R. Rodriguez
In-Reply-To: <1382978526-23929-1-git-send-email-mcgrof@do-not-panic.com>
I'm relicensing CRDA to copyleft-next-0.3.0. The original
motivation was to help with the BSD family but they are not
using any of this software and as this software grows I'd
like to ensure we use the best free software license
possible.
Fontana's work on copyleft-next is great and has good
community traction. At this point development for
copyleft-next has slowed down as copyleft-next-0.3.0
is already a good, usable alternative to GPLv2 and GPLv3.
A few notes:
* With copyleft we don't have to specify 'at your option
any later version' since the license allows that by
default.
* Some folks might wonder if copyleft-next-0.3.0 is
OSI OSD-conformant or FSF-free since neither of
those bodies have examined the license officially,
but note, although IANAL, that copyleft-next is
outbound-compatible with GPLv2 and GPLv3
Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
---
LICENSE | 14 +++-
copyleft-next-0.3.0 | 219 ++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 232 insertions(+), 1 deletion(-)
create mode 100644 copyleft-next-0.3.0
diff --git a/LICENSE b/LICENSE
index 652a6dd..cc26ff2 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,4 +1,16 @@
-Copyright (c) 2008, Luis R. Rodriguez <mcgrof@gmail.com>
+Copyright (c) 2013, Luis R. Rodriguez <mcgrof@do-not-panic.com>
+
+CRDA is licensed under copyleft-next 0.3.0
+
+Refer to copyleft-next-0.3.0 for license details, you can
+also always get the latest updates of copyleft-next from:
+
+https://gitorious.org/copyleft-next/
+
+This file incorporates work covered by the following copyright and
+permission notice:
+
+Copyright (c) 2008, Luis R. Rodriguez <mcgrof@do-not-panic.com>
Copyright (c) 2008, Johannes Berg <johannes@sipsolutions.net>
Copyright (c) 2008, Michael Green <Michael.Green@Atheros.com>
diff --git a/copyleft-next-0.3.0 b/copyleft-next-0.3.0
new file mode 100644
index 0000000..a66d5bf
--- /dev/null
+++ b/copyleft-next-0.3.0
@@ -0,0 +1,219 @@
+ copyleft-next 0.3.0 ("this License")
+ Release date: 2013-05-16
+
+1. License Grants; No Trademark License
+
+ Subject to the terms of this License, I grant You:
+
+ a) A non-exclusive, worldwide, perpetual, royalty-free, irrevocable
+ copyright license, to reproduce, Distribute, prepare derivative works
+ of, publicly perform and publicly display My Work.
+
+ b) A non-exclusive, worldwide, perpetual, royalty-free, irrevocable
+ patent license under Licensed Patents to make, have made, use, sell,
+ offer for sale, and import Covered Works.
+
+ This License does not grant any rights in My name, trademarks, service
+ marks, or logos.
+
+2. Distribution: General Conditions
+
+ You may Distribute Covered Works, provided that You (i) inform
+ recipients how they can obtain a copy of this License; (ii) satisfy the
+ applicable conditions of sections 3 through 6; and (iii) preserve all
+ Legal Notices contained in My Work (to the extent they remain
+ pertinent). "Legal Notices" means copyright notices, license notices,
+ license texts, and author attributions, but does not include logos,
+ other graphical images, trademarks or trademark legends.
+
+3. Conditions for Distributing Derived Works; Outbound GPL Compatibility
+
+ If You Distribute a Derived Work, You must license the entire Derived
+ Work as a whole under this License, with prominent notice of such
+ licensing. This condition may not be avoided through such means as
+ separate Distribution of portions of the Derived Work. You may
+ additionally license the Derived Work under the GPL, so that the
+ recipient may further Distribute the Derived Work under either this
+ License or the GPL.
+
+4. Condition Against Further Restrictions; Inbound License Compatibility
+
+ When Distributing a Covered Work, You may not impose further
+ restrictions on the exercise of rights in the Covered Work granted under
+ this License. This condition is not excused merely because such
+ restrictions result from Your compliance with conditions or obligations
+ extrinsic to this License (such as a court order or an agreement with a
+ third party).
+
+ However, You may Distribute a Covered Work incorporating material
+ governed by a license that is both OSI-Approved and FSF-Free as of the
+ release date of this License, provided that Your Distribution complies
+ with such other license.
+
+5. Conditions for Distributing Object Code
+
+ You may Distribute an Object Code form of a Covered Work, provided that
+ you accompany the Object Code with a URL through which the Corresponding
+ Source is made available, at no charge, by some standard or customary
+ means of providing network access to source code.
+
+ If you Distribute the Object Code in a physical product or tangible
+ storage medium ("Product"), the Corresponding Source must be available
+ through such URL for two years from the date of Your most recent
+ Distribution of the Object Code in the Product. However, if the Product
+ itself contains or is accompanied by the Corresponding Source (made
+ available in a customarily accessible manner), You need not also comply
+ with the first paragraph of this section.
+
+ Each recipient of the Covered Work from You is an intended third-party
+ beneficiary of this License solely as to this section 5, with the right
+ to enforce its terms.
+
+6. Symmetrical Licensing Condition for Upstream Contributions
+
+ If You Distribute a work to Me specifically for inclusion in or
+ modification of a Covered Work (a "Patch"), and no explicit licensing
+ terms apply to the Patch, You license the Patch under this License, to
+ the extent of Your copyright in the Patch. This condition does not
+ negate the other conditions of this License, if applicable to the Patch.
+
+7. Nullification of Copyleft/Proprietary Dual Licensing
+
+ If I offer to license, for a fee, a Covered Work under terms other than
+ a license that is OSI-Approved or FSF-Free as of the release date of this
+ License or a numbered version of copyleft-next released by the
+ Copyleft-Next Project, then the license I grant You under section 1 is no
+ longer subject to the conditions in sections 2 through 5.
+
+8. Copyleft Sunset
+
+ The conditions in sections 2 through 5 no longer apply once fifteen
+ years have elapsed from the date of My first Distribution of My Work
+ under this License.
+
+9. Pass-Through
+
+ When You Distribute a Covered Work, the recipient automatically receives
+ a license to My Work from Me, subject to the terms of this License.
+
+10. Termination
+
+ Your license grants under section 1 are automatically terminated if You
+
+ a) fail to comply with the conditions of this License, unless You cure
+ such noncompliance within thirty days after becoming aware of it, or
+
+ b) initiate a patent infringement litigation claim (excluding
+ declaratory judgment actions, counterclaims, and cross-claims)
+ alleging that any part of My Work directly or indirectly infringes
+ any patent.
+
+ Termination of Your license grants extends to all copies of Covered
+ Works You subsequently obtain. Termination does not terminate the
+ rights of those who have received copies or rights from You subject to
+ this License.
+
+ To the extent permission to make copies of a Covered Work is necessary
+ merely for running it, such permission is not terminable.
+
+11. Later License Versions
+
+ The Copyleft-Next Project may release new versions of copyleft-next,
+ designated by a distinguishing version number ("Later Versions").
+ Unless I explicitly remove the option of Distributing Covered Works
+ under Later Versions, You may Distribute Covered Works under any Later
+ Version.
+
+** 12. No Warranty **
+** **
+** My Work is provided "as-is", without warranty. You bear the risk **
+** of using it. To the extent permitted by applicable law, each **
+** Distributor of My Work excludes the implied warranties of title, **
+** merchantability, fitness for a particular purpose and **
+** non-infringement. **
+
+** 13. Limitation of Liability **
+** **
+** To the extent permitted by applicable law, in no event will any **
+** Distributor of My Work be liable to You for any damages **
+** whatsoever, whether direct, indirect, special, incidental, or **
+** consequential damages, whether arising under contract, tort **
+** (including negligence), or otherwise, even where the Distributor **
+** knew or should have known about the possibility of such damages. **
+
+14. Severability
+
+ The invalidity or unenforceability of any provision of this License
+ does not affect the validity or enforceability of the remainder of
+ this License. Such provision is to be reformed to the minimum extent
+ necessary to make it valid and enforceable.
+
+15. Definitions
+
+ "Copyleft-Next Project" means the project that maintains the source
+ code repository at <https://gitorious.org/copyleft-next/> as of the
+ release date of this License.
+
+ "Corresponding Source" of a Covered Work in Object Code form means (i)
+ the Source Code form of the Covered Work; (ii) all scripts,
+ instructions and similar information that are reasonably necessary for
+ a skilled developer to generate such Object Code from the Source Code
+ provided under (i); and (iii) a list clearly identifying all Separate
+ Works (other than those provided in compliance with (ii)) that were
+ specifically used in building and (if applicable) installing the
+ Covered Work (for example, a specified proprietary compiler including
+ its version number). Corresponding Source must be machine-readable.
+
+ "Covered Work" means My Work or a Derived Work.
+
+ "Derived Work" means a work of authorship that copies from, modifies,
+ adapts, is based on, is a derivative work of, transforms, translates or
+ contains all or part of My Work, such that copyright permission is
+ required. The following are not Derived Works: (i) Mere Aggregation;
+ (ii) a mere reproduction of My Work; and (iii) if My Work fails to
+ explicitly state an expectation otherwise, a work that merely makes
+ reference to My Work.
+
+ "Distribute" means to distribute, transfer or make a copy available to
+ someone else, such that copyright permission is required.
+
+ "Distributor" means Me and anyone else who Distributes a Covered Work.
+
+ "FSF-Free" means classified as 'free' by the Free Software Foundation.
+
+ "GPL" means a version of the GNU General Public License or the GNU
+ Affero General Public License.
+
+ "I"/"Me"/"My" refers to the individual or legal entity that places My
+ Work under this License. "You"/"Your" refers to the individual or legal
+ entity exercising rights in My Work under this License. A legal entity
+ includes each entity that controls, is controlled by, or is under
+ common control with such legal entity. "Control" means (a) the power to
+ direct the actions of such legal entity, whether by contract or
+ otherwise, or (b) ownership of more than fifty percent of the
+ outstanding shares or beneficial ownership of such legal entity.
+
+ "Licensed Patents" means all patent claims licensable royalty-free by
+ Me, now or in the future, that are necessarily infringed by making,
+ using, or selling My Work, and excludes claims that would be infringed
+ only as a consequence of further modification of My Work.
+
+ "Mere Aggregation" means an aggregation of a Covered Work with a
+ Separate Work.
+
+ "My Work" means the particular work of authorship I license to You
+ under this License.
+
+ "Object Code" means any form of a work that is not Source Code.
+
+ "OSI-Approved" means approved as 'Open Source' by the Open Source
+ Initiative.
+
+ "Separate Work" means a work that is separate from and independent of a
+ particular Covered Work and is not by its nature an extension or
+ enhancement of the Covered Work, and/or a runtime library, standard
+ library or similar component that is used to generate an Object Code
+ form of a Covered Work.
+
+ "Source Code" means the preferred form of a work for making
+ modifications to it.
--
1.8.4.rc3
^ permalink raw reply related
* [PATCH v2 0/6] crda: few more updates
From: Luis R. Rodriguez @ 2013-10-28 16:42 UTC (permalink / raw)
To: linux-wireless; +Cc: wireless-regdb, Luis R. Rodriguez
Here's a second spin, after quite a bit more testing I ran
into a few small issues with the parser and library. This
has these additional fixes / enhancements:
* Lifts the restriction on 32 rules, although the kernel
is limited by this we don't adhere to this limit on our
stream parser or optimizer
* The union code got updated to address two cases that are
invalid for unions
* A few fixes on db2rd and optimizer on using the stream
parser, if its NULL, bail, we weren't checking for it
* The optimizer was not considering band differences as
part of its key broker (when it decides it can use
two rules for optimization), to address this we deduce
the band and add that to the key mixing. Note that this
will need to be updated upon new frequency band additions.
This limits the scope of optimizations between their own
respective bands.
I've also gone ahead and tested this with a huge fluffy
non optimized regulatory domain of 40 rules, and also with
the wireless-regdb db.txt. I'll send some optimizations
based on this for wireless-regdb.
The only patches that go modified are the stream parser
and the optimizer.
Luis R. Rodriguez (6):
crda: relicense under copyleft-next-0.3.0
crda: fix -pedantic gcc compilation
crda: add regulatory domain stream parser
crda: add regulatory domain optimizer
crda: make ssl keys include stdint.h
crda: make reglib a shared library
LICENSE | 14 +-
Makefile | 54 +++-
copyleft-next-0.3.0 | 219 ++++++++++++++
crda.c | 4 +-
db2rd.c | 32 ++
optimize.c | 40 +++
reglib.c | 839 ++++++++++++++++++++++++++++++++++++++++++++++++++++
reglib.h | 60 ++++
utils/key2pub.py | 2 +
9 files changed, 1252 insertions(+), 12 deletions(-)
create mode 100644 copyleft-next-0.3.0
create mode 100644 db2rd.c
create mode 100644 optimize.c
--
1.8.4.rc3
^ permalink raw reply
* Re: I always need a miracle to connect with iwlwifi
From: Oleksij Rempel @ 2013-10-28 16:28 UTC (permalink / raw)
To: Felipe Contreras; +Cc: linux-wireless Mailing List, ilw, hostap@lists.shmoo.com
In-Reply-To: <CAMP44s05-NRskvWHNqzVxTRiB_2DeRsPwQGAZZ3saM-VC=ZyQA@mail.gmail.com>
Am 28.10.2013 16:44, schrieb Felipe Contreras:
> On Mon, Oct 28, 2013 at 3:52 AM, Oleksij Rempel <linux@rempel-privat.de> wrote:
>> Am 28.10.2013 10:38, schrieb Felipe Contreras:
>>> On Mon, Oct 28, 2013 at 2:31 AM, Oleksij Rempel <linux@rempel-privat.de> wrote:
>
>>>> Heh... this logs look like miracle :)
>>>> My first assumption would be buggy router. There is no answer in
>>>> wpa_supplicant log.
>>>
>>> Yeah, I bet the router is buggy, which router isn't? But why Windows 7
>>> connects fine?
>>
>> May be it includes some workaround?
>
>> You do not need to fight with devs, i think they are agree that some
>> thing is wrong. But believe me, there are so many access points, which
>> make problems or wear things. If you have a bug, does not mean other
>> user have it.
>
> I understand the problems of making wireless drivers work on different
> kinds of access points, and I'm not fighting with devs, I'm just
> saying that if it works in all other devices the problem is most
> likely on this one.
>
> And BTW, the devices we are talking about are very varied: Wii U,
> Windows 7, Windows 8.1, Nokia N9, Android phone, iPhone, iMac, Amazon
> Kindle. Yet the only device that seems to have a problem is my Linux
> machine, I think it's pretty clear where the problem is.
Do any of listed devices use mac80211? If not, you still have fallowing
options: wpa_supplicant, mac80211, iwlwifi driver, iwlwifi firmware. In
you arguments you even didn't tried to eliminate any of them. So, no. It
is not clear where problem is.
> And sure, it does not necessarily means that other people have the
> same problem, but it is very unlikely that I'm the only one.
what is your hardware? Did you tired to disable power save mode?
I have "Intel Centrino Advanced-N 6235", it use same driver and works
with three of my APs. I say just to show, that list of working hardware
is not helpful.
what is you AP? Mode it is running? Do changing settings of this AP
makes some difference? -- No, changing settings of you AP is not the way
to get you off.
>> Beside, how many clients use this AP?
>
> Probably around a dozen.
>
>> How big is the distance?
>
> Probably around 10m.
>
>> What do you configure in AdHock mode?
>
> Nothing, I don't think it even works, but it associates. I just add mode=1.
>
> network={
> ssid="AXTEL-XXX"
> proto=WPA2
> scan_ssid=1
> key_mgmt=WPA-PSK
> psk="XXX"
> mode=1
> }
>
>>>> Take wireshark and capture working and not working associational request.
>>>
>>> I'll try that. If only it was that easy to get a working association.
>>
>> Compare it with windows.
>
> Right, I forgot I can use wireshark in Windows.
>
>> and please read this, it will help to provide more information.
>> http://wireless.kernel.org/en/users/Documentation/Reporting_bugs
>
> I don't understand what exactly do you need from that list. I'm using
> 3.11.6, but as I said in the original report, the kernel version makes
> no difference, even as far back as 3.6.0. I've put the dmesg log in
> the original mail and there's nothing of value there. I could try
> running with CONFIG_MAC80211_*_DEBUG stuff enabled, but do you really
> think that will help?
>
> If you really must know, this is exactly what I'm running:
>
> config=$(mktemp)
> pid="/run/wpa_supplicant_wlan0.pid"
>
> cat > $config <<-EOF
> country=MX
> ap_scan=1
> eapol_version=2
> device_name=Nysa
> device_type=1-0050F204-1
>
> network={
> ssid="AXTEL-7111"
> proto=WPA2
> scan_ssid=1
> key_mgmt=WPA-PSK
> psk="C3657111"
> mode=0
> }
> EOF
>
> wpa_supplicant -B -t -d -P $pid -i wlan0 -D nl80211,wext -c $config -f
> /tmp/wpa.log
>
> rm -f "$config"
>
> I tried with wext, but that doesn't work at all. A curious fact is
> that I need to enable CONFIG_CFG80211_WEXT=y for AP scanning to work,
> even though I'm not using the wext driver.
>
> I will try to get the wireshark logs.
>
--
Regards,
Oleksij
^ permalink raw reply
* Re: [PATCH 16/16] wl1251: Add sysfs file address for setting permanent mac address
From: Pali Rohár @ 2013-10-28 16:21 UTC (permalink / raw)
To: Dan Williams
Cc: Johannes Berg, Luciano Coelho, John W. Linville, David S. Miller,
linux-wireless, netdev, linux-kernel, freemangordon,
aaro.koskinen, pavel, sre, joni.lapilainen
In-Reply-To: <1382974161.1542.18.camel@dcbw.foobar.com>
[-- Attachment #1: Type: Text/Plain, Size: 1983 bytes --]
On Monday 28 October 2013 16:29:21 Dan Williams wrote:
> On Mon, 2013-10-28 at 16:04 +0100, Pali Rohár wrote:
> > On Monday 28 October 2013 15:56:55 Johannes Berg wrote:
> > > On Mon, 2013-10-28 at 09:46 -0500, Dan Williams wrote:
> > > > If the device doesn't actually *have* a permanent MAC
> > > > address, then it shouldn't be returning one via ethtool,
> > > > and should return an error for ETHTOOL_GPERMADDR.
> > >
> > > There's currently no provision for that, but I agree it
> > > would be better to do so.
> > >
> > > johannes
> >
> > So what to do with devices which has MAC address stored in
> > some obscure place and there is userspace binary which can
> > read it?
> >
> > I think that there should be some way to tell kernel that
> > *this* is the permanent address and it should use it.
> >
> > This is reason why I proposed patch which adding sysfs entry
> > for setting permanent address from userspace in wl1251
> > driver.
>
> Ok, so the N900's MAC is stored in the "cal partition", which
> is a region of flash exposed to the OS as /dev/mtd1. That
> also stores the regulatory domain. Typically userspace
> binaries are used to pull out this and other data (see
> https://dev.openwrt.org/browser/packages/utils/calvaria/files/
> src/calvaria.c ) which is then used to initialize the device.
>
> Any idea what kernel driver is used to expose the CAL
> partition as /dev/mtd1? If it's nothing special maybe a
> small EEPROM-style driver could be written to read the
> relevant areas (and since they don't ever change, don't need
> to worry about something else writing at the same time).
>
> Dan
/dev/mtd1 is second (0 is first) OneNand partition. Nothing
special. Kernel driver for OnaNand is already in mainline kernel.
That partition also has NVS device data for wl1251 chip.
And you are right calvaria has GPL v2 code for parsing data in
that partition.
--
Pali Rohár
pali.rohar@gmail.com
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply
* Re: I always need a miracle to connect with iwlwifi
From: Felipe Contreras @ 2013-10-28 15:54 UTC (permalink / raw)
To: Krishna Chaitanya
Cc: Oleksij Rempel, linux-wireless Mailing List, ilw,
hostap@lists.shmoo.com
In-Reply-To: <CABPxzYLUG-X=p5z4fJusH63EvtuOy=EKfeQPScHDwGDpAJoFYg@mail.gmail.com>
On Mon, Oct 28, 2013 at 5:00 AM, Krishna Chaitanya
<chaitanya.mgit@gmail.com> wrote:
> On Mon, Oct 28, 2013 at 3:07 PM, Felipe Contreras
> <felipe.contreras@gmail.com> wrote:
>> Then why am I able to connect from my phone, other machines, and in
>> this machine with Windows 7?
>>
> So lets say "max clients=5" and first all of your devices except the
> linux connec
> to the AP, then they have no issues connecting. Now if the linux is
> the 6th device
> then it might have trouble connecting to the AP?? Its possible.
Yeah, but if max-clients = 5, and clients = 5, nothing would change
when I reboot to Windows and it works. Also, if it's working on Linux,
I reboot my machine, and then I cannot connect again. Plus, I
disconnect my phone, I try to connect in Linux, it keeps failing, I
connect my phone, and my phone works.
I don't think this theory matches the evidence at all.
--
Felipe Contreras
^ permalink raw reply
* Re: I always need a miracle to connect with iwlwifi
From: Felipe Contreras @ 2013-10-28 15:44 UTC (permalink / raw)
To: Oleksij Rempel; +Cc: linux-wireless Mailing List, ilw, hostap@lists.shmoo.com
In-Reply-To: <526E33C3.60302@rempel-privat.de>
On Mon, Oct 28, 2013 at 3:52 AM, Oleksij Rempel <linux@rempel-privat.de> wrote:
> Am 28.10.2013 10:38, schrieb Felipe Contreras:
>> On Mon, Oct 28, 2013 at 2:31 AM, Oleksij Rempel <linux@rempel-privat.de> wrote:
>>> Heh... this logs look like miracle :)
>>> My first assumption would be buggy router. There is no answer in
>>> wpa_supplicant log.
>>
>> Yeah, I bet the router is buggy, which router isn't? But why Windows 7
>> connects fine?
>
> May be it includes some workaround?
> You do not need to fight with devs, i think they are agree that some
> thing is wrong. But believe me, there are so many access points, which
> make problems or wear things. If you have a bug, does not mean other
> user have it.
I understand the problems of making wireless drivers work on different
kinds of access points, and I'm not fighting with devs, I'm just
saying that if it works in all other devices the problem is most
likely on this one.
And BTW, the devices we are talking about are very varied: Wii U,
Windows 7, Windows 8.1, Nokia N9, Android phone, iPhone, iMac, Amazon
Kindle. Yet the only device that seems to have a problem is my Linux
machine, I think it's pretty clear where the problem is.
And sure, it does not necessarily means that other people have the
same problem, but it is very unlikely that I'm the only one.
> Beside, how many clients use this AP?
Probably around a dozen.
> How big is the distance?
Probably around 10m.
> What do you configure in AdHock mode?
Nothing, I don't think it even works, but it associates. I just add mode=1.
network={
ssid="AXTEL-XXX"
proto=WPA2
scan_ssid=1
key_mgmt=WPA-PSK
psk="XXX"
mode=1
}
>>> Take wireshark and capture working and not working associational request.
>>
>> I'll try that. If only it was that easy to get a working association.
>
> Compare it with windows.
Right, I forgot I can use wireshark in Windows.
> and please read this, it will help to provide more information.
> http://wireless.kernel.org/en/users/Documentation/Reporting_bugs
I don't understand what exactly do you need from that list. I'm using
3.11.6, but as I said in the original report, the kernel version makes
no difference, even as far back as 3.6.0. I've put the dmesg log in
the original mail and there's nothing of value there. I could try
running with CONFIG_MAC80211_*_DEBUG stuff enabled, but do you really
think that will help?
If you really must know, this is exactly what I'm running:
config=$(mktemp)
pid="/run/wpa_supplicant_wlan0.pid"
cat > $config <<-EOF
country=MX
ap_scan=1
eapol_version=2
device_name=Nysa
device_type=1-0050F204-1
network={
ssid="AXTEL-7111"
proto=WPA2
scan_ssid=1
key_mgmt=WPA-PSK
psk="C3657111"
mode=0
}
EOF
wpa_supplicant -B -t -d -P $pid -i wlan0 -D nl80211,wext -c $config -f
/tmp/wpa.log
rm -f "$config"
I tried with wext, but that doesn't work at all. A curious fact is
that I need to enable CONFIG_CFG80211_WEXT=y for AP scanning to work,
even though I'm not using the wext driver.
I will try to get the wireshark logs.
--
Felipe Contreras
^ permalink raw reply
* Re: [PATCH 16/16] wl1251: Add sysfs file address for setting permanent mac address
From: Stephen Hemminger @ 2013-10-28 15:33 UTC (permalink / raw)
To: Johannes Berg
Cc: Dan Williams, Pali Rohár, Luciano Coelho, John W. Linville,
David S. Miller, linux-wireless, netdev, linux-kernel,
freemangordon, aaro.koskinen, pavel, sre, joni.lapilainen
In-Reply-To: <1382972215.17956.30.camel@jlt4.sipsolutions.net>
On Mon, 28 Oct 2013 15:56:55 +0100
Johannes Berg <johannes@sipsolutions.net> wrote:
> On Mon, 2013-10-28 at 09:46 -0500, Dan Williams wrote:
>
> > If the device doesn't actually *have* a permanent MAC address, then it
> > shouldn't be returning one via ethtool, and should return an error for
> > ETHTOOL_GPERMADDR.
>
> There's currently no provision for that, but I agree it would be better
> to do so.
>
> johannes
>
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
The current netdevice API handle the case of a device without a permanent
MAC address, slightly differently.
If device does not have a permanent address,
then:
1. dev->addr_assign_type should not be NET_ADDR_PERM
2. when device is registered dev->perm_addr will not be set
and retain all zeros value
4. when ethtool gets address it will return all zeros which
is not a valid address.
This case doesn't seem to be handled threo mac80211 API's
^ permalink raw reply
* Re: [PATCH 16/16] wl1251: Add sysfs file address for setting permanent mac address
From: Dan Williams @ 2013-10-28 15:29 UTC (permalink / raw)
To: Pali Rohár
Cc: Johannes Berg, Luciano Coelho, John W. Linville, David S. Miller,
linux-wireless, netdev, linux-kernel, freemangordon,
aaro.koskinen, pavel, sre, joni.lapilainen
In-Reply-To: <201310281604.48542@pali>
On Mon, 2013-10-28 at 16:04 +0100, Pali Rohár wrote:
> On Monday 28 October 2013 15:56:55 Johannes Berg wrote:
> > On Mon, 2013-10-28 at 09:46 -0500, Dan Williams wrote:
> > > If the device doesn't actually *have* a permanent MAC
> > > address, then it shouldn't be returning one via ethtool,
> > > and should return an error for ETHTOOL_GPERMADDR.
> >
> > There's currently no provision for that, but I agree it would
> > be better to do so.
> >
> > johannes
>
> So what to do with devices which has MAC address stored in some
> obscure place and there is userspace binary which can read it?
>
> I think that there should be some way to tell kernel that *this*
> is the permanent address and it should use it.
>
> This is reason why I proposed patch which adding sysfs entry for
> setting permanent address from userspace in wl1251 driver.
Ok, so the N900's MAC is stored in the "cal partition", which is a
region of flash exposed to the OS as /dev/mtd1. That also stores the
regulatory domain. Typically userspace binaries are used to pull out
this and other data (see
https://dev.openwrt.org/browser/packages/utils/calvaria/files/src/calvaria.c ) which is then used to initialize the device.
Any idea what kernel driver is used to expose the CAL partition
as /dev/mtd1? If it's nothing special maybe a small EEPROM-style driver
could be written to read the relevant areas (and since they don't ever
change, don't need to worry about something else writing at the same
time).
Dan
^ permalink raw reply
* Re: [PATCH 16/16] wl1251: Add sysfs file address for setting permanent mac address
From: Pali Rohár @ 2013-10-28 15:04 UTC (permalink / raw)
To: Johannes Berg
Cc: Dan Williams, Luciano Coelho, John W. Linville, David S. Miller,
linux-wireless, netdev, linux-kernel, freemangordon,
aaro.koskinen, pavel, sre, joni.lapilainen
In-Reply-To: <1382972215.17956.30.camel@jlt4.sipsolutions.net>
[-- Attachment #1: Type: Text/Plain, Size: 819 bytes --]
On Monday 28 October 2013 15:56:55 Johannes Berg wrote:
> On Mon, 2013-10-28 at 09:46 -0500, Dan Williams wrote:
> > If the device doesn't actually *have* a permanent MAC
> > address, then it shouldn't be returning one via ethtool,
> > and should return an error for ETHTOOL_GPERMADDR.
>
> There's currently no provision for that, but I agree it would
> be better to do so.
>
> johannes
So what to do with devices which has MAC address stored in some
obscure place and there is userspace binary which can read it?
I think that there should be some way to tell kernel that *this*
is the permanent address and it should use it.
This is reason why I proposed patch which adding sysfs entry for
setting permanent address from userspace in wl1251 driver.
--
Pali Rohár
pali.rohar@gmail.com
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply
* Re: [PATCH] nl80211: introduce NL80211_SCAN_FLAG_DISCOVERY_MODE
From: Johannes Berg @ 2013-10-28 15:00 UTC (permalink / raw)
To: Vladimir Kondratiev
Cc: linux-wireless, Luis R . Rodriguez, John W . Linville,
Jouni Malinen
In-Reply-To: <1382971021.17956.25.camel@jlt4.sipsolutions.net>
Ok, so you can't even get your own email address right - I'll ignore you
for a few weeks until you maybe get it right.
johannes
^ permalink raw reply
* Re: [PATCH 16/16] wl1251: Add sysfs file address for setting permanent mac address
From: Johannes Berg @ 2013-10-28 14:56 UTC (permalink / raw)
To: Dan Williams
Cc: Pali Rohár, Luciano Coelho, John W. Linville,
David S. Miller, linux-wireless, netdev, linux-kernel,
freemangordon, aaro.koskinen, pavel, sre, joni.lapilainen
In-Reply-To: <1382971562.1542.6.camel@dcbw.foobar.com>
On Mon, 2013-10-28 at 09:46 -0500, Dan Williams wrote:
> If the device doesn't actually *have* a permanent MAC address, then it
> shouldn't be returning one via ethtool, and should return an error for
> ETHTOOL_GPERMADDR.
There's currently no provision for that, but I agree it would be better
to do so.
johannes
^ permalink raw reply
* Re: [PATCH 01/14] cfg80211: consolidate passive-scan and no-ibss flags
From: Luis R. Rodriguez @ 2013-10-28 14:49 UTC (permalink / raw)
To: Johannes Berg
Cc: John W. Linville, linux-wireless, Janusz Dziedzic, smihir,
tushnimb
In-Reply-To: <1382971344.17956.27.camel@jlt4.sipsolutions.net>
On Mon, Oct 28, 2013 at 3:42 PM, Johannes Berg
<johannes@sipsolutions.net> wrote:
> I don't think you can make this change, it breaks API and ABI because
> the old IBSS flag is now ignored on input from old CRDA?
I addressed that by mapping it to NO-IR in-kernel, if it was used. In
other words if userspace sends it we'll respect it in the same way.
Luis
^ permalink raw reply
* Re: [PATCH 16/16] wl1251: Add sysfs file address for setting permanent mac address
From: Dan Williams @ 2013-10-28 14:46 UTC (permalink / raw)
To: Pali Rohár
Cc: Johannes Berg, Luciano Coelho, John W. Linville, David S. Miller,
linux-wireless, netdev, linux-kernel, freemangordon,
aaro.koskinen, pavel, sre, joni.lapilainen
In-Reply-To: <201310281500.24159@pali>
On Mon, 2013-10-28 at 15:00 +0100, Pali Rohár wrote:
> On Monday 28 October 2013 14:55:22 Johannes Berg wrote:
> > On Mon, 2013-10-28 at 14:49 +0100, Pali Rohár wrote:
> > > On Monday 28 October 2013 14:45:05 Johannes Berg wrote:
> > > > On Sat, 2013-10-26 at 22:34 +0200, Pali Rohár wrote:
> > > > > Driver wl1251 generating mac address randomly at startup
> > > > > and there is no way to set permanent mac address via
> > > > > SET_IEEE80211_PERM_ADDR. This patch export sysfs file
> > > > > which can set permanent mac address by userspace helper
> > > > > program. Patch is needed for devices which do not store
> > > > > mac address in internal wl1251 eeprom.
> > > >
> > > > This doesn't really seem like a good idea since you can
> > > > also just use 'ip' or whatever to set the MAC address.
> > > >
> > > > johannes
> > >
> > > AFAIK you cannot set permanent address (show by ethtool -P
> > > wlan0) via ip/ifconfig.
> >
> > You probably can't, but that address also doesn't matter at
> > all and isn't really used anywhere.
> >
> > johannes
>
> There are some (proprietary) applications which using permanent
> address for something...
>
> And also more important: some network managing tools using it.
> NetworkManager resetting current MAC address to permanent one
> before starting configuring interface.
>
> So this will lead to never use correct MAC address (but random
> permanent one) assigned for that wl1251 wireless card...
If the device doesn't actually *have* a permanent MAC address, then it
shouldn't be returning one via ethtool, and should return an error for
ETHTOOL_GPERMADDR. Setting the permanent MAC address shouldn't ever be
allowed except by the driver inspecting EEPROM, and certainly not via
sysfs.
mac80211 does have to do some special stuff due to virtual interfaces
and such, but in general, if the MAC address is randomly generated,
neither the driver nor mac80211 should be reporting that address as the
permanent address, only as the current one.
Dan
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox