Fix some compile errors.
This commit is contained in:
parent
b3aa5332c8
commit
f35b2c35cb
@ -101,7 +101,7 @@ struct hub_probe* probe_create(struct hub_info* hub, int sd, struct ip_addr_enca
|
||||
return NULL; /* OOM */
|
||||
|
||||
probe->hub = hub;
|
||||
probe->connection = (struct net_connection*) hub_malloc(sizeof(struct net_connection));
|
||||
probe->connection = net_con_create();
|
||||
net_con_initialize(probe->connection, sd, probe_net_event, probe, NET_EVENT_READ);
|
||||
net_con_set_timeout(probe->connection, TIMEOUT_CONNECTED);
|
||||
|
||||
|
@ -39,7 +39,7 @@ struct hub_user* user_create(struct hub_info* hub, struct net_connection* con, s
|
||||
{
|
||||
struct hub_user* user = NULL;
|
||||
|
||||
LOG_TRACE("user_create(), hub=%p, con[sd=%d]", hub, con->sd);
|
||||
LOG_TRACE("user_create(), hub=%p, con[sd=%d]", hub, net_con_get_sd(con));
|
||||
|
||||
user = (struct hub_user*) hub_malloc_zero(sizeof(struct hub_user));
|
||||
|
||||
|
@ -16,24 +16,9 @@
|
||||
/* FIXME: Meant for debugging */
|
||||
#define NET_EVENT_SET 0x0800
|
||||
|
||||
static inline int net_con_flag_get(struct net_connection* con, unsigned int flag)
|
||||
{
|
||||
return con->flags & flag;
|
||||
}
|
||||
|
||||
static inline void net_con_flag_set(struct net_connection* con, unsigned int flag)
|
||||
{
|
||||
con->flags |= flag;
|
||||
}
|
||||
|
||||
static inline void net_con_flag_unset(struct net_connection* con, unsigned int flag)
|
||||
{
|
||||
con->flags &= ~flag;
|
||||
}
|
||||
|
||||
#define NET_CON_STRUCT_BASIC \
|
||||
int sd; /** socket descriptor */ \
|
||||
unsigned int flags; /** Connection flags */ \
|
||||
uint32_t flags; /** Connection flags */ \
|
||||
void* ptr; /** data pointer */ \
|
||||
net_connection_cb callback; /** Callback function */ \
|
||||
time_t last_recv; /** Timestamp for last recv() */ \
|
||||
|
@ -26,6 +26,42 @@ struct net_connection
|
||||
struct event timeout; /** Used for internal timeout handling */
|
||||
};
|
||||
|
||||
int net_con_get_sd(struct net_connection* con)
|
||||
{
|
||||
return con->sd;
|
||||
}
|
||||
|
||||
void* net_con_get_ptr(struct net_connection* con)
|
||||
{
|
||||
return con->ptr;
|
||||
}
|
||||
|
||||
struct net_connection* net_con_create()
|
||||
{
|
||||
struct net_connection* con = (struct net_connection*) hub_malloc(sizeof(struct net_connection));
|
||||
return con;
|
||||
}
|
||||
|
||||
static inline int net_con_flag_get(struct net_connection* con, unsigned int flag)
|
||||
{
|
||||
return con->flags & flag;
|
||||
}
|
||||
|
||||
static inline void net_con_flag_set(struct net_connection* con, unsigned int flag)
|
||||
{
|
||||
con->flags |= flag;
|
||||
}
|
||||
|
||||
static inline void net_con_flag_unset(struct net_connection* con, unsigned int flag)
|
||||
{
|
||||
con->flags &= ~flag;
|
||||
}
|
||||
|
||||
void net_con_destroy(struct net_connection* con)
|
||||
{
|
||||
hub_free(con);
|
||||
}
|
||||
|
||||
static inline int net_con_convert_to_libevent_mask(int ev)
|
||||
{
|
||||
int events = 0;
|
||||
|
@ -42,6 +42,7 @@ struct net_timer
|
||||
void* ptr;
|
||||
};
|
||||
|
||||
|
||||
extern void net_timer_initialize(struct net_timer* timer, net_timeout_cb callback, void* ptr);
|
||||
extern void net_timer_reset(struct net_timer* timer, int seconds);
|
||||
extern void net_timer_shutdown(struct net_timer* timer);
|
||||
@ -49,6 +50,8 @@ extern void net_timer_shutdown(struct net_timer* timer);
|
||||
extern int net_con_get_sd(struct net_connection* con);
|
||||
extern void* net_con_get_ptr(struct net_connection* con);
|
||||
|
||||
extern struct net_connection* net_con_create();
|
||||
extern void net_con_destroy(struct net_connection*);
|
||||
extern void net_con_initialize(struct net_connection* con, int sd, net_connection_cb callback, const void* ptr, int events);
|
||||
extern void net_con_reinitialize(struct net_connection* con, net_connection_cb callback, const void* ptr, int events);
|
||||
extern void net_con_update(struct net_connection* con, int events);
|
||||
|
Loading…
Reference in New Issue
Block a user