diff options
author | Mikael Magnusson <mikma@users.sourceforge.net> | 2023-07-25 21:50:22 +0000 |
---|---|---|
committer | Mikael Magnusson <mikma@users.sourceforge.net> | 2023-07-25 21:50:22 +0000 |
commit | 224a8c55e09a455feddbaf41f44a60683d72f37f (patch) | |
tree | 9a07a292ea8f1fafee4f1784d4006870fdf9b2d7 /svr-runopts.c | |
parent | 41d4b4e7f791825b8e5b2979e49bc0f5409380e9 (diff) |
WIP bindtodevicebindtodevice
Diffstat (limited to 'svr-runopts.c')
-rw-r--r-- | svr-runopts.c | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/svr-runopts.c b/svr-runopts.c index 36ea26b..af966fb 100644 --- a/svr-runopts.c +++ b/svr-runopts.c @@ -351,6 +351,7 @@ void svr_getopts(int argc, char ** argv) { if (svr_opts.portcount == 0) { svr_opts.ports[0] = m_strdup(DROPBEAR_DEFPORT); svr_opts.addresses[0] = m_strdup(DROPBEAR_DEFADDRESS); + svr_opts.devices[0] = NULL; svr_opts.portcount = 1; } @@ -437,6 +438,7 @@ void svr_getopts(int argc, char ** argv) { static void addportandaddress(const char* spec) { char *spec_copy = NULL, *myspec = NULL, *port = NULL, *address = NULL; + char *device = NULL; if (svr_opts.portcount < DROPBEAR_MAX_PORTS) { @@ -444,7 +446,8 @@ static void addportandaddress(const char* spec) { spec_copy = m_strdup(spec); myspec = spec_copy; - if (myspec[0] == '[') { + if ((myspec = strchr(myspec, '['))) { + myspec[0] = '\0'; myspec++; port = strchr(myspec, ']'); if (!port) { @@ -457,9 +460,26 @@ static void addportandaddress(const char* spec) { /* Missing port -> exit */ dropbear_exit("Missing port"); } + + device = spec_copy; + if (device[strlen(device)-1] == ':') + device[strlen(device)-1] = '\0'; } else { + myspec = spec_copy; + /* search for ':', that separates address and port */ port = strrchr(myspec, ':'); + + if (port) { + device = strchr(myspec, ':'); + if (port == device) { + device = NULL; + } else if (device) /* always true */ { + device[0] = '\0'; + myspec = device + 1; + device = spec_copy; + } + } } if (!port) { @@ -483,6 +503,10 @@ static void addportandaddress(const char* spec) { } svr_opts.ports[svr_opts.portcount] = m_strdup(port); svr_opts.addresses[svr_opts.portcount] = m_strdup(address); + if (device) + svr_opts.devices[svr_opts.portcount] = m_strdup(device); + else + svr_opts.devices[svr_opts.portcount] = NULL; svr_opts.portcount++; m_free(spec_copy); } |