Commit 5f67fbdb authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Store the socket address in the session


git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@557 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent bc43663f
...@@ -207,6 +207,9 @@ struct sess { ...@@ -207,6 +207,9 @@ struct sess {
struct worker *wrk; struct worker *wrk;
unsigned sockaddrlen;
struct sockaddr *sockaddr;
/* formatted ascii client address */ /* formatted ascii client address */
char addr[TCP_ADDRBUFSIZE]; char addr[TCP_ADDRBUFSIZE];
char port[TCP_PORTBUFSIZE]; char port[TCP_PORTBUFSIZE];
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <sys/uio.h> #include <sys/uio.h>
#include <sys/socket.h>
#include "libvarnish.h" #include "libvarnish.h"
#include "heritage.h" #include "heritage.h"
...@@ -32,6 +33,7 @@ struct sessmem { ...@@ -32,6 +33,7 @@ struct sessmem {
struct sess sess; struct sess sess;
struct http http; struct http http;
struct sockaddr sockaddr[2]; /* INET6 hack */
}; };
/*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
...@@ -166,8 +168,6 @@ SES_New(struct sockaddr *addr, unsigned len) ...@@ -166,8 +168,6 @@ SES_New(struct sockaddr *addr, unsigned len)
{ {
struct sessmem *sm; struct sessmem *sm;
(void)addr; /* XXX */
(void)len; /* XXX */
sm = calloc( sm = calloc(
sizeof *sm + heritage.mem_workspace, sizeof *sm + heritage.mem_workspace,
1); 1);
...@@ -178,6 +178,11 @@ SES_New(struct sockaddr *addr, unsigned len) ...@@ -178,6 +178,11 @@ SES_New(struct sockaddr *addr, unsigned len)
sm->sess.magic = SESS_MAGIC; sm->sess.magic = SESS_MAGIC;
sm->sess.mem = sm; sm->sess.mem = sm;
sm->sess.http = &sm->http; sm->sess.http = &sm->http;
sm->sess.sockaddr = sm->sockaddr;
assert(len < sizeof(sm->sockaddr));
memcpy(sm->sess.sockaddr, addr, len);
sm->sess.sockaddrlen = len;
http_Setup(&sm->http, (void *)(sm + 1), heritage.mem_workspace); http_Setup(&sm->http, (void *)(sm + 1), heritage.mem_workspace);
return (&sm->sess); return (&sm->sess);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment