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

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

?? udp.c

?? 在freescale 的ne64上開發的源代碼
?? C
?? 第 1 頁 / 共 2 頁
字號:
/*
 *Copyright (c) 2000-2002 Viola Systems Ltd.
 *All rights reserved.
 *
 *Redistribution and use in source and binary forms, with or without 
 *modification, are permitted provided that the following conditions 
 *are met:
 *
 *1. Redistributions of source code must retain the above copyright 
 *notice, this list of conditions and the following disclaimer.
 *
 *2. Redistributions in binary form must reproduce the above copyright 
 *notice, this list of conditions and the following disclaimer in the 
 *documentation and/or other materials provided with the distribution.
 *
 *3. The end-user documentation included with the redistribution, if 
 *any, must include the following acknowledgment:
 *	"This product includes software developed by Viola 
 *	Systems (http://www.violasystems.com/)."
 *
 *Alternately, this acknowledgment may appear in the software itself, 
 *if and wherever such third-party acknowledgments normally appear.
 *
 *4. The names "OpenTCP" and "Viola Systems" must not be used to 
 *endorse or promote products derived from this software without prior 
 *written permission. For written permission, please contact 
 *opentcp@opentcp.org.
 *
 *5. Products derived from this software may not be called "OpenTCP", 
 *nor may "OpenTCP" appear in their name, without prior written 
 *permission of the Viola Systems Ltd.
 *
 *THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED 
 *WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
 *MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
 *IN NO EVENT SHALL VIOLA SYSTEMS LTD. OR ITS CONTRIBUTORS BE LIABLE 
 *FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
 *CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
 *SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 
 *BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
 *WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 
 *OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 
 *EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *====================================================================
 *
 *OpenTCP is the unified open source TCP/IP stack available on a series 
 *of 8/16-bit microcontrollers, please see <http://www.opentcp.org>.
 *
 *For more information on how to network-enable your devices, or how to 
 *obtain commercial technical support for OpenTCP, please see 
 *<http://www.violasystems.com/>.
 */

/** \file udp.c
 *	\brief OpenTCP UDP implementation
 *	\author 
 *		\li Jari Lahti (jari.lahti@violasystems.com)
 *	\version 1.0
 *	\date 15.7.2002
 *	\bug
 *	\warning
 *	\todo
 *		\li Send ICMP Destination Unreachable when receiving UDP packets
 *		to non-existent UDP ports.
 *  
 *	OpenTCP UDP implementation. All functions necessary for UDP packet
 *	processing are present here. Note that only a small subset
 *	of these functions must be used for "normal" applications that
 *	are using the UDP for communciation. For function declarations and
 *	lots of other usefull stuff see tcp_ip.h.
 *
 *	For examples how to use UDP and write applications that communicate
 *	using UDP see main.c and udp_demo.c.
 *
 */

#include "debug.h"
#include "datatypes.h"
#include "ethernet.h"
#include "ip.h"
#include "tcp_ip.h"
#include "system.h"

/** \brief UDP table holding socket parameters for every UDP socket 
 *
 *	UDP table is an array of ucb structures holding all of the 
 *  necessary information about the state, listener, port numbers
 *	and other info about the UDP sockets opened. Number of UDP sockets
 *	that can be opened at any given time is defined by the NO_OF_UDPSOCKETS
 *	and may be changed in order to change the amount of used RAM memory.
 *	See ucb definition for more information about the structure itself.
 *
 */
struct ucb udp_socket[NO_OF_UDPSOCKETS];

/**	\brief Used for storing field information about the received UDP packet
 *	
 *	Various fields from the received UDP packet are stored in this variable.
 *	See udp_frame definition for struct information.
 */
struct udp_frame received_udp_packet;

#if (NO_OF_UDPSOCKETS < 1 )
#error Number of upd sockets must be greater than 0
#endif //  modify #define NO_OF_UDPSOCKETS	x in udp.h

/** \brief Initialize UDP socket pool
 *	\ingroup core_initializer
 * 	\author 
 *		\li Jari Lahti (jari.lahti@violasystems.com)
 *	\date 26.07.2002
 *	\return 
 *		\li -1 - Error
 *		\li >0 - Number of UDP sockets initialized
 *	\warning 
 *		\li This function <b>must</b> be invoked before any other
 *			UDP-related function is called
 *
 *	This function initializes UDP socket pool to get everything into
 *	a known state at startup.
 */
