Re: [OpenWrt-Devel] Force 3G/GRPS with Huawei dongle

2010-05-06 Thread Bastian Bittorf
* yann lopez  [06.05.2010 11:20]:

> Let me know, if you'd like to commit it.

+   elif echo "$cardinfo" | grep huawei; then

please use 'echo xy | grep -q huawei'

or better define
 
is_huawei ()
{
local CARDINFO="$1"

case "$CARDINFO" in
 *huawei*) return 0 ;;
*) return 1 ;;
esac
}
 
and
   
elif is_huawei; then
...



bye, Bastian



signature.asc
Description: Digital signature
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] Force 3G/GRPS with Huawei dongle

2010-05-06 Thread Bastian Bittorf
* Mark Deneen  [06.05.2010 17:30]:

> Somewhat related -- Sierra Wireless cards typically speak a proprietary
> protocol on one of the USB serial ports.  I have enough of the protocol
> implemented to read RSSI values on UMTS and CDMA cards.
> 
> Is this something that OpenWrt is looking to include -- data card signal
> strengths?

it would be very nice to include that in an (from user-perspective)
hardware independant way. please post a link to your scripts and
i will think about an interface.

nbd: ATM there is no easy way to get a signal strength from
a any/madwifi/mac80211-wifi, something like:

wifi_rssi ()
{
local DEV="$WIFIDEV"
local NEIGHBOUR_MAC="$1"

some_driver_specific_magic()

echo "$RSSI"# maybe: return $POSITIVE_INTEGER
}

or? this is also needed for GSM/UMTS-related stuff.
how to begin?

bye, Bastian


signature.asc
Description: Digital signature
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] Force 3G/GRPS with Huawei dongle

2010-05-07 Thread Bastian Bittorf
* Mark Deneen  [06.05.2010 22:20]:

[...]

> strength, the PPP connection is dropped.  I solve this by having the
> process run all of the time, and handling the error state of the file
> closing on me. I am running a SVN version somewhere between 7.09 and
> 8.09 -- maybe the serial port issue has been resolved in backfire.

it's time to upgrade and check 8-)

> Also, a "good" RSSI value appears to be different depend on the cellular
> network.

just for clarification: IMHO it should only be possible to
measure the RSSI for a connected cell, not all possible cells - or?

bye, Bastian


signature.asc
Description: Digital signature
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] ar71xx, ath9k, low bandwidth in ad-hoc mode / mac80211 with HT-Rates (802.11n)

2010-07-27 Thread Bastian Bittorf

> > Is there a way to increase the bandwidth up to 300 Mbps?
> mac80211 does not support using HT rates in ad-hoc yet - that's
> still
> being worked on.

Somebody interested to work on this for some money/donation?

bye, Bastian Bittorf

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] mac80211 / ath9k / multicast-rate / ibss / adhoc / mesh

2010-09-13 Thread Bastian Bittorf
At the moment it is IMHO not possible to enforce
a multicast-rateset or even a simple fixed multicast-rate
with mac80211. So it is nearly impossible to build
a working mesh-network (olsr/batman) with mac80211 based
wifi-drivers. (because all protocols use packetloss
as index for link-cost/etx, but it has to be measured
the same way in the hole network, not with changing
rates...)

http://www.spinics.net/lists/linux-wireless/msg49049.html

When can we expect some work on "mrate" for mac80211?
Should i open a bounty somewhere?

bye, Bastian / weimarnetz.de
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] mac80211 / ath9k / multicast-rate / ibss / adhoc / mesh

2010-09-13 Thread Bastian Bittorf
At the moment it is IMHO not possible to enforce
a multicast-rateset or even a simple fixed multicast-rate
with mac80211. So it is nearly impossible to build
a working mesh-network (olsr/batman) with mac80211 based
wifi-drivers. (because all protocols use packetloss
as index for link-cost/etx, but it has to be measured
the same way in the hole network, not with changing
rates...)

http://www.spinics.net/lists/linux-wireless/msg49049.html

When can we expect some work on "mrate" for mac80211?
Should i open a bounty somewhere?

bye, Bastian / weimarnetz.de
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] mac80211 / openwrt - some complaints

2010-09-13 Thread Bastian Bittorf
after working some days with mac80211/atk9k-based devices,
i have several complaints about:


1) there is no way to set/get beacon rate

2) there is no way to set/get the multicastrate.
iw dev wlanX station dump outputs tx-rate,
but is tx=rate=mrate?

3) there is no way to get/set the txpower

4) there is no way to use HT40/802.11n-Rates with IBSS

some things i will work on:

5) there is no way to manipulate crond using UCI

6) there is no way to start/stop/restart sylogd

7) there is no way to start/stop/restart rdate

8) the /etc/config/dhcp is ugly! and too much dnsmasq-specific.

9) there is still "ifconfig" in the image! (we write the year 2010)


On the other side:
openwrt is incredibly straight forward in most things.
most other distros are lightyears behind... 8-)

bye, Bastian.
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] mac80211 / openwrt - some complaints

2010-09-13 Thread Bastian Bittorf
Zitat von Jo-Philipp Wich :

> > 3) there is no way to get/set the txpower
> 
> iwconfig txpower should still work.

on TP-Link_TL-WR1043ND it does not work:

r...@wifibox:~# iwlist wlan0 txpower
wlan0 unknown transmit-power information.

> > 4) there is no way to use HT40/802.11n-Rates with IBSS
> 
> Not implemented in mac80211.

Is anybody working on this?

> > 5) there is no way to manipulate crond using UCI
> 
> Should be trivial to implement.

i will send a patch...("ehrenwort!")

> > 6) there is no way to start/stop/restart sylogd
> 
> /etc/init.d/boot, could probably be moved to an extra init script.

yes, will send a patch

> > 7) there is no way to start/stop/restart rdate
> 
> "ifup wan". Its a hotplug driven mechanism, doing it as init script

yes, i read the script: but in a mesh-network, we have
no wan 8-), so how to call the script in a clear way?
(e.g. from cron)

> > 8) the /etc/config/dhcp is ugly! and too much dnsmasq-specific.
> 
> That one should remain backwards compatible at least for dhcp
> pools.

We are in trunk, not in redmond.

> > 9) there is still "ifconfig" in the image! (we write the year
> 2010)
> 
> The beloved "ip" is fat (300k) and not really needed for basic
> tasks,
> I'm strongly against making it a core dependency.

This was still discussed and a clear win for "ip"
(smaller binary of "ip" than ifconfig/route/arp and more
functions)
https://lists.openwrt.org/pipermail/openwrt-devel/2009-June/004481.html

bye, Bastian.
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] mac80211 / openwrt - some complaints / rdate

2010-09-13 Thread Bastian Bittorf
> see https://forum.openwrt.org/viewtopic.php?id=24719

/etc/init.d/rdate restart

would be much better, so i propose such a wrapper.
(which is not "enabled" by default)

bye, Bastian
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] mac80211 / openwrt - some complaints / txpower

2010-09-13 Thread Bastian Bittorf
> > on TP-Link_TL-WR1043ND it does not work:
> > 
> > r...@wifibox:~# iwlist wlan0 txpower
> > wlan0 unknown transmit-power information.

> Try just setting txpower via iwconfig. iwconfig  should
> also
> show the currently set txpower value.

this works, but it shows 27 dBm (500mW) ?
I propose an driver specific function within /lib/wifi/...

get_txpower() 
{
local networkname="$1"# e.g. wlan
# some magic for getting the right phy
}

bye, Bastian.

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] Dropbear init script fix for trunk/backfire

2010-09-14 Thread Bastian Bittorf
> Right now I would just change all UCI options for Dropbear to
> lowercase
> to make it consistent with all other packages, but Luci and X-Wrt

I'am fine with that, it's never to late to correct that mistake.
Seems, that it is time for an "uci styleguide"

bye, Bastian

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH] Package dnsmasq init-file

2010-10-27 Thread Bastian Bittorf
If an already running DHCP-server is found on
the configured interface, the init-script refuses
to start, but does not give a hint why. It took us
some days to track down this behavior in our MANET,
where every wifi/adhoc-node runs it own DHCP-server.
Now syslog is more verbose on this.

Signed-off-by: Bastian Bittorf 

Index: package/dnsmasq/files/dnsmasq.init
===
--- package/dnsmasq/files/dnsmasq.init	(Revision 23650)
+++ package/dnsmasq/files/dnsmasq.init	(Arbeitskopie)
@@ -283,7 +283,12 @@
 	#check for an already active dhcp server on the interface, unless 'force' is set
 	config_get_bool force "$cfg" force 0
 	[ $force -gt 0 ] || {
-		udhcpc -n -q -s /bin/true -t 1 -i $ifname >&- && return 0
+		udhcpc -n -q -s /bin/true -t 1 -i $ifname >&- && {
+			logger -t dnsmasq \
+"found already running DHCP-server on interface '$ifname'" \
+"refusing to start, use 'option force 1' to override"
+			return 0
+		}
 	}
 
 	config_get start "$cfg" start
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] mac80211 / uci / beacon-interval

2010-10-27 Thread Bastian Bittorf
I want to deliver a patch for uci-style configuration
for this: http://www.spinics.net/lists/linux-wireless/msg57794.html

what do you think is the best way?
(from users perspective)

option beaconinterval   1000
option bintval  1000
option bi   1000

bye, Bastian

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH] Package dnsmasq init-file

2010-11-19 Thread Bastian Bittorf
Bump!

Anyone likes to add this patch? bye, Bastian
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] ath9k / mac80211 / mcast_rate / b0rken

2010-11-19 Thread Bastian Bittorf
just to mention this, fixed mcast_rate is broken, it simply does nothing so

iw dev 'wlan0' ibss join MYWIFI 2412 fixed-freq 02:ca:ff:ee:ba:be mcast-rate 6

works, but mcast-rate is "auto" again...

bye, Bastian
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] mac80211 / ath9k / ibss / adhoc / probe-responses

2010-11-19 Thread Bastian Bittorf
in ibss/adhoc mode, i can see sometimes a lot of 
probe-responses (storms), which is not needed. is there
a way to omit this? with the oldsk00l whiterussian
firmware/hacked wl-driver, there was a ff_noprobe=1
fix to get this... 8-)

bye, Bastian
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] uhttpd / cgi VS images / proposal for changing

2011-01-09 Thread Bastian Bittorf
I can't establish the same behavior like busybox-httpd,
i want:

/www/cgi-bin-splash
/www/images/some_art.png
/www/cgi-bin/admin_page (=cgi-script)

The password protected space is possible via
/etc/httpd.conf , but how to get images + cgi?

if i choose

option cgi_prefix '/'

then the images are "cgi-scripts" and we get

"HTTP/1.0 403 Forbidden" via "text/plain"

bye, Bastian.

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] uhttpd / cgi VS images / proposal for changing

2011-01-09 Thread Bastian Bittorf
forgot the proposal:

what about making a switch for this:

option prefix_noncgi '/images"

to have normal output of /www/images/mypicture.png


bye, Bastian
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] uhttpd / cgi / redirect

2011-01-09 Thread Bastian Bittorf
i encountered a strange behavior in contrast
to busybox-httpd. for our splash we have a
custom-shell-script, which does the magic,
but with uhttpd, it does not work:

bast...@box:~$ wget -SO - "http://busybox.lan/cgi-bin-redirect";

--2011-01-09 17:35:20--  http://192.168.100.23/
Connecting to 192.168.100.23:80... connected.
HTTP request sent, awaiting response... 
  HTTP/1.1 302 Temporary Redirect
  Connection: close
  Cache-Control: no-cache
  Content-Type: text/html
  Location: http://192.168.100.23/cgi-bin-welcome?REDIRECTED=1
Location: http://192.168.100.23/cgi-bin-welcome?REDIRECTED=1 [following]


here the same while fetching the uhttpd-host:


bast...@box:~$ wget -SO - "http://uhttpd.lan/cgi-bin-redirect";

--2011-01-09 17:42:31--  http://192.168.100.26/
Connecting to 192.168.100.26:80... connected.
HTTP request sent, awaiting response... 
  HTTP/1.0 200 OK
  Connection: close
  Content-Type: text/plain
