miniupnpc-libevent: use service type from root description

This commit is contained in:
Thomas Bernard 2014-11-17 10:22:34 +01:00
parent 37cb73329a
commit 3065bc570f
2 changed files with 18 additions and 8 deletions

View File

@ -1,4 +1,4 @@
/* $Id: miniupnpc-libevent.c,v 1.10 2014/11/14 11:37:45 nanard Exp $ */
/* $Id: miniupnpc-libevent.c,v 1.11 2014/11/17 09:17:38 nanard Exp $ */
/* miniupnpc-libevent
* Copyright (c) 2008-2014, Thomas BERNARD <miniupnp@free.fr>
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
@ -342,9 +342,13 @@ static void upnpc_desc_received(struct evhttp_request * req, void * pvoid)
printIGD(&igd);
#endif /* DEBUG */
p->control_conn_url = build_url_string(igd.urlbase, p->root_desc_location, igd.first.controlurl);
p->conn_service_type = strdup(igd.first.servicetype);
p->control_cif_url = build_url_string(igd.urlbase, p->root_desc_location, igd.CIF.controlurl);
debug_printf("control_conn_url='%s'\n", p->control_conn_url);
debug_printf("control_cif_url='%s'\n", p->control_cif_url);
p->cif_service_type = strdup(igd.CIF.servicetype);
debug_printf("control_conn_url='%s'\n (service_type='%s')\n",
p->control_conn_url, p->conn_service_type);
debug_printf("control_cif_url='%s'\n (service_type='%s')\n",
p->control_cif_url, p->cif_service_type);
p->ready_cb(evhttp_request_get_response_code(req), p->cb_data);
}
@ -592,8 +596,12 @@ int upnpc_finalize(upnpc_t * p)
p->root_desc_location = NULL;
free(p->control_cif_url);
p->control_cif_url = NULL;
free(p->cif_service_type);
p->cif_service_type = NULL;
free(p->control_conn_url);
p->control_conn_url = NULL;
free(p->conn_service_type);
p->conn_service_type = NULL;
if(p->ssdp_socket >= 0) {
close(p->ssdp_socket);
p->ssdp_socket = -1;
@ -621,14 +629,14 @@ int upnpc_finalize(upnpc_t * p)
int upnpc_get_external_ip_address(upnpc_t * p)
{
return upnpc_send_soap_request(p, p->control_conn_url,
"urn:schemas-upnp-org:service:WANIPConnection:1",
p->conn_service_type/*"urn:schemas-upnp-org:service:WANIPConnection:1"*/,
"GetExternalIPAddress", NULL, 0);
}
int upnpc_get_link_layer_max_rate(upnpc_t * p)
{
return upnpc_send_soap_request(p, p->control_cif_url,
"urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1",
p->cif_service_type/*"urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1"*/,
"GetCommonLinkProperties", NULL, 0);
}
@ -649,7 +657,7 @@ int upnpc_delete_port_mapping(upnpc_t * p,
args[2].elt = "NewProtocol";
args[2].val = proto;
return upnpc_send_soap_request(p, p->control_conn_url,
"urn:schemas-upnp-org:service:WANIPConnection:1",
p->conn_service_type,/*"urn:schemas-upnp-org:service:WANIPConnection:1",*/
"DeletePortMapping",
args, 3);
}
@ -687,7 +695,7 @@ int upnpc_add_port_mapping(upnpc_t * p,
args[7].elt = "NewLeaseDuration";
args[7].val = lease_duration_str;
return upnpc_send_soap_request(p, p->control_conn_url,
"urn:schemas-upnp-org:service:WANIPConnection:1",
p->conn_service_type/*"urn:schemas-upnp-org:service:WANIPConnection:1"*/,
"AddPortMapping",
args, 8);
}

View File

@ -1,4 +1,4 @@
/* $Id: miniupnpc-libevent.h,v 1.5 2014/11/14 10:55:37 nanard Exp $ */
/* $Id: miniupnpc-libevent.h,v 1.6 2014/11/17 09:17:38 nanard Exp $ */
/* miniupnpc-libevent
* Copyright (c) 2008-2014, Thomas BERNARD <miniupnp@free.fr>
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
@ -42,7 +42,9 @@ typedef struct {
char * root_desc_location;
struct evhttp_connection * desc_conn;
char * control_cif_url;
char * cif_service_type;
char * control_conn_url;
char * conn_service_type;
struct evhttp_connection * soap_conn;
struct NameValueParserData soap_response_data;
upnpc_callback_fn ready_cb;