From d6a20d720cf355f403418515d86f19f6fbc68839 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96man?= Date: Tue, 16 Sep 2008 19:27:16 +0000 Subject: [PATCH] New member in http_connection 'hc_representative' containing username or ipaddress related to current connection --- http.c | 21 +++++++++++++++++---- http.h | 2 +- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/http.c b/http.c index fc3b0f7e..e59cf5e0 100644 --- a/http.c +++ b/http.c @@ -427,7 +427,7 @@ static int process_request(http_connection_t *hc, htsbuf_queue_t *spill) { char *v, *argv[2]; - int n; + int n, rval = -1; uint8_t authbuf[150]; /* Set keep-alive status */ @@ -461,17 +461,30 @@ process_request(http_connection_t *hc, htsbuf_queue_t *spill) } } + if(hc->hc_username != NULL) { + hc->hc_representative = strdup(hc->hc_username); + } else { + hc->hc_representative = malloc(30); + /* Not threadsafe ? */ + snprintf(hc->hc_representative, 30, + "%s", inet_ntoa(hc->hc_peer->sin_addr)); + + } + switch(hc->hc_version) { case RTSP_VERSION_1_0: - return -1; + rval = -1; + break; // rtsp_process_request(hc); return 0; case HTTP_VERSION_1_0: case HTTP_VERSION_1_1: - return http_process_request(hc, spill); + rval = http_process_request(hc, spill); + break; } - return -1; + free(hc->hc_representative); + return rval; } diff --git a/http.h b/http.h index a70b5193..b95bc8df 100644 --- a/http.h +++ b/http.h @@ -41,7 +41,7 @@ LIST_HEAD(rtsp_session_head, rtsp_session); typedef struct http_connection { int hc_fd; struct sockaddr_in *hc_peer; - char *hc_peername; + char *hc_representative; char *hc_url; int hc_keep_alive;