diff --git a/bin/pattyd.c b/bin/pattyd.c index a243573..481c1ca 100644 --- a/bin/pattyd.c +++ b/bin/pattyd.c @@ -175,18 +175,40 @@ static int handle_route(struct context *ctx, goto error_daemon_route_add; } } else if (strcmp(argv[1], "station") == 0) { - if (argc < 7 || strcmp(argv[3], "if") != 0 || strcmp(argv[5], "path") != 0) { - patty_error_fmt(&ctx->e, "line %d: Invalid station route declaration", - lineno); + int hopc = 0; + char **hops = NULL; - goto error_invalid_route; + if (argc < 5) { + if (strcmp(argv[3], "if") != 0) { + patty_error_fmt(&ctx->e, "line %d: Invalid station route declaration: Unexpected keyword '%s'", + lineno, argv[3]); + + goto error_invalid_route; + } + } else if (argc > 6) { + if (strcmp(argv[5], "path") != 0) { + patty_error_fmt(&ctx->e, "line %d: Invalid station route declaration: Unexpected keyword '%s'", + lineno, argv[5]); + + goto error_invalid_route; + } + + if (argc < 7) { + patty_error_fmt(&ctx->e, "line %d: Invalid station route declaration: No route path provided", + lineno); + + goto error_invalid_route; + } + + hopc = argc - 6; + hops = &argv[6]; } if (patty_daemon_route_add(ctx->daemon, argv[4], argv[2], - (const char **)&argv[6], - argc - 6) < 0) { + (const char **)hops, + hopc) < 0) { patty_error_fmt(&ctx->e, "line %d: Unable to add route for interface %s: %s", lineno, argv[4], strerror(errno)); diff --git a/doc/pattyd.conf.5 b/doc/pattyd.conf.5 index f79e737..4629a14 100644 --- a/doc/pattyd.conf.5 +++ b/doc/pattyd.conf.5 @@ -58,6 +58,11 @@ must be provided: .It Li pass Ar 12345 .It Li filter Ar spec .El +.It Li route station Ar CALLSGN Li if Ar ifname Li +Add a static route to reach +.Ar CALLSGN +via interface +.Ar ifname . .It Li route station Ar CALLSGN Li if Ar ifname Li path Ar HOP1 Op ... Add a static route to reach .Ar CALLSGN