miniupnpc-libevent: upnpc_set_local_address()
This commit is contained in:
parent
37c4f7dda1
commit
1217512a32
|
@ -680,6 +680,14 @@ int upnpc_start(upnpc_t * p)
|
||||||
return UPNPC_OK;
|
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)
|
static void upnpc_device_finalize(upnpc_device_t * d)
|
||||||
{
|
{
|
||||||
d->state = 0;
|
d->state = 0;
|
||||||
|
|
|
@ -76,11 +76,15 @@ struct upnpc {
|
||||||
upnpc_callback_fn ready_cb;
|
upnpc_callback_fn ready_cb;
|
||||||
upnpc_callback_fn soap_cb;
|
upnpc_callback_fn soap_cb;
|
||||||
void * cb_data;
|
void * cb_data;
|
||||||
|
char * local_address;
|
||||||
|
uint16_t local_port;
|
||||||
};
|
};
|
||||||
|
|
||||||
int upnpc_init(upnpc_t * p, struct event_base * base, const char * multicastif,
|
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);
|
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_start(upnpc_t * p);
|
||||||
|
|
||||||
int upnpc_finalize(upnpc_t * p);
|
int upnpc_finalize(upnpc_t * p);
|
||||||
|
|
|
@ -215,6 +215,7 @@ int main(int argc, char * * argv)
|
||||||
fprintf(stderr, "upnpc_init() failed\n");
|
fprintf(stderr, "upnpc_init() failed\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
upnpc_set_local_address(&upnp, local_address, 50000);
|
||||||
if(upnpc_start(&upnp) != UPNPC_OK) {
|
if(upnpc_start(&upnp) != UPNPC_OK) {
|
||||||
fprintf(stderr, "upnp_start() failed\n");
|
fprintf(stderr, "upnp_start() failed\n");
|
||||||
return 1;
|
return 1;
|
||||||
|
|
Loading…
Reference in New Issue