当前位置: 首页>>代码示例>>C++>>正文


C++ simpleUPnPcommand函数代码示例

本文整理汇总了C++中simpleUPnPcommand函数的典型用法代码示例。如果您正苦于以下问题:C++ simpleUPnPcommand函数的具体用法?C++ simpleUPnPcommand怎么用?C++ simpleUPnPcommand使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了simpleUPnPcommand函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: UPNP_GetTotalPacketsReceived

LIBSPEC UNSIGNED_INTEGER
UPNP_GetTotalPacketsReceived(const char * controlURL,
						const char * servicetype)
{
	struct NameValueParserData pdata;
	char * buffer;
	int bufsize;
	unsigned int r = 0;
	char * p;
	if(!(buffer = simpleUPnPcommand(-1, controlURL, servicetype,
	                                "GetTotalPacketsReceived", 0, &bufsize))) {
		return UPNPCOMMAND_HTTP_ERROR;
	}
	ParseNameValue(buffer, bufsize, &pdata);
	/*DisplayNameValueList(buffer, bufsize);*/
	free(buffer); buffer = NULL;
	p = GetValueFromNameValueList(&pdata, "NewTotalPacketsReceived");
	r = my_atoui(p);
	ClearNameValueList(&pdata);
	return r;
}
开发者ID:snarkus,项目名称:flylinkdc-r5xx,代码行数:21,代码来源:upnpcommands.c

示例2: UPNP_GetExternalIPAddress

/* UPNP_GetExternalIPAddress() call the corresponding UPNP method.
 * if the third arg is not null the value is copied to it.
 * at least 16 bytes must be available
 *
 * Return values :
 * 0 : SUCCESS
 * NON ZERO : ERROR Either an UPnP error code or an unknown error.
 *
 * 402 Invalid Args - See UPnP Device Architecture section on Control.
 * 501 Action Failed - See UPnP Device Architecture section on Control.
 */
LIBSPEC int
UPNP_GetExternalIPAddress(const char * controlURL,
                          const char * servicetype,
                          char * extIpAdd)
{
    struct NameValueParserData pdata;
    char * buffer;
    int bufsize;
    char * p;
    int ret = UPNPCOMMAND_UNKNOWN_ERROR;

    if(!extIpAdd || !controlURL || !servicetype)
        return UPNPCOMMAND_INVALID_ARGS;

    if(!(buffer = simpleUPnPcommand(-1, controlURL, servicetype,
                                    "GetExternalIPAddress", 0, &bufsize))) {
        return UPNPCOMMAND_HTTP_ERROR;
    }
    /*DisplayNameValueList(buffer, bufsize);*/
    ParseNameValue(buffer, bufsize, &pdata);
    free(buffer);
    buffer = NULL;
    /*printf("external ip = %s\n", GetValueFromNameValueList(&pdata, "NewExternalIPAddress") );*/
    p = GetValueFromNameValueList(&pdata, "NewExternalIPAddress");
    if(p) {
        strncpy(extIpAdd, p, 16 );
        extIpAdd[15] = '\0';
        ret = UPNPCOMMAND_SUCCESS;
    } else
        extIpAdd[0] = '\0';

    p = GetValueFromNameValueList(&pdata, "errorCode");
    if(p) {
        ret = UPNPCOMMAND_UNKNOWN_ERROR;
        sscanf(p, "%d", &ret);
    }

    ClearNameValueList(&pdata);
    return ret;
}
开发者ID:wdmchaft,项目名称:Psybrus,代码行数:51,代码来源:upnpcommands.c

示例3: UPNP_DeletePortMapping

