Added the peer's socket information to the connection structure. The

information is passed along during the initialization of the structure.
This commit is contained in:
Robert James Kaes 2002-05-23 18:23:29 +00:00
parent 9d0c65ad86
commit 09b1b9b925
2 changed files with 20 additions and 5 deletions

View File

@ -1,4 +1,4 @@
/* $Id: conns.c,v 1.10 2002-04-18 21:43:52 rjkaes Exp $ /* $Id: conns.c,v 1.11 2002-05-23 18:23:29 rjkaes Exp $
* *
* Create and free the connection structure. One day there could be * Create and free the connection structure. One day there could be
* other connnection related tasks put here, but for now the header * other connnection related tasks put here, but for now the header
@ -22,11 +22,11 @@
#include "buffer.h" #include "buffer.h"
#include "conns.h" #include "conns.h"
#include "heap.h"
#include "stats.h" #include "stats.h"
#include "utils.h"
struct conn_s * struct conn_s *
initialize_conn(int client_fd) initialize_conn(int client_fd, const char* ipaddr, const char* string_addr)
{ {
struct conn_s *connptr; struct conn_s *connptr;
struct buffer_s *cbuffer, *sbuffer; struct buffer_s *cbuffer, *sbuffer;
@ -68,6 +68,9 @@ initialize_conn(int client_fd)
connptr->remote_content_length = -1; connptr->remote_content_length = -1;
connptr->client_ip_addr = safestrdup(ipaddr);
connptr->client_string_addr = safestrdup(string_addr);
update_stats(STAT_OPEN); update_stats(STAT_OPEN);
return connptr; return connptr;
@ -105,6 +108,11 @@ destroy_conn(struct conn_s *connptr)
if (connptr->error_string) if (connptr->error_string)
safefree(connptr->error_string); safefree(connptr->error_string);
if (connptr->client_ip_addr)
safefree(connptr->client_ip_addr);
if (connptr->client_string_addr)
safefree(connptr->client_string_addr);
safefree(connptr); safefree(connptr);
update_stats(STAT_CLOSE); update_stats(STAT_CLOSE);

View File

@ -1,4 +1,4 @@
/* $Id: conns.h,v 1.9 2002-04-18 21:43:53 rjkaes Exp $ /* $Id: conns.h,v 1.10 2002-05-23 18:23:29 rjkaes Exp $
* *
* See 'conns.c' for a detailed description. * See 'conns.c' for a detailed description.
* *
@ -43,6 +43,12 @@ struct conn_s {
/* A Content-Length value from the remote server */ /* A Content-Length value from the remote server */
long remote_content_length; long remote_content_length;
/*
* Store the client's IP and hostname information
*/
char* client_ip_addr;
char* client_string_addr;
/* /*
* Store the incoming request's HTTP protocol. * Store the incoming request's HTTP protocol.
*/ */
@ -55,7 +61,8 @@ struct conn_s {
/* /*
* Functions for the creation and destruction of a connection structure. * Functions for the creation and destruction of a connection structure.
*/ */
extern struct conn_s* initialize_conn(int client_fd); extern struct conn_s* initialize_conn(int client_fd, const char* ipaddr,
const char* string_addr);
extern void destroy_conn(struct conn_s *connptr); extern void destroy_conn(struct conn_s *connptr);
#endif #endif