Moved the ipaddr object into the connection object.

This commit is contained in:
Jan Vidar Krey
2009-08-03 18:14:34 +02:00
parent 27c71a75ee
commit 4e43746c1b
11 changed files with 24 additions and 45 deletions

View File

@@ -82,7 +82,7 @@ static void net_con_event(int fd, short ev, void *arg)
#endif
}
void net_con_initialize(struct net_connection* con, int sd, const void* ptr, int events)
void net_con_initialize(struct net_connection* con, int sd, struct ip_addr_encap* addr, const void* ptr, int events)
{
LOG_DEBUG("net_con_initialize: sd=%d, ptr=%p", sd, ptr);
con->sd = sd;
@@ -90,6 +90,12 @@ void net_con_initialize(struct net_connection* con, int sd, const void* ptr, int
con->last_send = time(0);
con->last_recv = con->last_send;
/** IP address of peer */
if (addr)
{
memcpy(&con->ipaddr, addr, sizeof(struct ip_addr_encap));
}
if (events & EV_READ) net_con_flag_set(con, NET_WANT_READ);
if (events & EV_WRITE) net_con_flag_set(con, NET_WANT_WRITE);

View File

@@ -28,6 +28,7 @@ struct net_connection
unsigned int flags; /** Connection flags */
void* ptr; /** data pointer */
struct event event; /** libevent struct for read/write events */
struct ip_addr_encap ipaddr; /** IP address of peer */
time_t last_recv; /** Timestamp for last recv() */
time_t last_send; /** Timestamp for last send() */
#ifdef SSL_SUPPORT
@@ -37,7 +38,7 @@ struct net_connection
#endif /* SSL_SUPPORT */
};
extern void net_con_initialize(struct net_connection* con, int sd, const void* ptr, int events);
extern void net_con_initialize(struct net_connection* con, int sd, struct ip_addr_encap*, const void* ptr, int events);
extern void net_con_update(struct net_connection* con, int events);
extern void net_con_close(struct net_connection* con);