LIBSPEC int
UPNP_DeletePortMapping(const char * controlURL, const char * servicetype,
                       const char * extPort, const char * proto,
                       const char * remoteHost)
{
	/*struct NameValueParserData pdata;*/
	struct UPNParg * DeletePortMappingArgs;
	char buffer[4096];
	int bufsize = 4096;
	struct NameValueParserData pdata;
	const char * resVal;
	int ret;

	if(!extPort || !proto)
		return UPNPCOMMAND_INVALID_ARGS;

	DeletePortMappingArgs = calloc(4, sizeof(struct UPNParg));
	DeletePortMappingArgs[0].elt = "NewRemoteHost";
	DeletePortMappingArgs[0].val = remoteHost;
	DeletePortMappingArgs[1].elt = "NewExternalPort";
	DeletePortMappingArgs[1].val = extPort;
	DeletePortMappingArgs[2].elt = "NewProtocol";
	DeletePortMappingArgs[2].val = proto;
	simpleUPnPcommand(-1, controlURL, servicetype,
	                  "DeletePortMapping",
					  DeletePortMappingArgs, buffer, &bufsize);
	/*DisplayNameValueList(buffer, bufsize);*/
	ParseNameValue(buffer, bufsize, &pdata);
	resVal = GetValueFromNameValueList(&pdata, "errorCode");
	if(resVal) {
		ret = UPNPCOMMAND_UNKNOWN_ERROR;
		sscanf(resVal, "%d", &ret);
	} else {
		ret = UPNPCOMMAND_SUCCESS;
	}
	ClearNameValueList(&pdata);
	free(DeletePortMappingArgs);
	return ret;
}
开发者ID:ProfDrLuigi,项目名称:wired,代码行数:39,代码来源:upnpcommands.c

示例4: UPNP_GetPortMappingNumberOfEntries

LIBSPEC int
UPNP_GetPortMappingNumberOfEntries(const char * controlURL,
                                   const char * servicetype,
                                   unsigned int * numEntries)
{
    struct NameValueParserData pdata;
    char * buffer;
    int bufsize;
    char* p;
    int ret = UPNPCOMMAND_UNKNOWN_ERROR;
    if(!(buffer = simpleUPnPcommand(-1, controlURL, servicetype,
                                    "GetPortMappingNumberOfEntries", 0,
                                    &bufsize))) {
        return UPNPCOMMAND_HTTP_ERROR;
    }
#ifdef DEBUG
    DisplayNameValueList(buffer, bufsize);
#endif
    ParseNameValue(buffer, bufsize, &pdata);
    free(buffer);
    buffer = NULL;

    p = GetValueFromNameValueList(&pdata, "NewPortMappingNumberOfEntries");
    if(numEntries && p) {
        *numEntries = 0;
        sscanf(p, "%u", numEntries);
        ret = UPNPCOMMAND_SUCCESS;
    }

    p = GetValueFromNameValueList(&pdata, "errorCode");
    if(p) {
        ret = UPNPCOMMAND_UNKNOWN_ERROR;
        sscanf(p, "%d", &ret);
    }

    ClearNameValueList(&pdata);
    return ret;
}
开发者ID:wdmchaft,项目名称:Psybrus,代码行数:38,代码来源:upnpcommands.c

示例5: UPNP_GetConnectionTypeInfo

/* UPNP_GetConnectionTypeInfo() call the corresponding UPNP method
 * returns the connection type */
LIBSPEC int
UPNP_GetConnectionTypeInfo(const char * controlURL,
                           const char * servicetype,
                           char * connectionType)
{
    struct NameValueParserData pdata;
    char * buffer;
    int bufsize;
    char * p;
    int ret = UPNPCOMMAND_UNKNOWN_ERROR;

    if(!connectionType)
        return UPNPCOMMAND_INVALID_ARGS;

    if(!(buffer = simpleUPnPcommand(-1, controlURL, servicetype,
                                    "GetConnectionTypeInfo", 0, &bufsize))) {
        return UPNPCOMMAND_HTTP_ERROR;
    }
    ParseNameValue(buffer, bufsize, &pdata);
    free(buffer);
    buffer = NULL;
    p = GetValueFromNameValueList(&pdata, "NewConnectionType");
    /*p = GetValueFromNameValueList(&pdata, "NewPossibleConnectionTypes");*/
    /* PossibleConnectionTypes will have several values.... */
    if(p) {
        strncpy(connectionType, p, 64 );
        connectionType[63] = '\0';
        ret = UPNPCOMMAND_SUCCESS;
    } else
        connectionType[0] = '\0';
    p = GetValueFromNameValueList(&pdata, "errorCode");
    if(p) {
        ret = UPNPCOMMAND_UNKNOWN_ERROR;
        sscanf(p, "%d", &ret);
    }
    ClearNameValueList(&pdata);
    return ret;
}
开发者ID:wdmchaft,项目名称:Psybrus,代码行数:40,代码来源:upnpcommands.c

