This patch adds support for the "routes" option (backported from busybox 
1.18.0):
http://git.busybox.net/busybox/commit/?id=7d3a48a003cd645edfae2b404493688022b13193
http://git.busybox.net/busybox/commit/?id=ad8def2d8ad980a5b759c32a220828ea1248e5b6

Signed-off-by: Alexey Solovyev <alex.solov...@gmail.com>

Index: package/base-files/files/usr/share/udhcpc/default.script
===================================================================
--- package/base-files/files/usr/share/udhcpc/default.script    (revision 25238)
+++ package/base-files/files/usr/share/udhcpc/default.script    (working copy)
@@ -77,6 +77,8 @@
                change_state network "$ifc" gateway "$router"
        }
 
+       # STATIC ROUTES
+       [ -n "$routes" ] && set_classless_routes $(echo "$routes" | sed -e 
"s,/,/32 ,g")
        # CIDR STATIC ROUTES (rfc3442)
        [ -n "$staticroutes" ] && set_classless_routes $staticroutes
        [ -n "$msstaticroutes" ] && set_classless_routes $msstaticroutes
Index: package/busybox/patches/246-udhcpc_add_routes_option.patch
===================================================================
--- package/busybox/patches/246-udhcpc_add_routes_option.patch  (revision 0)
+++ package/busybox/patches/246-udhcpc_add_routes_option.patch  (revision 0)
@@ -0,0 +1,76 @@
+diff -urpN a/networking/udhcp/common.c b/networking/udhcp/common.c
+--- a/networking/udhcp/common.c        2011-01-13 23:00:25.000000000 +0300
++++ b/networking/udhcp/common.c        2011-01-21 15:44:39.000000000 +0300
+@@ -37,6 +37,7 @@ const struct dhcp_optflag dhcp_optflags[
+       { OPTION_U8                               , 0x17 }, /* DHCP_IP_TTL      
  */
+       { OPTION_U16                              , 0x1a }, /* DHCP_MTU         
  */
+       { OPTION_IP                   | OPTION_REQ, 0x1c }, /* DHCP_BROADCAST   
  */
++      { OPTION_IP_PAIR | OPTION_LIST            , 0x21 }, /* DHCP_ROUTES      
  */
+       { OPTION_STRING                           , 0x28 }, /* DHCP_NIS_DOMAIN  
  */
+       { OPTION_IP | OPTION_LIST                 , 0x29 }, /* DHCP_NIS_SERVER  
  */
+       { OPTION_IP | OPTION_LIST     | OPTION_REQ, 0x2a }, /* DHCP_NTP_SERVER  
  */
+@@ -98,6 +99,7 @@ const char dhcp_option_strings[] ALIGN1 
+       "ipttl" "\0"       /* DHCP_IP_TTL         */
+       "mtu" "\0"         /* DHCP_MTU            */
+       "broadcast" "\0"   /* DHCP_BROADCAST      */
++      "routes" "\0"      /* DHCP_ROUTES         */
+       "nisdomain" "\0"   /* DHCP_NIS_DOMAIN     */
+       "nissrv" "\0"      /* DHCP_NIS_SERVER     */
+       "ntpsrv" "\0"      /* DHCP_NTP_SERVER     */
+diff -urpN a/networking/udhcp/common.h b/networking/udhcp/common.h
+--- a/networking/udhcp/common.h        2011-01-13 23:00:25.000000000 +0300
++++ b/networking/udhcp/common.h        2011-01-21 15:42:30.000000000 +0300
+@@ -124,6 +124,7 @@ enum {
+ //#define DHCP_IP_TTL           0x17
+ //#define DHCP_MTU              0x1a
+ //#define DHCP_BROADCAST        0x1c
++//#define DHCP_ROUTES           0x21
+ //#define DHCP_NIS_DOMAIN       0x28
+ //#define DHCP_NIS_SERVER       0x29
+ //#define DHCP_NTP_SERVER       0x2a
+diff -urpN a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c
+--- a/networking/udhcp/dhcpc.c 2011-01-13 23:00:25.000000000 +0300
++++ b/networking/udhcp/dhcpc.c 2011-01-21 15:49:02.000000000 +0300
+@@ -107,6 +107,7 @@ static NOINLINE char *xmalloc_optname_op
+ 
+       /* option points to OPT_DATA, need to go back and get OPT_LEN */
+       len = option[OPT_LEN - OPT_DATA];
++
+       type = optflag->flags & OPTION_TYPE_MASK;
+       optlen = dhcp_option_lengths[type];
+       upper_length = len_of_option_as_string[type] * ((unsigned)len / 
(unsigned)optlen);
+@@ -115,17 +116,16 @@ static NOINLINE char *xmalloc_optname_op
+       dest += sprintf(ret, "%s=", opt_name);
+ 
+       while (len >= optlen) {
++              unsigned ip_ofs = 0;
++
+               switch (type) {
+               case OPTION_IP_PAIR:
+                       dest += sprint_nip(dest, "", option);
+                       *dest++ = '/';
+-                      option += 4;
+-                      optlen = 4;
++                      ip_ofs = 4;
++                      /* fall through */
+               case OPTION_IP:
+-                      dest += sprint_nip(dest, "", option);
+-// TODO: it can be a list only if (optflag->flags & OPTION_LIST).
+-// Should we bail out/warn if we see multi-ip option which is
+-// not allowed to be such? For example, DHCP_BROADCAST...
++                      dest += sprint_nip(dest, "", option + ip_ofs);
+                       break;
+ //            case OPTION_BOOLEAN:
+ //                    dest += sprintf(dest, *option ? "yes" : "no");
+@@ -300,7 +300,10 @@ static NOINLINE char *xmalloc_optname_op
+               } /* switch */
+               option += optlen;
+               len -= optlen;
+-              if (len <= 0)
++// TODO: it can be a list only if (optflag->flags & OPTION_LIST).
++// Should we bail out/warn if we see multi-ip option which is
++// not allowed to be such (for example, DHCP_BROADCAST)? -
++              if (len <= 0 /* || !(optflag->flags & OPTION_LIST) */)
+                       break;
+               *dest++ = ' ';
+               *dest = '\0';

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

Reply via email to