Length: unspecified [text/plain]
Saving to: `STDOUT'


[...here comes html-code with a redirection
note, which cannot be rendered, because
it's delivered as plaintext ...]


the output in shell is on both boxes the same:

r...@openwrt: _http redirect 302 http://1.1.1.1
HTTP/1.1 302 Temporary Redirect
Connection: close
Cache-Control: no-cache
Content-Type: text/html
Location: http://1.1.1.1


302 Temporary Redirect



http://1.1.1.1";>

302 - Temporary Redirect
click http://1.1.1.1";>here if you are not redirected
automatically.


Any ideas how to fix that?
How to enforce the MIME-Type of specific files?

bye, Bastian.

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] uhttpd / cgi / redirect

2011-01-09 Thread Bastian Bittorf
> So your script has to output:
> 
>   Status: 302 Temporary Redirect\r\n

Thank you SO much, 10 minutes later &&
a had given up 8-)) It works...

bye, Bastian
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] uhttpd / cgi VS images / proposal for changing

2011-01-09 Thread Bastian Bittorf
>   list interpreter 'cgi-bin-splash=/bin/ash'

Nice idea, but does not work, when starting in cli:

Error: Invalid interpreter: cgi-bin-welcome=/bin/ash

bye, Bastian
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] automated testing brainstorming

2011-01-09 Thread Bastian Bittorf
> > but I've recently came across a usb2-to-four-times-serial for 39
> euros [1]

Good idea. @work we have enough space/power to make
this. So i will setup:

1 x Computer
4 x Router
(Linksys WRT54GL, TP-Link 1043ND, DIR-300,  RouterStation Pro)
4 x Serial soldered to routers
1 x Internet
1 x Ethernet-Power-Socket (4x)

If we are ready, i will give out SSH access to someone
who has time to script some scripts - ok?

bye, Bastian

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] packages/ makefile / unison / bounty

2011-01-14 Thread Bastian Bittorf
i want to have unison[1] on my openwrt-boards.
has someone time to make the makefile, so it
cleanly appears in menuconfig?

The dependencies are IMHO ocaml[2,3], is it?

my bet is 50 euro, maybe other people are also
willing to give some money.

bye, Bastian

[1] http://www.cis.upenn.edu/~bcpierce/unison/
[2] http://caml.inria.fr/ocaml/
[3] http://brion.inria.fr/gallium/index.php/CrossCompiler

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] wireless / ibss / mac80211 / beaconinterval = bintval = bi

2011-01-14 Thread Bastian Bittorf
this patch[1] seems trivial, but it is not in wireless-testing
yet - anybody knows why? (it seems to me, that mac80211 can
handle beacon-interval, but the iw commandline does not
handle it yet)

bye, Bastian

[1] http://permalink.gmane.org/gmane.linux.kernel.wireless.general/57957
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] packages / makefile / unison / bounty

2011-01-15 Thread Bastian Bittorf
> has someone time to make the makefile, so it

some hints are here:
http://comments.gmane.org/gmane.comp.misc.nslu2.devel/1864
http://mybookworld.wikidot.com/forum/t-68436/unison-file-synchronizer
http://mybookworld.wikidot.com/forum/t-256393/gcc-compiler-in-optware

bye, Bastian
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] trashfiles in linux-ar71xx_generic/linux-2.6.32.27/.pc/

2011-01-15 Thread Bastian Bittorf
i'am unsure, but maybe this was an
commit accident: some files in directory

build_dir/linux-ar71xx_generic/linux-2.6.32.27/.pc/

have all permission flags unset, so

fgrep BLA
build_dir/linux-ar71xx_generic/linux-2.6.32.27/.pc/generic/202-mips_mem_functions_performance.patch/arch/mips/lib/memcmp.c

leads to an "permission denied"

bye, Bastian
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH] base-files: refactoring load_modules()

2011-01-15 Thread Bastian Bittorf
I was never satisfied with the ugly hack, how kernel-modules
were loaded in openwrt, but it works since the beginning. here
is a proposal to do it clean and also fast with ash-builtins.
side-effect is a better logging. e.g.:

Jan  1 00:00:25 box daemon.info load_modules(): insmod: can't insert 
'input-core': File exists
Jan  1 00:00:26 box daemon.info load_modules(): insmod: can't insert 
'input-polldev': File exists
Jan  1 00:00:33 box daemon.info load_modules(): [OK] 85 modules, time: 25.16 -> 
33.05

i have done some benchmarks with the old and the new code:
the new code seems to last a litte bit longer, in my case:
7.44 sec <-> 7.50 sec on an ar71xx/400mhz - should be ok IMHO.

Signed-off-by: Bastian Bittorf 

>From 019309c9156a5ed4a756619bc2bcce9a44cf50f2 Mon Sep 17 00:00:00 2001
From: Bastian Bittorf 
Date: Sat, 15 Jan 2011 14:29:34 +0100
Subject: [PATCH 1/2] load_modules() refactoring without sed

---
 package/base-files/files/etc/functions.sh |   27 ++-
 1 files changed, 22 insertions(+), 5 deletions(-)

diff --git a/package/base-files/files/etc/functions.sh b/package/base-files/files/etc/functions.sh
index acea617..2b6b7fc 100755
--- a/package/base-files/files/etc/functions.sh
+++ b/package/base-files/files/etc/functions.sh
@@ -205,11 +205,28 @@ config_list_foreach() {
 	done
 }
 
-load_modules() {
-	[ -d /etc/modules.d ] && {
-		cd /etc/modules.d
-		sed 's/^[^#]/insmod &/' $* | ash 2>&- || :
-	}
+load_modules()
+{
+	local LIST_FILES="/etc/modules.d/*"
+	local FILE LINE DUMMY T1 T2
+	local COUNT=0
+
+	read T1 DUMMY &1 | logger -t "load_modules()" -p daemon.info
+;;
+			esac
+		} done <$FILE
+	} done
+
+	read T2 DUMMY  $T2"
 }
 
 include() {
-- 
1.6.3.3


>From 1ea212bb59864de7dc37966c7fcb0e1dd827913e Mon Sep 17 00:00:00 2001
From: Bastian Bittorf 
Date: Sat, 15 Jan 2011 14:33:46 +0100
Subject: [PATCH 2/2] load_modules() removing unneeded argument to funtion

---
 package/base-files/files/etc/init.d/boot |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/package/base-files/files/etc/init.d/boot b/package/base-files/files/etc/init.d/boot
index 7927af1..eafafa5 100755
--- a/package/base-files/files/etc/init.d/boot
+++ b/package/base-files/files/etc/init.d/boot
@@ -79,7 +79,7 @@ start() {
 		[ -n "$rootdev" ] && ln -s "$rootdev" /dev/root
 	}
 
-	load_modules /etc/modules.d/*
+	load_modules
 }
 
 stop() {
-- 
1.6.3.3

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH] base-files: refactoring calc_tmpfs_size() without awk

2011-01-15 Thread Bastian Bittorf
it is always a good idea not to mixup different languages
in an environment. awk is nice to have but in the long run
should NOT be an essential file, especially this touched
algo targets devices with 8mb RAM or lower 8-)

there are more patches to follow, to bury awk from essential files.

side-effect: the code is better readable.
there was an discussion about that:

http://www.mail-archive.com/openwrt-devel@lists.openwrt.org/msg01217.html

Signed-off-by: Bastian Bittorf 

>From 019309c9156a5ed4a756619bc2bcce9a44cf50f2 Mon Sep 17 00:00:00 2001
From: Bastian Bittorf 
Date: Sat, 15 Jan 2011 14:29:34 +0100
Subject: [PATCH 1/3] load_modules() refactoring without sed

---
 package/base-files/files/etc/functions.sh |   27 ++-
 1 files changed, 22 insertions(+), 5 deletions(-)

diff --git a/package/base-files/files/etc/functions.sh b/package/base-files/files/etc/functions.sh
index acea617..2b6b7fc 100755
--- a/package/base-files/files/etc/functions.sh
+++ b/package/base-files/files/etc/functions.sh
@@ -205,11 +205,28 @@ config_list_foreach() {
 	done
 }
 
-load_modules() {
-	[ -d /etc/modules.d ] && {
-		cd /etc/modules.d
-		sed 's/^[^#]/insmod &/' $* | ash 2>&- || :
-	}
+load_modules()
+{
+	local LIST_FILES="/etc/modules.d/*"
+	local FILE LINE DUMMY T1 T2
+	local COUNT=0
+
+	read T1 DUMMY &1 | logger -t "load_modules()" -p daemon.info
+;;
+			esac
+		} done <$FILE
+	} done
+
+	read T2 DUMMY  $T2"
 }
 
 include() {
-- 
1.6.3.3


>From 1ea212bb59864de7dc37966c7fcb0e1dd827913e Mon Sep 17 00:00:00 2001
From: Bastian Bittorf 
Date: Sat, 15 Jan 2011 14:33:46 +0100
Subject: [PATCH 2/3] load_modules() removing unneeded argument to funtion

---
 package/base-files/files/etc/init.d/boot |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/package/base-files/files/etc/init.d/boot b/package/base-files/files/etc/init.d/boot
index 7927af1..eafafa5 100755
--- a/package/base-files/files/etc/init.d/boot
+++ b/package/base-files/files/etc/init.d/boot
@@ -79,7 +79,7 @@ start() {
 		[ -n "$rootdev" ] && ln -s "$rootdev" /dev/root
 	}
 
-	load_modules /etc/modules.d/*
+	load_modules
 }
 
 stop() {
-- 
1.6.3.3


>From d68ce12485b45ac1e693c49eed8fcc7aedc0c8e0 Mon Sep 17 00:00:00 2001
From: Bastian Bittorf 
Date: Sat, 15 Jan 2011 17:40:21 +0100
Subject: [PATCH 3/3] refactoring calc_tmpfs_size(), using ash-builtins instead of awk

---
 .../base-files/files/lib/preinit/10_essential_fs   |   28 +---
 1 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/package/base-files/files/lib/preinit/10_essential_fs b/package/base-files/files/lib/preinit/10_essential_fs
index ab317dc..d9dffda 100644
--- a/package/base-files/files/lib/preinit/10_essential_fs
+++ b/package/base-files/files/lib/preinit/10_essential_fs
@@ -10,13 +10,33 @@ do_mount_sysfs() {
 mount sysfs /sys -t sysfs
 }
 
-calc_tmpfs_size() {
-pi_size=$(awk '/MemTotal:/ {l=5242880;mt=($2*1024);print((s=mt/2)l)?mt-l:s}' /proc/meminfo)
+calc_tmpfs_size()	# [bytes] - 50% of total mem, but at least 5mb must be untouched
+{
+	local MEM_BORDER="5242880"
+	local LINE MEM_TOTAL MEM_UNTOUCHED SIZE_TMPFS
+
+	while read LINE; do {
+		case "$LINE" in
+			MemTotal:*)
+set $LINE
+MEM_TOTAL="$(( $2 * 1024 ))"
+break
+			;;
+		esac
+	} done ___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH] base-files: refactoring load_modules()

2011-01-15 Thread Bastian Bittorf
> As an outsider, I'd just like to say that I find this new code
> more
> complex for very little benefit.

really? more lines maybe, but straightforward and not hacky.
attached is the algo, without better logging - but
i think the better logging is worth it.

bye, Bastian.
load_modules()
{
local LIST_FILES="/etc/modules.d/*"
local FILE LINE

for FILE in $LIST_FILES; do {
while read LINE; do {
case "$LINE" in
  "#"*|"") ;;
*) insmod $LINE ;;
esac
} done <$FILE
} done
}
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PACKAGE] ulogd / segfault

2011-01-15 Thread Bastian Bittorf
this works:
ulogd --help 

this segfaults:
ulogd -d

root@box:~ lsmod |grep -i ulog
ipt_ULOG3968  0 
x_tables9312 41
ipt_ULOG,xt_HL,xt_hl,xt_MARK,ipt_ECN,xt_CLASSIFY,xt_time,xt_tcpmss,xt_statistic,xt_mark,xt_length,ipt_ecn,xt_DSCP,xt_dscp,xt_string,xt_layer7,xt_quota,xt_pkttype,xt_owner,compat_xtables,ipt_REDIRECT,ipt_NETMAP,ipt_MASQUERADE,iptable_nat,xt_CONNMARK,xt_recent,xt_helper,xt_conntrack,xt_connmark,xt_connbytes,xt_NOTRACK,xt_state,ipt_REJECT,xt_TCPMSS,ipt_LOG,xt_comment,xt_multiport,xt_mac,xt_limit,ip_tables,xt_tcpudp

platform is ar71xx - with selfbuilt trunk

bye, Bastian
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH] base-files: refactoring manual_coldplugging_of_interfaces_during_boot / without awk

2011-01-15 Thread Bastian Bittorf
another one, which can be easily done without using of awk.

Signed-off-by: Bastian Bittorf 

>From d62cbe4451d648a7a5c3e96b12356037a9fe8438 Mon Sep 17 00:00:00 2001
From: Bastian Bittorf 
Date: Sat, 15 Jan 2011 20:22:48 +0100
Subject: [PATCH 1/1] refactoring manual coldplugging of interfaces using ash-builtins insteadt of awk

---
 package/base-files/files/etc/init.d/boot |   13 -
 1 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/package/base-files/files/etc/init.d/boot b/package/base-files/files/etc/init.d/boot
index eafafa5..313db59 100755
--- a/package/base-files/files/etc/init.d/boot
+++ b/package/base-files/files/etc/init.d/boot
@@ -68,8 +68,19 @@ start() {
 			--set-rules-file /etc/hotplug2.rules \
 			--max-children 1 >/dev/null 2>&1 &
 
+	list_network_interfaces()
+	{
+		local LINE
+
+		while read LINE; do {
+			case "$LINE" in
+*:*) echo ${LINE%:*} ;;
+			esac
+		} done ___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH] base-files: refactoring manual_coldplugging_of_interfaces_during_boot / without awk

2011-01-15 Thread Bastian Bittorf
Zitat von Felix Fietkau :

> On 2011-01-15 8:26 PM, Bastian Bittorf wrote:
> > another one, which can be easily done without using of awk.
> Makes it look ugly though - what's the point of this?

It is always a bad idea to mix up different languages
in one environment. Another point is, to bury awk in
base-files. There is no reason for it, these are only
quick hacks from the old days of whiterussian 8-).

IMHO this a lot better and not that ugly, like with
awk. The function_name() says what it does. If
the function disturbs, than we should move it to an
include, but this has nothing to do with this patch.
(maybe a function manual_coldplugging_on_boot() )

we should make an "clean me up"-week this year.

bye, Bastian

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH] base-files: refactoring manual_coldplugging_of_interfaces_during_boot / without awk

2011-01-15 Thread Bastian Bittorf
> The all-caps names should be reserved for global vars 

i'am fine with this, new patches tomorrow.

bye, bastian (lowercase 8-)
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH] base-files: refactoring load_modules(), 2nd try / proper coding style

2011-01-16 Thread Bastian Bittorf
I was never satisfied with the ugly hack, how kernel-modules
were loaded in openwrt, but it works since the beginning. here
is a proposal to do it clean and also fast with ash-builtins.
side-effect is a better logging. e.g.:

Jan  1 00:00:25 box daemon.info load_modules(): insmod: can't insert 
'input-core': File exists
Jan  1 00:00:26 box daemon.info load_modules(): insmod: can't insert 
'input-polldev': File exists
Jan  1 00:00:33 box daemon.info load_modules(): [OK] 85 modules, time: 25.16 -> 
33.05

i have done some benchmarks with the old and the new code:
the new code seems to last a litte bit longer, in my case:
7.44 sec <-> 7.50 sec on an ar71xx/400mhz - should be ok IMHO.

Signed-off-by: Bastian Bittorf 
>From d584b3e50a67b5e63949430ce16128d8bc5a0066 Mon Sep 17 00:00:00 2001
From: Bastian Bittorf 
Date: Sun, 16 Jan 2011 11:17:26 +0100
Subject: [PATCH] load_modules() refactoring without sed

---
 package/base-files/files/etc/functions.sh |   27 ++-
 package/base-files/files/etc/init.d/boot  |2 +-
 2 files changed, 23 insertions(+), 6 deletions(-)

diff --git a/package/base-files/files/etc/functions.sh b/package/base-files/files/etc/functions.sh
index acea617..af2bb12 100755
--- a/package/base-files/files/etc/functions.sh
+++ b/package/base-files/files/etc/functions.sh
@@ -205,11 +205,28 @@ config_list_foreach() {
 	done
 }
 
-load_modules() {
-	[ -d /etc/modules.d ] && {
-		cd /etc/modules.d
-		sed 's/^[^#]/insmod &/' $* | ash 2>&- || :
-	}
+load_modules()
+{
+	local list_files="/etc/modules.d/*"
+	local file line dummy t1 t2
+	local count=0
+
+	read t1 dummy &1 | logger -t "load_modules()" -p daemon.info
+;;
+			esac
+		} done <$file
+	} done
+
+	read t2 dummy  $t2"
 }
 
 include() {
diff --git a/package/base-files/files/etc/init.d/boot b/package/base-files/files/etc/init.d/boot
index 7927af1..eafafa5 100755
--- a/package/base-files/files/etc/init.d/boot
+++ b/package/base-files/files/etc/init.d/boot
@@ -79,7 +79,7 @@ start() {
 		[ -n "$rootdev" ] && ln -s "$rootdev" /dev/root
 	}
 
-	load_modules /etc/modules.d/*
+	load_modules
 }
 
 stop() {
-- 
1.6.3.3

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH] base-files: refactoring manual_coldplugging_during_boot without AWK / 2nd try (coding style)

2011-01-16 Thread Bastian Bittorf
It is always a bad idea to mix up different languages
in one environment. Another point is, to bury awk in
base-files. There is no reason for it, these are only
quick hacks from the old days of whiterussian 8-).

IMHO this a lot better and not that ugly, like with
awk. The function_name() says what it does. If
the function disturbs, than we should move it to an
include, but this has nothing to do with this patch.
(maybe a function manual_coldplugging_on_boot() )

Signed-off-by: Bastian Bittorf 

>From 848263afbe42087b2c51387688816be5590f090b Mon Sep 17 00:00:00 2001
From: Bastian Bittorf 
Date: Sun, 16 Jan 2011 11:39:09 +0100
Subject: [PATCH] refactoring manual_coldplugging_of_interfaces_during_boot / without awk / 2nd try (coding style)

---
 package/base-files/files/etc/init.d/boot |   15 +--
 1 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/package/base-files/files/etc/init.d/boot b/package/base-files/files/etc/init.d/boot
index 7927af1..308d91a 100755
--- a/package/base-files/files/etc/init.d/boot
+++ b/package/base-files/files/etc/init.d/boot
@@ -68,8 +68,19 @@ start() {
 			--set-rules-file /etc/hotplug2.rules \
 			--max-children 1 >/dev/null 2>&1 &
 
+	list_network_interfaces()
+	{
+		local line
+
+		while read line; do {
+			case "$line" in
+*:*) echo ${line%:*} ;;
+			esac
+		} done ___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH] base-files: refactoring calc_tmpfs_size without awk / 2nd try (coding style)

2011-01-16 Thread Bastian Bittorf
It is always a bad idea to mix up different languages
in one environment. Another point is, to bury awk in
base-files. There is no reason for it, these are only
quick hacks from the old days of whiterussian 8-).

now we call the function + get a value, and do not rely
on a global set var_name, which's name was unclear.

Signed-off-by: Bastian Bittorf 

>From 5fde9d204cfd9aa0e40b93e1400efb96a8cd4e2f Mon Sep 17 00:00:00 2001
From: Bastian Bittorf 
Date: Sun, 16 Jan 2011 11:55:25 +0100
Subject: [PATCH] refactoring calc_tmpfs_size() without awk

---
 .../base-files/files/lib/preinit/10_essential_fs   |   29 ---
 1 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/package/base-files/files/lib/preinit/10_essential_fs b/package/base-files/files/lib/preinit/10_essential_fs
index ab317dc..6f0193c 100644
--- a/package/base-files/files/lib/preinit/10_essential_fs
+++ b/package/base-files/files/lib/preinit/10_essential_fs
@@ -10,16 +10,35 @@ do_mount_sysfs() {
 mount sysfs /sys -t sysfs
 }
 
-calc_tmpfs_size() {
-pi_size=$(awk '/MemTotal:/ {l=5242880;mt=($2*1024);print((s=mt/2)l)?mt-l:s}' /proc/meminfo)
+calc_tmpfs_size()	# [bytes] - 50% of total mem, but at least 5mb must be untouched
+{
+	local mem_border=5242880
+	local line mem_total mem_untouched size_tmpfs
+
+	while read line; do {
+		case "$line" in
+			MemTotal:*)
+set $line
+mem_total=$(( $2 * 1024 ))
+break
+			;;
+		esac
+	} done ___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH] base-files: refactoring find_mtd_part() without awk, grep - without forks

2011-01-16 Thread Bastian Bittorf
It is always a bad idea to mix up different languages
in one environment. Another point is, to bury awk in
base-files. There is no reason for it, these are only
quick hacks from the old days of whiterussian 8-).

now we use ash-builtins and dont fork.
i have done some benchmarks, and the code is
nearly 2 times faster, than the old one.
(1 passes: 115sec old <-> 62sec new code)

Signed-off-by: Bastian Bittorf 

>From 726f36df7b668604df4fe6fce6b8e588e05ae881 Mon Sep 17 00:00:00 2001
From: Bastian Bittorf 
Date: Sun, 16 Jan 2011 12:23:28 +0100
Subject: [PATCH] refactoring find_mtd_part() without awk, without forking, clean coding style

---
 package/base-files/files/etc/functions.sh |   31 ++--
 1 files changed, 24 insertions(+), 7 deletions(-)

diff --git a/package/base-files/files/etc/functions.sh b/package/base-files/files/etc/functions.sh
index acea617..fe19375 100755
--- a/package/base-files/files/etc/functions.sh
+++ b/package/base-files/files/etc/functions.sh
@@ -220,13 +220,30 @@ include() {
 	done
 }
 
-find_mtd_part() {
-	local PART="$(grep "\"$1\"" /proc/mtd | awk -F: '{print $1}')"
-	local PREFIX=/dev/mtdblock
-	
-	PART="${PART##mtd}"
-	[ -d /dev/mtdblock ] && PREFIX=/dev/mtdblock/
-	echo "${PART:+$PREFIX$PART}"
+find_mtd_part()
+{
+	local partition_name="$1"		# e.g. rootfs_data
+	local line partition_number prefix
+
+	while read line; do {
+		case "$line" in
+			*"\"$partition_name\""*)
+IFS=":"
+set $line
+partition_number=${1##mtd}	# mtd3 -> 3
+unset IFS
+break
+			;;
+		esac
+	} done  {  [] ... }
-- 
1.6.3.3

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH] base-files: refactoring unbridge() without awk/grep

2011-01-16 Thread Bastian Bittorf
it is always a bad idea to mix up different languages
in one environment. Another point is, to bury awk in
base-files. There is no reason for it, these are only
quick hacks from the old days of whiterussian 8-).

i have also removed all the >/dev/null - statements,
which are IMHO not neccesary anymore. there is also
a check for an call without args.

Signed-off-by: Bastian Bittorf 

>From 43cd5dfefcf0527b295f445900b9d650f7dffc53 Mon Sep 17 00:00:00 2001
From: Bastian Bittorf 
Date: Sun, 16 Jan 2011 13:55:55 +0100
Subject: [PATCH] refactoring unbridge() without awk/grep

---
 package/base-files/files/lib/network/config.sh |   39 ++-
 1 files changed, 24 insertions(+), 15 deletions(-)

diff --git a/package/base-files/files/lib/network/config.sh b/package/base-files/files/lib/network/config.sh
index 449d252..d166966 100755
--- a/package/base-files/files/lib/network/config.sh
+++ b/package/base-files/files/lib/network/config.sh
@@ -405,19 +405,28 @@ stop_interface_dhcp() {
 	uci -P /var/state revert "network.$config"
 }
 
-unbridge() {
-	local dev="$1"
-	local brdev
-
-	[ -x /usr/sbin/brctl ] || return 0
-	brctl show 2>/dev/null | grep "$dev" >/dev/null && {
-		# interface is still part of a bridge, correct that
-
-		for brdev in $(brctl show | awk '$2 ~ /^[0-9].*\./ { print $1 }'); do
-			brctl delif "$brdev" "$dev" 2>/dev/null >/dev/null
-			do_sysctl net.ipv6.conf.$dev.disable_ipv6 0
-			[ "${dev##wlan}" != "$dev" ] && \
-do_sysctl net.ipv6.conf.mon.$dev.disable_ipv6 0
-		done
-	}
+unbridge()
+{
+	local remove_dev="$1"
+	local brdev line
+
+	[ ! -x /usr/sbin/brctl -o -z "$remove_dev" ] && return 0
+
+	brctl show | while read line; do {
+		case "$line" in
+			"bridge name"*) ;;	# ignore headline
+			*)
+set $line
+brdev="$1"
+
+[ "$brdev" = "$remove_dev" ] && {
+	brctl delif "$brdev" "$remove_dev"
+	do_sysctl net.ipv6.conf.$remove_dev.disable_ipv6 0
+
+	[ "${remove_dev##wlan}" != "$remove_dev" ] && \
+		do_sysctl net.ipv6.conf.mon.$remove_dev.disable_ipv6 0
+}
+			;;
+		esac
+	} done
 }
-- 
1.6.3.3

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH] base-files: refactoring rootfs_type() without awk

2011-01-16 Thread Bastian Bittorf
it is always a bad idea to mix up different languages
in one environment. Another point is, to bury awk in
base-files. There is no reason for it, these are only
quick hacks from the old days of whiterussian 8-).

by using better varnames, the code is now readable.

Signed-off-by: Bastian Bittorf 

>From 41cf954a24faf211e6dd523c37dc074fd26391db Mon Sep 17 00:00:00 2001
From: Bastian Bittorf 
Date: Sun, 16 Jan 2011 14:33:39 +0100
Subject: [PATCH] refactoring rootfs_type() without awk

---
 package/base-files/files/lib/upgrade/common.sh |   17 +++--
 1 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/package/base-files/files/lib/upgrade/common.sh b/package/base-files/files/lib/upgrade/common.sh
index 970016e..90fc642 100644
--- a/package/base-files/files/lib/upgrade/common.sh
+++ b/package/base-files/files/lib/upgrade/common.sh
@@ -102,8 +102,21 @@ v() {
 	[ "$VERBOSE" -ge 1 ] && echo "$@"
 }
 
-rootfs_type() {
-	mount | awk '($3 ~ /^\/$/) && ($5 !~ /rootfs/) { print $5 }'
+rootfs_type()
+{
+	local line mountpoint fstype
+
+	mount | while read line; do {
+
+		set $line
+		mountpoint="$3"
+		fstype="$5"
+
+		[ "$mountpoint" = "/" -a "$fstype" != "rootfs" ] && {
+			echo "$fstype"
+			return
+		}
+	} done
 }
 
 get_image() { #  [  ]
-- 
1.6.3.3

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] uhttpd / strange bug

2011-01-16 Thread Bastian Bittorf
if i fetch a cgi-script and this script
also fetches something from localhost,
than the webserver hangs, until restart.

so:

cgi-bin-welcome.sh

has something like
wget http://127.0.0.1/cgi-bin-database.sh
then the server hangs.

bye, Bastian.

PS: the flag "-A" (tcp-keepalive) is not documented in wiki

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] Optimize for speed, not for size

2011-01-16 Thread Bastian Bittorf
what is the best point to enforce an
compilation with -O3 instead of -Os ?

I tried to change

target/linux/ar71xx/Makefile -> CFLAGS:

after menuconfig, but then my
image didn't work - or is there
a cleaner way?

bye, Bastian
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] Optimize for speed, not for size

2011-01-16 Thread Bastian Bittorf
> The -O3 optimization adds a good bit of size that means more page
> faults and cache misses, which translates to slower real-world
> performance.

this is theory as must be checked.
our routers are so powerful (16mb RAM or more, these
where workstations some years ago), so we
have enough space and maybe can achieve a little
bit more speed...

If i unterstand -Os correctly, than it is an -O2 optimization,
but also reduces codesize. 

bye, Bastian

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] Optimize for speed, not for size

2011-01-17 Thread Bastian Bittorf
> Do they also have as much (L2) cache as your workstations some
> years ago?

good catch! L1/L2-cache = 64kb (mips24kc) if i read the
specs correctly, which isn't that bad...anyway:
if it really speeds up, we can only see in practise...

bye, Bastian.

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PACKAGE] ulogd / segfault

2011-01-18 Thread Bastian Bittorf
> this segfaults:
> ulogd -d

it correspond to this ticket: https://dev.openwrt.org/ticket/8481

bye, Bastian
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH] base-files/hotplug: refactoring ifup/netstate

2011-01-19 Thread Bastian Bittorf
it is always a bad idea to mix up different languages
in one environment. now we use ash-builtins to get
uptime_in_seconds() instead of using cryptic sed-style.

Signed-off-by: Bastian Bittorf 
>From 00c9af1c15d9a9f1959651a0fd7eac014e4e9808 Mon Sep 17 00:00:00 2001
From: Bastian Bittorf 
Date: Wed, 19 Jan 2011 08:52:07 +0100
Subject: [PATCH] hotplug/netstate: uptime_in_seconds with ash-builtins

---
 .../files/etc/hotplug.d/iface/00-netstate  |   18 --
 1 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/package/base-files/files/etc/hotplug.d/iface/00-netstate b/package/base-files/files/etc/hotplug.d/iface/00-netstate
index e2e5845..f3b0d3e 100644
--- a/package/base-files/files/etc/hotplug.d/iface/00-netstate
+++ b/package/base-files/files/etc/hotplug.d/iface/00-netstate
@@ -1,5 +1,19 @@
 [ ifup = "$ACTION" ] && {
+
+	uptime_in_seconds()
+	{
+		local uptime dummy
+
+		IFS='. '
+		read uptime dummy ___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH] base-files/hotplug: refactoring ifup/netstate

2011-01-19 Thread Bastian Bittorf
> Did you test it with the other 'selectable' shells as well?

only with dash/bash and ash,
but these commands are very simple and are
working on every somehow organzied posix-shell.

> IMHO you should keep things as they are. I had to read your patch
> three times before I got the clue what you're trying

really? come'on: what does a function named uptime_in_seconds() ?

> to accomplish, while the original line simply read 'ah they use sed
> to filter something out of /proc/uptime'. I think

you named it: something.

> this use of sed is common sense.

yes, but this does'nt make it better if many
people do it wrong.

> If you think that sed regular expressions are cryptic (and I agree

i'am very familiar with sed and use it very
often - but thats not the point. the point is:
we don't must use another language, if it
doesnt make sense (e.g. for speed)

bye, Bastian. - (who want's to do a refactoring and reordering on the hole 
base-files stuff which is a real mess...)
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH] base-files/hotplug: refactoring ifup/netstate V2

2011-01-19 Thread Bastian Bittorf
it is always a bad idea to mix up different languages
in one environment. now we use ash-builtins to get
uptime_in_seconds() instead of using cryptic sed-style.

Signed-off-by: Bastian Bittorf 
>From a0997188ea3a325db33f9041297ebfea0180e31f Mon Sep 17 00:00:00 2001
From: Bastian Bittorf 
Date: Wed, 19 Jan 2011 15:51:14 +0100
Subject: [PATCH] hotplug/netstate() get_uptime - clean_code

---
 .../files/etc/hotplug.d/iface/00-netstate  |   12 ++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/package/base-files/files/etc/hotplug.d/iface/00-netstate b/package/base-files/files/etc/hotplug.d/iface/00-netstate
index e2e5845..37aab81 100644
--- a/package/base-files/files/etc/hotplug.d/iface/00-netstate
+++ b/package/base-files/files/etc/hotplug.d/iface/00-netstate
@@ -1,5 +1,13 @@
 [ ifup = "$ACTION" ] && {
+
+	uptime_in_seconds()
+	{
+		cut -d'.' -f1 /proc/uptime
+	}
+
 	uci_set_state network "$INTERFACE" up 1 
-	uci_set_state network "$INTERFACE" connect_time $(sed -ne 's![^0-9].*$!!p' /proc/uptime)
-	[ -n "$DEVICE" ] && uci_set_state network "$INTERFACE" ifname "$DEVICE"
+	uci_set_state network "$INTERFACE" connect_time $(uptime_in_seconds)
+
+	[ -n "$DEVICE" ] && \
+		uci_set_state network "$INTERFACE" ifname "$DEVICE"
 }
-- 
1.6.3.3

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH] base-files/hotplug: refactoring ifup/netstate

2011-01-19 Thread Bastian Bittorf
> Notice please that your function returns "whatever" before IFS or
> the full input if it does not contain IFS.
> The original sed expression returns the validated number string or
> an empty string.

You are right, i have reworked the patch.

if /proc/uptime does not return a number, than
you have _really_ other problems IMHO.

bye, Bastian
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH] base-files/hotplug: refactoring ifup/netstate

2011-01-19 Thread Bastian Bittorf
> Sed will return the same output, regardless what shell you use.

You say: lets use another language, we cannot
be sure, that our shell-scripts are portable.

IMHO we should better work on the scripts, to
be sure they are portable - and don't change the
language.

> >> IMHO you should keep things as they are. I had to read your

what you say is:
is compile's: lets ship it - but IMHO we should
clean up, as often we can. if it breaks - than we
have something done wrong before...

> Well, 'something' is good enough to read the code and if I need to
> know and don't understand the details, I can alway
> paste 'sed -ne 's![^0-9].*$!!p' /proc/uptime' on a command line.

ok, maybe in this special example.
what about this code in file:
package/base-files/files/etc/hotplug.d/iface/10-routes

for ifn in $(ifconfig | sed -ne 
"s/^\(\($DEVICE${device:+\|$device}\|br-$INTERFACE\):[^[:space:]]\+\).*/\1/p"); 
do

how long must you read, to get it?
how easy you can paste this to a cmdline?

> >> this use of sed is common sense.
> > yes, but this does'nt make it better if many
> > people do it wrong.
> >
> That's not an excuse. We should help/train/review so that it is
> done properly.

exact, thats the point: review. and make it better, if possible - so here is 
the patch...

> Next week we can enjoy a patch from somebody who thinks that it is
> better to use sed,awk or cut here instead of doing it
> your way... ??

if the next/somebody has a reason to change it,
than he is welcome. we should always administer
the code...

bye, Bastian
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH] base-files/hotplug: refactoring ifup/netstate V2

2011-01-19 Thread Bastian Bittorf
> The use of sed an awk should not be consider "a different"
> languages
> simple because aren't different languages but just tools like read

yes, but we should use the best suiting tool,
and this means NOT that we should use
oneliners which are often unreadable, when
looking through code...

> Moreover I found the resulting code after "restyling" less
> readable
> and unnecessarily long.

long is not a problem: we have a function name.
better long code which is well organized and
readable than oneliners in _different_ languages
on 1 page.

bye, Bastian

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH] base-files/hotplug: refactoring ifup/netstate V2

2011-01-20 Thread Bastian Bittorf
> >> it is always a bad idea to mix up different languages
> >> in one environment.
> 
> I don't accept this is a valid starting point.  I agree that it is
> useful to limit the number of tools/languages you use, but you
> should
> still try and use the right tool/language for the right job.

your are right. the question is:

original:
sed -ne 's![^0-9].*$!!p' /proc/uptime

patch:
cut -d'.' -f1 /proc/uptime

patch-2:
uptime_in_seconds()
{
cut -d'.' -f1 /proc/uptime
}

what is the better tool?
what is better readable?
must we really sanitize /proc/uptime for numbers?

> Indeed: /bin/sh was designed around the idea that running an
> external
> command like `sed' is basically equivalent to a function call to

