📄 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/10/26 12:26:01 $* $Source: M:/psisrc/stack/incl/rcs/ip.h $* $Revision: 1.13 $*************************************************************************** File Description: IP (Internet Protocol) defines***************************************************************************/#ifndef _IP_#define _IP_#include "config.h"#include "ccdep.h"#include "in.h"/* ULP pseudo IP header */ /* The order is not correct, but it doesn't matter for the checksum. * This was designed to lay over the IP header overlay. */typedef u8 PIPH_T;#define PIPH_ZERO 0 /* zero byte, 1 byte */#define PIPH_PROTOCOL (PIPH_ZERO+1) /* Upper Level Protocol, 1 byte */#define PIPH_LENGTH (PIPH_PROTOCOL+1) /* ULP length, 2 bytes */#define PIPH_SADDR (PIPH_LENGTH+2) /* source address, 4 bytes */#define PIPH_DADDR (PIPH_SADDR+4) /* destination address, 4 bytes */#define SIZEOF_PIPH_T (PIPH_DADDR+4)/* IP header */typedef u8 IPH_T;#define IPH_IHL 0 /* version and IP header length, 1 byte */#define IPH_TOS (IPH_IHL+1) /* type of service, 1 byte */#define IPH_TLENGTH (IPH_TOS+1) /* total length, 2 bytes */#define IPH_IDENT (IPH_TLENGTH+2) /* identification, 2 bytes */#define IPH_FRAGOFF (IPH_IDENT+2) /* flags and fragmentation offset, 2 bytes */#define IPH_PIPH (IPH_FRAGOFF+2) /* Pseudo IP Header */#define SIZEOF_IPH_T (IPH_PIPH+SIZEOF_PIPH_T)/* defines to map rest of IP header on ULP pseudo header */#define IPH_TTL (IPH_PIPH+PIPH_ZERO)#define IPH_PROTOCOL (IPH_PIPH+PIPH_PROTOCOL)#define IPH_CHECKSUM (IPH_PIPH+PIPH_LENGTH)#define IPH_SADDR (IPH_PIPH+PIPH_SADDR)#define IPH_DADDR (IPH_PIPH+PIPH_DADDR)/* iph_ihl fields */#define IP_V4 4 /* IP version 4 */#define IP_VER 0xF0 /* IP version mask *//* macro to extract IP version from IP header pointer */#define iphv(iphp) (((iphp)[IPH_IHL] & IP_VER) >> 4)#define IP_IHL 0x0F /* IP header length mask *//* macro to extract IP header length from IP header pointer */#define iphl(iphp) ((u16)(((iphp)[IPH_IHL] & IP_IHL) << 2))#ifdef USE_IP_OPTIONS#define IP_MHL 60 /* max IP header length */#define IPO_MAXLEN (IP_MHL-SIZEOF_IPH_T) /* maximum option size */#else#define IP_MHL SIZEOF_IPH_T /* max IP header length */#define IPO_MAXLEN 0 /* maximum option size */#endif/* bit fields in iph_tos */#define IP_PRECEDENCE 0xE0 /* top 3 bits of 'iph_tos' */#define IP_DELAY 0x10 /* delay */#define IP_THROUGHPUT 0x08 /* throughput */#define IP_RELIABLE 0x04 /* reliability *//* Precedence values (masked by IP_PRECEDENCE) */#define IP_NC 0xE0 /* Network Control */#define IP_IC 0xC0 /* Internetwork Control */#define IP_CRITIC 0xA0 /* CRITIC/ECP */#define IP_FLSHO 0x80 /* Flash Override */#define IP_FLASH 0x60 /* Flash */#define IP_IMMED 0x40 /* Immediate */#define IP_PRIORITY 0x20 /* Priority */#define IP_ROUTINE 0x00 /* Routine *//* bit fields in iph_fragoff */#define IP_RS 0x8000 /* reserved - must be off */#define IP_DF 0x4000 /* Don't Fragment flag */#define IP_MF 0x2000 /* More Fragments flag */#define IP_OFFSET 0x1FFF /* Fragment Offset in segment */#define IP_MAXTTL 255 /* maximum packet life (4:15 minutes) *//* Bit fields of iph_saddr & iph_daddr */#define IP_BROADCAST ((u32)0xFFFFFFFF) /* The real broadcast address */#define IP_BSD_BROADCAST ((u32)0) /* BSD 4.2 style broadcast address */#define MASK_A_CLASS ((u32)0x80000000)#define MASK_B_CLASS ((u32)0xC0000000)#define MASK_C_CLASS ((u32)0xE0000000)#define MASK_EX_CLASS ((u32)0xE0000000)#define A_CLASS ((u32)0x00000000)#define B_CLASS ((u32)0x80000000)#define C_CLASS ((u32)0xC0000000)#define EX_CLASS ((u32)0xE0000000)#define NET_A_CLASS ((u32)0xFF000000)#define NET_B_CLASS ((u32)0xFFFF0000)#define NET_C_CLASS ((u32)0xFFFFFF00)#define NET_EX_CLASS ((u32)0xFFFFFFFF)#define HOST_A_CLASS ((u32)0x00FFFFFF)#define HOST_B_CLASS ((u32)0x0000FFFF)#define HOST_C_CLASS ((u32)0x000000FF)#define HOST_EX_CLASS ((u32)0xFFFFFFFF)/* macro to compare two ip addresses through given mask to see * if the network portion matches */#define ip_unm(u1, u2, m) ( (((u1) ^ (u2)) & (m)) == 0L)/* defines for IP level options */#define IPO_CF 0x80 /* copy flag */#define IPO_CLASS 0x60 /* option class */#define IPO_NUMBER 0x1F /* option number *//* values for copy flag */#define IPO_NCOPIED 0x00 /* option not copied */#define IPO_COPIED 0x80 /* option copied *//* values for option class */#define IPO_CONTROL 0x00 /* control */#define IPO_R1 0x20 /* reserved for future use */#define IPO_DEBUG 0x40 /* debugging and measurement */#define IPO_R2 0x60 /* reserved for future use *//* values for option number */#define IPO_EOL 0x00 /* end of option list */#define IPO_NOP 0x01 /* 'u16' filler */#define IPO_SECURITY 0x02 /* security:compartment:handling:tcc */#define IPO_LSR 0x03 /* loose source and record route */#define IPO_SSR 0x09 /* strict source and record route */#define IPO_RR 0x07 /* record route */#define IPO_SID 0x08 /* stream identifier */#define IPO_TS 0x04 /* Internet timestamp */#define IPO_RA 0x14 /* Router Alert */ /* IP socket security option structure */typedef u8 IPOS_T;#define IPOS_SECURITY 0 /* security, 2 bytes */#define IPOS_COMPARTMENTS (IPOS_SECURITY+2) /* compartments, 2 bytes */#define IPOS_HANDLING (IPOS_COMPARTMENTS+2) /* handling restrictions, 2 bytes */#define IPOS_TCC (IPOS_HANDLING+2) /* transmission control code (m.s. 24 bits), 4 bytes */#define SIZEOF_IPOS_T (IPOS_TCC+4)/* Values for S field of security option */#define IPOS_UNCLASSIFIED 0x0000 /* Unclassified */#define IPOS_CONFIDENTIAL 0xF135 /* Confidential */#define IPOS_EFTO 0x789A /* EFTO */#define IPOS_MMMM 0xBC4D /* MMMM */#define IPOS_PROG 0x5E26 /* PROG */#define IPOS_RESTRICTED 0xAF13 /* Restricted */#define IPOS_SECRET 0xD788 /* Secret */#define IPOS_TOP_SECRET 0x6BC5 /* Top Secret */#define IPOS_R0 0x35E2 /* Reserved for future use */#define IPOS_R1 0x9AF1 /* " " " " */#define IPOS_R2 0x4D78 /* " " " " */#define IPOS_R3 0x24BD /* " " " " */#define IPOS_R4 0x135E /* " " " " */#define IPOS_R5 0x89AF /* " " " " */#define IPOS_R6 0xC4D6 /* " " " " */#define IPOS_R7 0xE26B /* " " " " *//* IP socket timestamp option *//* NOT USED */typedef u8 IPOT_T;#define IPOT_OVERFLOW_TYPE 0 /* overflow/flag, 2 bytes */#define IPOT_TIMESTAMPS 2 /* timestamp/address slots (max 9), 4 bytes each */#define SIZEOF_IPOT_T (IPOT_TIMESTAMPS+36)/* bits defined in Internet timestamp option */#define IPO_T_OVER 0xF0 /* Overflow mask */#define IPO_T_TYPE 0x0F /* Timestamp type mask */#define IPO_T_TO 0x00 /* Timestamps only */#define IPO_T_IT 0x01 /* Internet address/timestamp pairs */#define IPO_T_PIT 0x03 /* Prespecified internet address/timestamp pairs *//* ip_timer() (fragmentation timer) fires each second */#define IP_T_DEF 1000 /* Default constants used by IP */#define IP_DTOS 0 /* default type of service */#define m_prec m_p0 /* message precedence */#define m_ttl m_p1 /* time-to-live */#define IP_DTTL 60 /* Default Time to live */#define ipsu sop->so_psu.dpu_state.dpsu_ip /* pointer to ip psu */#define nipsu nsop->so_psu.dpu_state.dpsu_ip /* pointer to ip psu *//* bits returned by 'ip_bc_type', indicating types of broadcast address */#define UNKBCAST 0x1 /* not yet known */#define BSDBCAST 0x80 /* 4.2BSD (host = 0) style */#define NETBCAST 0x20 /* applies to a whole network */#define OTHER_NET 0x2 /* Address not on this network *//* 0 is reserved to mean no type of broadcast *//* Macro to determine whether an IP address is a multicast address *//* int is_D_class (u8 *p_ip_address){ return( ((p_ip_address[0] & 0xF0) == 0xE0) ? 1 : 0 );} */#define is_D_class(a) ( (((a)[0] & 0xF0) == 0xE0) ? 1 : 0 )/* Default value for lifetime of incoming fragments not reunited with the other fragments of the same packet */#ifndef IP_REASSEMBLY_TTL#define IP_REASSEMBLY_TTL 60#endif#endif /*_IP_*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -