www.pudn.com > ARM_Ethernet.rar > rcf_socket.h, change:2006-04-07,size:7984b


/****************************************Copyright (c)************************************************** 
**                               Guangzou ZLG-MCU Development Co.,LTD. 
**                                      graduate school 
**                                 http://www.zlgmcu.com 
** 
**--------------File Info------------------------------------------------------------------------------- 
** File Name: rcf_socket.h 
** Last modified Date:  2004-11-27 
** Last Version: 1.0 
** Descriptions: socket HEAD FILE 
** 
**------------------------------------------------------------------------------------------------------ 
** Created By: Yehaoben 
** Created date:   2004-11-27 
** Version: 1.0 
** Descriptions: First version 
** 
**------------------------------------------------------------------------------------------------------ 
** Modified by: 
** Modified date: 
** Version: 
** Descriptions: 
** 
********************************************************************************************************/ 
 
#ifdef SOCKET_GLOBALS 
#define SOCKET_EXT 
#else 
#define SOCKET_EXT extern  
#endif  
 
#define	SOCKET	unsigned char 
 
#define PF_INET		0 
#define AF_INET		1 
 
/* 
 * Level number for (get/set)sockopt() to apply to socket itself. 
 */ 
#define SOL_SOCKET      0xffff          /* options for socket level */ 
 
/* 
 * Types 
 */ 
#define SOCK_STREAM     1               /* stream socket */ 
#define SOCK_DGRAM      2               /* datagram socket */ 
#define SOCK_RAW        3               /* raw-protocol interface */ 
#define SOCK_RDM        4               /* reliably-delivered message */ 
#define SOCK_SEQPACKET  5               /* sequenced packet stream */ 
 
/* 
 * Option flags per-socket. 
 */ 
#define SO_DEBUG        0x0001          /* turn on debugging info recording */ 
#define SO_ACCEPTCONN   0x0002          /* socket has had listen() */ 
#define SO_REUSEADDR    0x0004          /* allow local address reuse */ 
#define SO_KEEPALIVE    0x0008          /* keep connections alive */ 
#define SO_DONTROUTE    0x0010          /* just use interface addresses */ 
#define SO_BROADCAST    0x0020          /* permit sending of broadcast msgs */ 
#define SO_USELOOPBACK  0x0040          /* bypass hardware when possible */ 
#define SO_LINGER             0x0080          /* linger on close if data present */ 
#define SO_OOBINLINE    0x0100          /* leave received OOB data in line */ 
 
#define SO_DONTLINGER   (u_int)(~SO_LINGER) 
 
/* 
 * Additional options. 
 */ 
#define SO_SNDBUF       0x1001          /* send buffer size */ 
#define SO_RCVBUF       0x1002          /* receive buffer size */ 
#define SO_SNDLOWAT     0x1003          /* send low-water mark */ 
#define SO_RCVLOWAT     0x1004          /* receive low-water mark */ 
#define SO_SNDTIMEO     0x1005          /* send timeout */ 
#define SO_RCVTIMEO     0x1006          /* receive timeout */ 
#define SO_ERROR        0x1007          /* get error status and clear */ 
#define SO_TYPE         0x1008          /* get socket type */ 
 
 
 
#define TCP_PROTOCOL	0 
#define UDP_PROTOCOL	1 
 
#ifndef	MAX_TCP_LINKS	 
#define MAX_TCP_LINKS	0 
#endif 
 
#ifndef	MAX_UDP_LINKS	 
#define MAX_UDP_LINKS	0 
#endif 
 
#define MAX_SOCKETS	MAX_TCP_LINKS+MAX_UDP_LINKS 
 
#define INVALID_SOCKET  (SOCKET)(~0) 
#define SOCKET_ERROR    (SOCKET)(~0)//(-1) 
#define SOCKET_RCV_ERROR	(unsigned short)(-1) 
#define SOCKET_SENFM_ERROR	SOCKET_RCV_ERROR 
#define SOCKET_SEN_ERROR	(unsigned int)(-1) 
 
/************ error reasons ********************/ 
/* 
 * All Zlg Sockets error constants are biased by ZLGBASEERR from 
 * the "normal" 
 */ 
#define ZLGBASEERR              10000 
/* 
 * ZLG Sockets definitions of regular C error constants 
 */ 
#define ZLGEINTR                (ZLGBASEERR+4) 
#define ZLGEBADF                (ZLGBASEERR+9) 
#define ZLGEACCES               (ZLGBASEERR+13) 
#define ZLGEFAULT               (ZLGBASEERR+14) 
/* 地址长度太小 (bind) */ 
#define ZLGEINVAL				(ZLGBASEERR+22) 
/* 在ACCEPT前未激活listen,(accpet) */ 
#define ZLGEMFILE               (ZLGBASEERR+24) 
/* 调用accept时队列为空, (accpet) */ 
/* 
 * ZLG Sockets definitions of regular Berkeley error constants 
 */ 
