chiark / gitweb /
Allow "-" as exroutes parameter.
authorian <ian>
Fri, 24 Sep 1999 16:05:10 +0000 (16:05 +0000)
committerian <ian>
Fri, 24 Sep 1999 16:05:10 +0000 (16:05 +0000)
ipif/service.c

index ad55e30..0050dd2 100644 (file)
@@ -15,7 +15,7 @@
  *      <peer-addr> is the address of the point-to-point peer.
  *  <prefix>/<mask>,<prefix>/<mask>,...
  *      List of additional routes to add for this interface.
- *      May be the empty argument.
+ *      May be the empty argument, or `-' if this is problematic.
  *
  * <config> is either
  *    <gid>,<prefix>/<len>[,<junk>]
@@ -431,29 +431,32 @@ static void parseargs(int argc, const char *const *argv) {
   addrnet_mustdiffer("local-addr",localaddr,~0UL, "peer-addr",peeraddr,~0UL);
   
   carg= *++argv;
-  for (nexroutes=0;
-       carg && *carg;
-       nexroutes++) {
-    if (nexroutes == MAXEXROUTES)
-      fatal("too many extra routes (only %d allowed)",MAXEXROUTES);
-    sprintf(erwhatbuf,"route#%d",nexroutes);
+  if (strcmp(carg,"-")) {
+    for (nexroutes=0;
+        carg && *carg;
+        nexroutes++) {
+      if (nexroutes == MAXEXROUTES)
+       fatal("too many extra routes (only %d allowed)",MAXEXROUTES);
+      sprintf(erwhatbuf,"route#%d",nexroutes);
     
-    eat_prefixmask(&carg,erwhatbuf, ",",0, &routeaddr,&routemask,0);
-    if (routemask == ~0UL) {
-      addrnet_mustdiffer(erwhatbuf,routeaddr,routemask, "local-addr",localaddr,~0UL);
-      addrnet_mustdiffer(erwhatbuf,routeaddr,routemask, "peer-addr",peeraddr,~0UL);
-    }
-    for (i=0; i<nexroutes; i++) {
-      sprintf(erwhatbuf2,"route#%d",i);
-      addrnet_mustdiffer(erwhatbuf,routeaddr,routemask,
-                        erwhatbuf2,exroutes[i].prefix,exroutes[i].mask);
+      eat_prefixmask(&carg,erwhatbuf, ",",0, &routeaddr,&routemask,0);
+      if (routemask == ~0UL) {
+       addrnet_mustdiffer(erwhatbuf,routeaddr,routemask, "local-addr",localaddr,~0UL);
+       addrnet_mustdiffer(erwhatbuf,routeaddr,routemask, "peer-addr",peeraddr,~0UL);
+      }
+      for (i=0; i<nexroutes; i++) {
+       sprintf(erwhatbuf2,"route#%d",i);
+       addrnet_mustdiffer(erwhatbuf,routeaddr,routemask,
+                          erwhatbuf2,exroutes[i].prefix,exroutes[i].mask);
+      }
+      exroutes[nexroutes].prefix= routeaddr;
+      exroutes[nexroutes].mask= routemask;
+      exroutes[nexroutes].allow= 0;
+      ip2txt(routeaddr,exroutes[nexroutes].prefixtxt);
+      ip2txt(routemask,exroutes[nexroutes].masktxt);
     }
-    exroutes[nexroutes].prefix= routeaddr;
-    exroutes[nexroutes].mask= routemask;
-    exroutes[nexroutes].allow= 0;
-    ip2txt(routeaddr,exroutes[nexroutes].prefixtxt);
-    ip2txt(routemask,exroutes[nexroutes].masktxt);
   }
+
   ip2txt(localaddr,localtxt);
   ip2txt(peeraddr,peertxt);
 }