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

📄 net.h

📁 基于东南大学开发的SEP3203的ARM7中的所有驱动
💻 H
📖 第 1 页 / 共 2 页
字号:
/*****************************************************************************

* net.h - Network communications global header file.

*

* Copyright (c) 1998 Global Election Systems Inc.

*

* The authors hereby grant permission to use, copy, modify, distribute,

* and license this software and its documentation for any purpose, provided

* that existing copyright notices are retained in all copies and that this

* notice and the following disclaimer are included verbatim in any 

* distributions. No written agreement, license, or royalty fee is required

* for any of the authorized uses.

*

* THIS SOFTWARE IS PROVIDED BY THE 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 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.

*

******************************************************************************

* REVISION HISTORY

*

* 98-01-30 Guy Lancaster <glanca@gesn.com>, Global Election Systems Inc.

*	Original built from BSD network code.

******************************************************************************

* PURPOSE

*

*	This file contains all of the "global" data needed by the communications

* code.  This includes code collected from a number of public code sources as

* well as the code to interface it to our environment.

*****************************************************************************/

/*

 * ++Copyright++ 1985, 1989

 * -

 * Copyright (c) 1985, 1989

 *    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.

 * -

 * Portions Copyright (c) 1993 by Digital Equipment Corporation.

 * 

 * Permission to use, copy, modify, and distribute this software for any

 * purpose with or without fee is hereby granted, provided that the above

 * copyright notice and this permission notice appear in all copies, and that

 * the name of Digital Equipment Corporation not be used in advertising or

 * publicity pertaining to distribution of the document or software without

 * specific, written prior permission.

 * 

 * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL

 * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES

 * OF MERCHANTABILITY AND FITNESS.   IN NO EVENT SHALL DIGITAL EQUIPMENT

 * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL

 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR

 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS

 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS

 * SOFTWARE.

 * -

 * --Copyright--

 */

/*

 * pppd.h - PPP daemon global declarations.

 *

 * Copyright (c) 1989 Carnegie Mellon University.

 * All rights reserved.

 *

 * Redistribution and use in source and binary forms are permitted

 * provided that the above copyright notice and this paragraph are

 * duplicated in all such forms and that any documentation,

 * advertising materials, and other materials related to such

 * distribution and use acknowledge that the software was developed

 * by Carnegie Mellon University.  The name of the

 * University may not be used to endorse or promote products derived

 * from this software without specific prior written permission.

 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR

 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED

 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.

 *

 * $Id: NET.H,v 1.1.1.1 2004/12/22 10:02:09 zyu Exp $

 */

/*

 * ppp_defs.h - PPP definitions.

 *

 * Copyright (c) 1994 The Australian National University.

 * All rights reserved.

 *

 * Permission to use, copy, modify, and distribute this software and its

 * documentation is hereby granted, provided that the above copyright

 * notice appears in all copies.  This software is provided without any

 * warranty, express or implied. The Australian National University

 * makes no representations about the suitability of this software for

 * any purpose.

 *

 * IN NO EVENT SHALL THE AUSTRALIAN NATIONAL UNIVERSITY BE LIABLE TO ANY

 * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES

 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF

 * THE AUSTRALIAN NATIONAL UNIVERSITY HAVE BEEN ADVISED OF THE POSSIBILITY

 * OF SUCH DAMAGE.

 *

 * THE AUSTRALIAN NATIONAL UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES,

 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY

 * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS

 * ON AN "AS IS" BASIS, AND THE AUSTRALIAN NATIONAL UNIVERSITY HAS NO

 * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,

 * OR MODIFICATIONS.

 */



/*

 * Constants and structures defined by the internet system,

 * Per RFC 790, September 1981, and numerous additions.

 */



#ifndef NET_H

#define NET_H



#include "os.h"

#include "nettypes.h"



#define KILOBYTE 1024L				/* Bytes in a kilobyte */

#define u_long unsigned long





/************************

*** PUBLIC DATA TYPES ***

************************/



/*

 * Interface types.

 */

/* Supported network interface types. */

typedef enum {

	IFT_UNSPEC = 0,				/* No interface */

	IFT_PPP,					/* Point-to-Point Protocol */

	IFT_ETH 					/* Ethernet 802.2 Protocol */

} IfType;





/*

 * Address families.

 */

#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_IMPLINK		3			/* arpanet imp addresses */

#define	AF_PUP			4			/* pup protocols: e.g. BSP */

#define	AF_CHAOS		5			/* mit CHAOS protocols */

