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

📄 pgpnetipdef.h

📁 PGP8.0源码 请认真阅读您的文件包然后写出其具体功能
💻 H
字号:
/*____________________________________________________________________________
	Copyright (C) 2002 PGP Corporation
	All rights reserved.

	$Id: pgpNetIPdef.h,v 1.10 2002/08/06 20:10:25 dallen Exp $
____________________________________________________________________________*/

#ifndef Included_pgpNetIPdef_h	/* [ */
#define Included_pgpNetIPdef_h

/*	This file is not very portable at all, so just take what we need and leave the rest of it behind.
	Try to move most stuff over to our regular files. */

/*	This includes UDP_HEADER(8) + NON_IKE_MARKER(8) + NON_ESP_MARKER(4) + AH_ENVELOPE(4) */
#define AH_NATTRAV_HEADER_SIZE	24

/*	This includes UDP_HEADER(8) + NON_IKE_MARKER(8) */
#define ESP_NATTRAV_HEADER_SIZE 16

#if PGP_WIN32
#pragma pack(push, 1)
#endif

typedef struct tag_ETHERNET_HEADER {

	PGPByte	eth_dstAddress[6];
	PGPByte	eth_srcAddress[6];
	PGPByte	eth_protocolType[2];
	
} ETHERNET_HEADER, *PETHERNET_HEADER;


#if PGP_WIN32
#pragma pack(pop)
#endif

#define		PROTOCOL_ICMP		1
#define		PROTOCOL_IGMP		2
#define		PROTOCOL_TCP		6
#define		PROTOCOL_UDP		17

typedef struct tag_IP_HEADER {
	PGPByte ip_versionandheaderlength;
    //PGPByte ip_headerlength:4;
    //PGPByte ip_version:4;
    PGPByte ip_tos;
    PGPUInt16 ip_len;
    PGPUInt16 ip_id;
    PGPUInt16 ip_foff;
    PGPByte ip_ttl;
    PGPByte ip_prot;
    PGPUInt16 ip_chksum;
    PGPUInt32 ip_src;
    PGPUInt32 ip_dest;
}IP_HEADER, *PIP_HEADER;

typedef struct tag_ICMP_HEADER {
	PGPByte	icmp_type;
	PGPByte	icmp_code;
	PGPUInt16	icmp_checksum;
} ICMP_HEADER, *PICMP_HEADER;

typedef struct tag_UDP_HEADER {
   unsigned short source_port;
   unsigned short dest_port;
   unsigned short msg_len;
   unsigned short checksum;
}UDP_HEADER, *PUDP_HEADER;



#if ! PGP_UNIX_DARWIN
#define		IPPORT				0x0800
#define		IPPROT_NET			0x0008
#define		ARPPROT				0x0806
#define		ARPPROT_NET			0x0608
#define		PPPOE_DISCOVERY_PORT			0x8863
#define		PPPOE_DISCOVERY_PORT_NET		0x6388
#define		PPPOE_SESSION_PORT				0x8864
#define		PPPOE_SESSION_PORT_NET			0x6488
#define		kPGPnetIKEPortHost	0x01f4		// 500
#define		kPGPnetIKEPortNet	0xf401

#define MAX_ETHER_FRAME_SIZE	1514
#define MIN_ETHER_FRAME_SIZE	60
#define	ETHER_HEADER_SIZE		14
#define IP_HEADER_SIZE			20
#define ICMP_HEADER_SIZE		8
#define UDP_HEADER_SIZE			8

#define MAX_TEST_ICMP_DATA_SIZE 100

#ifndef IP_RF
#define IP_RF 0x80        // reserved
#endif
#ifndef IP_DF
#define IP_DF 0x40        // don't fragment
#endif
#ifndef IP_MF
#define IP_MF 0x20        // more fragments
#endif
#define IP_SAVE_FLAGS (IP_RF|IP_MF) // flags saved from packet to each fragment
#define IP_OFFSET ~0xe0    // fragment offset mask

#define IP_DONT_FRAGMENT(x)		((x) & 0x0040)
#define IP_MORE_FRAGMENT(x)		((x) & 0x0020)
#define IP_LAST_FRAGMENT(x)		!(IP_MORE_FRAGMENT(x))


#if PGP_WIN32
#pragma pack(push, 1)
#endif