INT8 udp_init (void)
{
	UINT8 i;
	struct ucb* soc;
	
	//UDP_DEBUGOUT("Initializing UDP");
	
	for(i=0; i < NO_OF_UDPSOCKETS; i++) {
		soc = &udp_socket[i];			/* Get Socket	*/
		
		soc->state = UDP_STATE_FREE;
		soc->tos = 0;
		soc->locport = 0;
		soc->opts = UDP_OPT_SEND_CS | UDP_OPT_CHECK_CS;	 
		soc->event_listener = 0;
		
		//UDP_DEBUGOUT(".");
		
	}
	
	//UDP_DEBUGOUT("\n\rUDP Initialized\n\r");
	
	/* Return number of sockets initialized	*/
	
	return(i+1);

}

/** \brief Allocate a free socket in UDP socket pool
 *  \ingroup udp_app_api
 * 	\author 
 *		\li Jari Lahti (jari.lahti@violasystems.com)
 *	\date 26.07.2002
 *	\param tos type of service for socket. For now nothing implemented so 0.
 *	\param listener pointer to callback function that will be invoked by
 *		the TCP/IP stack to inform socket application of #UDP_DATA_ARRIVAL
 *		event (for now only this, in future maybe others!)
 *	\param opts Options for checksum generation & inspection. Can be one
 *		of the following:
 *		\li #UDP_OPT_NONE
 *		\li #UDP_OPT_SEND_CS
 *		\li #UDP_OPT_CHECK_CS
 *		\li #UDP_OPT_SEND_CS | #UDP_OPT_CHECK_CS
 *	\return 
 *		\li -1 - Error
 *		\li >=0 - Handle to reserved socket
 *
 *	Invoke this function to try to obtain a free socket from UDP socket pool.
 *	Function returns a handle to the free socket that is later used for 
 *	accessing the allocated socket.
 */
INT8 udp_getsocket (UINT8 tos, INT32 (*listener)(INT8, UINT8, UINT32, UINT16, UINT16, UINT16), UINT8 opts )
{
	INT8 i;
	struct ucb* soc;
	
	if(listener == 0) {
		//UDP_DEBUGOUT("ERROR:Event listener function for UDP not specified\r\n");
		return(-1);
	}
	
	//UDP_DEBUGOUT("Searching for free UDP socket...\r\n");
	
	for(i=0; i < NO_OF_UDPSOCKETS; i++) {
		soc = &udp_socket[i];			/* Get Socket	*/
	
		if(soc->state == UDP_STATE_FREE) {
			/* We found it	*/
			
			//UDP_DEBUGOUT("Free socket found\r\n");
			
			soc->state = UDP_STATE_CLOSED;
			soc->tos = tos;
			soc->locport = 0;
			
			soc->opts = 0;
			
			if(opts & UDP_OPT_SEND_CS)
				soc->opts |= UDP_OPT_SEND_CS;
			if(opts & UDP_OPT_CHECK_CS)
				soc->opts |= UDP_OPT_CHECK_CS;
			
			soc->event_listener = listener;

			/* Return handle	*/
			
			return(i);
		}
	
	}
	
	/* We are there so no socket found	*/
	
	//UDP_DEBUGOUT("No UDP socket found\r\n");
	return(-1);

}


/** \brief Release a given socket
 *	\ingroup udp_app_api
 * 	\author 
 *		\li Jari Lahti (jari.lahti@violasystems.com)
 *	\date 26.07.2002
 *	\param sochandle handle of UDP socket to be released
 *	\return 
 *		\li -1 - error
 *		\li >=0 - OK (returns handle to release socket)
 *
 *	This function releases UDP socket. This means that the socket entry is
 *	marked as free and all of the ucb fields are initialized to default
 *	values.
 */
INT8 udp_releasesocket (INT8 sochandle)
{
	struct ucb* soc;
	
	if( sochandle > NO_OF_UDPSOCKETS ) {
		//UDP_DEBUGOUT("Socket handle non-valid\r\n");
		return(-1);
	}
	
	if( sochandle < 0 ) {
		//UDP_DEBUGOUT("Socket handle non-valid\r\n");
		return(-1);
	}
	
	soc = &udp_socket[sochandle];		/* Get referense	*/
	
	soc->state = UDP_STATE_FREE;
	soc->tos = 0;
	soc->locport = 0;
	soc->opts = UDP_OPT_SEND_CS | UDP_OPT_CHECK_CS;	
	soc->event_listener = 0;

	return(sochandle);

}


