summaryrefslogtreecommitdiff
path: root/uclient-http.c
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2014-04-07 21:11:58 +0200
committerFelix Fietkau <nbd@openwrt.org>2014-04-07 21:11:58 +0200
commitcb7867a867e45949950e03de0ea845e483ffc6eb (patch)
treef3c3987753d5cd6b53d023144fcf3f2a19b7a166 /uclient-http.c
parent316bcc8c62e195a892813b050a922ebd3935eba2 (diff)
downloaduclient-cb7867a867e45949950e03de0ea845e483ffc6eb.tar.gz
add support for querying local/remote address
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Diffstat (limited to 'uclient-http.c')
-rw-r--r--uclient-http.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/uclient-http.c b/uclient-http.c
index 05dd3aa..ee354c7 100644
--- a/uclient-http.c
+++ b/uclient-http.c
@@ -503,6 +503,7 @@ uclient_http_send_headers(struct uclient_http *uh)
static void uclient_http_headers_complete(struct uclient_http *uh)
{
enum auth_type auth_type = uh->auth_type;
+ socklen_t sl;
uh->state = HTTP_STATE_RECV_DATA;
uh->uc.meta = uh->meta.head;
@@ -515,6 +516,13 @@ static void uclient_http_headers_complete(struct uclient_http *uh)
return;
}
+ memset(&uh->uc.local_addr, 0, sizeof(uh->uc.local_addr));
+ memset(&uh->uc.remote_addr, 0, sizeof(uh->uc.remote_addr));
+
+ sl = sizeof(uh->uc.local_addr);
+ getsockname(uh->ufd.fd.fd, &uh->uc.local_addr.sa, &sl);
+ getpeername(uh->ufd.fd.fd, &uh->uc.remote_addr.sa, &sl);
+
if (uh->uc.cb->header_done)
uh->uc.cb->header_done(&uh->uc);