示例6: UPNP_GetStatusInfo

/* UPNP_GetStatusInfo() call the corresponding UPNP method
 * returns the current status and uptime */
void UPNP_GetStatusInfo(const char * controlURL,
												const char * servicetype,
												char * status, 
												unsigned int * uptime)
{
	struct NameValueParserData pdata;
	char buffer[4096];
	int bufsize = 4096;
	char * p;
	char* up;

	if(!status && !uptime)
		return;

	simpleUPnPcommand(-1, controlURL, servicetype, "GetStatusInfo", 0, buffer, &bufsize);
	ParseNameValue(buffer, bufsize, &pdata);
	/*DisplayNameValueList(buffer, bufsize);*/
	up = GetValueFromNameValueList(&pdata, "NewUptime");
	p = GetValueFromNameValueList(&pdata, "NewConnectionStatus");

	if(status)
	{
		if(p){
			strncpy(status, p, 64 );
			status[63] = '\0';
		}else
			status[0]= '\0';
	}

	if(uptime){
		if(p)
			sscanf(up,"%u",uptime);
		else
			uptime = 0;
	}

	ClearNameValueList(&pdata);
}
开发者ID:SupportSpace,项目名称:SupportCenter,代码行数:40,代码来源:upnpcommands.c

示例7: UPNP_DeletePortMapping

void UPNP_DeletePortMapping(const char * controlURL, const char * servicetype,
                            const char * extPort, const char * proto)
{
	/*struct NameValueParserData pdata;*/
	struct UPNParg * DeletePortMappingArgs;
	char buffer[4096];
	int bufsize = 4096;

	if(!extPort)
		return;	

	DeletePortMappingArgs = calloc(4, sizeof(struct UPNParg));
	DeletePortMappingArgs[0].elt = "NewRemoteHost";
	DeletePortMappingArgs[1].elt = "NewExternalPort";
	DeletePortMappingArgs[1].val = extPort;
	DeletePortMappingArgs[2].elt = "NewProtocol";
	DeletePortMappingArgs[2].val = proto;
	simpleUPnPcommand(-1, controlURL, servicetype,
	                  "DeletePortMapping",
					  DeletePortMappingArgs, buffer, &bufsize);
	/*DisplayNameValueList(buffer, bufsize);*/
	free(DeletePortMappingArgs);
}
开发者ID:SupportSpace,项目名称:SupportCenter,代码行数:23,代码来源:upnpcommands.c

示例8: UPNP_AddPortMapping

LIBSPEC int
UPNP_AddPortMapping(const char * controlURL, const char * servicetype,
                    const char * extPort,
                    const char * inPort,
                    const char * inClient,
                    const char * desc,
                    const char * proto,
                    const char * remoteHost,
                    const char * leaseDuration)
{
    struct UPNParg * AddPortMappingArgs;
    char * buffer;
    int bufsize;
    struct NameValueParserData pdata;
    const char * resVal;
    int ret;

    if(!inPort || !inClient || !proto || !extPort)
        return UPNPCOMMAND_INVALID_ARGS;

    AddPortMappingArgs = calloc(9, sizeof(struct UPNParg));
    AddPortMappingArgs[0].elt = "NewRemoteHost";
    AddPortMappingArgs[0].val = remoteHost;
    AddPortMappingArgs[1].elt = "NewExternalPort";
    AddPortMappingArgs[1].val = extPort;
    AddPortMappingArgs[2].elt = "NewProtocol";
    AddPortMappingArgs[2].val = proto;
    AddPortMappingArgs[3].elt = "NewInternalPort";
    AddPortMappingArgs[3].val = inPort;
    AddPortMappingArgs[4].elt = "NewInternalClient";
    AddPortMappingArgs[4].val = inClient;
    AddPortMappingArgs[5].elt = "NewEnabled";
    AddPortMappingArgs[5].val = "1";
    AddPortMappingArgs[6].elt = "NewPortMappingDescription";
    AddPortMappingArgs[6].val = desc?desc:"libminiupnpc";
    AddPortMappingArgs[7].elt = "NewLeaseDuration";
    AddPortMappingArgs[7].val = leaseDuration?leaseDuration:"0";
    if(!(buffer = simpleUPnPcommand(-1, controlURL, servicetype,
                                    "AddPortMapping", AddPortMappingArgs,
                                    &bufsize))) {
        free(AddPortMappingArgs);
        return UPNPCOMMAND_HTTP_ERROR;
    }
    /*DisplayNameValueList(buffer, bufsize);*/
    /*buffer[bufsize] = '\0';*/
    /*puts(buffer);*/
    ParseNameValue(buffer, bufsize, &pdata);
    free(buffer);
    buffer = NULL;
    resVal = GetValueFromNameValueList(&pdata, "errorCode");
    if(resVal) {
        /*printf("AddPortMapping errorCode = '%s'\n", resVal); */
        ret = UPNPCOMMAND_UNKNOWN_ERROR;
        sscanf(resVal, "%d", &ret);
    } else {
        ret = UPNPCOMMAND_SUCCESS;
    }
    ClearNameValueList(&pdata);
    free(AddPortMappingArgs);
    return ret;
}
开发者ID:wdmchaft,项目名称:Psybrus,代码行数:61,代码来源:upnpcommands.c