#define ZLGEWOULDBLOCK          (ZLGBASEERR+35) 
#define ZLGEINPROGRESS          (ZLGBASEERR+36) 
#define ZLGEALREADY             (ZLGBASEERR+37) 
#define ZLGENOTSOCK             (ZLGBASEERR+38) /* 描述字不是一个SOCKET (bind,listen)*/ 
#define ZLGEDESTADDRREQ         (ZLGBASEERR+39) 
#define ZLGEMSGSIZE             (ZLGBASEERR+40) 
#define ZLGEPROTOTYPE           (ZLGBASEERR+41)	/* 指定的协议不适用于本SOCKET (socket)*/ 
#define ZLGENOPROTOOPT          (ZLGBASEERR+42) 
#define ZLGEPROTONOSUPPORT      (ZLGBASEERR+43) /* 不支持指定的协议 (socket)*/ 
#define ZLGESOCKTNOSUPPORT      (ZLGBASEERR+44) 
#define ZLGEOPNOTSUPP           (ZLGBASEERR+45) /* socket不正常调用listen (listen) */ 
#define ZLGEPFNOSUPPORT         (ZLGBASEERR+46) 
#define ZLGEAFNOSUPPORT         (ZLGBASEERR+47) 
#define ZLGEADDRINUSE           (ZLGBASEERR+48) /* 所定端口已在使用 (bind,listen) */ 
#define ZLGEADDRNOTAVAIL        (ZLGBASEERR+49) 
#define ZLGENETDOWN             (ZLGBASEERR+50) 
#define ZLGENETUNREACH          (ZLGBASEERR+51) 
#define ZLGENETRESET            (ZLGBASEERR+52) 
#define ZLGECONNABORTED         (ZLGBASEERR+53) 
#define ZLGECONNRESET           (ZLGBASEERR+54) 
#define ZLGENOBUFS              (ZLGBASEERR+55) /* 无可用缓存区 (socket,listen,accept)*/ 
#define ZLGEISCONN              (ZLGBASEERR+56) 
#define ZLGENOTCONN             (ZLGBASEERR+57) 
#define ZLGESHUTDOWN            (ZLGBASEERR+58) 
#define ZLGETOOMANYREFS         (ZLGBASEERR+59) 
#define ZLGETIMEDOUT            (ZLGBASEERR+60) 
#define ZLGECONNREFUSED         (ZLGBASEERR+61) 
#define ZLGELOOP                (ZLGBASEERR+62) 
#define ZLGENAMETOOLONG         (ZLGBASEERR+63) 
#define ZLGEHOSTDOWN            (ZLGBASEERR+64) 
#define ZLGEHOSTUNREACH         (ZLGBASEERR+65) 
#define ZLGENOTEMPTY            (ZLGBASEERR+66) 
#define ZLGEPROCLIM             (ZLGBASEERR+67) 
#define ZLGEUSERS               (ZLGBASEERR+68) 
#define ZLGEDQUOT               (ZLGBASEERR+69) 
#define ZLGESTALE               (ZLGBASEERR+70) 
#define ZLGEREMOTE              (ZLGBASEERR+71) 
 
#define ZLGEDISCON              (ZLGBASEERR+101) 
 
/* 
 * Extended ZLG Sockets error constant definitions 
 */ 
#define ZLGSYSNOTREADY          (ZLGBASEERR+91) 
#define ZLGVERNOTSUPPORTED      (ZLGBASEERR+92) 
#define ZLGNOTINITIALISED       (ZLGBASEERR+93)	/* 使用该API之前应先初始化,调用socket (bind,listen) */ 
#define ZLGNOTMOREUDPLINK       (ZLGBASEERR+94) /* UDP 连接不够 (socket) */ 
 
/* 
 * Error return codes from gethostbyname() and gethostbyaddr() 
 * (when using the resolver). Note that these errors are 
 * retrieved via ZLGGetLastError() and must therefore follow 
 * the rules for avoiding clashes with error numbers from 
 * specific implementations or language run-time systems. 
 * For this reason the codes are based at ZLGBASEERR+1001. 
 * Note also that [ZLG]NO_ADDRESS is defined only for 
 * compatibility purposes. 
 */ 
 
 
/******************************************************************************************************** 
**                             Structure Define 
********************************************************************************************************/ 
typedef struct { 
			uint8 		State;				/* BIT5 ENABLE */ 
			uint16		protocol; 
			uint16		af; 
			uint16		type; 
			uint8		My_Ip[4]; 
			uint16		My_Port; 
			uint16		Max_Queue; 
			uint8		queue[MAX_TCP_LINKS]; 
			uint8		Udp_Queue; 
			uint8		BCFlag;//广播标志 
			}SOCKET_ST; 
struct	sockaddr{ 
			uint16		sin_family; 
			uint8		sin_addr[4]; 
			uint16		sin_port; 
	}; 
/********************************************************************************************************* 
**                            End Of File 
********************************************************************************************************/