#define	AF_NS			6			/* XEROX NS protocols */

#define	AF_ISO			7			/* ISO protocols */

#define	AF_OSI			AF_ISO

#define	AF_ECMA			8			/* european computer manufacturers */

#define	AF_DATAKIT		9			/* datakit protocols */

#define	AF_CCITT		10			/* CCITT protocols, X.25 etc */

#define	AF_SNA			11			/* IBM SNA */

#define	AF_DECnet		12			/* DECnet */

#define	AF_DLI			13			/* DEC Direct data link interface */

#define	AF_LAT			14			/* LAT */

#define	AF_HYLINK		15			/* NSC Hyperchannel */

#define	AF_APPLETALK	16			/* Apple Talk */

#define	AF_ROUTE		17			/* Internal Routing Protocol */

#define	AF_LINK			18			/* Link layer interface */

#define	pseudo_AF_XTP	19			/* eXpress Transfer Protocol (no AF) */

#define	AF_COIP			20			/* connection-oriented IP, aka ST II */

#define	AF_CNT			21			/* Computer Network Technology */

#define	pseudo_AF_RTIP	22			/* Help Identify RTIP packets */

#define	AF_IPX			23			/* Novell Internet Protocol */

#define	AF_SIP			24			/* Simple Internet Protocol */

#define	pseudo_AF_PIP	25			/* Help Identify PIP packets */

#define	AF_ISDN			26			/* Integrated Services Digital Network*/

#define	AF_E164			AF_ISDN		/* CCITT E.164 recommendation */

#define	pseudo_AF_KEY	27			/* Internal key-management function */

#define	AF_INET6		28			/* IPv6 */

#define	AF_NATM			29			/* native ATM access */

#define	AF_PPP			30			/* PPP protocols */



#define	AF_MAX			31



/*

 * Protocols

 */

#define	IPPROTO_IP		0			/* dummy for IP */

#define	IPPROTO_ICMP	1			/* control message protocol */

#define	IPPROTO_IGMP	2			/* group mgmt protocol */

#define	IPPROTO_GGP		3			/* gateway^2 (deprecated) */

#define	IPPROTO_TCP		6			/* tcp */

#define	IPPROTO_EGP		8			/* exterior gateway protocol */

#define	IPPROTO_PUP		12			/* pup */

#define	IPPROTO_UDP		17			/* user datagram protocol */

#define	IPPROTO_IDP		22			/* xns idp */

#define	IPPROTO_TP		29 			/* tp-4 w/ class negotiation */

#define	IPPROTO_EON		80			/* ISO cnlp */

#define	IPPROTO_ENCAP	98			/* encapsulation header */



#define	IPPROTO_RAW		255			/* raw IP packet */

#define	IPPROTO_MAX		256









#define	IPPORT_DOMAIN 		53

#define	IPPORT_HTTP			80





/*

 * The arguments to the ctlinput routine are

 *	(*protosw[].pr_ctlinput)(cmd, sa, arg);

 * where cmd is one of the commands below, sa is a pointer to a sockaddr,

 * and arg is an optional caddr_t argument used within a protocol family.

 */

#define	PRC_IFDOWN				0	/* interface transition */

#define	PRC_ROUTEDEAD			1	/* select new route if possible ??? */

#define	PRC_QUENCH2				3	/* DEC congestion bit says slow down */

#define	PRC_QUENCH				4	/* some one said to slow down */

#define	PRC_MSGSIZE				5	/* message size forced drop */

#define	PRC_HOSTDEAD			6	/* host appears to be down */

#define	PRC_HOSTUNREACH			7	/* deprecated (use PRC_UNREACH_HOST) */

#define	PRC_UNREACH_NET			8	/* no route to network */

#define	PRC_UNREACH_HOST		9	/* no route to host */

#define	PRC_UNREACH_PROTOCOL	10	/* dst says bad protocol */

#define	PRC_UNREACH_PORT		11	/* bad port # */

/* was	PRC_UNREACH_NEEDFRAG	12	   (use PRC_MSGSIZE) */

#define	PRC_UNREACH_SRCFAIL		13	/* source route failed */

#define	PRC_REDIRECT_NET		14	/* net routing redirect */

#define	PRC_REDIRECT_HOST		15	/* host routing redirect */

#define	PRC_REDIRECT_TOSNET		16	/* redirect for type of service & net */

#define	PRC_REDIRECT_TOSHOST	17	/* redirect for tos & host */

