miniupnpd/upnpsoap.c: Adding skeleton of DeviceProtection:1 implementation
This commit is contained in:
parent
bbe96a15b6
commit
6794650f5a
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: upnpsoap.c,v 1.122 2014/03/10 11:04:53 nanard Exp $ */
|
/* $Id: upnpsoap.c,v 1.123 2014/04/09 12:39:54 nanard Exp $ */
|
||||||
/* MiniUPnP project
|
/* MiniUPnP project
|
||||||
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
|
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
|
||||||
* (c) 2006-2014 Thomas Bernard
|
* (c) 2006-2014 Thomas Bernard
|
||||||
|
@ -1827,6 +1827,97 @@ GetPinholePackets(struct upnphttp * h, const char * action)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef ENABLE_DP_SERVICE
|
||||||
|
static void
|
||||||
|
SendSetupMessage(struct upnphttp * h, const char * action)
|
||||||
|
{
|
||||||
|
static const char resp[] =
|
||||||
|
"<u:%sResponse "
|
||||||
|
"xmlns:u=\"%s\">"
|
||||||
|
"<NewOutMessage>%s</NewOutMessage>"
|
||||||
|
"</u:%sResponse>";
|
||||||
|
char body[1024];
|
||||||
|
int bodylen;
|
||||||
|
struct NameValueParserData data;
|
||||||
|
const char * ProtocolType; /* string */
|
||||||
|
const char * InMessage; /* base64 */
|
||||||
|
const char * OutMessage = ""; /* base64 */
|
||||||
|
|
||||||
|
ParseNameValue(h->req_buf + h->req_contentoff, h->req_contentlen, &data);
|
||||||
|
ProtocolType = GetValueFromNameValueList(&data, "NewProtocolType"); /* string */
|
||||||
|
InMessage = GetValueFromNameValueList(&data, "NewInMessage"); /* base64 */
|
||||||
|
|
||||||
|
if(ProtocolType == NULL || InMessage == NULL)
|
||||||
|
{
|
||||||
|
ClearNameValueList(&data);
|
||||||
|
SoapError(h, 402, "Invalid Args");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
/*if(strcmp(ProtocolType, "DeviceProtection:1") != 0)*/
|
||||||
|
if(strcmp(ProtocolType, "WPS") != 0)
|
||||||
|
{
|
||||||
|
ClearNameValueList(&data);
|
||||||
|
SoapError(h, 600, "Argument Value Invalid"); /* 703 ? */
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
/* TODO : put here code for WPS */
|
||||||
|
|
||||||
|
bodylen = snprintf(body, sizeof(body), resp,
|
||||||
|
action, "urn:schemas-upnp-org:service:DeviceProtection:1",
|
||||||
|
OutMessage, action);
|
||||||
|
BuildSendAndCloseSoapResp(h, body, bodylen);
|
||||||
|
ClearNameValueList(&data);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
GetSupportedProtocols(struct upnphttp * h, const char * action)
|
||||||
|
{
|
||||||
|
static const char resp[] =
|
||||||
|
"<u:%sResponse "
|
||||||
|
"xmlns:u=\"%s\">"
|
||||||
|
"<NewProtocolList>%s</NewProtocolList>"
|
||||||
|
"</u:%sResponse>";
|
||||||
|
char body[1024];
|
||||||
|
int bodylen;
|
||||||
|
const char * ProtocolList =
|
||||||
|
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
|
||||||
|
"<SupportedProtocols xmlns=\"urn:schemas-upnp-org:gw:DeviceProtection\""
|
||||||
|
" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""
|
||||||
|
" xsi:schemaLocation=\"urn:schemas-upnp-org:gw:DeviceProtection"
|
||||||
|
" http://www.upnp.org/schemas/gw/DeviceProtection-v1.xsd\">"
|
||||||
|
"<Introduction><Name>WPS</Name></Introduction>"
|
||||||
|
"<Login><Name>PKCS5</Name></Login>"
|
||||||
|
"</SupportedProtocols>";
|
||||||
|
|
||||||
|
bodylen = snprintf(body, sizeof(body), resp,
|
||||||
|
action, "urn:schemas-upnp-org:service:DeviceProtection:1",
|
||||||
|
ProtocolList, action);
|
||||||
|
BuildSendAndCloseSoapResp(h, body, bodylen);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
GetAssignedRoles(struct upnphttp * h, const char * action)
|
||||||
|
{
|
||||||
|
static const char resp[] =
|
||||||
|
"<u:%sResponse "
|
||||||
|
"xmlns:u=\"%s\">"
|
||||||
|
"<NewRoleList>%s</NewRoleList>"
|
||||||
|
"</u:%sResponse>";
|
||||||
|
char body[1024];
|
||||||
|
int bodylen;
|
||||||
|
const char * RoleList;
|
||||||
|
|
||||||
|
if(h->ssl != NULL)
|
||||||
|
RoleList = "Admin Basic";
|
||||||
|
else
|
||||||
|
RoleList = "Public";
|
||||||
|
|
||||||
|
bodylen = snprintf(body, sizeof(body), resp,
|
||||||
|
action, "urn:schemas-upnp-org:service:DeviceProtection:1",
|
||||||
|
RoleList, action);
|
||||||
|
BuildSendAndCloseSoapResp(h, body, bodylen);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Windows XP as client send the following requests :
|
/* Windows XP as client send the following requests :
|
||||||
* GetConnectionTypeInfo
|
* GetConnectionTypeInfo
|
||||||
|
@ -1884,6 +1975,12 @@ soapMethods[] =
|
||||||
{ "DeletePinhole", DeletePinhole}, /* Required */
|
{ "DeletePinhole", DeletePinhole}, /* Required */
|
||||||
{ "CheckPinholeWorking", CheckPinholeWorking}, /* Optional */
|
{ "CheckPinholeWorking", CheckPinholeWorking}, /* Optional */
|
||||||
{ "GetPinholePackets", GetPinholePackets}, /* Required */
|
{ "GetPinholePackets", GetPinholePackets}, /* Required */
|
||||||
|
#endif
|
||||||
|
#ifdef ENABLE_DP_SERVICE
|
||||||
|
/* DeviceProtection */
|
||||||
|
{ "SendSetupMessage", SendSetupMessage}, /* Required */
|
||||||
|
{ "GetSupportedProtocols", GetSupportedProtocols}, /* Required */
|
||||||
|
{ "GetAssignedRoles", GetAssignedRoles}, /* Required */
|
||||||
#endif
|
#endif
|
||||||
{ 0, 0 }
|
{ 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue