亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? upnpsoap.c

?? miniupnpd可以在嵌入式linux中實現upnp功能
?? C
?? 第 1 頁 / 共 2 頁
字號:
/* $Id: upnpsoap.c,v 1.62 2008/04/25 16:24:12 nanard Exp $ *//* MiniUPnP project * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ * (c) 2006-2008 Thomas Bernard  * This software is subject to the conditions detailed * in the LICENCE file provided within the distribution */#include <stdio.h>#include <stdlib.h>#include <string.h>#include <sys/socket.h>#include <unistd.h>#include <syslog.h>#include <sys/types.h>#include <arpa/inet.h>#include <netinet/in.h>#include <netdb.h>#include "config.h"#include "upnpglobalvars.h"#include "upnphttp.h"#include "upnpsoap.h"#include "upnpreplyparse.h"#include "upnpredirect.h"#include "getifaddr.h"#include "getifstats.h"static voidBuildSendAndCloseSoapResp(struct upnphttp * h,                          const char * body, int bodylen){	static const char beforebody[] =		"<?xml version=\"1.0\"?>\r\n"		"<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" "		"s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">"		"<s:Body>";	static const char afterbody[] =		"</s:Body>"		"</s:Envelope>\r\n";	BuildHeader_upnphttp(h, 200, "OK",  sizeof(beforebody) - 1		+ sizeof(afterbody) - 1 + bodylen );	memcpy(h->res_buf + h->res_buflen, beforebody, sizeof(beforebody) - 1);	h->res_buflen += sizeof(beforebody) - 1;	memcpy(h->res_buf + h->res_buflen, body, bodylen);	h->res_buflen += bodylen;	memcpy(h->res_buf + h->res_buflen, afterbody, sizeof(afterbody) - 1);	h->res_buflen += sizeof(afterbody) - 1;	SendResp_upnphttp(h);	CloseSocket_upnphttp(h);}static voidGetConnectionTypeInfo(struct upnphttp * h, const char * action){	static const char resp[] =		"<u:GetConnectionTypeInfoResponse "		"xmlns:u=\"urn:schemas-upnp-org:service:WANIPConnection:1\">"		"<NewConnectionType>IP_Routed</NewConnectionType>"		"<NewPossibleConnectionTypes>IP_Routed</NewPossibleConnectionTypes>"		"</u:GetConnectionTypeInfoResponse>";	BuildSendAndCloseSoapResp(h, resp, sizeof(resp)-1);}static voidGetTotalBytesSent(struct upnphttp * h, const char * action){	int r;	static const char resp[] =		"<u:%sResponse "		"xmlns:u=\"%s\">"		"<NewTotalBytesSent>%lu</NewTotalBytesSent>"		"</u:%sResponse>";	char body[512];	int bodylen;	struct ifdata data;	r = getifstats(ext_if_name, &data);	bodylen = snprintf(body, sizeof(body), resp,	         action, "urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1",             r<0?0:data.obytes, action);	BuildSendAndCloseSoapResp(h, body, bodylen);}static voidGetTotalBytesReceived(struct upnphttp * h, const char * action){	int r;	static const char resp[] =		"<u:%sResponse "		"xmlns:u=\"%s\">"		"<NewTotalBytesReceived>%lu</NewTotalBytesReceived>"		"</u:%sResponse>";	char body[512];	int bodylen;	struct ifdata data;	r = getifstats(ext_if_name, &data);	bodylen = snprintf(body, sizeof(body), resp,	         action, "urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1",	         r<0?0:data.ibytes, action);	BuildSendAndCloseSoapResp(h, body, bodylen);}static voidGetTotalPacketsSent(struct upnphttp * h, const char * action){	int r;	static const char resp[] =		"<u:%sResponse "		"xmlns:u=\"%s\">"		"<NewTotalPacketsSent>%lu</NewTotalPacketsSent>"		"</u:%sResponse>";	char body[512];	int bodylen;	struct ifdata data;	r = getifstats(ext_if_name, &data);	bodylen = snprintf(body, sizeof(body), resp,	         action, "urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1",	         r<0?0:data.opackets, action);	BuildSendAndCloseSoapResp(h, body, bodylen);}static voidGetTotalPacketsReceived(struct upnphttp * h, const char * action){	int r;	static const char resp[] =		"<u:%sResponse "		"xmlns:u=\"%s\">"		"<NewTotalPacketsReceived>%lu</NewTotalPacketsReceived>"		"</u:%sResponse>";	char body[512];	int bodylen;	struct ifdata data;	r = getifstats(ext_if_name, &data);	bodylen = snprintf(body, sizeof(body), resp,	         action, "urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1",	         r<0?0:data.ipackets, action);	BuildSendAndCloseSoapResp(h, body, bodylen);}static voidGetCommonLinkProperties(struct upnphttp * h, const char * action){	static const char resp[] =		"<u:%sResponse "		"xmlns:u=\"%s\">"		/*"<NewWANAccessType>DSL</NewWANAccessType>"*/		"<NewWANAccessType>Cable</NewWANAccessType>"		"<NewLayer1UpstreamMaxBitRate>%lu</NewLayer1UpstreamMaxBitRate>"		"<NewLayer1DownstreamMaxBitRate>%lu</NewLayer1DownstreamMaxBitRate>"		"<NewPhysicalLinkStatus>Up</NewPhysicalLinkStatus>"		"</u:%sResponse>";	char body[2048];	int bodylen;	struct ifdata data;	if((downstream_bitrate == 0) || (upstream_bitrate == 0))	{		if(getifstats(ext_if_name, &data) >= 0)		{			if(downstream_bitrate == 0) downstream_bitrate = data.baudrate;			if(upstream_bitrate == 0) upstream_bitrate = data.baudrate;		}	}	bodylen = snprintf(body, sizeof(body), resp,	    action, "urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1",		upstream_bitrate, downstream_bitrate,	    action);	BuildSendAndCloseSoapResp(h, body, bodylen);}static voidGetStatusInfo(struct upnphttp * h, const char * action){	static const char resp[] =		"<u:%sResponse "		"xmlns:u=\"%s\">"		"<NewConnectionStatus>Connected</NewConnectionStatus>"		"<NewLastConnectionError>ERROR_NONE</NewLastConnectionError>"		"<NewUptime>%ld</NewUptime>"		"</u:%sResponse>";	char body[512];	int bodylen;	time_t uptime;	uptime = (time(NULL) - startup_time);	bodylen = snprintf(body, sizeof(body), resp,		action, "urn:schemas-upnp-org:service:WANIPConnection:1",		(long)uptime, action);		BuildSendAndCloseSoapResp(h, body, bodylen);}static voidGetNATRSIPStatus(struct upnphttp * h, const char * action){	static const char resp[] =		"<u:GetNATRSIPStatusResponse "		"xmlns:u=\"urn:schemas-upnp-org:service:WANIPConnection:1\">"		"<NewRSIPAvailable>0</NewRSIPAvailable>"		"<NewNATEnabled>1</NewNATEnabled>"		"</u:GetNATRSIPStatusResponse>";	BuildSendAndCloseSoapResp(h, resp, sizeof(resp)-1);}static voidGetExternalIPAddress(struct upnphttp * h, const char * action){	static const char resp[] =		"<u:%sResponse "		"xmlns:u=\"%s\">"		"<NewExternalIPAddress>%s</NewExternalIPAddress>"		"</u:%sResponse>";	char body[512];	int bodylen;	char ext_ip_addr[INET_ADDRSTRLEN];#ifndef MULTIPLE_EXTERNAL_IP	if(use_ext_ip_addr)	{		strncpy(ext_ip_addr, use_ext_ip_addr, INET_ADDRSTRLEN);	}	else if(getifaddr(ext_if_name, ext_ip_addr, INET_ADDRSTRLEN) < 0)	{		syslog(LOG_ERR, "Failed to get ip address for interface %s",			ext_if_name);		strncpy(ext_ip_addr, "0.0.0.0", INET_ADDRSTRLEN);	}#else	int i;	strncpy(ext_ip_addr, "0.0.0.0", INET_ADDRSTRLEN);	for(i = 0; i<n_lan_addr; i++)	{		if( (h->clientaddr.s_addr & lan_addr[i].mask.s_addr)		   == (lan_addr[i].addr.s_addr & lan_addr[i].mask.s_addr))		{			strncpy(ext_ip_addr, lan_addr[i].ext_ip_str, INET_ADDRSTRLEN);			break;		}	}#endif	bodylen = snprintf(body, sizeof(body), resp,	              action, "urn:schemas-upnp-org:service:WANIPConnection:1",				  ext_ip_addr, action);	BuildSendAndCloseSoapResp(h, body, bodylen);}static voidAddPortMapping(struct upnphttp * h, const char * action){	int r;	static const char resp[] =		"<u:AddPortMappingResponse "		"xmlns:u=\"urn:schemas-upnp-org:service:WANIPConnection:1\"/>";	struct NameValueParserData data;	char * int_ip, * int_port, * ext_port, * protocol, * desc;	char * leaseduration;	unsigned short iport, eport;	struct hostent *hp; /* getbyhostname() */	char ** ptr; /* getbyhostname() */	struct in_addr result_ip;/*unsigned char result_ip[16];*/ /* inet_pton() */	ParseNameValue(h->req_buf + h->req_contentoff, h->req_contentlen, &data);	int_ip = GetValueFromNameValueList(&data, "NewInternalClient");	if (!int_ip)	{		ClearNameValueList(&data);		SoapError(h, 402, "Invalid Args");		return;	}	/* if ip not valid assume hostname and convert */	if (inet_pton(AF_INET, int_ip, &result_ip) <= 0) 	{		hp = gethostbyname(int_ip);		if(hp && hp->h_addrtype == AF_INET) 		{ 			for(ptr = hp->h_addr_list; ptr && *ptr; ptr++)		   	{				int_ip = inet_ntoa(*((struct in_addr *) *ptr));				result_ip = *((struct in_addr *) *ptr);				/* TODO : deal with more than one ip per hostname */				break;			}		} 		else 		{			syslog(LOG_ERR, "Failed to convert hostname '%s' to ip address", int_ip); 			ClearNameValueList(&data);			SoapError(h, 402, "Invalid Args");			return;		}					}	/* check if NewInternalAddress is the client address */	if(GETFLAG(SECUREMODEMASK))	{		if(h->clientaddr.s_addr != result_ip.s_addr)		{			syslog(LOG_INFO, "Client %s tried to redirect port to %s",			       inet_ntoa(h->clientaddr), int_ip);			ClearNameValueList(&data);			SoapError(h, 718, "ConflictInMappingEntry");			return;		}	}	int_port = GetValueFromNameValueList(&data, "NewInternalPort");	ext_port = GetValueFromNameValueList(&data, "NewExternalPort");	protocol = GetValueFromNameValueList(&data, "NewProtocol");	desc = GetValueFromNameValueList(&data, "NewPortMappingDescription");	leaseduration = GetValueFromNameValueList(&data, "NewLeaseDuration");	if (!int_port || !ext_port || !protocol)	{		ClearNameValueList(&data);		SoapError(h, 402, "Invalid Args");		return;	}	eport = (unsigned short)atoi(ext_port);	iport = (unsigned short)atoi(int_port);	if(leaseduration && atoi(leaseduration)) {		syslog(LOG_WARNING, "NewLeaseDuration=%s", leaseduration);	}	syslog(LOG_INFO, "%s: ext port %hu to %s:%hu protocol %s for: %s",			action, eport, int_ip, iport, protocol, desc);	r = upnp_redirect(eport, int_ip, iport, protocol, desc);	ClearNameValueList(&data);	/* possible error codes for AddPortMapping :	 * 402 - Invalid Args	 * 501 - Action Failed	 * 715 - Wildcard not permited in SrcAddr	 * 716 - Wildcard not permited in ExtPort	 * 718 - ConflictInMappingEntry	 * 724 - SamePortValuesRequired     * 725 - OnlyPermanentLeasesSupported             The NAT implementation only supports permanent lease times on             port mappings     * 726 - RemoteHostOnlySupportsWildcard             RemoteHost must be a wildcard and cannot be a specific IP             address or DNS name     * 727 - ExternalPortOnlySupportsWildcard             ExternalPort must be a wildcard and cannot be a specific port             value */	switch(r)	{	case 0:	/* success */		BuildSendAndCloseSoapResp(h, resp, sizeof(resp)-1);		break;	case -2:	/* already redirected */	case -3:	/* not permitted */		SoapError(h, 718, "ConflictInMappingEntry");		break;	default:		SoapError(h, 501, "ActionFailed");	}}static voidGetSpecificPortMappingEntry(struct upnphttp * h, const char * action){	int r;	static const char resp[] =		"<u:%sResponse "		"xmlns:u=\"%s\">"		"<NewInternalPort>%u</NewInternalPort>"

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
天堂av在线一区| 成人美女视频在线看| 懂色av中文一区二区三区| 91成人国产精品| 久久精品亚洲麻豆av一区二区| 亚洲自拍偷拍欧美| 国产成人夜色高潮福利影视| 7777精品伊人久久久大香线蕉完整版 | 欧美色网站导航| 国产欧美日韩精品一区| 强制捆绑调教一区二区| 色欧美片视频在线观看在线视频| 欧美va亚洲va香蕉在线| 天堂精品中文字幕在线| 色婷婷久久99综合精品jk白丝| 久久久不卡影院| 久久精品国内一区二区三区| 欧美日韩一区高清| 一区二区三区欧美视频| 99久久精品免费| 欧美国产精品一区| 国产乱人伦偷精品视频不卡| 91精品国产美女浴室洗澡无遮挡| 亚洲综合一区二区三区| 一本一道综合狠狠老| 国产精品第13页| av网站免费线看精品| 国产精品三级在线观看| 成人免费视频app| 亚洲国产成人自拍| 成人免费看片app下载| 国产亚洲欧美激情| 国产成人自拍网| 久久久综合九色合综国产精品| 久久 天天综合| 日韩精品一区二区三区在线观看| 日韩精品每日更新| 欧美一区二区在线播放| 美女脱光内衣内裤视频久久网站| 欧美日韩成人在线| 日韩电影一区二区三区四区| 91精品啪在线观看国产60岁| 美日韩一级片在线观看| 精品国产免费一区二区三区四区| 久久精品国产99| 久久久亚洲欧洲日产国码αv| 久久69国产一区二区蜜臀| 国产日韩精品视频一区| 成人晚上爱看视频| 最新日韩在线视频| 91久久精品一区二区三| 日韩精品电影在线观看| 欧美成人vps| 国产不卡免费视频| 亚洲免费在线视频一区 二区| 欧美在线视频不卡| 蜜臀av性久久久久蜜臀av麻豆| 精品国产百合女同互慰| 成人动漫在线一区| 一区二区三区四区高清精品免费观看| 欧美性猛片xxxx免费看久爱| 蜜桃视频在线观看一区| 国产精品女人毛片| 欧美伊人久久久久久午夜久久久久| 日韩精品高清不卡| 日本一区二区综合亚洲| 欧美性一区二区| 狠狠色综合色综合网络| 亚洲欧美日韩国产成人精品影院| 91精品国产一区二区三区香蕉| 国产成人一级电影| 爽好多水快深点欧美视频| 国产亚洲综合在线| 欧美伊人久久久久久午夜久久久久| 六月丁香综合在线视频| 国产精品国产馆在线真实露脸| 8x福利精品第一导航| eeuss国产一区二区三区| 亚洲国产成人va在线观看天堂| 久久综合色一综合色88| 精品视频一区二区三区免费| 国产成人啪午夜精品网站男同| 亚洲成a人片在线不卡一二三区| 国产亚洲自拍一区| 555www色欧美视频| 91麻豆视频网站| 国产黑丝在线一区二区三区| 日韩国产欧美在线播放| 亚洲欧美自拍偷拍色图| 精品国产乱码久久久久久免费| 欧美亚洲日本国产| www.欧美日韩| 国产福利91精品一区| 日韩不卡一区二区三区| 一区二区三区不卡视频在线观看| 日韩1区2区3区| 亚洲综合久久久久| 国产精品狼人久久影院观看方式| 日韩免费电影一区| 欧美日韩高清不卡| 欧美在线影院一区二区| 91网站在线观看视频| 成人av在线观| 国模冰冰炮一区二区| 免费观看在线综合| 五月天一区二区三区| 亚洲一区二区精品久久av| 亚洲手机成人高清视频| 国产精品久久久久影院老司| 国产片一区二区| 国产调教视频一区| 欧美国产精品一区| 国产欧美一区二区在线| 国产亚洲精品久| 久久女同性恋中文字幕| 久久综合狠狠综合| 久久亚洲精品小早川怜子| 精品国产电影一区二区| 久久久久国产一区二区三区四区 | 亚洲午夜精品网| 亚洲影院理伦片| 亚洲第一在线综合网站| 午夜精品福利久久久| 日本少妇一区二区| 久久电影网电视剧免费观看| 国内精品久久久久影院色| 国产精品综合二区| 国产成人在线视频网址| 成人18视频在线播放| 色欧美日韩亚洲| 欧美日韩国产另类一区| 日韩一区二区高清| 久久久噜噜噜久噜久久综合| 国产午夜精品一区二区三区嫩草| 中文一区一区三区高中清不卡| 成人免费在线视频观看| 亚洲一区成人在线| 免费人成在线不卡| 国产白丝网站精品污在线入口| 99久久国产综合精品女不卡| 91久久国产最好的精华液| 欧美高清一级片在线| 欧美精品一区二区三区久久久| 国产欧美久久久精品影院| 一区二区三区欧美日| 免费观看30秒视频久久| 国产精品亚洲人在线观看| 色综合久久久久| 日韩手机在线导航| 亚洲欧洲一区二区三区| 日韩av在线免费观看不卡| 国产一区二区精品久久| 一本一本大道香蕉久在线精品| 91精品国产综合久久香蕉的特点| 久久精品日韩一区二区三区| 亚洲一区二区视频在线| 国产伦精品一区二区三区视频青涩| av电影天堂一区二区在线| 日韩小视频在线观看专区| 国产精品久久看| 麻豆国产精品777777在线| 91在线精品一区二区三区| 日韩欧美综合一区| 亚洲综合在线电影| 色综合久久综合网欧美综合网| 欧美变态口味重另类| 亚洲综合成人网| 国产福利电影一区二区三区| 欧美精品自拍偷拍| 自拍偷拍国产精品| 国产精品资源站在线| 欧美日韩免费高清一区色橹橹| 欧美国产一区二区在线观看| 奇米影视在线99精品| 在线视频一区二区免费| 国产女人18毛片水真多成人如厕 | 激情六月婷婷综合| 欧美日本在线看| 最新中文字幕一区二区三区| 狠狠久久亚洲欧美| 欧美一个色资源| 亚洲一区二区av电影| 色婷婷精品久久二区二区蜜臂av | 亚洲黄色性网站| 成人免费高清在线| 亚洲精品一区二区三区福利| 偷窥国产亚洲免费视频| 色综合天天性综合| 国产精品女主播av| 从欧美一区二区三区| 久久天天做天天爱综合色| 久久99国产精品麻豆| 欧美一区二区三区喷汁尤物| 午夜电影一区二区| 欧美日韩一区 二区 三区 久久精品| 亚洲欧美日韩久久| 91亚洲精华国产精华精华液| 中文字幕一区日韩精品欧美| av电影一区二区| 亚洲精品欧美专区|