⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 so.h

📁 用于嵌入式系统的TCP/IP协议栈及若干服务
💻 H
字号:
/**            Copyright (c) 1998-2001 by NETsilicon Inc.**  This software is copyrighted by and is the sole property of*  NETsilicon.  All rights, title, ownership, or other interests*  in the software remain the property of NETsilicon.  This*  software may only be used in accordance with the corresponding*  license agreement.  Any unauthorized use, duplication, transmission,*  distribution, or disclosure of this software is expressly forbidden.**  This Copyright notice may not be removed or modified without prior*  written consent of NETsilicon.**  NETsilicon, reserves the right to modify this software*  without notice.**  NETsilicon*  411 Waverley Oaks Road                  USA 781.647.1234*  Suite 227                               http://www.netsilicon.com*  Waltham, MA 02452                       AmericaSales@netsilicon.com***************************************************************************  $Name: Fusion 6.52 Fusion 6.51 $*  $Date: 2001/09/20 10:19:23 $*  $Source: M:/psisrc/stack/incl/rcs/so.h $*  $Revision: 1.14 $***************************************************************************  File Description:  Definitions and Macros for dealing with the `so_t'*                     (Socket) structure**************************************************************************/#ifndef _SO_#define _SO_#include "config.h"#include "ccdep.h"#include "q.h"#include "std.h"#include "socket.h"#include "timer.h"#include "dsu.h"#include "psu.h"#include "in.h"/* flags for sock_t.so_flags */#define F_SO_OPEN       (u16)0x0001#define F_SO_CONNECTED  (u16)0x0002/*                      */#define F_SO_TEMP       (u16)0x0004#define F_SO_ICLOSE     (u16)0x0008         /* Close is occuring from socket layer down                                            */#define F_SO_CLOSING    (u16)0x0010#define F_SO_RSHUTDOWN  (u16)0x0020          /* reading shutdown */#define F_SO_WSHUTDOWN  (u16)0x0040          /* writing shutdown */#define F_SO_MAKING_PROGRESS  (u16)0x0080  /* Making progress towards close */#define F_SO_LAST_CHANCE      (u16)0x0100  /* Last chance to close it */#define F_SO_NTSETUP    (u16)0x0200          /* joined to net terminal */#define F_SO_LOOPMULTI  (u16)0x400           /* Loopback of multicast datagrams                                                sent by this socket (if this machine											    is a member of the multicast group)											    default is that its enabled */#ifdef  DYNASOCK#define is_closing(sop)         ((sop) && bT1((sop)->so_flags,F_SO_CLOSING))#define is_connected(sop)       ((sop) && bT1((sop)->so_flags,F_SO_CONNECTED))#define is_open(sop)            ((sop) && bT1((sop)->so_flags,F_SO_OPEN))#define is_packet(sop)          ((sop) && !is_stream(sop))#define is_stream(sop)          ((sop) && (sop)->so_prp->pr_type == SOCK_STREAM)#define is_rshutdown(sop)       ((sop) && bT1((sop)->so_flags,F_SO_RSHUTDOWN))#define is_wshutdown(sop)       ((sop) && bT1((sop)->so_flags,F_SO_WSHUTDOWN))#define is_info_socket(sop)     ((sop) && (sop)->so_index == 0)#define needs_connect(sop)      ((sop) && bT1((sop)->so_prp->pr_flags,F_PR_NEEDS_CONNECT))#else#define is_closing(sop)         bT1((sop)->so_flags,F_SO_CLOSING)#define is_connected(sop)       bT1((sop)->so_flags,F_SO_CONNECTED)#define is_open(sop)            bT1((sop)->so_flags,F_SO_OPEN)#define is_packet(sop)          (!is_stream(sop))#define is_stream(sop)          ((sop)->so_prp->pr_type == SOCK_STREAM)#define is_rshutdown(sop)       bT1((sop)->so_flags,F_SO_RSHUTDOWN)#define is_wshutdown(sop)       bT1((sop)->so_flags,F_SO_WSHUTDOWN)#define is_info_socket(sop)     ((sop)->so_index == 0)#define needs_connect(sop)      bT1((sop)->so_prp->pr_flags,F_PR_NEEDS_CONNECT)#endif#define so_cqhead(sop,errp,wait_ok)     ((m *)gq_head(&((sop)->so_cq),errp,wait_ok))#define so_rqhead(sop,errp,wait_ok)     ((m *)gq_head(&((sop)->so_rq),errp,wait_ok))#define so_rqwaiting(sop)       ((sop)->so_rq.gq_sleeping)#define so_rqout(sop)           gq_out(&(sop)->so_rq,1)#define so_clr_notify(sop, news)        ((sop)->so_news &= ~(news))/* socket multicast group membership */typedef struct so_mcast_t {	struct so_mcast_t *next; /* forward link */	struct so_mcast_t *prev; /* forward link */	struct netdev *ndp;	/* device on which multicast packet received */	struct in_addr multiaddr; /* the multicast group */ } so_mcast_t;/* list of multicast group membership structures */typedef struct so_mcast_list_t {	struct so_mcast_t *first;	struct so_mcast_t *last;} so_mcast_list_t;/* socket */typedef struct so_t {	q               so_q;           /* for protocol/family use */	gq              so_cq;          /* connection queue */	gq              so_sq;          /* send queue */	gq              so_rq;          /* receive queue */	gq              so_hq;          /* holding queue */	so_addr         so_dest;        /* where we're going to */	so_addr         so_src;         /* our network address (sans net #) */	secure          so_secure;      /* security structure */	struct pr_t     * so_prp;       /* protocol entrypoint pointer */	struct netdev   * so_ndp;       /* Link for RAW stuff */	struct so_t     * so_pair;      /* paired socket */	q               so_sonq;        /* for event notification */	u16             so_flags;       /* socket flags */	u16             so_index;       /* this sockets index */	u16             so_psize;       /* maximum packet size */	u16             so_hsize;       /* maximum header size */#ifdef SOCKET_USE_OLD_SOCKOPT_FUNCTIONS	u16             so_options;     /* socket option flags */#else	u32             so_options;     /* socket option flags */#endif	u16             so_poptions;    /* protocol specific option flags */	u16             so_news;        /* news awaiting notification */	i16             so_nti;         /* net terminal structure index */	int             so_err;         /* error recorded for a socket by asynchronous									   process -- gets recorded in "so_error" when	                                   returned to application via *errp parameter of									   any API function */	int				so_error;		/* most recent error for a socket, available to									   user via the SO_ERROR socket, matches error codes									   returned in the *errp parameter of the fns API									   socket functions */	tcb				*so_ctcb;		/* pointer to close timer block */	psu             so_psu;         /* protocol specific union */	/* the following fields were added to hold the values of multicast-related 	   socket options */	u8				mc_ttl;			/* time-to-live for multicast packets sent by									   this socket -- defaults to 1 */	struct netdev	*mc_ndp;		/* device on which outgoing multicast datagrams									   should be transmitted for this socket */	so_mcast_list_t	so_mcast_list;  /* List of multicast group memberships for this									   socket */} so_t;import  so_t    ** sop_tbl;/* macro for the FNS API functions to return an error to the caller and record   the error in the socket structure for querying by the SO_ERROR socket option */#define SOCKET_ERROR_RETURN(s,e) {s->so_error = *e; return(ERR);}/******************************************************************************//* Data strucutre for storing entries in a table of information about the     *//* socket options, for use in building validation and dispatch tables for     *//* socket options. Used at the TCP and SOCKET levels -- could be used at IP   *//* level too with a little effort                                             *//******************************************************************************/typedef struct _sockopt_entry_ {     int optname;    int optvalsize;    int  (*getfunc)(so_t *sop,int optname,char *optval);  /* function to call to "get" this option */    int  (*setfunc)(so_t *sop,int optname,char *optval);  /* function to call to "set" this option */} sockopt_entry_;/*********************************************************************//* Function to look for a specified optname in our table of          *//* sockopt_entry_ structures. Parameters are the option name and     *//* a pointer to the first entry in the table.                        *//*   Returns pointer to the specified entry or NULL if not found     *//*********************************************************************/import sockopt_entry_ *find_sockopt_entry(int optname,sockopt_entry_ *tbl);/*********************************************************************//* functions to process a specified socket option using the information in   the specified socket option entry table *//*********************************************************************/import int process_set_sockopt(so_t * sop,int optname,u8 *optval, int optlen, 							   sockopt_entry_ *tbl);export int process_get_sockopt(so_t * sop,int optname,u8 *optval, int *optlen, 							   sockopt_entry_ *tbl);#endif  /*_SO_*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -