www.pudn.com > IPsec_Src_Instal.rar > PktHdr.h
//****************************************************************************//
//* //
//* Copyright (C) 2003, James Antognini, antognini@mindspring.com. //
//* //
//****************************************************************************//
/*
Copyright © 2003 Printing Communications Associates, Inc. (PCAUSA)
The right to use this code in your own derivative works is granted so long as
1. Your own derivative works include significant modifications of your own.
2. You retain the above copyright notices and this paragraph in its
entirety within sources derived from this code.
This product includes software developed by PCAUSA. The name of
PCAUSA 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 MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#define ETH_HEADER_SIZE 14
#define ETH_MAX_DATA_SIZE 1500
#define ETH_MAX_PACKET_SIZE ETH_HEADER_SIZE + ETH_MAX_DATA_SIZE
#define ETH_MIN_PACKET_SIZE 60
#define lnEthHdr 14 // Size of Ethernet header.
#define lnIPHdr 20 // Size of IP header.
#define lnTCPHdrMin 20 // Minimum size of TCP header.
typedef enum
{
EthHTypeIP = 0x0800,
EthHTypeARP = 0x0806,
EthHTypeRARP = 0x8035
}
EthHType;
typedef struct _EthHdr
{
char DestMAC[6];
char SrcMAC[6];
USHORT Type; //0x0800=>IP
}EthHdr, *pEthHdr;
typedef struct _IPHdr
{
union
{
UCHAR HdrLenVer;
struct
{
UCHAR IPHdrLen : 4;
UCHAR IPVer : 4;
};
};
UCHAR TypeOfService;
USHORT TotalLength;
USHORT Identification;
union
{
USHORT FragmentationSummary;
struct
{
USHORT FragmentOffset1 : 5;
USHORT LastFragment : 1;
USHORT CannotFragment : 1;
USHORT padding : 1; // Reserved, must be zero.
USHORT FragmentOffset2 : 8;
};
};
UCHAR TTL;
UCHAR Protocol;
USHORT Checksum;
ULONG SourceAddress;
ULONG DestinationAddress;
}IPHdr, *pIPHdr;
typedef struct _TCPHdr
{
USHORT SrcPort;
USHORT DestPort;
ULONG SeqNbr;
ULONG AckNbr;
union
{
UCHAR OffsetReserved;
struct
{
UCHAR Reserved : 4;
UCHAR DataOffset : 4;
};
};
union
{
UCHAR Flags;
struct
{
UCHAR EndOfData : 1;
UCHAR Synchronize : 1;
UCHAR Reset : 1;
UCHAR PushFunction : 1;
UCHAR AckFdSignificant : 1;
UCHAR UrgentData : 1;
};
};
USHORT Window;
USHORT Checksum;
USHORT UrgentPtr;
}TCPHdr, *pTCPHdr;
typedef struct _AHHdr
{
UCHAR NextHeader;
UCHAR PayloadLength;
USHORT Reserved;
ULONG SPI;
ULONG SNF;
UCHAR Auth[16];
// ULONG NewVa;
// ULONG OrigVa;
}AHHdr, * pAHHdr;
/*
* Protocols
*/
#define IPPROTO_IP 0 /* dummy for IP */
#define IPPROTO_ICMP 1 /* control message protocol */
#define IPPROTO_IGMP 2 /* internet group management protocol */
#define IPPROTO_GGP 3 /* gateway^2 (deprecated) */
#define IPPROTO_TCP 6 /* tcp */
#define IPPROTO_PUP 12 /* pup */
#define IPPROTO_UDP 17 /* user datagram protocol */
#define IPPROTO_IDP 22 /* xns idp */
#define IPPROTO_IPV6 41 /* IPv6 */
#define IPPROTO_ND 77 /* UNOFFICIAL net disk proto */
#define IPPROTO_ICLFXBM 78
#define IPPROTO_RAW 255 /* raw IP packet */
#define IPPROTO_MAX 256
VOID
GetPktPayload(
PNDIS_PACKET pPacket, // Address of packet descriptor.
PUCHAR pOutBfr, // Address of output buffer, to get copied packet payload.
ULONG ulOutBfrAvail, // Size of output buffer.
PULONG pUlBytesCopied // Output variable for number of bytes copied.
);
USHORT
GetIPChecksum(PUSHORT IPH, USHORT IPHdr);
NDIS_STATUS PPBuildOrigPkt(
PUCHAR pPayload, // Address of current (encapsulated) payload.
ULONG OrigPayloadl,
PUCHAR * pUnencPayload, // Address of variable to hold new payload address.
PULONG pUnencPayloadLn // Address of variable to hold new payload length.
);