Support routes via interfaces without hops

This commit is contained in:
XANTRONIX Development 2021-12-02 21:06:15 -05:00 committed by XANTRONIX Industrial
parent 595a58f32a
commit b5f31264ac
2 changed files with 33 additions and 6 deletions

View file

@ -175,18 +175,40 @@ static int handle_route(struct context *ctx,
goto error_daemon_route_add; goto error_daemon_route_add;
} }
} else if (strcmp(argv[1], "station") == 0) { } else if (strcmp(argv[1], "station") == 0) {
if (argc < 7 || strcmp(argv[3], "if") != 0 || strcmp(argv[5], "path") != 0) { int hopc = 0;
patty_error_fmt(&ctx->e, "line %d: Invalid station route declaration", char **hops = NULL;
lineno);
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, if (patty_daemon_route_add(ctx->daemon,
argv[4], argv[4],
argv[2], argv[2],
(const char **)&argv[6], (const char **)hops,
argc - 6) < 0) { hopc) < 0) {
patty_error_fmt(&ctx->e, "line %d: Unable to add route for interface %s: %s", patty_error_fmt(&ctx->e, "line %d: Unable to add route for interface %s: %s",
lineno, argv[4], strerror(errno)); lineno, argv[4], strerror(errno));

View file

@ -58,6 +58,11 @@ must be provided:
.It Li pass Ar 12345 .It Li pass Ar 12345
.It Li filter Ar spec .It Li filter Ar spec
.El .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 ... .It Li route station Ar CALLSGN Li if Ar ifname Li path Ar HOP1 Op ...
Add a static route to reach Add a static route to reach
.Ar CALLSGN .Ar CALLSGN