typedef struct tag_ARP_HEADER {
	PGPUInt16 arp_hrd;
	PGPUInt16 arp_pro;
	PGPByte  arp_hln;
	PGPByte  arp_pln;
	PGPUInt16 arp_op;

	PGPByte  arp_src_hrd_addr[6];
	PGPUInt32  arp_src_ip_addr;
	PGPByte  arp_dst_hrd_addr[6];
	PGPUInt32  arp_dst_ip_addr;

}ARP_HEADER, *PARP_HEADER;

#if PGP_WIN32
#pragma pack(pop)
#endif

#define ICMP_TYPE_ECHO_REQUEST		0x08
#define ICMP_TYPE_ECHO_REPLY		0x00
#define	ICMP_TYPE_UNREACHABLE		0x03
#define ICMP_TYPE_SOURCE_QUENCH		0x04

#define ICMP_UNREACHABLE_CODE_NETWORK_UNREACHABLE	0x00
#define ICMP_UNREACHABLE_CODE_HOST_UNREACHABLE		0x01
#define ICMP_UNREACHABLE_CODE_PROTOCOL_UNREACHABLE	0x02
#define ICMP_UNREACHABLE_CODE_PORT_UNREACHABLE		0x03
#define ICMP_UNREACHABLE_CODE_FRAGMENT				0x04


typedef struct tag_CODE5_ICMP_DATA {
	PGPUInt16	code5_unused;
	PGPUInt16	code5_mtu;
} CODE5_ICMP_DATA, *PCODE5_ICMP_DATA;

typedef struct tag_TYPE3_ICMP_HEADER {
	PGPByte		icmp_type;
	PGPByte		icmp_code;
	PGPUInt16	icmp_checksum;

	union {
		PGPUInt32			icmp_unused;
		CODE5_ICMP_DATA		icmp_code5;
	} u;

	IP_HEADER	icmp_ip_header;
	PGPByte		icmp_ip_data[8];

} TYPE3_ICMP_HEADER, *PTYPE3_ICMP_HEADER;

#define UDP_PORT_BOOTPS			0x43
#define UDP_PORT_BOOTPC			0x44
#define UDP_PORT_BOOTPS_NET		0x4300
#define UDP_PORT_BOOTPC_NET		0x4400

typedef struct tag_DHCP_HEADER {
	unsigned char	op;
	unsigned char	htype;
	unsigned char	hlen;
	unsigned char	hops;
	unsigned long	xid;
	unsigned short	secs;
	unsigned short	flags;
	unsigned long	ciaddr;
	unsigned long	yiaddr;
	unsigned long	siaddr;
	unsigned long	giaddr;
	unsigned char	chaddr[16];
	unsigned char	sname[64];
	unsigned char	file[128];
	unsigned long	cookie;
} DHCP_HEADER, *PDHCP_HEADER;
/*
   0                   1                   2                   3
   0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |     op (1)    |   htype (1)   |   hlen (1)    |   hops (1)    |
   +---------------+---------------+---------------+---------------+
   |                            xid (4)                            |
   +-------------------------------+-------------------------------+
   |           secs (2)            |           flags (2)           |
   +-------------------------------+-------------------------------+
   |                          ciaddr  (4)                          |
   +---------------------------------------------------------------+
   |                          yiaddr  (4)                          |
   +---------------------------------------------------------------+
   |                          siaddr  (4)                          |
   +---------------------------------------------------------------+
   |                          giaddr  (4)                          |
   +---------------------------------------------------------------+
   |                                                               |
   |                          chaddr  (16)                         |
   |                                                               |
   |                                                               |
   +---------------------------------------------------------------+
   |                                                               |
   |                          sname   (64)                         |
   +---------------------------------------------------------------+
   |                                                               |
   |                          file    (128)                        |
   +---------------------------------------------------------------+
   |                                                               |
   |                          options (variable)                   |
   +---------------------------------------------------------------+
*/

#if ! PGP_UNIX

#define htons(a) ((((a) & 0XFF00) >> 8) | (((a) & 0X00FF) << 8))
#define ntohs(a) ((PGPUInt16) htons(a))
#define htonl(a) ((((a) & 0XFF000000) >> 24) | (((a) & 0X00FF0000) >> 8) | \
		  (((a) & 0X0000FF00) << 8)  | (((a) & 0X000000FF) << 24))
#define ntohl(a) (htonl(a))

#endif

#endif

#endif /* ] Included_pgpNetIPdef_h */

⌨️ 快捷键说明

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