31#ifdef WPP_EVENT_TRACING
32#include "sw-offload.tmh"
37#define MAX_SUPPORTED_IPV6_HEADERS (256 - 4)
88#define PROTOCOL_UDP 17
91#define IP_HEADER_LENGTH(pHeader) (((pHeader)->ip_verlen & 0x0F) << 2)
92#define TCP_HEADER_LENGTH(pHeader) ((pHeader->tcp_flags & 0xF0) >> 2)
121 tcpipDataAt = ipHeaderSize +
sizeof(
TCPHeader);
125 if (
len >= tcpipDataAt)
130 res.XxpIpHeaderSize = tcpipDataAt;
134 DPrintf(2, (
"tcp: %d < min headers %d",
len, tcpipDataAt));
146 res.XxpIpHeaderSize = udpDataStart;
147 if (
len >= udpDataStart)
153 DPrintf(2, (
"udp: len %d, datagramLength %d",
len, datagramLength));
163 UCHAR ip_version = (ver_len & 0xF0) >> 4;
170 ipHeaderSize = (ver_len & 0xF) << 2;
172 DPrintf(3, (
"ip_version %d, ipHeaderSize %d, protocol %d, iplen %d",
173 ip_version, ipHeaderSize, pIpHeader->
v4.
ip_protocol, fullLength));
179 DPrintf(2, (
"ip v.%d, iplen %d", ip_version, fullLength));
182 else if (ip_version == 6)
186 ipHeaderSize =
sizeof(pIpHeader->
v6);
190 fullLength += ipHeaderSize;
191 while (nextHeader != 59)
200 res.xxpFull =
len >= fullLength ? 1 : 0;
207 res.xxpFull =
len >= fullLength ? 1 : 0;
224 if (
len >= ((
ULONG)ipHeaderSize + 8))
233 DPrintf(0, (
"[%s] ERROR: Break in the middle of ext. headers(len %d, hdr > %d)",
__FUNCTION__,
len, ipHeaderSize));
249 DPrintf(3, (
"ip_version %d, ipHeaderSize %d, protocol %d, iplen %d",
250 ip_version, ipHeaderSize, nextHeader, fullLength));
251 res.ipHeaderSize = ipHeaderSize;
262 res.ipHeaderSize = ipHeaderSize;
263 res.xxpFull =
len >= fullLength ? 1 : 0;
292 return len - headerLength;
297 return fullLength +
sizeof(pIpHeader->
v6) - (
USHORT)
res.ipHeaderSize;
328 ipph.
z1 = ipph.
z2 = ipph.
z3 = 0;
337 USHORT headerAndPayloadLen)
352 if(arrivedChecksum == 0xFFFF)
355 return computedChecksum == arrivedChecksum;
415 if (
len >=
res.ipHeaderSize)
423 if (
len >= (
ULONG)(
res.ipHeaderSize +
sizeof(*pTcpHeader)))
431 else if (
res.xxpFull)
450 else if (
res.xxpFull)
480 if (
len >=
res.ipHeaderSize)
512 else if (
res.xxpFull)
531 static const char *
const IPCaseName[4] = {
"not tested",
"Non-IP",
"IPv4",
"IPv6" };
537 return IPCaseName[
res.ipStatus];
542 static const char *
const CSCaseName[4] = {
"not tested",
"(too short)",
"OK",
"Bad" };
543 return CSCaseName[
res.ipCheckSum];
548 static const char *
const CSCaseName[4] = {
"-",
"PCS",
"CS",
"Bad" };
549 return CSCaseName[
res.xxpCheckSum];
557 DPrintf(
level, (
"[%s] %s packet IPCS %s%s, checksum %s%s", procname,
560 res.fixedIpCS ?
"(fixed)" :
"",
562 res.fixedXxpCS ?
"(fixed)" :
""));
static cab_ULONG checksum(const cab_UBYTE *data, cab_UWORD bytes, cab_ULONG csum)
#define DPrintf(Level, Fmt)
struct _tagTCPHeader TCPHeader
struct _tagUDPHeader UDPHeader
struct _tagIPv4Header IPv4Header
static __inline USHORT swap_short(USHORT us)
GLuint GLuint GLsizei count
#define RtlOffsetToPointer(Base, Offset)
static __inline tTcpIpPacketParsingResult ProcessUDPHeader(tTcpIpPacketParsingResult _res, PVOID pIpHeader, ULONG len, USHORT ipHeaderSize)
tTcpIpPacketParsingResult ParaNdis_CheckSumVerify(PVOID buffer, ULONG size, ULONG flags, LPCSTR caller)
struct _tagIPv4PseudoHeader tIPv4PseudoHeader
static __inline tTcpIpPacketParsingResult ProcessTCPHeader(tTcpIpPacketParsingResult _res, PVOID pIpHeader, ULONG len, USHORT ipHeaderSize)
tTcpIpPacketParsingResult ParaNdis_ReviewIPPacket(PVOID buffer, ULONG size, LPCSTR caller)
static __inline USHORT CalculateIpv4PseudoHeaderChecksum(IPv4Header *pIpHeader, USHORT headerAndPayloadLen)
static VOID CalculateUdpChecksumGivenPseudoCS(UDPHeader *pUdpHeader, ULONG udpLength)
static LPCSTR __inline GetIPCSCase(tTcpIpPacketParsingResult res)
static __inline USHORT GetXxpHeaderAndPayloadLen(IPHeader *pIpHeader, tTcpIpPacketParsingResult res)
struct _tagIPv6PseudoHeader tIPv6PseudoHeader
static LPCSTR __inline GetPacketCase(tTcpIpPacketParsingResult res)
struct _tagIPv6ExtHeader IPv6ExtHeader
static __inline VOID CalculateTcpChecksumGivenPseudoCS(TCPHeader *pTcpHeader, ULONG tcpLength)
struct _tagIPv6Header IPv6Header
#define MAX_SUPPORTED_IPV6_HEADERS
static __inline USHORT CheckSumCalculator(ULONG val, PVOID buffer, ULONG len)
static __inline tTcpIpPacketParsingResult VerifyIpChecksum(IPv4Header *pIpHeader, tTcpIpPacketParsingResult known, BOOLEAN bFix)
#define TCP_HEADER_LENGTH(pHeader)
static __inline tTcpIpPacketParsingResult VerifyTcpChecksum(IPHeader *pIpHeader, ULONG len, tTcpIpPacketParsingResult known, ULONG whatToFix)
static __inline tTcpIpPacketParsingResult VerifyUdpChecksum(IPHeader *pIpHeader, ULONG len, tTcpIpPacketParsingResult known, ULONG whatToFix)
static __inline tTcpIpPacketParsingResult QualifyIpPacket(IPHeader *pIpHeader, ULONG len)
static __inline USHORT CalculateIpv6PseudoHeaderChecksum(IPv6Header *pIpHeader, USHORT headerAndPayloadLen)
static __inline BOOLEAN CompareNetCheckSumOnEndSystem(USHORT computedChecksum, USHORT arrivedChecksum)
#define IP_HEADER_LENGTH(pHeader)
static __inline USHORT CalculateIpPseudoHeaderChecksum(IPHeader *pIpHeader, tTcpIpPacketParsingResult res, USHORT headerAndPayloadLen)
static LPCSTR __inline GetXxpCSCase(tTcpIpPacketParsingResult res)
static __inline VOID PrintOutParsingResult(tTcpIpPacketParsingResult res, int level, LPCSTR procname)
static __inline VOID CalculateIpChecksum(IPv4Header *pIpHeader)