#define	PRC_TIMXCEED_INTRANS	18	/* packet lifetime expired in transit */

#define	PRC_TIMXCEED_REASS		19	/* lifetime expired on reass q */

#define	PRC_PARAMPROB			20	/* header incorrect */



#define	PRC_NCMDS				21



#define	PRC_IS_REDIRECT(cmd)	\
	((cmd) >= PRC_REDIRECT_NET && (cmd) <= PRC_REDIRECT_TOSHOST)





/*

 * The basic PPP frame.

 */

#define PPP_HDRLEN	4		/* octets for standard ppp header */

#define PPP_FCSLEN	2		/* octets for FCS */





/*

 * Significant octet values.

 */

#define	PPP_ALLSTATIONS	0xff	/* All-Stations broadcast address */

#define	PPP_UI			0x03	/* Unnumbered Information */

#define	PPP_FLAG		0x7e	/* Flag Sequence */

#define	PPP_ESCAPE		0x7d	/* Asynchronous Control Escape */

#define	PPP_TRANS		0x20	/* Asynchronous transparency modifier */



/*

 * Protocol field values.

 */

#define	PPP_IP			0x21	/* Internet Protocol */

#define	PPP_AT			0x29	/* AppleTalk Protocol */

#define	PPP_VJC_COMP	0x2d	/* VJ compressed TCP */

#define	PPP_VJC_UNCOMP	0x2f	/* VJ uncompressed TCP */

#define	PPP_COMP		0xfd	/* compressed packet */

#define	PPP_IPCP		0x8021	/* IP Control Protocol */

#define	PPP_ATCP		0x8029	/* AppleTalk Control Protocol */

#define	PPP_CCP			0x80fd	/* Compression Control Protocol */

#define	PPP_LCP			0xc021	/* Link Control Protocol */

#define	PPP_PAP			0xc023	/* Password Authentication Protocol */

#define	PPP_LQR			0xc025	/* Link Quality Report protocol */

#define	PPP_CHAP		0xc223	/* Cryptographic Handshake Auth. Protocol */

#define	PPP_CBCP		0xc029	/* Callback Control Protocol */



/*

 * Values for FCS calculations.

 */

#define	PPP_INITFCS	0xffff	/* Initial FCS value */

#define	PPP_GOODFCS	0xf0b8	/* Good final FCS value */

#define	PPP_FCS(fcs, c)	(((fcs) >> 8) ^ fcstab[((fcs) ^ (c)) & 0xff])



/*

 * Extended asyncmap - allows any character to be escaped.

 */

typedef u_char	ext_accm[32];



/*

 * What to do with network protocol (NP) packets.

 */

enum NPmode {

    NPMODE_PASS,		/* pass the packet through */

    NPMODE_DROP,		/* silently drop the packet */

    NPMODE_ERROR,		/* return an error */

    NPMODE_QUEUE		/* save it up for later. */

};



/*

 * Inline versions of get/put char/short/long.

 * Pointer is advanced; we assume that both arguments

 * are lvalues and will already be in registers.

 * cp MUST be u_char *.

 */

#define GETCHAR(c, cp) { \
	(c) = *(cp)++; \
}

#define PUTCHAR(c, cp) { \
	*(cp)++ = (u_char) (c); \
}





#define GETSHORT(s, cp) { \
	(s) = *(cp)++ << 8; \
	(s) |= *(cp)++; \
}

#define PUTSHORT(s, cp) { \
	*(cp)++ = (u_char) ((s) >> 8); \
	*(cp)++ = (u_char) (s); \
}



#define GETLONG(l, cp) { \
	(l) = *(cp)++ << 8; \
	(l) |= *(cp)++; (l) <<= 8; \
	(l) |= *(cp)++; (l) <<= 8; \
	(l) |= *(cp)++; \
}

#define PUTLONG(l, cp) { \
	*(cp)++ = (u_char) ((l) >> 24); \
	*(cp)++ = (u_char) ((l) >> 16); \
	*(cp)++ = (u_char) ((l) >> 8); \
	*(cp)++ = (u_char) (l); \
}





#define INCPTR(n, cp)	((cp) += (n))

#define DECPTR(n, cp)	((cp) -= (n))



#define BCMP(s0, s1, l)		memcmp((u_char *)(s0), (u_char *)(s1), (l))

#define BCOPY(s, d, l)		memcpy((d), (s), (l))

#define bcopy(s, d, l)		memcpy((d), (s), (l))

#define BZERO(s, n)			memset(s, 0, n)

⌨️ 快捷键说明

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