yes, but in practise it is a good idea to use internal
functions/commands (speed, memory).

> a library function.  That's why /bin/sh is very limited in the
> text-handling functionality it provides directly.  So by and

/bin/sh is more limited than sed, but still strong.

> `sed' is part of the /bin/sh language (I've managed to survive 20
> years
> of unix without ever really learning awk, so I don't feel quite as
> strongly about awk as about sed).

i like this sentence 8-)

I will stop sending patches like this, because i see that
many people have stomachache with these, but i propose
for menuconfig a selection like this:

[ ] base-files standard
[ ] base-files mini (no sed/awk, experimental)

bye, Bastian

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH] base-files/hotplug: refactoring ifup/netstate V2

2011-01-20 Thread Bastian Bittorf
> if
> you, in 1, 6, 12 months, still forward port all the changes and
> fixes
> done in base-files to base-files-mini ?!

of course i can maintain my "private" branch
personally, but I really think I'am not alone.
If we have it in openwrt-git, everybody can use the code.

If we really recognize, that the package is bad
maintained, then: just remove it. I'am sure, that
it is easy to maintain, because there are not much
changes in this package in the past.

> included (see hostapd and hostapd-mini). so calling in
> basefile-shell_only would be more applicable, although the purpose

ok, i'am fine with this name.
purpose can be: clean_code and lowmem-boards.

bye, Bastian.
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH] base-files/hotplug: refactoring ifup/netstate V2

2011-01-20 Thread Bastian Bittorf
> > [ ] base-files standard
> > [ ] base-files mini (no sed/awk, experimental)
> 
> But how many space is safe if busybox is compiled without sed and
> awk?

485.928 bytes original
451.976 bytes without sed+awk

but thats not only the point. if we have a selectable
experimental base-files package, we have the chance to:

- clean up base-files
- trying new concepts in base-files
- e.g. trying to abondon ifconfig/route/arp by using ip
- (having support for lowmem-devices =<4MB RAM)

without having stomach ache, when base breaks.

bye, Bastian

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH] base-files/hotplug: refactoring ifup/netstate V2

2011-01-20 Thread Bastian Bittorf
> > - e.g. trying to abondon ifconfig/route/arp by using ip
> 
> i doubt that owrt will ever switch to using ip, at least not in
> its
> current state.

but it's really a pity, that a _network_ distro uses
an 25+ years old concept 8-). openwrt can only use
ip, if we change a lot in base-files...

> > without having stomach ache, when base breaks.
> 
> i dont get the "when base breaks" bit

many people are using trunk in production
and of course it is really bad, if something brakes.

nobody wants this, but if we work on the base-files
there is a chance, that we introduce new bugs.

so if the people have the choice:
base-files (stable/experimental)

bye, Bastian.

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH] base-files: refactoring load_modules()

2011-01-20 Thread Bastian Bittorf
> for micro images usually busybox is used and awk/sed are available
> busybox applets. i really doubt that the size increase is in
> proportion to the rework (including bugfixing) the already working
> code.

think future: do we ever rely on busybox?
maybe some users use e.g. toybox[1] later?

bye, Bastian.

[1] http://www.landley.net/code/toybox/about.html

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH] packages/dnsmasq: add support for option "--dhcp-script"

2011-01-27 Thread Bastian Bittorf
adding support for "--dhcp-script" (long) "-6" (short).
each time dnsmasq see's a dhcp-request, it calls a confireable
script with some arguments. e.g.

file "/etc/config/dhcp"

option dhcpscript '/tmp/test.sh'

file "test.sh"

#!/bin/sh
logger "dhcp! 1='$1' 2='$2' 3='$3' 4='$4'"

this performs the following syslog:

root@box:~ logread -f
Jan 27 09:41:03 box user.info hostapd: wlan0: STA 00:13:e8:a5:b0:f1 IEEE 
802.11: authenticated
Jan 27 09:41:03 box user.info hostapd: wlan0: STA 00:13:e8:a5:b0:f1 IEEE 
802.11: associated (aid 1)
Jan 27 09:41:03 box daemon.info dnsmasq-dhcp[16537]: DHCPREQUEST(wlan0) 
10.10.44.5 00:13:e8:a5:b0:f1
Jan 27 09:41:03 box daemon.info dnsmasq-dhcp[16537]: DHCPACK(wlan0) 10.10.44.5 
00:13:e8:a5:b0:f1 polyphem
Jan 27 09:41:03 box user.notice root: dhcp! 1='old' 2='00:13:e8:a5:b0:f1' 
3='10.10.44.5' 4='polyphem'

Signed-off-by: Bastian Bittorf 

>From d4134d94e45b858fba80799715416d7be6479c7e Mon Sep 17 00:00:00 2001
From: Bastian Bittorf 
Date: Thu, 27 Jan 2011 09:48:26 +0100
Subject: [PATCH] add support for dnsmasq dhcp-script

---
 package/dnsmasq/files/dnsmasq.init |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/package/dnsmasq/files/dnsmasq.init b/package/dnsmasq/files/dnsmasq.init
index ef1a8e9..9bd6225 100644
--- a/package/dnsmasq/files/dnsmasq.init
+++ b/package/dnsmasq/files/dnsmasq.init
@@ -78,6 +78,7 @@ dnsmasq() {
 	append_bool "$cfg" enable_tftp "--enable-tftp"
 	append_bool "$cfg" nonwildcard "-z"
 
+	append_parm "$cfg" dhcpscript "-6"
 	append_parm "$cfg" cachesize "-c"
 	append_parm "$cfg" dnsforwardmax "-0"
 	append_parm "$cfg" port "-p"
-- 
1.6.3.3

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH] packages/mac80211.sh Reordering calls for beacon-interval/mcast-rate

2011-01-27 Thread Bastian Bittorf
wifi is b0rken at the moment, it matters
in which order we call mcast-rate/beacon-interval
please apply ASAP.

just to mention this: the antenna-call also 
does not work, but wifi comes up anyway. without
this patch wifi comes NOT up!

Signed-off-by: Bastian Bittorf 

>From d7eb0950471f99faffa22ae9d9e830ce63037b7d Mon Sep 17 00:00:00 2001
From: Bastian Bittorf 
Date: Thu, 27 Jan 2011 16:12:03 +0100
Subject: [PATCH] order of mcast-rate/beacon-interval matters, so we reorder

---
 package/mac80211/files/lib/wifi/mac80211.sh |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/package/mac80211/files/lib/wifi/mac80211.sh b/package/mac80211/files/lib/wifi/mac80211.sh
index 7e38cea..a1767df 100644
--- a/package/mac80211/files/lib/wifi/mac80211.sh
+++ b/package/mac80211/files/lib/wifi/mac80211.sh
@@ -425,8 +425,8 @@ enable_mac80211() {
 
 	iw dev "$ifname" ibss join "$ssid" $freq \
 		${fixed:+fixed-freq} $bssid \
-		${mcval:+mcast-rate $mcval} \
 		${bintval:+beacon-interval $bintval} \
+		${mcval:+mcast-rate $mcval} \
 		${basicrates:+basic-rates $basicrates} \
 		${keyspec:+keys $keyspec}
 ;;
-- 
1.6.3.3

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH] packages/mac80211.sh refactoring get_freq()

2011-01-27 Thread Bastian Bittorf
lowered forking, cleaner approach, faster.

a loop of 1000 calls, works nearly
twice as fast, as the old code.

anyway:
would'nt it be better to have a case-table, which
can translate (phyX, band, channel) -> freq?

Signed-off-by: Bastian Bittorf 
>From e681b67765ddfd9264205f8444b1e999ccc6b6a1 Mon Sep 17 00:00:00 2001
From: Bastian Bittorf 
Date: Thu, 27 Jan 2011 17:31:44 +0100
Subject: [PATCH] refactoring get_freq, lowered forks, cleaner

---
 package/mac80211/files/lib/wifi/mac80211.sh |   26 +++---
 1 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/package/mac80211/files/lib/wifi/mac80211.sh b/package/mac80211/files/lib/wifi/mac80211.sh
index 13d6584..e51aa8f 100644
--- a/package/mac80211/files/lib/wifi/mac80211.sh
+++ b/package/mac80211/files/lib/wifi/mac80211.sh
@@ -227,11 +227,31 @@ disable_mac80211() (
 
 	return 0
 )
-get_freq() {
+
+get_freq()
+{
 	local phy="$1"
-	local chan="$2"
-	iw "$phy" info | grep -E -m1 "(\* ${chan:-} MHz${chan:+|\\[$chan\\]})" | grep MHz | awk '{print $2}'
+	local channel="$2"
+	local freq line startparse
+
+	iw "$phy" info | while read line; do {
+
+		[ -n "$startparse" ] && {
+			case "$line" in
+*" [$channel] "*)
+	set $line	# e.g. '* 2442 MHz [7] (27.0 dBm)'
+	echo $2
+	return
+;;
+			esac
+		}
+
+		case "$line" in
+			*"Frequencies:"*) startparse=1 ;;
+		esac
+	} done
 }
+
 enable_mac80211() {
 	local device="$1"
 	config_get channel "$device" channel
-- 
1.6.3.3

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH] mac80211.sh setting ESSID in station mode

2011-01-28 Thread Bastian Bittorf
in station/client mode we forgot to set the ESSID,
so there was no connection possible. this is just
a proposal - i'am unsure if there is a better place
for the command.

Signed-off-by: Bastian Bittorf 
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH] mac80211.sh setting ESSID in station mode

2011-01-28 Thread Bastian Bittorf
in station/client mode we forgot to set the ESSID,
so there was no connection possible. this is just
a proposal - i'am unsure if there is a better place
for the command.

Signed-off-by: Bastian Bittorf 
>From 831ce3fda06bbccc0a2be09b783a4a2e2db41b69 Mon Sep 17 00:00:00 2001
From: Bastian Bittorf 
Date: Fri, 28 Jan 2011 13:56:59 +0100
Subject: [PATCH] setting ESSID in client/station-mode, after the interface is up

---
 package/mac80211/files/lib/wifi/mac80211.sh |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/package/mac80211/files/lib/wifi/mac80211.sh b/package/mac80211/files/lib/wifi/mac80211.sh
index ac1562f..61032eb 100644
--- a/package/mac80211/files/lib/wifi/mac80211.sh
+++ b/package/mac80211/files/lib/wifi/mac80211.sh
@@ -439,6 +439,8 @@ enable_mac80211() {
 			continue
 		}
 	fi
+
+	iw dev "$ifname" connect "$ssid"
 ;;
 			esac
 			mac80211_start_vif "$vif" "$ifname"
-- 
1.6.3.3

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] uhttpd / bug when decoding URL

2011-01-28 Thread Bastian Bittorf
when decoding an RFC2396-url-encoded string
on commandline, there a two mistakes:

first, the ssl-check is loaded, which is not
needed. second a '+' is not decoded to space.
(and it seems, that the hole decoding is not
feature-complete)

e.g.  uhttpd -d "open+wrt"

should return "open wrt", but leads to:

root@box:~ uhttpd -d "open+wrt"
Notice: Unable to load TLS plugin - disabling SSL support! (Reason: File not 
found)
open+wrt

bye, Bastian
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] problem with iproute2 VS busybox ip-applet

2011-01-29 Thread Bastian Bittorf
if i install "ip" after using already builtin
busybox "ip applet", then we have to files:

/bin/ip (symlinks to busybox)
/usr/sbin/ip (real ip)

so the postinstall-process of iproute2
should detect this, throw a logmessage
(and remove "/bin/ip"?).

should i send a patch, is there are
there reasons not to do...

bye, Bastian.

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH] broadcom/diag recognize Dell Truemobile 2300 / TM2300 without ModelId

2011-01-29 Thread Bastian Bittorf
sorry for call up the deads, but during fiddling
with 10 devices we recognized, that they all where
not detected correctly, because of a missing nvram-var.

this patch makes it work without the var.

Signed-off-by: Bastian Bittorf 

>From 283c46fb06407e45e436e86d55c1f58471e9a3f7 Mon Sep 17 00:00:00 2001
From: Bastian Bittorf 
Date: Sat, 29 Jan 2011 13:46:19 +0100
Subject: [PATCH] recognize Dell Truemobile 2300 v1 / TM2300 with missing nvram var ModelId

---
 package/broadcom-diag/src/diag.c |5 -
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/package/broadcom-diag/src/diag.c b/package/broadcom-diag/src/diag.c
index 55dfa75..4c4b432 100644
--- a/package/broadcom-diag/src/diag.c
+++ b/package/broadcom-diag/src/diag.c
@@ -959,7 +959,7 @@ static struct platform_t __init *platform_detect(void)
 		if (!strcmp(buf, "WR850G"))
 			return &platforms[WR850GV2V3];
 		if (!strcmp(buf, "WX-5565") && !strcmp(getvar("boardtype"),"bcm94710ap"))
-			return &platforms[TM2300]; /* Dell TrueMobile 2300 */
+			return &platforms[TM2300]; /* Dell TrueMobile 2300 v1 */
 		if (startswith(buf,"WE800G")) /* WE800G* */
 			return &platforms[WE800G];
 	}
@@ -1077,6 +1077,9 @@ static struct platform_t __init *platform_detect(void)
 			if (simple_strtoul(boardnum, NULL, 0) == 2)
 return &platforms[WAP54GV1];
 		}
+		if (!strcmp(boardnum, "44") && !strcmp(boardtype,"bcm94710ap"))
+			return &platforms[TM2300]; /* Dell TrueMobile 2300 v1 (ModelId unset) */
+
 		/* MN-700 has also hardware_version 'WL500-...', so use boardnum */
 		if (startswith(getvar("hardware_version"), "WL500-")) {
 			if (!strcmp(getvar("boardnum"), "mn700"))
-- 
1.6.3.3

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH] recognize Dell Truemobile 2300 v1 / TM2300 with missing nvram var ModelId / enhanced

2011-01-29 Thread Bastian Bittorf
during fiddling with 10 devices we recognized,
that they all where not detected correctly,
because of a missing nvram-var. till this patch
diag relies on a var, which is not in pmon - so
only original routers worked (never erased nvram).

if diag does not work correctly, than the switch
is bad configured - so no wan. this patch makes it
work without the var. the lower the risc of false
positives we take 3 vars into account.

Signed-off-by: Bastian Bittorf 
i
>From d2e26453bc641348341e2869ba9cfcc0b96ea86f Mon Sep 17 00:00:00 2001
From: Bastian Bittorf 
Date: Sat, 29 Jan 2011 13:46:19 +0100
Subject: [PATCH] recognize dell truemobile 2300 with even with missing nvram var ModelId

---
 package/broadcom-diag/src/diag.c |5 -
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/package/broadcom-diag/src/diag.c b/package/broadcom-diag/src/diag.c
index 55dfa75..a428267 100644
--- a/package/broadcom-diag/src/diag.c
+++ b/package/broadcom-diag/src/diag.c
@@ -959,7 +959,7 @@ static struct platform_t __init *platform_detect(void)
 		if (!strcmp(buf, "WR850G"))
 			return &platforms[WR850GV2V3];
 		if (!strcmp(buf, "WX-5565") && !strcmp(getvar("boardtype"),"bcm94710ap"))
-			return &platforms[TM2300]; /* Dell TrueMobile 2300 */
+			return &platforms[TM2300]; /* Dell TrueMobile 2300 v1 */
 		if (startswith(buf,"WE800G")) /* WE800G* */
 			return &platforms[WE800G];
 	}
@@ -1077,6 +1077,9 @@ static struct platform_t __init *platform_detect(void)
 			if (simple_strtoul(boardnum, NULL, 0) == 2)
 return &platforms[WAP54GV1];
 		}
+		if (!strcmp(boardnum, "44") && !strcmp(boardtype,"bcm94710ap") && !strcmp(getvar("clkfreq"), "125"))
+			return &platforms[TM2300]; /* Dell TrueMobile 2300 v1 (missing var ModelId) */
+
 		/* MN-700 has also hardware_version 'WL500-...', so use boardnum */
 		if (startswith(getvar("hardware_version"), "WL500-")) {
 			if (!strcmp(getvar("boardnum"), "mn700"))
-- 
1.6.3.3

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH v2 1/1] Redux: Allow user to apply settings to solos h/w before bringing up network

2011-01-31 Thread Bastian Bittorf

+dialog() {
+   local tag="$(echo "$1" | cut -d= -f1)"
+   local value="$(echo "$1" | cut -d= -f2-)"

i think the trailing '-' is an mistake...

+  response="$(soloscli -s "$port" "$tag" "$value")"
+   [ $? -ne 0 ] && {
+   logger "soloscli($port): $tag '$value' returns $response"

you can also write:

var="$( false )" || {
 logger ...
}


bye, Bastian.
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] Refactoring base-files

2011-02-05 Thread Bastian Bittorf
Some weeks ago, i started (undesired) a discussion[1,2]
about how and why i think the base-files should get
a refurbishment. I send several patches as a proposal,
but it was not possible to apply them - the reasons are:

- the code changed nearly nothing, only the style
- some people mentioned, that the old code was not good,
  but it worked since years and changes in base are risky
- it is not clear, if lowmem-targets are part of openwrt
  (most of the patches uses lower mem and are faster)
- there is no official coding style, that enforces the
  use of specific ways how to do things
- i mixed the reasons, why i wrote the new code

Here some words about this:

I like openwrt. There are many concepts i want to see
in other distros. I'm not satisfied with many scripts
and the way how people make a solution. Ofcourse this
is my personal opinion, but there are good reasons to
speak loud:

- clean code (not obfuscated)

This should be the most imported thing.
It helps to debug.
It lowers the entry-border.
It makes it easier to change the code and do refactoring.
(i have some ideas to modularize the functions/files, at the
moment we often include files which we don't need)

It does NOT help to make a oneliner and 1000 users asks
themself: what does THIS line? [3]

But while we are at it:
- don't fork, if not needed. examples from /etc/init.d/compache:

[ "`cat /proc/swaps | grep 'ramzswap0'`" != "" ] && swapoff /dev/ramzswap0

better use:
fgrep -q "ramzswap0" /proc/swaps || ...

- use function_names to say what you want to do

- use better shell builtins, instead of invoking another language
  (e.g. awk, sed, lua) - only if there is no other option
- using of shell builtins, leads to lower mem usage and are (mostly) faster

In the first discussion, i explained that awk is big and should not
be in base-files. During experiments it turned out, that these are only
some kilobytes. But the real reasons are explained above.

The next step can be:
- make an official coding-style (at the moment much is mixed)
- make an offical way, how to solve typical problems in scripts
- make "base-files (experimental)" which can be selected in menuconfig
  and i will maintain it. if people select it, they know the risk
- vote for or against it
- refactoring/refactoring/refactoring and try new concepts/ideas

Thanks for your time,
Bastian

[1] https://lists.openwrt.org/pipermail/openwrt-devel/2011-January/009171.html
[2] https://lists.openwrt.org/pipermail/openwrt-devel/2011-January/009273.html
[3] https://lists.openwrt.org/pipermail/openwrt-devel/2011-January/009199.html

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] Enhancement for Gigabit-Switch RTL8366RB (TP-Link 1043nd) /

2011-03-10 Thread Bastian Bittorf
IGMP-Snooping
Reply-To: 
X-Editor: vi http://ex-vi.sourceforge.net/

There is an open Ticket
https://dev.openwrt.org/ticket/7977

With some more functions.
I really would like to see this applied.
Another wish/idea:

Support IGMP-snooping. This would make it
possible to use it together with IP-TV and
a bridged LAN/WIFI without disturbing WIFI
and also lowering CPU-load.

Datasheet on Page 69 says:
"Switch bit 6 from Switch Global Control Register (SGCR) from 0 to 1"

http://realtek.info/pdf/rtl8366_8369_datasheet_1-1.pdf

bye, Bastian

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] ath9k / channel greaeter 11 / txpower too low / regdomain / crda

2011-03-22 Thread Bastian Bittorf
in actual trunk, when i compile for ar71xx (TP-Link1043ND) with

kernel-modules ->
 -> wireless drivers
 -> kmod-ath
 -> configuration
 -> YES "Force Atheros drivers to respect the user's regdomain settings"

in /etc/config/wireless i set:

option 'channel' '12'
option 'country' 'JP'
option 'txpower' '20'

but it fails. after checking:

iw reg get

it show JP, but with:

iw phy phy0 info | fgrep MHz 

* 2412 MHz [1] (17.0 dBm)
* 2417 MHz [2] (18.0 dBm)
* 2422 MHz [3] (18.0 dBm)
* 2427 MHz [4] (18.0 dBm)
* 2432 MHz [5] (18.0 dBm)
* 2437 MHz [6] (18.0 dBm)
* 2442 MHz [7] (18.0 dBm)
* 2447 MHz [8] (18.0 dBm)
* 2452 MHz [9] (18.0 dBm)
* 2457 MHz [10] (18.0 dBm)
* 2462 MHz [11] (17.0 dBm)
* 2467 MHz [12] (19.0 dBm)
* 2472 MHz [13] (19.0 dBm)
* 2484 MHz [14] (19.0 dBm)

we can see a, that it is not the same like CRDA:

cfg80211: Calling CRDA for country: JP
cfg80211: Regulatory domain changed to country: JP
cfg80211: (start_freq - end_freq @ bandwidth), (max_antenna_gain, max_eirp)
cfg80211: (2402000 KHz - 2472000 KHz @ 4 KHz), (N/A, 2000 mBm)
cfg80211: (2457000 KHz - 2482000 KHz @ 2 KHz), (N/A, 2000 mBm)
cfg80211: (2474000 KHz - 2494000 KHz @ 2 KHz), (N/A, 2000 mBm)
cfg80211: (491 KHz - 493 KHz @ 1 KHz), (N/A, 2300 mBm)
cfg80211: (491 KHz - 499 KHz @ 4 KHz), (N/A, 2300 mBm)
cfg80211: (493 KHz - 495 KHz @ 1 KHz), (N/A, 2300 mBm)
cfg80211: (503 KHz - 5045000 KHz @ 1 KHz), (N/A, 2300 mBm)
cfg80211: (503 KHz - 509 KHz @ 4 KHz), (N/A, 2300 mBm)
cfg80211: (505 KHz - 506 KHz @ 1 KHz), (N/A, 2300 mBm)
cfg80211: (517 KHz - 525 KHz @ 4 KHz), (N/A, 2000 mBm)
cfg80211: (525 KHz - 533 KHz @ 4 KHz), (N/A, 2000 mBm)
cfg80211: (549 KHz - 571 KHz @ 4 KHz), (N/A, 2300 mBm)

so this fails:

root@box:~ iw dev wlan0 set txpower fixed 2000
command failed: Invalid argument (-22)

the txpower is fine, when not using the ath-kmodule-option.
then we can use txpower 27 with country US.

what to do now?

bye, Bastian.

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] iptables / missing libip4tc.so.0

2011-03-29 Thread Bastian Bittorf
I build from trunk for ar71xx.
I already tried make clean/distclean.

After flashing the router i get:

root@openwrt:~ iptables -h
iptables: can't load library 'libip4tc.so.0'

the file belongs to iptables and is defined here:

package/iptables/Makefile

but it is not build?:
build@box:$ grep "iptables" .config | grep -v ^#
CONFIG_DEFAULT_iptables=y
CONFIG_PACKAGE_iptables=y
CONFIG_PACKAGE_iptables-mod-conntrack=y
CONFIG_PACKAGE_iptables-mod-conntrack-extra=y
CONFIG_PACKAGE_iptables-mod-extra=y
CONFIG_PACKAGE_iptables-mod-filter=y
CONFIG_PACKAGE_iptables-mod-ipopt=y
CONFIG_PACKAGE_iptables-mod-nat=y
CONFIG_PACKAGE_iptables-mod-nat-extra=y
CONFIG_PACKAGE_iptables-mod-ulog=y

maybe this is related:
https://forum.openwrt.org/viewtopic.php?pid=123430

any ideas?

bye, Bastian
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] iptables / missing libip4tc.so.0

2011-03-31 Thread Bastian Bittorf
> > Did you forget to run make oldconfig after updating?

Yes, again I have learned something.

Is it safe, to always do "make oldconfig" when
going with trunk, instead of a simple "make"?

Every morning i do:

cd ../packages
git pull
cd ../openwrt
git pull
get_coffee &
make V=99

> Does this error happen only with -h?  If so, I don't think that

No matter which args were given...
Problem solved now, thanks for feedback.

bye, Bastian


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH] fix kmod-fs-btrfs deps / zlib_deflate / makefile

2011-04-11 Thread Bastian Bittorf
btrfs needs zlib_deflate, which was built but not included

Signed-off-by: Bastian Bittorf 

>From cf929ddffe84d5ab6d6e33a5046f6af6e3bb37fc Mon Sep 17 00:00:00 2001
From: Bastian Bittorf 
Date: Mon, 11 Apr 2011 09:32:01 +0200
Subject: [PATCH] btrfs depends needs zlib_deflate, respect this in makefile

---
 package/kernel/modules/fs.mk |8 +---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/package/kernel/modules/fs.mk b/package/kernel/modules/fs.mk
index 846bc82..c2ae551 100644
--- a/package/kernel/modules/fs.mk
+++ b/package/kernel/modules/fs.mk
@@ -28,10 +28,12 @@ define KernelPackage/fs-btrfs
   DEPENDS:=+kmod-libcrc32c
   KCONFIG:=\
 	CONFIG_BTRFS_FS \
-	CONFIG_BTRFS_FS_POSIX_ACL=n
+	CONFIG_BTRFS_FS_POSIX_ACL=n \
+	CONFIG_ZLIB_DEFLATE
   FILES:=\
-	$(LINUX_DIR)/fs/btrfs/btrfs.ko
-  AUTOLOAD:=$(call AutoLoad,30,btrfs,1)
+	$(LINUX_DIR)/fs/btrfs/btrfs.ko \
+	$(LINUX_DIR)/lib/zlib_deflate/zlib_deflate.ko
+  AUTOLOAD:=$(call AutoLoad,30,zlib_deflate btrfs,1)
 endef
 
 define KernelPackage/fs-btrfs/description
-- 
1.7.1

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] Retaining WAN IP addresses across reboots

2011-04-13 Thread Bastian Bittorf
> Please also note that the real time clock is important for knowing
> if
> the DHCP lease is still valid.
> Since most routers don't have a hardware RTC, there is no way to
> know
> it the DHCP lease is still valid before you get WAN connectivity to
> update the time with NTP.

in our special openwrt-build we have a function like

time_seems_correct()

which simply return 1 if the time is older or much newer than the builddate of 
the firmware-image. (during build we write the unixtimestamp to /etc/buildtime, 
but it is also possible to use 'uname -a')

thanks for pointing at this problem. something interesting:
i have seen many routers, which have a date of year 2027
or 2021 after booting...

bye, Bastian...

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [EMAIL PROTECTED]: [PATCH] refactoring base-files for using "ip" instead of "ifconfig/route..."]

2008-05-17 Thread Bastian Bittorf
hello hackers,

here are some patches to let the user decide
wether to use "ifconfig/route..." or the nice
command "ip", which is much more cleaner IMHO.

This is not complete yet, but let me first know, if
the used fallback-method or "elegant" or if I have
to rewrite the code.

Bastian Bittorf <[EMAIL PROTECTED]>

Index: package/base-files/files/etc/preinit
===
--- package/base-files/files/etc/preinit(Revision 11157)
+++ package/base-files/files/etc/preinit(Arbeitskopie)
@@ -3,8 +3,24 @@
 export PATH=/bin:/sbin:/usr/bin:/usr/sbin
 . /etc/diag.sh
 
-failsafe_ip() {
-   ifconfig $ifname 192.168.1.1 netmask 255.255.255.0 broadcast 
192.168.1.255 up
+failsafe_ip ()
+{
+   localDEVICE="$ifname"   # ifname is global known
+   localIP="192.168.1.1"
+   local BROADCAST="192.168.1.255" # maybe calculate from 
IP/NETMASK?
+   local   NETMASK="255.255.255.0"
+   local CIDR_MASK="24"# which must be NETMASK in 
other notation (maybe calculate?)
+
+   ifconfig $DEVICE $IP netmask $NETMASK broadcast $BROADCAST up
+
+   [ "$?" -ne 0 ] && { # returncode not 0 -> ifconfig is n/a 
-> fallback by using ip
+
+   ip addr add dev $DEVICE $IP/$CIDR_MASK broadcast $BROADCAST
+   ip link set dev $DEVICE arp on  
+   ip link set dev $DEVICE up
+   }
+
+   netmsg $BROADCAST "configured $IP/$CIDR_MASK on device $DEVICE"
 }
 
 failsafe() {


signature.asc
Description: Digital signature
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
http://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [EMAIL PROTECTED]: [PATCH] refactoring base-files for using "ip" instead of "ifconfig/route..."]

2008-05-17 Thread Bastian Bittorf
* Brian J. Murrell <[EMAIL PROTECTED]> [17.05.2008 15:45]:

> > +   local BROADCAST="192.168.1.255" # maybe calculate from 
> > IP/NETMASK?
> > +   local   NETMASK="255.255.255.0"
> > +   local CIDR_MASK="24"# which must be NETMASK in 
> > other notation (maybe calculate?)
>  ^
> Don't try to line these up at the "=".  It doesn't increase readability.

Do you think so? I believe that it is better readable

> Use the || short-circuit syntax:
> 
>   ifconfig $DEVICE $IP netmask $NETMASK broadcast $BROADCAST up || {
>   # ifconfig failed -> fallback to using ip
>   ip addr add dev $DEVICE $IP/$CIDR_MASK broadcast $BROADCAST
>   ip link set dev $DEVICE arp on  
>   ip link set dev $DEVICE up
>   }

Not very nice, especially on large conditions.
Other opinions to both suggestions?

bye, Bastian - thanks for reply



signature.asc
Description: Digital signature
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
http://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [EMAIL PROTECTED]: [PATCH] refactoring base-files for using "ip" instead of "ifconfig/route..."]

2008-05-17 Thread Bastian Bittorf
* Peter Denison <[EMAIL PROTECTED]> [17.05.2008 15:00]:

> I would far rather see 'ip' tried first, and then fall back to ifconfig  
> (which is almost guaranteed to be present) than the other way round.

Ofcourse this is my goal, but let it us do slow and safe I think...

bye, Bastian.


signature.asc
Description: Digital signature
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
http://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [EMAIL PROTECTED]: [PATCH] refactoring base-files for using "ip" instead of "ifconfig/route..."]

2008-05-17 Thread Bastian Bittorf
* Ondrej Zajicek <[EMAIL PROTECTED]> [17.05.2008 15:45]:

> You can use "broadcast +" to let program compute proper broadcast address.

ok, will do so...

> > +   ip link set dev $DEVICE arp on  
> 
> This is unnecessry, isn't it?

Maybe, but it doesn hurt. See the examples at:
http://www.policyrouting.org/iproute2.doc.html#ss9.2.1

bye, Bastian.



signature.asc
Description: Digital signature
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
http://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH] adding usage-information to ipcalc.sh

2008-05-17 Thread Bastian Bittorf
because i hate to look into source just
to guess the cmdline-params...

bye, Bastian

Index: package/base-files/files/bin/ipcalc.sh
===
--- package/base-files/files/bin/ipcalc.sh  (Revision 11157)
+++ package/base-files/files/bin/ipcalc.sh  (Arbeitskopie)
@@ -1,7 +1,18 @@
 #!/bin/sh
 
-awk -f /usr/lib/common.awk -f - $* <  [start] [num]"
+   print ""
+   print "sense: this calculates var=value-pairs of"
+   print "   broadcast, network, prefix and"
+   print "   optionally start- and end-ip"
+   
+   exit 1
+   }
+
ipaddr=ip2int(ARGV[1])
netmask=ip2int(ARGV[2])
network=and(ipaddr,netmask)



signature.asc
Description: Digital signature
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
http://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH] refactoring ifconfig->ip , cleanups, /etc/preinit

2008-05-17 Thread Bastian Bittorf
first base-file which now can work with ip and ifconfig
some cleanups for better reading. can anyone explain,
what the "size"-awk thing makes really?

bye, Bastian <[EMAIL PROTECTED]>

Index: package/base-files/files/etc/preinit
===
--- package/base-files/files/etc/preinit(Revision 11157)
+++ package/base-files/files/etc/preinit(Arbeitskopie)
@@ -1,18 +1,37 @@
 #!/bin/sh
 # Copyright (C) 2006 OpenWrt.org
+
 export PATH=/bin:/sbin:/usr/bin:/usr/sbin
 . /etc/diag.sh
 
-failsafe_ip() {
-   ifconfig $ifname 192.168.1.1 netmask 255.255.255.0 broadcast 
192.168.1.255 up
+failsafe_ip ()
+{
+   localDEVICE="$1"# ARG1
+   localIP="192.168.1.1"
+   local  MASK="255.255.255.0"
+   local BROADCAST="$( /bin/ipcalc.sh $IP $MASK | sed -n 
's/^BROADCAST=\(.*\)/\1/p' )"
+   local   PRE="$( /bin/ipcalc.sh $IP $MASK | sed -n 
's/^PRE=\(.*\)/\1/p'   )"
+
+   ifconfig $DEVICE $IP netmask $MASK broadcast $BROADCAST up
+
+   [ "$?" -ne 0 ] && { # 
returncode not 0 -> ifconfig n/a -> fallback to ip
+
+   ip addr add dev $DEVICE $IP/$PRE broadcast +# 
broadcast is calculated (is this clean? we calc it anyway)
+   ip link set dev $DEVICE arp on  # maybe 
not necessary
+   ip link set dev $DEVICE up
+   }
+
+   netmsg $BROADCAST "set up $IP/$PRE dev $DEVICE"
+   netmsg $BROADCAST "Entering Failsafe!"
 }
 
-failsafe() {
+failsafe ()
+{
[ -n "$ifname" ] && grep "$ifname" /proc/net/dev >/dev/null && {
-   failsafe_ip
-   netmsg 192.168.1.255 "Entering Failsafe!"
+   failsafe_ip $ifname
telnetd -l /bin/login <> /dev/null 2>&1
}
+
lock /tmp/.failsafe
ash --login
 }
@@ -20,7 +39,7 @@
 mount proc /proc -t proc
 mount sysfs /sys -t sysfs
 
-size=$(awk '/MemTotal:/ {l=5242880;mt=($2*1024);print((s=mt/2) /dev/null; then



signature.asc
Description: Digital signature
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
http://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH] refactoring ifconfig->ip, /sbin/ifdown

2008-05-17 Thread Bastian Bittorf
another base-file:

Index: package/base-files/files/sbin/ifdown
===
--- package/base-files/files/sbin/ifdown(Revision 11157)
+++ package/base-files/files/sbin/ifdown(Arbeitskopie)
@@ -59,6 +59,11 @@
 [ ."$device" != ."$ifname" ] || device=
 for dev in $ifname $device; do
ifconfig "$dev" 0.0.0.0 down >/dev/null 2>/dev/null
+
+   [ "$?" -ne 0 ] && { # returncode not 0 -> ifconfig 
n/a -> fallback using ip
+   
+   ip link set dev "$dev" down >/dev/null 2>/dev/null
+   }
 done
 
 config_get iftype "$cfg" type



signature.asc
Description: Digital signature
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
http://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH] refactoring ifconfig->ip, fix for previous patch /etc/preinit

2008-05-17 Thread Bastian Bittorf
missspelled something. string must be "PREFIX" not only "PRE"

bye, Bastian <[EMAIL PROTECTED]>

Index: package/base-files/files/etc/preinit
===
--- package/base-files/files/etc/preinit(Revision 11157)
+++ package/base-files/files/etc/preinit(Arbeitskopie)
@@ -1,18 +1,37 @@
 #!/bin/sh
 # Copyright (C) 2006 OpenWrt.org
+
 export PATH=/bin:/sbin:/usr/bin:/usr/sbin
 . /etc/diag.sh
 
-failsafe_ip() {
-   ifconfig $ifname 192.168.1.1 netmask 255.255.255.0 broadcast 
192.168.1.255 up
+failsafe_ip ()
+{
+   localDEVICE="$1"# ARG1
+   localIP="192.168.1.1"
+   local  MASK="255.255.255.0"
+   local BROADCAST="$( /bin/ipcalc.sh $IP $MASK | sed -n 
's/^BROADCAST=\(.*\)/\1/p' )"
+   local   PRE="$( /bin/ipcalc.sh $IP $MASK | sed -n 
's/^PREFIX=\(.*\)/\1/p')"
+
+   ifconfig $DEVICE $IP netmask $MASK broadcast $BROADCAST up
+
+   [ "$?" -ne 0 ] && { # 
returncode not 0 -> ifconfig n/a -> fallback to ip
+
+   ip addr add dev $DEVICE $IP/$PRE broadcast +# 
broadcast is calculated (is this clean? we calc it anyway)
+   ip link set dev $DEVICE arp on  # maybe 
not necessary
+   ip link set dev $DEVICE up
+   }
+
+   netmsg $BROADCAST "set up $IP/$PRE dev $DEVICE"
+   netmsg $BROADCAST "Entering Failsafe!"
 }
 
-failsafe() {
+failsafe ()
+{
[ -n "$ifname" ] && grep "$ifname" /proc/net/dev >/dev/null && {
-   failsafe_ip
-   netmsg 192.168.1.255 "Entering Failsafe!"
+   failsafe_ip $ifname
telnetd -l /bin/login <> /dev/null 2>&1
}
+
lock /tmp/.failsafe
ash --login
 }
@@ -20,7 +39,7 @@
 mount proc /proc -t proc
 mount sysfs /sys -t sysfs
 
-size=$(awk '/MemTotal:/ {l=5242880;mt=($2*1024);print((s=mt/2) /dev/null; then



signature.asc
Description: Digital signature
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
http://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH] refactoring ifconfig->ip, /usr/share/udhcpc/default.script

2008-05-17 Thread Bastian Bittorf
this is a bit more, integrating fallback for
ifconfig AND route...this script needs some rewrite,
because it was and is ugly in some sections

bye, Bastian <[EMAIL PROTECTED]>

Index: package/base-files/files/usr/share/udhcpc/default.script
===
--- package/base-files/files/usr/share/udhcpc/default.script(Revision 11157)
+++ package/base-files/files/usr/share/udhcpc/default.script(Arbeitskopie)
@@ -27,6 +27,12 @@
 case "$1" in
deconfig)
ifconfig $interface 0.0.0.0
+
+   [ "$?" -ne 0 ] && { # returncode not 0 -> 
ifconfig n/a -> fallback using ip
+   
+   ip addr flush dev $interface
+   }
+
hotplug_event ifdown
;;
renew|bound)
@@ -34,16 +40,51 @@
netmask ${subnet:-255.255.255.0} \
broadcast ${broadcast:-+}
 
+   [ "$?" -ne 0 ] && { # returncode not 0 -> 
ifconfig n/a -> fallback using ip
+
+   PRE="$( /bin/ipcalc.sh $ip ${subnet:-255.255.255.0} | 
sed -n 's/^PREFIX=\(.*\)/\1/p' )"
+
+   ip addr add dev $interface ${ip}/${PRE} broadcast +
+   }
+
[ -n "$router" ] && {
for i in $router ; do
echo "adding router $i"
route add default gw $i dev $interface
-   valid="$valid|$i"
 
+   [ "$?" -ne 0 ] && { # returncode not 0 -> 
route n/a -> fallback using ip
+
+   ip route add default via "$i" dev 
"$interface"
+   }
+
+   valid="$valid|$i"   # leads to: 
"ip_1|ip_2|ip_n"
+
done
 
+   #
+   # this section needs a refactoring,
+   # because it is unreadable
+   #
+
echo "deleting old routes"
+
+   # this leads to something like:
+   # route del -net 0.0.0.0 gw 1.2.3.4 ; ...
+
$(route -n | awk '/^0.0.0.0\W{9}('$valid')\W/ {next} 
/^0.0.0.0/ {print "route del -net "$1" gw "$2";"}')
+   
+   [ "$?" -ne 0 ] && { # returncode not 0 -> 
route n/a -> fallback using ip
+   
+   IFS="|" # field separator, set
+   for IP in $valid; do
+   
+   # leads to something like:
+   # ip route del default via 1.2.3.4 dev 
br0  ; ...
+
+   $( ip route list exact 0/0 via $IP | 
sed "s/default dev \(.*\)/ip route del default via $IP dev \1 ;/" )
+   done
+   unset IFS   # back to normal 
separator
+   }
}

[ -n "$dns" ] && {



signature.asc
Description: Digital signature
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
http://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH] refactoring ifconfig->ip , cleanups, /etc/preinit

2008-05-17 Thread Bastian Bittorf
* Florian Fainelli <[EMAIL PROTECTED]> [17.05.2008 18:40]:

> This awk call calculates the half of the available RAM to later allow 
> base-files setting up a tmpfs of exactly of this size.


wouldt it be better (for understanding) to do something like:

-

while read NUL MEM NUL; do
[ "$MEM" != "used:" ] && {
MEM=$(( $MEM / 2 )) # filling var MEM with
break   # the half of the avail mem 
[bytes]
}
done 

signature.asc
Description: Digital signature
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
http://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH 0/5] BASEFILES, refactoring ifconfig/route -> ip , explanation

2008-05-18 Thread Bastian Bittorf
After discussing some style- and method-related things,
now the hole bunch of basefiles that are affected:

./package/base-files/files/etc/hotplug.d/iface/10-routes
./package/base-files/files/etc/preinit
./package/base-files/files/lib/network/config.sh
./package/base-files/files/sbin/ifdown
./package/base-files/files/usr/share/udhcpc/default.script

(i've just grep'ed all basefiles for "ifconfig " and "route ")

Signed-off-by: Bastian Bittorf <[EMAIL PROTECTED]>



signature.asc
Description: Digital signature
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
http://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH 2/5] BASEFILES, refactoring ifconfig/route -> ip , /etc/preinit

2008-05-18 Thread Bastian Bittorf
I've also added one more netmsg and moved the
netmsg direct into the function, for not having
two different places for the broadcast-address.

Signed-off-by: Bastian Bittorf <[EMAIL PROTECTED]>

---

Index: package/base-files/files/etc/preinit
===
--- package/base-files/files/etc/preinit(Revision 11157)
+++ package/base-files/files/etc/preinit(Arbeitskopie)
@@ -1,18 +1,35 @@
 #!/bin/sh
 # Copyright (C) 2006 OpenWrt.org
+
 export PATH=/bin:/sbin:/usr/bin:/usr/sbin
 . /etc/diag.sh
 
-failsafe_ip() {
-   ifconfig $ifname 192.168.1.1 netmask 255.255.255.0 broadcast 
192.168.1.255 up
+failsafe_ip ()
+{
+   localDEVICE="$1"# ARG1
+   localIP="192.168.1.1"
+   local  MASK="255.255.255.0"
+   local BROADCAST="$( /bin/ipcalc.sh $IP $MASK | sed -n 
's/^BROADCAST=\(.*\)/\1/p' )"
+   local   PRE="$( /bin/ipcalc.sh $IP $MASK | sed -n 
's/^PREFIX=\(.*\)/\1/p')"
+
+   ifconfig $DEVICE $IP netmask $MASK broadcast $BROADCAST up || {
+   # 
ifconfig n/a -> fallback to ip
+   ip addr add dev $DEVICE $IP/$PRE broadcast +# 
broadcast is calculated (is this clean? we calc it anyway)
+   ip link set dev $DEVICE arp on  # maybe 
not necessary
+   ip link set dev $DEVICE up
+   }
+
+   netmsg $BROADCAST "set up $IP/$PRE dev $DEVICE" # 
would'nt it be better to send
+   netmsg $BROADCAST "Entering Failsafe!"  # this 
messages to 255.255.255.255 ?
 }
 
-failsafe() {
+failsafe ()
+{
[ -n "$ifname" ] && grep "$ifname" /proc/net/dev >/dev/null && {
-   failsafe_ip
-   netmsg 192.168.1.255 "Entering Failsafe!"
+   failsafe_ip $ifname
telnetd -l /bin/login <> /dev/null 2>&1
}
+
lock /tmp/.failsafe
ash --login
 }



signature.asc
Description: Digital signature
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
http://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH 3/5] BASEFILES, refactoring ifconfig/route -> ip , /sbin/ifdown

2008-05-18 Thread Bastian Bittorf
Only a small one.
Maybe we should also flush the ip-address?

Signed-off-by: Bastian Bittorf <[EMAIL PROTECTED]>

---

Index: package/base-files/files/sbin/ifdown
===
--- package/base-files/files/sbin/ifdown(Revision 11157)
+++ package/base-files/files/sbin/ifdown(Arbeitskopie)
@@ -58,7 +58,9 @@
 
 [ ."$device" != ."$ifname" ] || device=
 for dev in $ifname $device; do
-   ifconfig "$dev" 0.0.0.0 down >/dev/null 2>/dev/null
+   ifconfig "$dev" 0.0.0.0 down >/dev/null 2>/dev/null || {
+   ip link set dev "$dev" down >/dev/null 2>/dev/null  # 
ifconfig n/a -> fallback using ip
+   }
 done
 
 config_get iftype "$cfg" type



signature.asc
Description: Digital signature
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
http://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH 1/5] BASEFILES, refactoring ifconfig/route -> ip , /etc/hotplug.d/iface/10-routes

2008-05-18 Thread Bastian Bittorf
maybe we should define variables for some things, so
we must not double-generate things...
Is it correct to use absolut path: /usb/sbin/ip ?

Signed-off-by: Bastian Bittorf <[EMAIL PROTECTED]>

---

Index: package/base-files/files/etc/hotplug.d/iface/10-routes
===
--- package/base-files/files/etc/hotplug.d/iface/10-routes  (Revision 11157)
+++ package/base-files/files/etc/hotplug.d/iface/10-routes  (Arbeitskopie)
@@ -28,7 +28,11 @@
dest="${netmask:+-net "$target" netmask "$netmask"}"
dest="${dest:--host "$target"}"

-   /sbin/route add $dest gw "$gateway" ${dev:+dev "$dev"} ${metric:+ 
metric "$metric"}
+   /sbin/route add $dest gw "$gateway" ${dev:+dev "$dev"} ${metric:+ 
metric "$metric"} || {
+   # route is n/a -> fallback by using ip
+   local PRE="$( /bin/ipcalc.sh $target $netmask | sed -n 
's/^PREFIX=\(.*\)/\1/p' )"
+   /usr/sbin/ip route add ${target}/${PRE} via "$gateway" 
${dev:+dev "$dev"} ${metric:+ metric "$metric"}  
+   }
 }
 
 add_route6() {
@@ -56,7 +60,10 @@
return 1
}
 
-   /sbin/route -A inet6 add $target gw "$gateway" ${dev:+dev "$dev"} 
${metric:+ metric "$metric"}
+   /sbin/route -A inet6 add $target gw "$gateway" ${dev:+dev "$dev"} 
${metric:+ metric "$metric"} || {
+   # route is n/a -> fallback by using ip
+   /usr/sbin/ip route add $target via "$gateway" ${dev:+dev 
"$dev"} ${metric:+ metric "$metric"}
+   }
 }
 
 case "$ACTION" in




signature.asc
Description: Digital signature
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
http://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH 4/5] BASEFILES, refactoring ifconfig/route -> ip , /usr/share/udhcpc/default.script

2008-05-18 Thread Bastian Bittorf
This is a big more, added also some comments.
Maybe some things can be more readable. Can the
originator do some explanations in code?

Signed-off-by: Bastian Bittorf <[EMAIL PROTECTED]>

---

Index: package/base-files/files/usr/share/udhcpc/default.script
===
--- package/base-files/files/usr/share/udhcpc/default.script(Revision 11157)
+++ package/base-files/files/usr/share/udhcpc/default.script(Arbeitskopie)
@@ -26,24 +26,43 @@
 
 case "$1" in
deconfig)
-   ifconfig $interface 0.0.0.0
+   ifconfig $interface 0.0.0.0 || {
+   ip addr flush dev $interface# ifconfig n/a 
-> fallback using ip
+   }
+
hotplug_event ifdown
;;
renew|bound)
-   ifconfig $interface $ip \
-   netmask ${subnet:-255.255.255.0} \
-   broadcast ${broadcast:-+}
+   MASK="${subnet:-255.255.255.0}"
 
+   ifconfig $interface $ip netmask $MASK broadcast ${broadcast:-+} 
|| {
+   PRE="$( /bin/ipcalc.sh $ip $MASK | sed -n 
's/^PREFIX=\(.*\)/\1/p' )"# ifconfig n/a -> fallback using ip
+   ip addr add dev $interface ${ip}/${PRE} broadcast +
+   }
+
[ -n "$router" ] && {
for i in $router ; do
echo "adding router $i"
-   route add default gw $i dev $interface
-   valid="$valid|$i"
+   route add default gw $i dev $interface || {
+   ip route add default via "$i" dev 
"$interface"  # route n/a -> fallback using ip
+   }
 
+   valid="$valid|$i"   # leads to: 
"ip_1|ip_2|ip_n"
+
done
+   # this section needs 
refactoring, because it is unreadable
+   echo "deleting old routes"  # this leads to 
something like: route del -net 0.0.0.0 gw 1.2.3.4 ; ...
 
-   echo "deleting old routes"
-   $(route -n | awk '/^0.0.0.0\W{9}('$valid')\W/ {next} 
/^0.0.0.0/ {print "route del -net "$1" gw "$2";"}')
+   $(route -n | awk '/^0.0.0.0\W{9}('$valid')\W/ {next} 
/^0.0.0.0/ {print "route del -net "$1" gw "$2";"}') || {
+   # route n/a -> fallback 
using ip
+   IFS="|" # field separator, set
+   for IP in $valid; do
+   
+   # leads to something like: ip route del 
default via 1.2.3.4 dev br0  ; ...
+   $( ip route list exact 0/0 via $IP | 
sed "s/default dev \(.*\)/ip route del default via $IP dev \1 ;/" )
+   done
+   unset IFS   # back to normal 
separator
+   }
}

[ -n "$dns" ] && {



signature.asc
Description: Digital signature
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
http://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH 0/5] BASEFILES, refactoring ifconfig/route -> ip , explanation

2008-05-18 Thread Bastian Bittorf
* Felix Fietkau <[EMAIL PROTECTED]> [18.05.2008 15:23]:

> The problem with this approach is that it relies only on the return type 
> of the ifconfig/route calls. I'd suggest the following approach:
> In a central include file, check for presence of the ip applet or  
> executable and if it is not present, define a function ip(), which calls  
> ifconfig and route.

sounds fine, will deliver a patch this week.

bye, Bastian.


signature.asc
Description: Digital signature
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
http://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] watchdog/crondog : (was Re: [PATCH 7/7] atheros: ar531x watchdog support)

2008-05-21 Thread Bastian Bittorf
* Axel Gembe <[EMAIL PROTECTED]> [20.05.2008 20:30]:

> Good to hear that. I really dislike targets without proper watchdog so I

I forgot that to mention on wcw2008/berlin, but IMHO those
hardware-watchdog are a nice-to-have but not really necessary.
Practically i have never seen an router which totally hangs,
so the hw-watchdog would'nt react...

In Weimar we had _some_ situations, were do to memory-problems
nearly all tasks were killed. Even sshd/dropbear and cron were
killed. So sven-ola added an kernel-module named "crondog", which
is early loaded and not killed in lowmem situations.
A cron-called-script has to do this regulary:

test -e /dev/misc/crondog && echo > /dev/misc/crondog   # sign of life

If crond is'nt running anymore (and so the checkers cant check:
"is sshd running?", "is httpd running?",...), then the device
reboots hard.

Maybe we can include this as a package in openWRT.
Does anyone have enough skill the enhance the crondog.o-driver
to be more platform independent, so we can include this as a
package in menuconfig?

Greeting from Weimar, Bastian


signature.asc
Description: Digital signature
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
http://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] watchdog/crondog

2008-05-21 Thread Bastian Bittorf
* Axel Gembe <[EMAIL PROTECTED]> [21.05.2008 14:00]:

> First, you can't guarantee which processes are killed by the oom-killer,  
> so you might end up with dropbear killed and cron still running.
> I think what you need is softdog. It is in the current kernels and does  
> just that.
> Just configure the watchdog program to check for whatever condition  
> (i.e. pid files) you want.

Yes, but thats not the trick - we changed from softdog to crondog,
because many routers were unreachable (only pingable) but never rebooted.

The trick is IMHO:
start the watchdog-refresher as late as possible during
/etc/init.d/, because usually in lowmem-situations the
later started tasks are killed as first...or am I wrong?

bye, Bastian


signature.asc
Description: Digital signature
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
http://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] Interest in a openwrt router database to partially replace TOH?

2013-12-09 Thread bittorf wireless )) Bastian Bittorf
* Joris de Vries  [09.12.2013 09:52]:
> > the hardware is known to be out of production. Looking for
> > hardware to buy to run OpenWRT is... less than straightforward.
> 
> This is so absolutely true. I have gone as far as to create a snippet (link 
> included, please don't click, it's horrible) that I run from Chrome's 
> DevTools in order to hide all the routers that have less than certain amounts 
> of flash and ram (https://gist.github.com/Zsub/7868748), but more 
> comprehensive filtering would be very welcome!
>

so this leads to some new fields we should take for the upcoming(tm) template:

RAM = e.g. '64'
FLASH = e.g. '8'

and i propose

WIFI = '2.4' or '2.4 + 5' or '2.4/5'

which means:
1 x 2.4 ghz,
1 x 2.4 and 1 x 5 ghz (sumultan),
1 x 2.4 or 5ghz (either or)

bye, bastian
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


<    3   4   5   6   7   8