/** \brief Open a given UDP socket for communication
 *  \ingroup udp_app_api
 * 	\author 
 *		\li Jari Lahti (jari.lahti@violasystems.com)
 *	\date 26.07.2002
 *	\param sochandle handle to socket to be opened
 *	\param locport local port number
 *	\return
 *		\li -1 - Error
 *		\li >=0 - Handle to opened socket
 *
 *	This function binds local port to given UDP socket and opens
 *	the socket (virtually) in order to enable communication.
 */
INT8 udp_open (INT8 sochandle, UINT16 locport)
{
	struct ucb* soc;
	
	if( sochandle > NO_OF_UDPSOCKETS ) {
		//UDP_DEBUGOUT("Socket handle non-valid\r\n");
		return(-1);
	}
	
	if( sochandle < 0 ) {
		//UDP_DEBUGOUT("Socket handle non-valid\r\n");
		return(-1);
	}
	
	if(locport == 0) {
		locport=udp_getfreeport();
		return(-1);
	}
	
	soc = &udp_socket[sochandle];		/* Get referense	*/

	soc->state = UDP_STATE_OPENED;
	soc->locport = locport;
	
	return(sochandle);

}



/** \brief Close given socket for communication
 *  \ingroup udp_app_api
 * 	\author 
 *		\li Jari Lahti (jari.lahti@violasystems.com)
 *	\date 26.07.2002
 *	\param sochandle handle to socket to be closed
 *	\return 
 *		\li -1 - Error
 *		\li >=0 - handle to closed socket
 *
 *	Closes a given socket in order to disable further communication
 *	over it.
 */
INT8 udp_close (INT8 sochandle)
{
	struct ucb* soc;
	
	if( sochandle > NO_OF_UDPSOCKETS ) {
		//UDP_DEBUGOUT("Socket handle non-valid\r\n");
		return(-1);
	}
	
	if( sochandle < 0 ) {
		//UDP_DEBUGOUT("Socket handle non-valid\r\n");
		return(-1);
	}
	
	soc = &udp_socket[sochandle];		/* Get referense	*/

	soc->state = UDP_STATE_CLOSED;
	
	return(sochandle);

}


