diff options
author | Jo-Philipp Wich <jow@openwrt.org> | 2012-07-13 17:10:56 +0000 |
---|---|---|
committer | Jo-Philipp Wich <jow@openwrt.org> | 2012-07-13 17:10:56 +0000 |
commit | 268dea84ecccf5c23b7b95f303c29d02bbc4d4b6 (patch) | |
tree | a10b65cb7ffda97d2ca25344848cb6952b2b6ad7 /package/uhttpd/src/uhttpd-utils.c | |
parent | 89511a81d0c9f6a22db3ca0c4a9975bc98228e01 (diff) | |
download | master-187ad058-268dea84ecccf5c23b7b95f303c29d02bbc4d4b6.tar.gz master-187ad058-268dea84ecccf5c23b7b95f303c29d02bbc4d4b6.tar.bz2 master-187ad058-268dea84ecccf5c23b7b95f303c29d02bbc4d4b6.zip |
[package] uhttpd: various changes
- remove unused variables
- simply ignore command line args which belong to not enabled features
- resolve peer address at accept() time, should solve (#11850)
- remove floating point operations where possible
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@32704 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'package/uhttpd/src/uhttpd-utils.c')
-rw-r--r-- | package/uhttpd/src/uhttpd-utils.c | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/package/uhttpd/src/uhttpd-utils.c b/package/uhttpd/src/uhttpd-utils.c index 50b10e6050..c8d3bb40f4 100644 --- a/package/uhttpd/src/uhttpd-utils.c +++ b/package/uhttpd/src/uhttpd-utils.c @@ -334,7 +334,7 @@ int uh_http_sendf(struct client *cl, struct http_request *req, len = vsnprintf(buffer, sizeof(buffer), fmt, ap); va_end(ap); - if ((req != NULL) && (req->version > 1.0)) + if ((req != NULL) && (req->version > UH_HTTP_VER_1_0)) ensure_ret(uh_http_sendc(cl, buffer, len)); else if (len > 0) ensure_ret(uh_tcp_send(cl, buffer, len)); @@ -348,7 +348,7 @@ int uh_http_send(struct client *cl, struct http_request *req, if (len < 0) len = strlen(buf); - if ((req != NULL) && (req->version > 1.0)) + if ((req != NULL) && (req->version > UH_HTTP_VER_1_0)) ensure_ret(uh_http_sendc(cl, buf, len)); else if (len > 0) ensure_ret(uh_tcp_send(cl, buf, len)); @@ -865,13 +865,13 @@ int uh_auth_check(struct client *cl, struct http_request *req, /* 401 */ uh_http_sendf(cl, NULL, - "HTTP/%.1f 401 Authorization Required\r\n" - "WWW-Authenticate: Basic realm=\"%s\"\r\n" - "Content-Type: text/plain\r\n" - "Content-Length: 23\r\n\r\n" - "Authorization Required\n", - req->version, cl->server->conf->realm - ); + "%s 401 Authorization Required\r\n" + "WWW-Authenticate: Basic realm=\"%s\"\r\n" + "Content-Type: text/plain\r\n" + "Content-Length: 23\r\n\r\n" + "Authorization Required\n", + http_versions[req->version], + cl->server->conf->realm); return 0; } @@ -922,7 +922,8 @@ struct listener * uh_listener_lookup(int sock) } -struct client * uh_client_add(int sock, struct listener *serv) +struct client * uh_client_add(int sock, struct listener *serv, + struct sockaddr_in6 *peer) { struct client *new = NULL; socklen_t sl; @@ -930,6 +931,7 @@ struct client * uh_client_add(int sock, struct listener *serv) if ((new = (struct client *)malloc(sizeof(struct client))) != NULL) { memset(new, 0, sizeof(struct client)); + memcpy(&new->peeraddr, peer, sizeof(new->peeraddr)); new->fd.fd = sock; new->server = serv; @@ -937,14 +939,8 @@ struct client * uh_client_add(int sock, struct listener *serv) new->rpipe.fd = -1; new->wpipe.fd = -1; - /* get remote endpoint addr */ - sl = sizeof(struct sockaddr_in6); - memset(&(new->peeraddr), 0, sl); - getpeername(sock, (struct sockaddr *) &(new->peeraddr), &sl); - /* get local endpoint addr */ sl = sizeof(struct sockaddr_in6); - memset(&(new->servaddr), 0, sl); getsockname(sock, (struct sockaddr *) &(new->servaddr), &sl); new->next = uh_clients; @@ -988,7 +984,7 @@ void uh_client_remove(struct client *cl) for (cur = uh_clients; cur; prv = cur, cur = cur->next) { - if ((cur == cl) || (!cl && cur->dead)) + if (cur == cl) { if (prv) prv->next = cur->next; |