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

📄 netsock.h

📁 基于东南大学开发的SEP3203的ARM7中的所有驱动
💻 H
字号:
/* netsock.h - headers for BSD Socket API

 * $Id: netsock.h,v 1.1.1.1 2004/12/22 10:02:10 zyu Exp $

 * Copyright (C)2002 Jiang Wei.

 */



/* Source code here is derived from and based upon sys/socket.h of  4.4BSD,

 * distributed by Univ. of Calif., Berkley and BSDi.

 *

 * Copyright (c) 1982, 1985, 1986, 1988, 1993, 1994

 *	The Regents of the University of California.  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. All advertising materials mentioning features or use of this software

 *    must display the following acknowledgement:

 *	This product includes software developed by the University of

 *	California, Berkeley and its contributors.

 * 4. Neither the name of the University nor the names of its contributors

 *    may be used to endorse or promote products derived from this software

 *    without specific prior written permission.

 *

 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND

 * ANY EXPRESS 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 THE REGENTS OR 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.

 *

 *	@(#)socket.h	8.4 (Berkeley) 2/21/94

  */



#ifndef _NETSOCK_H

#define _NETSOCK_H





#define MAXSOCK	10



/*

 * 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_REUSEPORT	0x0200		/* allow local address & port reuse */

#define	SO_TIMESTAMP	0x0400		/* timestamp received dgram traffic */



/*

 * Level number for (get/set)sockopt() to apply to socket itself.

 */

#define	SOL_SOCKET	0xffff		/* options for socket level */



/*

 * Address families.

 */

 #ifndef NET_H

#define	AF_UNSPEC	0		/* unspecified */

#define	AF_LOCAL	1		/* local to host (pipes, portals) */

#define	AF_UNIX		AF_LOCAL	/* backward compatibility */

#define	AF_INET		2		/* internetwork: UDP, TCP, etc. */



#define	AF_MAX		3



#define	PF_UNSPEC	AF_UNSPEC

#define	PF_LOCAL	AF_LOCAL

#define	PF_UNIX		PF_LOCAL	/* backward compatibility */

#define	PF_INET		AF_INET

#endif



/*

 * Structure used by kernel to store most

 * addresses.

 */

/*struct sockaddr {

	u_char		sa_len;		 total length */

/*	sa_family_t	sa_family;	 address family */

/*	char		sa_data[14];	 actually longer; address value */

/*}; */

#define	SOCK_MAXADDRLEN	255		/* longest possible addresses */



/*

 * Maximum queue length specifiable by listen.

 */

#define	SOMAXCONN	128



/*

 * 4.3 compat sockaddr, move to compat file later

 */

struct osockaddr {

	u_short	sa_family;		/* address family */

	char	sa_data[14];		/* up to 14 bytes of direct address */

};



/*

 * howto arguments for shutdown(2), specified by Posix.1g.

 */

#define	SHUT_RD		0		/* shut down the reading side */

#define	SHUT_WR		1		/* shut down the writing side */

#define	SHUT_RDWR	2		/* shut down both sides */



#define ssize_t long

#define off_t long

#define size_t long

#define socklen_t long



int	accept(int, struct sockaddr *, socklen_t *);

int	bind (int, const struct sockaddr *, socklen_t);

int	connect (int, const struct sockaddr *, socklen_t);

int	getpeername (int, struct sockaddr *, socklen_t *);

int	getsockname (int, struct sockaddr *, socklen_t *);

int	getsockopt (int, int, int, void *, socklen_t *);

int	listen (int, int);

ssize_t	recv (int, void *, size_t, int);

ssize_t	recvfrom (int, void *, size_t, int, struct sockaddr *, socklen_t *);

ssize_t	send (int, const void *, size_t, int);

ssize_t	sendto (int, const void *, size_t, int, const struct sockaddr *, socklen_t);

int	setsockopt (int, int, int, const void *, socklen_t);

int	socket (int, int, int);

int	close(int);



#endif /* _NETSOCK_H */



⌨️ 快捷键说明

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