/** \brief Send data to remote host using given UDP socket
 *  \ingroup udp_app_api
 * 	\author 
 *		\li Jari Lahti (jari.lahti@violasystems.com)
 *	\date 26.07.2002
 *	\param sochandle handle to UDP socket to use
 *	\param remip remote IP address to which data should be sent
 *	\param remport remote port number to which data should be sent

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久99热国产| av在线这里只有精品| 午夜av一区二区| 亚洲欧美精品午睡沙发| 久久精品欧美一区二区三区不卡 | 国产一区二区三区在线观看精品| 亚洲免费伊人电影| 亚洲人成网站在线| 亚洲免费av观看| 亚洲一区在线免费观看| 一区二区在线看| 亚洲成人动漫av| 一区二区三区成人在线视频| 五月天激情小说综合| 五月天一区二区| 国产91丝袜在线播放0| 色综合天天在线| 91欧美激情一区二区三区成人| 欧洲精品在线观看| 欧美日韩黄色一区二区| 亚洲精品一线二线三线| 中文字幕在线不卡一区| 首页欧美精品中文字幕| 99re热视频这里只精品| 精品免费一区二区三区| 亚洲欧美另类在线| 日韩经典一区二区| 91日韩在线专区| 日韩丝袜情趣美女图片| 亚洲欧美日韩电影| 日本va欧美va精品发布| 一本一道波多野结衣一区二区| 欧美大白屁股肥臀xxxxxx| 亚洲一卡二卡三卡四卡 | 亚洲丰满少妇videoshd| 成人美女视频在线看| 日韩三级中文字幕| 亚洲影院免费观看| 色偷偷一区二区三区| 26uuuu精品一区二区| 午夜精品一区二区三区三上悠亚| 成人免费av资源| 久久精品在这里| 色综合视频在线观看| 中文字幕电影一区| 国产一区二区三区在线观看免费视频| 欧美精品一卡两卡| 亚洲五月六月丁香激情| 91网站在线观看视频| 国产视频一区二区在线观看| 久久er99热精品一区二区| 欧美精选在线播放| 亚洲成av人片| 在线看国产一区| 久久久久久亚洲综合| 日韩av电影天堂| 欧美色综合网站| 日韩综合小视频| 日韩视频在线观看一区二区| 蜜桃免费网站一区二区三区| 在线电影欧美成精品| 亚洲第一主播视频| 欧美日韩国产bt| 视频一区中文字幕| 久久在线观看免费| 99久久精品久久久久久清纯| 一区二区三区日韩欧美精品| 5566中文字幕一区二区电影 | 欧美国产亚洲另类动漫| 国产盗摄一区二区| 亚洲免费视频成人| 欧美一区二区三区精品| 美洲天堂一区二卡三卡四卡视频| 欧美一区二区三区免费大片| 激情伊人五月天久久综合| 中文av一区特黄| 91精品在线免费| 黑人精品欧美一区二区蜜桃| 亚洲精品菠萝久久久久久久| 欧美一区二区在线免费播放| 成人激情小说网站| 性感美女极品91精品| 国产欧美精品一区二区色综合| 91极品美女在线| 免费精品99久久国产综合精品| 精品99一区二区三区| 欧美日韩一区二区在线观看| 国产成+人+日韩+欧美+亚洲| 一区二区激情小说| 国产精品成人在线观看| 欧美精品色一区二区三区| 99久久国产综合色|国产精品| 蜜臀久久久久久久| 亚洲午夜一二三区视频| 国产精品成人网| 精品国偷自产国产一区| 在线观看免费一区| 日本韩国欧美一区二区三区| 成人av免费在线观看| 国产一区二区三区视频在线播放| 亚洲一区视频在线| 亚洲人成网站精品片在线观看| 中文欧美字幕免费| 欧美激情中文不卡| 欧美国产日韩一二三区| 中文字幕中文字幕中文字幕亚洲无线| 91麻豆精品国产自产在线| 欧美亚洲免费在线一区| 91官网在线免费观看| 97久久超碰国产精品| 北条麻妃一区二区三区| 成人爽a毛片一区二区免费| 高清日韩电视剧大全免费| av电影一区二区| 成人免费va视频| 色婷婷国产精品| 欧美亚洲尤物久久| 在线视频一区二区免费| 欧美精品 日韩| 精品福利一区二区三区| 国产精品嫩草影院av蜜臀| 亚洲高清免费观看 | 亚洲午夜私人影院| 免费在线观看视频一区| 高清不卡一区二区在线| 欧美三区在线观看| 26uuu久久综合| 亚洲精品大片www| 三级影片在线观看欧美日韩一区二区| 三级精品在线观看| 国产河南妇女毛片精品久久久| 色狠狠综合天天综合综合| 日韩你懂的在线观看| 中文字幕不卡一区| 香蕉乱码成人久久天堂爱免费| 极品美女销魂一区二区三区免费| av网站免费线看精品| 欧美在线观看视频在线| 日韩一区二区电影网| 国产精品免费视频网站| 天天亚洲美女在线视频| 成人妖精视频yjsp地址| 精品国产一区二区精华| 日韩精品每日更新| 国产精品中文有码| 色妞www精品视频| 久久久久国产精品厨房| 天堂在线一区二区| 在线免费精品视频| 国产精品视频第一区| 成人动漫一区二区三区| 欧美成人女星排行榜| 看片的网站亚洲| 欧美日韩中文一区| 午夜欧美电影在线观看| 91日韩一区二区三区| 国产成人免费视| 精品粉嫩超白一线天av| 久久精品国产亚洲a| 91麻豆精品国产无毒不卡在线观看| 亚洲乱码国产乱码精品精的特点| 色婷婷精品久久二区二区蜜臂av| 国产精品久久夜| 成人三级在线视频| 国产精品视频yy9299一区| 成人app网站| 国产亚洲人成网站| 国产真实乱偷精品视频免| 精品国产乱码久久久久久影片| 亚洲午夜久久久久久久久电影网 | 青青国产91久久久久久| 久久久午夜精品理论片中文字幕| 蜜桃视频在线一区| 国产欧美一区二区精品婷婷| 国产精品456露脸| 亚洲黄色片在线观看| 91福利精品第一导航| 一区av在线播放| 欧美一区二区三级| 国产成人99久久亚洲综合精品| ...xxx性欧美| 91精品国产免费| 99r精品视频| 午夜视频一区在线观看| 久久一区二区视频| 色www精品视频在线观看| 日本不卡一区二区三区| 亚洲人快播电影网| 制服丝袜av成人在线看| av不卡在线播放| 日本欧美韩国一区三区| 一级女性全黄久久生活片免费| 欧美大片在线观看一区| 欧美亚一区二区| eeuss鲁片一区二区三区在线看| 午夜欧美电影在线观看| 国产精品久久久久婷婷二区次| 制服丝袜中文字幕一区| 欧美性猛交xxxxxxxx| 国产乱色国产精品免费视频|