Moved the ipaddr object into the connection object.
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user