summaryrefslogtreecommitdiffstats
path: root/lib/sockopt.c
diff options
context:
space:
mode:
authorMartin Winter <mwinter@opensourcerouting.org>2017-01-24 16:42:11 +0100
committerMartin Winter <mwinter@opensourcerouting.org>2017-01-25 18:40:55 +0100
commit950765ba1034f125ae8106f1f554bb362abfa108 (patch)
tree32a5f1810e77c23a5ecfb029df6081e267207435 /lib/sockopt.c
parentpimd: Add missing 'socket' getopt cmdline option (diff)
downloadfrr-950765ba1034f125ae8106f1f554bb362abfa108.tar.xz
frr-950765ba1034f125ae8106f1f554bb362abfa108.zip
lib: Add set_socket_path() to sockopt.c to override the path element of a (vty) socket (but keep filename)
Signed-off-by: Martin Winter <mwinter@opensourcerouting.org>
Diffstat (limited to 'lib/sockopt.c')
-rw-r--r--lib/sockopt.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/sockopt.c b/lib/sockopt.c
index 461e1f7f5..570b575a7 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, char *defaultpath, char *newpath, int maxsize)
+{
+ 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)
{