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 ()
+{
+ local DEVICE="$ifname" # ifname is global known
+ local IP="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 [email protected] http://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
