Home | History | Annotate | Download | only in wps

Lines Matching defs:srv

23 	struct http_server *srv;
45 struct http_server *srv = req->srv;
51 srv->cb(srv->cb_ctx, req);
61 static struct http_request * http_request_init(struct http_server *srv, int fd,
66 if (srv->request_count >= HTTP_SERVER_MAX_CONNECTIONS) {
75 req->srv = srv;
94 struct http_server *srv;
99 srv = req->srv;
101 r = srv->requests;
107 srv->requests = r->next;
108 srv->request_count--;
203 struct http_server *srv = eloop_ctx;
207 conn = accept(srv->fd, (struct sockaddr *) &addr, &addr_len);
216 req = http_request_init(srv, conn, &addr);
222 req->next = srv->requests;
223 srv->requests = req;
224 srv->request_count++;
234 struct http_server *srv;
237 srv = os_zalloc(sizeof(*srv));
238 if (srv == NULL)
240 srv->cb = cb;
241 srv->cb_ctx = cb_ctx;
243 srv->fd = socket(AF_INET, SOCK_STREAM, 0);
244 if (srv->fd < 0)
247 if (setsockopt(srv->fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) < 0)
255 if (fcntl(srv->fd, F_SETFL, O_NONBLOCK) < 0)
258 srv->port = 49152;
260 srv->port = port;
267 sin.sin_port = htons(srv->port);
268 if (bind(srv->fd, (struct sockaddr *) &sin, sizeof(sin)) == 0)
272 if (++srv->port == 65535 || port >= 0)
277 "%s", srv->port, strerror(errno));
280 if (listen(srv->fd, 10 /* max backlog */) < 0)
282 if (fcntl(srv->fd, F_SETFL, O_NONBLOCK) < 0)
284 if (eloop_register_sock(srv->fd, EVENT_TYPE_READ, http_server_cb,
285 srv, NULL))
289 inet_ntoa(*addr), srv->port);
291 return srv;
294 http_server_deinit(srv);
299 void http_server_deinit(struct http_server *srv)
301 if (srv == NULL)
303 if (srv->fd >= 0) {
304 eloop_unregister_sock(srv->fd, EVENT_TYPE_READ);
305 close(srv->fd);
307 http_request_free_all(srv->requests);
309 os_free(srv);
313 int http_server_get_port(struct http_server *srv)
315 return srv->port;