Commit 39998cb2 authored by Yann Diorcet's avatar Yann Diorcet

Fix memory leak and add local address funciton

parent a1f11352
......@@ -37,6 +37,8 @@ typedef struct _upnp_igd_port_mapping {
int remote_port;
const char* description;
void *cookie;
} upnp_igd_port_mapping;
typedef void (*upnp_igd_callback_function)(void *cookie, upnp_igd_event event, void *arg);
......@@ -46,6 +48,7 @@ typedef struct _upnp_igd_context upnp_igd_context;
upnp_igd_context* upnp_igd_create(upnp_igd_callback_function cb_fct, upnp_igd_print_function print_fct, void *cookie);
void upnp_igd_destroy(upnp_igd_context *igd_ctxt);
char *upnp_igd_get_local_ipaddress(upnp_igd_context *igd_ctxt);
const char *upnp_igd_get_external_ipaddress(upnp_igd_context *igd_ctxt);
const char *upnp_igd_get_connection_status(upnp_igd_context *igd_ctxt);
int upnp_igd_get_nat_enabled(upnp_igd_context *igd_ctxt);
......
......@@ -987,6 +987,10 @@ upnp_igd_context* upnp_igd_create(upnp_igd_callback_function cb_fct, upnp_igd_pr
}
upnp_igd_print(igd_ctxt, UPNP_IGD_MESSAGE, "UPnP IGD Initialized ipaddress:%s port:%u\n", ip_address ? ip_address : "{NULL}", port);
if(ip_address != NULL) {
free(ip_address);
}
upnp_igd_print(igd_ctxt, UPNP_IGD_DEBUG, "UPnP IGD client registering...\n");
ret = UpnpRegisterClient(upnp_igd_callback, igd_ctxt, &igd_ctxt->upnp_handle);
if (ret != UPNP_E_SUCCESS) {
......
......@@ -84,6 +84,20 @@ int upnp_igd_port_mapping_callback(Upnp_EventType event_type, void* event, void
return ret;
}
/********************************************************************************
* upnp_igd_get_local_ipaddress
*
* Description:
* Return the local ip address or NULL if doesn't exist.
*
* Parameters:
* igd_ctxt -- The upnp igd context
*
********************************************************************************/
char *upnp_igd_get_local_ipaddress(upnp_igd_context *igd_ctxt) {
return UpnpGetServerIpAddress();
}
/********************************************************************************
* upnp_igd_get_external_ipaddress
*
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment