use name server from query in SOAP responses
to be finished :)
This commit is contained in:
parent
fde90d221b
commit
a4b97cf105
|
@ -1,5 +1,8 @@
|
|||
$Id: Changelog.txt,v 1.400 2015/08/26 07:32:31 nanard Exp $
|
||||
|
||||
2015/09/15:
|
||||
use name server from query in SOAP responses
|
||||
|
||||
2015/08/25:
|
||||
better bind socket to right interface(s),
|
||||
using struct ip_mreqn, SO_BINDTODEVICE
|
||||
|
|
|
@ -65,21 +65,32 @@ BuildSendAndCloseSoapResp(struct upnphttp * h,
|
|||
}
|
||||
|
||||
static void
|
||||
GetConnectionTypeInfo(struct upnphttp * h, const char * action)
|
||||
GetConnectionTypeInfo(struct upnphttp * h, const char * action, const char * ns)
|
||||
{
|
||||
#if 0
|
||||
static const char resp[] =
|
||||
"<u:GetConnectionTypeInfoResponse "
|
||||
"xmlns:u=\"" SERVICE_TYPE_WANIPC "\">"
|
||||
"<NewConnectionType>IP_Routed</NewConnectionType>"
|
||||
"<NewPossibleConnectionTypes>IP_Routed</NewPossibleConnectionTypes>"
|
||||
"</u:GetConnectionTypeInfoResponse>";
|
||||
UNUSED(action);
|
||||
#endif
|
||||
static const char resp[] =
|
||||
"<u:%sResponse "
|
||||
"xmlns:u=\"%s\">"
|
||||
"<NewConnectionType>IP_Routed</NewConnectionType>"
|
||||
"<NewPossibleConnectionTypes>IP_Routed</NewPossibleConnectionTypes>"
|
||||
"</u:%sResponse>";
|
||||
char body[512];
|
||||
int bodylen;
|
||||
|
||||
BuildSendAndCloseSoapResp(h, resp, sizeof(resp)-1);
|
||||
bodylen = snprintf(body, sizeof(body), resp,
|
||||
action, ns, action);
|
||||
BuildSendAndCloseSoapResp(h, body, bodylen);
|
||||
}
|
||||
|
||||
static void
|
||||
GetTotalBytesSent(struct upnphttp * h, const char * action)
|
||||
GetTotalBytesSent(struct upnphttp * h, const char * action, const char * ns)
|
||||
{
|
||||
int r;
|
||||
|
||||
|
@ -95,13 +106,13 @@ GetTotalBytesSent(struct upnphttp * h, const char * action)
|
|||
|
||||
r = getifstats(ext_if_name, &data);
|
||||
bodylen = snprintf(body, sizeof(body), resp,
|
||||
action, "urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1",
|
||||
action, ns,
|
||||
r<0?0:data.obytes, action);
|
||||
BuildSendAndCloseSoapResp(h, body, bodylen);
|
||||
}
|
||||
|
||||
static void
|
||||
GetTotalBytesReceived(struct upnphttp * h, const char * action)
|
||||
GetTotalBytesReceived(struct upnphttp * h, const char * action, const char * ns)
|
||||
{
|
||||
int r;
|
||||
|
||||
|
@ -117,13 +128,13 @@ GetTotalBytesReceived(struct upnphttp * h, const char * action)
|
|||
|
||||
r = getifstats(ext_if_name, &data);
|
||||
bodylen = snprintf(body, sizeof(body), resp,
|
||||
action, "urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1",
|
||||
action, ns,
|
||||
r<0?0:data.ibytes, action);
|
||||
BuildSendAndCloseSoapResp(h, body, bodylen);
|
||||
}
|
||||
|
||||
static void
|
||||
GetTotalPacketsSent(struct upnphttp * h, const char * action)
|
||||
GetTotalPacketsSent(struct upnphttp * h, const char * action, const char * ns)
|
||||
{
|
||||
int r;
|
||||
|
||||
|
@ -139,13 +150,13 @@ GetTotalPacketsSent(struct upnphttp * h, const char * action)
|
|||
|
||||
r = getifstats(ext_if_name, &data);
|
||||
bodylen = snprintf(body, sizeof(body), resp,
|
||||
action, "urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1",
|
||||
action, ns,/*"urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1",*/
|
||||
r<0?0:data.opackets, action);
|
||||
BuildSendAndCloseSoapResp(h, body, bodylen);
|
||||
}
|
||||
|
||||
static void
|
||||
GetTotalPacketsReceived(struct upnphttp * h, const char * action)
|
||||
GetTotalPacketsReceived(struct upnphttp * h, const char * action, const char * ns)
|
||||
{
|
||||
int r;
|
||||
|
||||
|
@ -161,13 +172,13 @@ GetTotalPacketsReceived(struct upnphttp * h, const char * action)
|
|||
|
||||
r = getifstats(ext_if_name, &data);
|
||||
bodylen = snprintf(body, sizeof(body), resp,
|
||||
action, "urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1",
|
||||
action, ns,
|
||||
r<0?0:data.ipackets, action);
|
||||
BuildSendAndCloseSoapResp(h, body, bodylen);
|
||||
}
|
||||
|
||||
static void
|
||||
GetCommonLinkProperties(struct upnphttp * h, const char * action)
|
||||
GetCommonLinkProperties(struct upnphttp * h, const char * action, const char * ns)
|
||||
{
|
||||
/* WANAccessType : set depending on the hardware :
|
||||
* DSL, POTS (plain old Telephone service), Cable, Ethernet */
|
||||
|
@ -200,7 +211,7 @@ GetCommonLinkProperties(struct upnphttp * h, const char * action)
|
|||
status = "Down";
|
||||
}
|
||||
bodylen = snprintf(body, sizeof(body), resp,
|
||||
action, "urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1",
|
||||
action, ns,
|
||||
wan_access_type,
|
||||
upstream_bitrate, downstream_bitrate,
|
||||
status, action);
|
||||
|
@ -208,7 +219,7 @@ GetCommonLinkProperties(struct upnphttp * h, const char * action)
|
|||
}
|
||||
|
||||
static void
|
||||
GetStatusInfo(struct upnphttp * h, const char * action)
|
||||
GetStatusInfo(struct upnphttp * h, const char * action, const char * ns)
|
||||
{
|
||||
static const char resp[] =
|
||||
"<u:%sResponse "
|
||||
|
@ -229,13 +240,13 @@ GetStatusInfo(struct upnphttp * h, const char * action)
|
|||
status = get_wan_connection_status_str(ext_if_name);
|
||||
uptime = (time(NULL) - startup_time);
|
||||
bodylen = snprintf(body, sizeof(body), resp,
|
||||
action, SERVICE_TYPE_WANIPC,
|
||||
action, ns, /*SERVICE_TYPE_WANIPC,*/
|
||||
status, (long)uptime, action);
|
||||
BuildSendAndCloseSoapResp(h, body, bodylen);
|
||||
}
|
||||
|
||||
static void
|
||||
GetNATRSIPStatus(struct upnphttp * h, const char * action)
|
||||
GetNATRSIPStatus(struct upnphttp * h, const char * action, const char * ns)
|
||||
{
|
||||
static const char resp[] =
|
||||
"<u:GetNATRSIPStatusResponse "
|
||||
|
@ -256,7 +267,7 @@ GetNATRSIPStatus(struct upnphttp * h, const char * action)
|
|||
}
|
||||
|
||||
static void
|
||||
GetExternalIPAddress(struct upnphttp * h, const char * action)
|
||||
GetExternalIPAddress(struct upnphttp * h, const char * action, const char * ns)
|
||||
{
|
||||
static const char resp[] =
|
||||
"<u:%sResponse "
|
||||
|
@ -296,7 +307,7 @@ GetExternalIPAddress(struct upnphttp * h, const char * action)
|
|||
}
|
||||
#endif
|
||||
bodylen = snprintf(body, sizeof(body), resp,
|
||||
action, SERVICE_TYPE_WANIPC,
|
||||
action, ns, /*SERVICE_TYPE_WANIPC,*/
|
||||
ext_ip_addr, action);
|
||||
BuildSendAndCloseSoapResp(h, body, bodylen);
|
||||
}
|
||||
|
@ -304,7 +315,7 @@ GetExternalIPAddress(struct upnphttp * h, const char * action)
|
|||
/* AddPortMapping method of WANIPConnection Service
|
||||
* Ignored argument : NewEnabled */
|
||||
static void
|
||||
AddPortMapping(struct upnphttp * h, const char * action)
|
||||
AddPortMapping(struct upnphttp * h, const char * action, const char * ns)
|
||||
{
|
||||
int r;
|
||||
|
||||
|
@ -464,7 +475,7 @@ AddPortMapping(struct upnphttp * h, const char * action)
|
|||
|
||||
/* AddAnyPortMapping was added in WANIPConnection v2 */
|
||||
static void
|
||||
AddAnyPortMapping(struct upnphttp * h, const char * action)
|
||||
AddAnyPortMapping(struct upnphttp * h, const char * action, const char * ns)
|
||||
{
|
||||
int r;
|
||||
static const char resp[] =
|
||||
|
@ -574,7 +585,7 @@ AddAnyPortMapping(struct upnphttp * h, const char * action)
|
|||
{
|
||||
case 0: /* success */
|
||||
bodylen = snprintf(body, sizeof(body), resp,
|
||||
action, SERVICE_TYPE_WANIPC,
|
||||
action, ns, /*SERVICE_TYPE_WANIPC,*/
|
||||
eport, action);
|
||||
BuildSendAndCloseSoapResp(h, body, bodylen);
|
||||
break;
|
||||
|
@ -590,7 +601,7 @@ AddAnyPortMapping(struct upnphttp * h, const char * action)
|
|||
}
|
||||
|
||||
static void
|
||||
GetSpecificPortMappingEntry(struct upnphttp * h, const char * action)
|
||||
GetSpecificPortMappingEntry(struct upnphttp * h, const char * action, const char * ns)
|
||||
{
|
||||
int r;
|
||||
|
||||
|
@ -672,7 +683,7 @@ GetSpecificPortMappingEntry(struct upnphttp * h, const char * action)
|
|||
}
|
||||
|
||||
static void
|
||||
DeletePortMapping(struct upnphttp * h, const char * action)
|
||||
DeletePortMapping(struct upnphttp * h, const char * action, const char * ns)
|
||||
{
|
||||
int r;
|
||||
|
||||
|
@ -766,7 +777,7 @@ DeletePortMapping(struct upnphttp * h, const char * action)
|
|||
|
||||
/* DeletePortMappingRange was added in IGD spec v2 */
|
||||
static void
|
||||
DeletePortMappingRange(struct upnphttp * h, const char * action)
|
||||
DeletePortMappingRange(struct upnphttp * h, const char * action, const char * ns)
|
||||
{
|
||||
int r = -1;
|
||||
static const char resp[] =
|
||||
|
@ -833,7 +844,7 @@ DeletePortMappingRange(struct upnphttp * h, const char * action)
|
|||
}
|
||||
|
||||
static void
|
||||
GetGenericPortMappingEntry(struct upnphttp * h, const char * action)
|
||||
GetGenericPortMappingEntry(struct upnphttp * h, const char * action, const char * ns)
|
||||
{
|
||||
int r;
|
||||
|
||||
|
@ -904,7 +915,7 @@ GetGenericPortMappingEntry(struct upnphttp * h, const char * action)
|
|||
int bodylen;
|
||||
char body[2048];
|
||||
bodylen = snprintf(body, sizeof(body), resp,
|
||||
action, SERVICE_TYPE_WANIPC, rhost,
|
||||
action, ns, /*SERVICE_TYPE_WANIPC,*/ rhost,
|
||||
(unsigned int)eport, protocol, (unsigned int)iport, iaddr, desc,
|
||||
leaseduration, action);
|
||||
BuildSendAndCloseSoapResp(h, body, bodylen);
|
||||
|
@ -915,7 +926,7 @@ GetGenericPortMappingEntry(struct upnphttp * h, const char * action)
|
|||
|
||||
/* GetListOfPortMappings was added in the IGD v2 specification */
|
||||
static void
|
||||
GetListOfPortMappings(struct upnphttp * h, const char * action)
|
||||
GetListOfPortMappings(struct upnphttp * h, const char * action, const char * ns)
|
||||
{
|
||||
static const char resp_start[] =
|
||||
"<u:%sResponse "
|
||||
|
@ -1019,7 +1030,7 @@ http://www.upnp.org/schemas/gw/WANIPConnection-v2.xsd">
|
|||
return;
|
||||
}
|
||||
bodylen = snprintf(body, bodyalloc, resp_start,
|
||||
action, SERVICE_TYPE_WANIPC);
|
||||
action, ns/*SERVICE_TYPE_WANIPC*/);
|
||||
if(bodylen < 0)
|
||||
{
|
||||
SoapError(h, 501, "ActionFailed");
|
||||
|
@ -1093,7 +1104,7 @@ http://www.upnp.org/schemas/gw/WANIPConnection-v2.xsd">
|
|||
|
||||
#ifdef ENABLE_L3F_SERVICE
|
||||
static void
|
||||
SetDefaultConnectionService(struct upnphttp * h, const char * action)
|
||||
SetDefaultConnectionService(struct upnphttp * h, const char * action, const char * ns)
|
||||
{
|
||||
static const char resp[] =
|
||||
"<u:SetDefaultConnectionServiceResponse "
|
||||
|
@ -1128,11 +1139,11 @@ SetDefaultConnectionService(struct upnphttp * h, const char * action)
|
|||
}
|
||||
|
||||
static void
|
||||
GetDefaultConnectionService(struct upnphttp * h, const char * action)
|
||||
GetDefaultConnectionService(struct upnphttp * h, const char * action, const char * ns)
|
||||
{
|
||||
static const char resp[] =
|
||||
"<u:%sResponse "
|
||||
"xmlns:u=\"urn:schemas-upnp-org:service:Layer3Forwarding:1\">"
|
||||
"xmlns:u=\"%s\">"
|
||||
"<NewDefaultConnectionService>%s:WANConnectionDevice:1,"
|
||||
SERVICE_ID_WANIPC "</NewDefaultConnectionService>"
|
||||
"</u:%sResponse>";
|
||||
|
@ -1143,20 +1154,21 @@ GetDefaultConnectionService(struct upnphttp * h, const char * action)
|
|||
int bodylen;
|
||||
|
||||
bodylen = snprintf(body, sizeof(body), resp,
|
||||
action, uuidvalue_wcd, action);
|
||||
action, ns, uuidvalue_wcd, action);
|
||||
BuildSendAndCloseSoapResp(h, body, bodylen);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Added for compliance with WANIPConnection v2 */
|
||||
static void
|
||||
SetConnectionType(struct upnphttp * h, const char * action)
|
||||
SetConnectionType(struct upnphttp * h, const char * action, const char * ns)
|
||||
{
|
||||
#ifdef UPNP_STRICT
|
||||
const char * connection_type;
|
||||
#endif /* UPNP_STRICT */
|
||||
struct NameValueParserData data;
|
||||
UNUSED(action);
|
||||
UNUSED(ns);
|
||||
|
||||
ParseNameValue(h->req_buf + h->req_contentoff, h->req_contentlen, &data);
|
||||
#ifdef UPNP_STRICT
|
||||
|
@ -1175,17 +1187,19 @@ SetConnectionType(struct upnphttp * h, const char * action)
|
|||
|
||||
/* Added for compliance with WANIPConnection v2 */
|
||||
static void
|
||||
RequestConnection(struct upnphttp * h, const char * action)
|
||||
RequestConnection(struct upnphttp * h, const char * action, const char * ns)
|
||||
{
|
||||
UNUSED(action);
|
||||
UNUSED(ns);
|
||||
SoapError(h, 606, "Action not authorized");
|
||||
}
|
||||
|
||||
/* Added for compliance with WANIPConnection v2 */
|
||||
static void
|
||||
ForceTermination(struct upnphttp * h, const char * action)
|
||||
ForceTermination(struct upnphttp * h, const char * action, const char * ns)
|
||||
{
|
||||
UNUSED(action);
|
||||
UNUSED(ns);
|
||||
SoapError(h, 606, "Action not authorized");
|
||||
}
|
||||
|
||||
|
@ -1198,7 +1212,7 @@ QueryStateVariable remains useful as a limited test tool but may not be
|
|||
part of some future versions of UPnP.
|
||||
*/
|
||||
static void
|
||||
QueryStateVariable(struct upnphttp * h, const char * action)
|
||||
QueryStateVariable(struct upnphttp * h, const char * action, const char * ns)
|
||||
{
|
||||
static const char resp[] =
|
||||
"<u:%sResponse "
|
||||
|
@ -1228,7 +1242,7 @@ QueryStateVariable(struct upnphttp * h, const char * action)
|
|||
|
||||
status = get_wan_connection_status_str(ext_if_name);
|
||||
bodylen = snprintf(body, sizeof(body), resp,
|
||||
action, "urn:schemas-upnp-org:control-1-0",
|
||||
action, ns,/*"urn:schemas-upnp-org:control-1-0",*/
|
||||
status, action);
|
||||
BuildSendAndCloseSoapResp(h, body, bodylen);
|
||||
}
|
||||
|
@ -1251,7 +1265,7 @@ QueryStateVariable(struct upnphttp * h, const char * action)
|
|||
snprintf(strn, sizeof(strn), "%i",
|
||||
upnp_get_portmapping_number_of_entries());
|
||||
bodylen = snprintf(body, sizeof(body), resp,
|
||||
action, "urn:schemas-upnp-org:control-1-0",
|
||||
action, ns,/*"urn:schemas-upnp-org:control-1-0",*/
|
||||
strn, action);
|
||||
BuildSendAndCloseSoapResp(h, body, bodylen);
|
||||
}
|
||||
|
@ -1270,7 +1284,7 @@ QueryStateVariable(struct upnphttp * h, const char * action)
|
|||
#endif
|
||||
/* WANIPv6FirewallControl actions */
|
||||
static void
|
||||
GetFirewallStatus(struct upnphttp * h, const char * action)
|
||||
GetFirewallStatus(struct upnphttp * h, const char * action, const char * ns)
|
||||
{
|
||||
static const char resp[] =
|
||||
"<u:%sResponse "
|
||||
|
@ -1283,7 +1297,7 @@ GetFirewallStatus(struct upnphttp * h, const char * action)
|
|||
int bodylen;
|
||||
|
||||
bodylen = snprintf(body, sizeof(body), resp,
|
||||
action, "urn:schemas-upnp-org:service:WANIPv6FirewallControl:1",
|
||||
action, ns, /*"urn:schemas-upnp-org:service:WANIPv6FirewallControl:1",*/
|
||||
GETFLAG(IPV6FCFWDISABLEDMASK) ? 0 : 1,
|
||||
GETFLAG(IPV6FCINBOUNDDISALLOWEDMASK) ? 0 : 1,
|
||||
action);
|
||||
|
@ -2013,7 +2027,7 @@ GetAssignedRoles(struct upnphttp * h, const char * action)
|
|||
static const struct
|
||||
{
|
||||
const char * methodName;
|
||||
void (*methodImpl)(struct upnphttp *, const char *);
|
||||
void (*methodImpl)(struct upnphttp *, const char *, const char *);
|
||||
}
|
||||
soapMethods[] =
|
||||
{
|
||||
|
@ -2070,11 +2084,15 @@ ExecuteSoapAction(struct upnphttp * h, const char * action, int n)
|
|||
char * p;
|
||||
char * p2;
|
||||
int i, len, methodlen;
|
||||
char namespace[256];
|
||||
|
||||
/* SoapAction example :
|
||||
* urn:schemas-upnp-org:service:WANIPConnection:1#GetStatusInfo */
|
||||
p = strchr(action, '#');
|
||||
if(p && (p - action) < n) {
|
||||
for(i = 0; i < ((int)sizeof(namespace) - 1) && (action + i) < p; i++)
|
||||
namespace[i] = action[i];
|
||||
namespace[i] = '\0';
|
||||
p++;
|
||||
p2 = strchr(p, '"');
|
||||
if(p2 && (p2 - action) <= n)
|
||||
|
@ -2090,7 +2108,7 @@ ExecuteSoapAction(struct upnphttp * h, const char * action, int n)
|
|||
syslog(LOG_DEBUG, "Remote Call of SoapMethod '%s'",
|
||||
soapMethods[i].methodName);
|
||||
#endif /* DEBUG */
|
||||
soapMethods[i].methodImpl(h, soapMethods[i].methodName);
|
||||
soapMethods[i].methodImpl(h, soapMethods[i].methodName, namespace);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue