summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
5e91d4d)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
*
* The remaining arguments are supplied by the (untrusted) caller:
*
*
* The remaining arguments are supplied by the (untrusted) caller:
*
- * <local-addr>,<peer-addr>,<mtu>,<proto>
+ * <local-addr>,<peer-addr>,<mtu>[,[<proto>]]
*
* As for slattach. The only supported protocol is slip.
* Alternatively, set to `debug' to print debugging info and
*
* As for slattach. The only supported protocol is slip.
* Alternatively, set to `debug' to print debugging info and
#include <unistd.h>
#include <stdint.h>
#include <poll.h>
#include <unistd.h>
#include <stdint.h>
#include <poll.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/types.h>
#include <sys/wait.h>
if (len_r) *len_r= len;
}
if (len_r) *len_r= len;
}
+static char *eat_optionalstr(const char **argp,
+ const char *what,
+ const char *def) {
+ ptrdiff_t len;
+ const char *start= *argp;
+ const char *comma= strchr(start, ',');
+ if (comma) {
+ len= comma - start;
+ *argp= comma + 1;
+ } else {
+ len= strlen(start);
+ *argp= start + len;
+ }
+ if (!len) {
+ start= def;
+ len= strlen(def);
+ }
+ char *r = malloc(len+1);
+ if (!r) sysfatal("malloc for command line string");
+ memcpy(r,start,len);
+ r[len]= 0;
+ return r;
+}
+
static int addrnet_isin(unsigned long prefix, unsigned long mask,
unsigned long mprefix, unsigned long mmask) {
return !(~mask & mmask) && (prefix & mmask) == mprefix;
static int addrnet_isin(unsigned long prefix, unsigned long mask,
unsigned long mprefix, unsigned long mmask) {
return !(~mask & mmask) && (prefix & mmask) == mprefix;
peeraddr= eat_addr(&carg,"peer-addr", ",",0);
mtu= eat_number(&carg,"mtu", 576,65536, ",",0);
localallow= peerallow= 0;
peeraddr= eat_addr(&carg,"peer-addr", ",",0);
mtu= eat_number(&carg,"mtu", 576,65536, ",",0);
localallow= peerallow= 0;
-
- if (!strcmp(carg,"debug")) {
+
+ char *protostr = eat_optionalstr(&carg,"protocol","slip");
+ if (!strcmp(protostr,"debug")) {
proto= 0;
} else {
for (cprotop= protos_ok;
proto= 0;
} else {
for (cprotop= protos_ok;
- (proto= *cprotop) && strcmp(proto,carg);
+ (proto= *cprotop) && strcmp(proto,protostr);
cprotop++);
if (!proto) fatal("invalid protocol");
}
cprotop++);
if (!proto) fatal("invalid protocol");
}