diff options
-rw-r--r-- | openbsd-compat/port-net.c | 40 | ||||
-rw-r--r-- | openbsd-compat/port-net.h | 7 |
2 files changed, 43 insertions, 4 deletions
diff --git a/openbsd-compat/port-net.c b/openbsd-compat/port-net.c index d384b1454..f6e32ad49 100644 --- a/openbsd-compat/port-net.c +++ b/openbsd-compat/port-net.c | |||
@@ -41,7 +41,44 @@ | |||
41 | * including tun/tap forwarding and routing domains. | 41 | * including tun/tap forwarding and routing domains. |
42 | */ | 42 | */ |
43 | 43 | ||
44 | #if defined(SYS_RDOMAIN_XXX) | 44 | #if defined(SYS_RDOMAIN_LINUX) || defined(SSH_TUN_LINUX) |
45 | #include <linux/if.h> | ||
46 | #endif | ||
47 | |||
48 | #if defined(SYS_RDOMAIN_LINUX) | ||
49 | char * | ||
50 | sys_get_rdomain(int fd) | ||
51 | { | ||
52 | char dev[IFNAMSIZ + 1]; | ||
53 | socklen_t len = sizeof(dev) - 1; | ||
54 | |||
55 | if (getsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, dev, &len) == -1) { | ||
56 | error("%s: cannot determine VRF for fd=%d : %s", | ||
57 | __func__, fd, strerror(errno)); | ||
58 | return NULL; | ||
59 | } | ||
60 | dev[len] = '\0'; | ||
61 | return strdup(dev); | ||
62 | } | ||
63 | |||
64 | int | ||
65 | sys_set_rdomain(int fd, const char *name) | ||
66 | { | ||
67 | if (setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, | ||
68 | name, strlen(name)) == -1) { | ||
69 | error("%s: setsockopt(%d, SO_BINDTODEVICE, %s): %s", | ||
70 | __func__, fd, name, strerror(errno)); | ||
71 | return -1; | ||
72 | } | ||
73 | return 0; | ||
74 | } | ||
75 | |||
76 | int | ||
77 | valid_rdomain(const char *name) | ||
78 | { | ||
79 | return 0; | ||
80 | } | ||
81 | #elif defined(SYS_RDOMAIN_XXX) | ||
45 | /* XXX examples */ | 82 | /* XXX examples */ |
46 | char * | 83 | char * |
47 | sys_get_rdomain(int fd) | 84 | sys_get_rdomain(int fd) |
@@ -84,7 +121,6 @@ sys_set_process_rdomain(const char *name) | |||
84 | */ | 121 | */ |
85 | 122 | ||
86 | #if defined(SSH_TUN_LINUX) | 123 | #if defined(SSH_TUN_LINUX) |
87 | #include <linux/if.h> | ||
88 | #include <linux/if_tun.h> | 124 | #include <linux/if_tun.h> |
89 | 125 | ||
90 | int | 126 | int |
diff --git a/openbsd-compat/port-net.h b/openbsd-compat/port-net.h index 715e9fb34..8aa4085f4 100644 --- a/openbsd-compat/port-net.h +++ b/openbsd-compat/port-net.h | |||
@@ -31,14 +31,17 @@ int sys_tun_infilter(struct ssh *, struct Channel *, char *, int); | |||
31 | u_char *sys_tun_outfilter(struct ssh *, struct Channel *, u_char **, size_t *); | 31 | u_char *sys_tun_outfilter(struct ssh *, struct Channel *, u_char **, size_t *); |
32 | #endif | 32 | #endif |
33 | 33 | ||
34 | #if defined(SYS_RDOMAIN_XXX) | 34 | #if defined(SYS_RDOMAIN_LINUX) |
35 | # define HAVE_SYS_GET_RDOMAIN | 35 | # define HAVE_SYS_GET_RDOMAIN |
36 | # define HAVE_SYS_SET_RDOMAIN | 36 | # define HAVE_SYS_SET_RDOMAIN |
37 | # define HAVE_SYS_SET_PROCESS_RDOMAIN | ||
38 | # define HAVE_SYS_VALID_RDOMAIN | 37 | # define HAVE_SYS_VALID_RDOMAIN |
39 | char *sys_get_rdomain(int fd); | 38 | char *sys_get_rdomain(int fd); |
40 | int sys_set_rdomain(int fd, const char *name); | 39 | int sys_set_rdomain(int fd, const char *name); |
41 | int valid_rdomain(const char *name); | 40 | int valid_rdomain(const char *name); |
41 | #endif | ||
42 | |||
43 | #if defined(SYS_RDOMAIN_XXX) | ||
44 | # define HAVE_SYS_SET_PROCESS_RDOMAIN | ||
42 | void sys_set_process_rdomain(const char *name); | 45 | void sys_set_process_rdomain(const char *name); |
43 | #endif | 46 | #endif |
44 | 47 | ||