Lines Matching +full:s +full:- +full:mode

33 #include "openbsd-compat/sys-queue.h"
54 socklen_t len = sizeof(dev) - 1; in sys_get_rdomain()
56 if (getsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, dev, &len) == -1) { in sys_get_rdomain()
57 error("%s: cannot determine VRF for fd=%d : %s", in sys_get_rdomain()
69 name, strlen(name)) == -1) { in sys_set_rdomain()
70 error("%s: setsockopt(%d, SO_BINDTODEVICE, %s): %s", in sys_set_rdomain()
72 return -1; in sys_set_rdomain()
87 if ((fd = socket(AF_INET, SOCK_STREAM, 0)) == -1) in sys_valid_rdomain()
90 name, strlen(name)) == -1) { in sys_valid_rdomain()
108 return -1; in sys_set_rdomain()
120 fatal("%s: not supported", __func__); in sys_set_process_rdomain()
126 * uses some preprocessor definitions for various platform-specific
136 * System-specific tunnel open function
144 sys_tun_open(int tun, int mode, char **ifname) in sys_tun_open() argument
147 int fd = -1; in sys_tun_open()
152 if ((fd = open(TUN_CTRL_DEV, O_RDWR)) == -1) { in sys_tun_open()
153 debug("%s: failed to open tunnel control device \"%s\": %s", in sys_tun_open()
155 return (-1); in sys_tun_open()
160 if (mode == SSH_TUNMODE_ETHERNET) { in sys_tun_open()
171 debug("%s: invalid tunnel id %x: %s", __func__, in sys_tun_open()
178 if (ioctl(fd, TUNSETIFF, &ifr) == -1) { in sys_tun_open()
179 debug("%s: failed to configure tunnel (mode %d): %s", __func__, in sys_tun_open()
180 mode, strerror(errno)); in sys_tun_open()
185 debug("%s: tunnel mode %d fd %d", __func__, mode, fd); in sys_tun_open()
187 debug("%s: %s mode %d fd %d", __func__, ifr.ifr_name, mode, fd); in sys_tun_open()
196 return (-1); in sys_tun_open()
209 sys_tun_open(int tun, int mode, char **ifname) in sys_tun_open() argument
213 int fd = -1, sock; in sys_tun_open()
222 if (mode == SSH_TUNMODE_ETHERNET) { in sys_tun_open()
224 debug("%s: no layer 2 tunnelling support", __func__); in sys_tun_open()
225 return (-1); in sys_tun_open()
233 snprintf(name, sizeof(name), "/dev/%s%d", tunbase, tun); in sys_tun_open()
236 for (tun = 100; tun >= 0; tun--) { in sys_tun_open()
237 snprintf(name, sizeof(name), "/dev/%s%d", in sys_tun_open()
243 debug("%s: invalid tunnel %u\n", __func__, tun); in sys_tun_open()
244 return (-1); in sys_tun_open()
248 debug("%s: %s open failed: %s", __func__, name, in sys_tun_open()
250 return (-1); in sys_tun_open()
256 if (mode != SSH_TUNMODE_ETHERNET && in sys_tun_open()
257 ioctl(fd, TUNSIFHEAD, &flag) == -1) { in sys_tun_open()
258 debug("%s: ioctl(%d, TUNSIFHEAD, 1): %s", __func__, fd, in sys_tun_open()
264 debug("%s: %s mode %d fd %d", __func__, name, mode, fd); in sys_tun_open()
266 /* Set the tunnel device operation mode */ in sys_tun_open()
267 snprintf(ifr.ifr_name, sizeof(ifr.ifr_name), "%s%d", tunbase, tun); in sys_tun_open()
268 if ((sock = socket(PF_UNIX, SOCK_STREAM, 0)) == -1) in sys_tun_open()
271 if (ioctl(sock, SIOCGIFFLAGS, &ifr) == -1) in sys_tun_open()
275 if (ioctl(sock, SIOCSIFFLAGS, &ifr) == -1) in sys_tun_open()
290 debug("%s: failed to set %s mode %d: %s", __func__, name, in sys_tun_open()
291 mode, strerror(errno)); in sys_tun_open()
292 return (-1); in sys_tun_open()
297 * System-specific channel filters
303 * IP packets using OpenBSD's numbers.
324 return -1; in sys_tun_infilter()
328 if (len <= sizeof(iph) || len > sizeof(rbuf) - 4) in sys_tun_infilter()
329 return -1; in sys_tun_infilter()
341 return -1; in sys_tun_infilter()
347 if ((r = sshbuf_put_string(c->input, ptr, len)) != 0) in sys_tun_infilter()
348 fatal("%s: buffer error: %s", __func__, ssh_err(r)); in sys_tun_infilter()
361 if ((r = sshbuf_get_string(c->output, data, dlen)) != 0) in sys_tun_outfilter()
362 fatal("%s: buffer error: %s", __func__, ssh_err(r)); in sys_tun_outfilter()
369 *dlen -= sizeof(af); in sys_tun_outfilter()