miniupnpc-libevent: split upnpc_init() / upnpc_start()
This commit is contained in:
parent
2d89a05982
commit
f7ec0e17c3
|
@ -606,7 +606,6 @@ int upnpc_init(upnpc_t * p, struct event_base * base, const char * multicastif,
|
|||
{
|
||||
int opt = 1;
|
||||
struct sockaddr_in addr;
|
||||
struct timeval timeout;
|
||||
|
||||
if(p == NULL || base == NULL)
|
||||
return UPNPC_ERR_INVALID_ARGS;
|
||||
|
@ -654,6 +653,14 @@ int upnpc_init(upnpc_t * p, struct event_base * base, const char * multicastif,
|
|||
close(p->ssdp_socket);
|
||||
return UPNPC_ERR_BIND_FAILED;
|
||||
}
|
||||
return UPNPC_OK;
|
||||
}
|
||||
|
||||
int upnpc_start(upnpc_t * p)
|
||||
{
|
||||
struct timeval timeout;
|
||||
if(p == NULL || p->base == NULL)
|
||||
return UPNPC_ERR_INVALID_ARGS;
|
||||
/* event on SSDP */
|
||||
p->ev_ssdp_recv = event_new(p->base, p->ssdp_socket,
|
||||
EV_READ|EV_PERSIST,
|
||||
|
|
|
@ -81,6 +81,8 @@ struct upnpc {
|
|||
int upnpc_init(upnpc_t * p, struct event_base * base, const char * multicastif,
|
||||
upnpc_callback_fn ready_cb, upnpc_callback_fn soap_cb, void * cb_data);
|
||||
|
||||
int upnpc_start(upnpc_t * p);
|
||||
|
||||
int upnpc_finalize(upnpc_t * p);
|
||||
|
||||
int upnpc_get_external_ip_address(upnpc_device_t * p);
|
||||
|
|
|
@ -215,6 +215,10 @@ int main(int argc, char * * argv)
|
|||
fprintf(stderr, "upnpc_init() failed\n");
|
||||
return 1;
|
||||
}
|
||||
if(upnpc_start(&upnp) != UPNPC_OK) {
|
||||
fprintf(stderr, "upnp_start() failed\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
event_base_dispatch(base); /* TODO : check return value */
|
||||
printf("finishing...\n");
|
||||
|
|
Loading…
Reference in New Issue