Lines Matching refs:buf

91 proxy_read_line(int fd, char *buf, size_t bufsz)  in proxy_read_line()  argument
98 if (atomicio(read, fd, buf + off, 1) != 1) in proxy_read_line()
101 if (buf[off] == '\r') in proxy_read_line()
103 if (buf[off] == '\n') { in proxy_read_line()
104 buf[off] = '\0'; in proxy_read_line()
184 unsigned char buf[1024]; in socks_connect() local
215 buf[0] = SOCKS_V5; in socks_connect()
216 buf[1] = 1; in socks_connect()
217 buf[2] = SOCKS_NOAUTH; in socks_connect()
218 cnt = atomicio(vwrite, proxyfd, buf, 3); in socks_connect()
222 cnt = atomicio(read, proxyfd, buf, 2); in socks_connect()
226 if (buf[1] == SOCKS_NOMETHOD) in socks_connect()
237 buf[0] = SOCKS_V5; in socks_connect()
238 buf[1] = SOCKS_CONNECT; in socks_connect()
239 buf[2] = 0; in socks_connect()
240 buf[3] = SOCKS_DOMAIN; in socks_connect()
241 buf[4] = hlen; in socks_connect()
242 memcpy(buf + 5, host, hlen); in socks_connect()
243 memcpy(buf + 5 + hlen, &serverport, sizeof serverport); in socks_connect()
248 buf[0] = SOCKS_V5; in socks_connect()
249 buf[1] = SOCKS_CONNECT; in socks_connect()
250 buf[2] = 0; in socks_connect()
251 buf[3] = SOCKS_IPV4; in socks_connect()
252 memcpy(buf + 4, &in4->sin_addr, sizeof in4->sin_addr); in socks_connect()
253 memcpy(buf + 8, &in4->sin_port, sizeof in4->sin_port); in socks_connect()
258 buf[0] = SOCKS_V5; in socks_connect()
259 buf[1] = SOCKS_CONNECT; in socks_connect()
260 buf[2] = 0; in socks_connect()
261 buf[3] = SOCKS_IPV6; in socks_connect()
262 memcpy(buf + 4, &in6->sin6_addr, sizeof in6->sin6_addr); in socks_connect()
263 memcpy(buf + 20, &in6->sin6_port, in socks_connect()
271 cnt = atomicio(vwrite, proxyfd, buf, wlen); in socks_connect()
275 cnt = atomicio(read, proxyfd, buf, 4); in socks_connect()
278 if (buf[1] != 0) { in socks_connect()
280 socks5_strerror(buf[1])); in socks_connect()
282 switch (buf[3]) { in socks_connect()
284 cnt = atomicio(read, proxyfd, buf + 4, 6); in socks_connect()
289 cnt = atomicio(read, proxyfd, buf + 4, 18); in socks_connect()
302 buf[0] = SOCKS_V4; in socks_connect()
303 buf[1] = SOCKS_CONNECT; /* connect */ in socks_connect()
304 memcpy(buf + 2, &in4->sin_port, sizeof in4->sin_port); in socks_connect()
305 memcpy(buf + 4, &in4->sin_addr, sizeof in4->sin_addr); in socks_connect()
306 buf[8] = 0; /* empty username */ in socks_connect()
309 cnt = atomicio(vwrite, proxyfd, buf, wlen); in socks_connect()
313 cnt = atomicio(read, proxyfd, buf, 8); in socks_connect()
316 if (buf[1] != 90) { in socks_connect()
318 socks4_strerror(buf[1])); in socks_connect()
329 r = snprintf(buf, sizeof(buf), in socks_connect()
333 r = snprintf(buf, sizeof(buf), in socks_connect()
337 if (r < 0 || (size_t)r >= sizeof(buf)) in socks_connect()
339 r = strlen(buf); in socks_connect()
341 cnt = atomicio(vwrite, proxyfd, buf, r); in socks_connect()
351 r = snprintf(buf, sizeof(buf), "%s:%s", in socks_connect()
354 if (r == -1 || (size_t)r >= sizeof(buf) || in socks_connect()
355 b64_ntop(buf, strlen(buf), resp, in socks_connect()
358 r = snprintf(buf, sizeof(buf), "Proxy-Authorization: " in socks_connect()
360 if (r < 0 || (size_t)r >= sizeof(buf)) in socks_connect()
362 r = strlen(buf); in socks_connect()
363 if ((cnt = atomicio(vwrite, proxyfd, buf, r)) != r) in socks_connect()
366 explicit_bzero(buf, sizeof buf); in socks_connect()
374 proxy_read_line(proxyfd, buf, sizeof(buf)); in socks_connect()
376 (strncmp(buf, "HTTP/1.0 407 ", 12) == 0 || in socks_connect()
377 strncmp(buf, "HTTP/1.1 407 ", 12) == 0)) { in socks_connect()
384 } else if (strncmp(buf, "HTTP/1.0 200 ", 12) != 0 && in socks_connect()
385 strncmp(buf, "HTTP/1.1 200 ", 12) != 0) in socks_connect()
386 errx(1, "Proxy error: \"%s\"", buf); in socks_connect()
390 proxy_read_line(proxyfd, buf, sizeof(buf)); in socks_connect()
391 if (*buf == '\0') in socks_connect()
394 if (*buf != '\0') in socks_connect()