diff options
| author | Donald Sharp <sharpd@cumulusnetworks.com> | 2017-02-02 10:42:51 -0500 |
|---|---|---|
| committer | Donald Sharp <sharpd@cumulusnetworks.com> | 2017-02-02 10:42:51 -0500 |
| commit | 1a35e2e56533f75d68ed30bf24b3c131da4ba950 (patch) | |
| tree | 068c7730ed7a58d5374d8123d81720597b40bbcd /lib/sockopt.c | |
| parent | b384af46d50caaae87e1c7807227ac6b4d87f377 (diff) | |
| parent | 56041a77064fe6924ca55dd4e394777b7a5900d0 (diff) | |
Merge remote-tracking branch 'origin/stable/2.0'
Diffstat (limited to 'lib/sockopt.c')
| -rw-r--r-- | lib/sockopt.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/sockopt.c b/lib/sockopt.c index 2a9f907cb3..91b0602b3a 100644 --- a/lib/sockopt.c +++ b/lib/sockopt.c @@ -29,6 +29,29 @@ #include "sockopt.h" #include "sockunion.h" +/* Replace the path of given defaultpath with newpath, but keep filename */ +void +set_socket_path (char *path, const char *defaultpath, char *newpath, int maxsize) +{ + const char *sock_name; + + sock_name = strrchr(defaultpath, '/'); + if (sock_name) + /* skip '/' */ + sock_name++; + else + /* + * VTYSH_PATH configured as relative path + * during config? Should really never happen for + * sensible config + */ + sock_name = defaultpath; + + strlcpy (path, newpath, maxsize); + strlcat (path, "/", maxsize); + strlcat (path, sock_name, maxsize); +} + void setsockopt_so_recvbuf (int sock, int size) { |