示例9: UPNP_GetGenericPortMappingEntry

int UPNP_GetGenericPortMappingEntry(const char * controlURL,
                                     const char * servicetype,
									 const char * index,
									 char * extPort,
									 char * intClient,
									 char * intPort,
									 char * protocol,
									 char * desc,
									 char * enabled,
									 char * rHost,
									 char * duration)
{
	struct NameValueParserData pdata;
	struct UPNParg * GetPortMappingArgs;
	char buffer[4096];
	int bufsize = 4096;
	char * p;
	int r = -1;
	intClient[0] = '\0';
	intPort[0] = '\0';
	GetPortMappingArgs = calloc(2, sizeof(struct UPNParg));
	GetPortMappingArgs[0].elt = "NewPortMappingIndex";
	GetPortMappingArgs[0].val = index;
	simpleUPnPcommand(-1, controlURL, servicetype,
	                  "GetGenericPortMappingEntry",
					  GetPortMappingArgs, buffer, &bufsize);
	ParseNameValue(buffer, bufsize, &pdata);
	p = GetValueFromNameValueList(&pdata, "NewRemoteHost");
	if(p && rHost)
	{
		strncpy(rHost, p, 64);
		rHost[63] = '\0';
	}
	p = GetValueFromNameValueList(&pdata, "NewExternalPort");
	if(p && extPort)
	{
		strncpy(extPort, p, 6);
		extPort[5] = '\0';
		r = 0;
	}
	p = GetValueFromNameValueList(&pdata, "NewProtocol");
	if(p && protocol)
	{
		strncpy(protocol, p, 4);
		protocol[3] = '\0';
	}
	p = GetValueFromNameValueList(&pdata, "NewInternalClient");
	if(p && intClient)
	{
		strncpy(intClient, p, 16);
		intClient[15] = '\0';
		r = 0;
	}
	p = GetValueFromNameValueList(&pdata, "NewInternalPort");
	if(p && intPort)
	{
		strncpy(intPort, p, 6);
		intPort[5] = '\0';
	}
	p = GetValueFromNameValueList(&pdata, "NewEnabled");
	if(p && enabled)
	{
		strncpy(enabled, p, 4);
		enabled[3] = '\0';
	}
	p = GetValueFromNameValueList(&pdata, "NewPortMappingDescription");
	if(p && desc)
	{
		strncpy(desc, p, 80);
		desc[79] = '\0';
	}
	p = GetValueFromNameValueList(&pdata, "NewLeaseDuration");
	if(p && duration)
	{
		strncpy(duration, p, 16);
		duration[15] = '\0';
	}
	ClearNameValueList(&pdata);
	free(GetPortMappingArgs);
	return r;
}
开发者ID:SupportSpace,项目名称:SupportCenter,代码行数:81,代码来源:upnpcommands.c


注:本文中的simpleUPnPcommand函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。