diff options
author | jp161948 <none@none> | 2007-10-26 07:29:16 -0700 |
---|---|---|
committer | jp161948 <none@none> | 2007-10-26 07:29:16 -0700 |
commit | 9b03ea0f916d36e6ec001b90683afcaee8e29a40 (patch) | |
tree | c15358939ef4c4b1318e3f463c0482391fbfb094 /usr/src/cmd/ssh/libssh/common/misc.c | |
parent | 6f1fe22336d824f58bda6680410a6b1c2a72ea2d (diff) | |
download | illumos-joyent-9b03ea0f916d36e6ec001b90683afcaee8e29a40.tar.gz |
PSARC/2007/610 ssh(1) binding address for port forwarding
6506674 allow specific binding address to be used with -LRD options for ssh(1)
6619347 SunSSH is not fully compatible with RFC4254 with regard to port forwarding
Diffstat (limited to 'usr/src/cmd/ssh/libssh/common/misc.c')
-rw-r--r-- | usr/src/cmd/ssh/libssh/common/misc.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/usr/src/cmd/ssh/libssh/common/misc.c b/usr/src/cmd/ssh/libssh/common/misc.c index 6431255004..dcd7902021 100644 --- a/usr/src/cmd/ssh/libssh/common/misc.c +++ b/usr/src/cmd/ssh/libssh/common/misc.c @@ -306,6 +306,48 @@ convtime(const char *s) return total; } +/* + * Search for next delimiter between hostnames/addresses and ports. + * Argument may be modified (for termination). + * Returns *cp if parsing succeeds. + * *cp is set to the start of the next delimiter, if one was found. + * If this is the last field, *cp is set to NULL. + */ +char * +hpdelim(char **cp) +{ + char *s, *old; + + if (cp == NULL || *cp == NULL) + return NULL; + + old = s = *cp; + if (*s == '[') { + if ((s = strchr(s, ']')) == NULL) + return NULL; + else + s++; + } else if ((s = strpbrk(s, ":/")) == NULL) + s = *cp + strlen(*cp); /* skip to end (see first case below) */ + + switch (*s) { + case '\0': + *cp = NULL; /* no more fields*/ + break; + + case ':': + case '/': + *s = '\0'; /* terminate */ + *cp = s + 1; + break; + + default: + return NULL; + } + + return old; +} + char * cleanhostname(char *host) { |