miniupnpc-libevent: upnpc_set_local_address()

This commit is contained in:
Thomas Bernard 2014-12-12 18:58:06 +01:00
parent 37c4f7dda1
commit 1217512a32
3 changed files with 13 additions and 0 deletions

View File

@ -680,6 +680,14 @@ int upnpc_start(upnpc_t * p)
return UPNPC_OK;
}
int upnpc_set_local_address(upnpc_t * p, const char * address, uint16_t port)
{
if(!p || !address) return UPNPC_ERR_INVALID_ARGS;
p->local_address = strdup(address); /* TODO check error */
p->local_port = port;
return UPNPC_OK;
}
static void upnpc_device_finalize(upnpc_device_t * d)
{
d->state = 0;

View File

@ -76,11 +76,15 @@ struct upnpc {
upnpc_callback_fn ready_cb;
upnpc_callback_fn soap_cb;
void * cb_data;
char * local_address;
uint16_t local_port;
};
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_set_local_address(upnpc_t * p, const char * address, uint16_t port);
int upnpc_start(upnpc_t * p);
int upnpc_finalize(upnpc_t * p);

View File

@ -215,6 +215,7 @@ int main(int argc, char * * argv)
fprintf(stderr, "upnpc_init() failed\n");
return 1;
}
upnpc_set_local_address(&upnp, local_address, 50000);
if(upnpc_start(&upnp) != UPNPC_OK) {
fprintf(stderr, "upnp_start() failed\n");
return 1;