Lines Matching refs:buf

39   unsigned char buf[NI_MAXHOST + 16];  in socks4a_connect()  local
59 buf[0] = 0x04; in socks4a_connect()
60 buf[1] = 0x01; in socks4a_connect()
63 memcpy(buf + 2, &port_n, sizeof(port_n)); in socks4a_connect()
66 buf[4] = 0x00; in socks4a_connect()
67 buf[5] = 0x00; in socks4a_connect()
68 buf[6] = 0x00; in socks4a_connect()
69 buf[7] = 0x01; in socks4a_connect()
72 buf[8] = 0x00; in socks4a_connect()
75 memcpy(buf + sz, ctx->host, strlen(ctx->host) + 1); in socks4a_connect()
78 r = ctx->f_send(ctx->p_send, buf, sz); in socks4a_connect()
83 r = ctx->f_recv(ctx->p_recv, buf, 8); in socks4a_connect()
87 if (buf[1] == 0x5a) { in socks4a_connect()
97 unsigned char buf[NI_MAXHOST + 16]; in socks5_connect() local
122 buf[0] = 0x05; in socks5_connect()
123 buf[1] = 0x01; in socks5_connect()
124 buf[2] = 0x00; in socks5_connect()
126 r = ctx->f_send(ctx->p_send, buf, 3); in socks5_connect()
130 r = ctx->f_recv(ctx->p_recv, buf, 2); in socks5_connect()
134 if (buf[0] != 0x05 || buf[1] != 0x00) { in socks5_connect()
135 verb("V: proxy5: auth error %02x %02x", buf[0], buf[1]); in socks5_connect()
148 buf[0] = 0x05; in socks5_connect()
149 buf[1] = 0x01; in socks5_connect()
150 buf[2] = 0x00; in socks5_connect()
151 buf[3] = 0x03; in socks5_connect()
152 buf[4] = strlen(ctx->host); in socks5_connect()
154 memcpy(buf + 5, ctx->host, strlen(ctx->host)); in socks5_connect()
156 memcpy(buf + sz, &port_n, sizeof(port_n)); in socks5_connect()
159 r = ctx->f_send(ctx->p_send, buf, sz); in socks5_connect()
174 r = ctx->f_recv(ctx->p_recv, buf, 4); in socks5_connect()
178 if (buf[0] != 0x05 || buf[1] != 0x00) { in socks5_connect()
179 verb("V: proxy5: connect error %02x %02x", buf[0], buf[1]); in socks5_connect()
183 if (buf[3] == 0x03) { in socks5_connect()
185 r = ctx->f_recv(ctx->p_recv, buf + 4, 1); in socks5_connect()
189 len = buf[4] + 2; in socks5_connect()
191 r = ctx->f_recv(ctx->p_recv, buf + 5, min(len, sizeof(buf))); in socks5_connect()
196 } else if (buf[3] == 0x01) { in socks5_connect()
198 r = ctx->f_recv(ctx->p_recv, buf + 4, 6); in socks5_connect()
209 int sock_gets(proxy_polarssl_ctx *ctx, char *buf, size_t sz) in sock_gets() argument
213 *buf++ = c; in sock_gets()
216 *buf = '\0'; in sock_gets()
226 char buf[4096]; in http_connect() local
229 snprintf(buf, sizeof(buf), "CONNECT %s:%d HTTP/1.1\r\n", in http_connect()
231 r = ctx->f_send(ctx->p_send, (unsigned char *) buf, strlen(buf)); in http_connect()
232 if (r != strlen(buf)) in http_connect()
235 snprintf(buf, sizeof(buf), "Host: %s:%d\r\n", ctx->host, ctx->port); in http_connect()
236 r = ctx->f_send(ctx->p_send, (unsigned char *) buf, strlen(buf)); in http_connect()
237 if (r != strlen(buf)) in http_connect()
239 strcpy(buf, "\r\n"); in http_connect()
240 r = ctx->f_send(ctx->p_send, (unsigned char *) buf, strlen(buf)); in http_connect()
241 if (r != strlen(buf)) in http_connect()
244 r = sock_gets(ctx, buf, sizeof(buf)); in http_connect()
248 if (sscanf(buf, "HTTP/%*s %d", &retcode) != 1) in http_connect()
253 while (!(r = sock_gets(ctx, buf, sizeof(buf)))) { in http_connect()
254 if (!strcmp(buf, "\r\n")) { in http_connect()