Lines Matching refs:c

28 	void (*cb)(void *ctx, struct http_client *c,
38 struct http_client *c = eloop_data; in http_client_timeout() local
39 wpa_printf(MSG_DEBUG, "HTTP: Timeout (c=%p)", c); in http_client_timeout()
40 c->cb(c->cb_ctx, c, HTTP_CLIENT_TIMEOUT); in http_client_timeout()
47 struct http_client *c = cookie; in http_client_got_response() local
52 eloop_cancel_timeout(http_client_timeout, c, NULL); in http_client_got_response()
55 if (httpread_hdr_type_get(c->hread) == HTTPREAD_HDR_TYPE_REPLY) in http_client_got_response()
57 int reply_code = httpread_reply_code_get(c->hread); in http_client_got_response()
61 inet_ntoa(c->dst.sin_addr), in http_client_got_response()
62 ntohs(c->dst.sin_port)); in http_client_got_response()
63 c->cb(c->cb_ctx, c, HTTP_CLIENT_OK); in http_client_got_response()
67 inet_ntoa(c->dst.sin_addr), in http_client_got_response()
68 ntohs(c->dst.sin_port)); in http_client_got_response()
69 c->cb(c->cb_ctx, c, HTTP_CLIENT_INVALID_REPLY); in http_client_got_response()
72 c->cb(c->cb_ctx, c, HTTP_CLIENT_INVALID_REPLY); in http_client_got_response()
75 c->cb(c->cb_ctx, c, HTTP_CLIENT_TIMEOUT); in http_client_got_response()
78 c->cb(c->cb_ctx, c, HTTP_CLIENT_FAILED); in http_client_got_response()
86 struct http_client *c = eloop_ctx; in http_client_tx_ready() local
90 send_len = wpabuf_len(c->req) - c->req_pos; in http_client_tx_ready()
93 inet_ntoa(c->dst.sin_addr), ntohs(c->dst.sin_port), in http_client_tx_ready()
94 (unsigned long) wpabuf_len(c->req), in http_client_tx_ready()
97 res = send(c->sd, wpabuf_head_u8(c->req) + c->req_pos, send_len, 0); in http_client_tx_ready()
101 eloop_unregister_sock(c->sd, EVENT_TYPE_WRITE); in http_client_tx_ready()
102 c->cb(c->cb_ctx, c, HTTP_CLIENT_FAILED); in http_client_tx_ready()
109 res, (unsigned long) wpabuf_len(c->req), in http_client_tx_ready()
111 c->req_pos += res; in http_client_tx_ready()
116 inet_ntoa(c->dst.sin_addr), ntohs(c->dst.sin_port)); in http_client_tx_ready()
117 eloop_unregister_sock(c->sd, EVENT_TYPE_WRITE); in http_client_tx_ready()
118 wpabuf_free(c->req); in http_client_tx_ready()
119 c->req = NULL; in http_client_tx_ready()
121 c->hread = httpread_create(c->sd, http_client_got_response, c, in http_client_tx_ready()
122 c->max_response, HTTP_CLIENT_TIMEOUT_SEC); in http_client_tx_ready()
123 if (c->hread == NULL) { in http_client_tx_ready()
124 c->cb(c->cb_ctx, c, HTTP_CLIENT_FAILED); in http_client_tx_ready()
133 struct http_client *c, in http_client_addr() argument
137 struct http_client *c; in http_client_addr() local
139 c = os_zalloc(sizeof(*c)); in http_client_addr()
140 if (c == NULL) in http_client_addr()
142 c->sd = -1; in http_client_addr()
143 c->dst = *dst; in http_client_addr()
144 c->max_response = max_response; in http_client_addr()
145 c->cb = cb; in http_client_addr()
146 c->cb_ctx = cb_ctx; in http_client_addr()
148 c->sd = socket(AF_INET, SOCK_STREAM, 0); in http_client_addr()
149 if (c->sd < 0) in http_client_addr()
152 if (fcntl(c->sd, F_SETFL, O_NONBLOCK) != 0) { in http_client_addr()
158 if (connect(c->sd, (struct sockaddr *) dst, sizeof(*dst))) { in http_client_addr()
171 if (eloop_register_sock(c->sd, EVENT_TYPE_WRITE, http_client_tx_ready, in http_client_addr()
172 c, NULL) || in http_client_addr()
174 http_client_timeout, c, NULL)) in http_client_addr()
177 c->req = req; in http_client_addr()
179 return c; in http_client_addr()
182 http_client_free(c); in http_client_addr()
239 struct http_client *c, in http_client_url() argument
244 struct http_client *c; in http_client_url() local
274 c = http_client_addr(&dst, req, max_response, cb, cb_ctx); in http_client_url()
275 if (c == NULL) { in http_client_url()
280 return c; in http_client_url()
284 void http_client_free(struct http_client *c) in http_client_free() argument
286 if (c == NULL) in http_client_free()
288 httpread_destroy(c->hread); in http_client_free()
289 wpabuf_free(c->req); in http_client_free()
290 if (c->sd >= 0) { in http_client_free()
291 eloop_unregister_sock(c->sd, EVENT_TYPE_WRITE); in http_client_free()
292 close(c->sd); in http_client_free()
294 eloop_cancel_timeout(http_client_timeout, c, NULL); in http_client_free()
295 os_free(c); in http_client_free()
299 struct wpabuf * http_client_get_body(struct http_client *c) in http_client_get_body() argument
301 if (c->hread == NULL) in http_client_get_body()
303 wpabuf_set(&c->body, httpread_data_get(c->hread), in http_client_get_body()
304 httpread_length_get(c->hread)); in http_client_get_body()
305 return &c->body; in http_client_get_body()
309 char * http_client_get_hdr_line(struct http_client *c, const char *tag) in http_client_get_hdr_line() argument
311 if (c->hread == NULL) in http_client_get_hdr_line()
313 return httpread_hdr_line_get(c->hread, tag); in http_client_get_hdr_line()