ReactOS 0.4.16-dev-297-gc569aee
routines.c
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS TCP/IP protocol driver
4 * FILE: tcpip/routines.c
5 * PURPOSE: Common routines
6 * PROGRAMMERS: Casper S. Hornstrup (chorns@users.sourceforge.net)
7 * REVISIONS:
8 * CSH 01/08-2000 Created
9 */
10
11#include "precomp.h"
12
13static UINT RandomNumber = 0x12345678;
14
15
17 VOID)
18/*
19 * FUNCTION: Returns a pseudo random number
20 * RETURNS:
21 * Pseudo random number
22 */
23{
24 RandomNumber ^= 0x78563412;
25
26 return RandomNumber;
27}
28
29#if DBG
30static VOID DisplayIPHeader(
33{
34 /* FIXME: IPv4 only */
36
37 DbgPrint("IPv4 header:\n");
38 DbgPrint("VerIHL: 0x%x (version 0x%x, length %d 32-bit words)\n",
39 IPHeader->VerIHL, (IPHeader->VerIHL & 0xF0) >> 4, IPHeader->VerIHL & 0x0F);
40 DbgPrint(" Tos: %d\n", IPHeader->Tos);
41 DbgPrint(" TotalLength: %d\n", WN2H(IPHeader->TotalLength));
42 DbgPrint(" Id: %d\n", WN2H(IPHeader->Id));
43 DbgPrint(" FlagsFragOfs: 0x%x (offset 0x%x)\n", WN2H(IPHeader->FlagsFragOfs), WN2H(IPHeader->FlagsFragOfs) & IPv4_FRAGOFS_MASK);
44 if ((WN2H(IPHeader->FlagsFragOfs) & IPv4_DF_MASK) > 0) DbgPrint(" IPv4_DF - Don't fragment\n");
45 if ((WN2H(IPHeader->FlagsFragOfs) & IPv4_MF_MASK) > 0) DbgPrint(" IPv4_MF - More fragments\n");
46 DbgPrint(" Ttl: %d\n", IPHeader->Ttl);
47 DbgPrint(" Protocol: %d\n", IPHeader->Protocol);
48 DbgPrint(" Checksum: 0x%x\n", WN2H(IPHeader->Checksum));
49 DbgPrint(" SrcAddr: %d.%d.%d.%d\n",
50 ((IPHeader->SrcAddr >> 0) & 0xFF), ((IPHeader->SrcAddr >> 8) & 0xFF),
51 ((IPHeader->SrcAddr >> 16) & 0xFF), ((IPHeader->SrcAddr >> 24) & 0xFF));
52 DbgPrint(" DstAddr: %d.%d.%d.%d\n",
53 ((IPHeader->DstAddr >> 0) & 0xFF), ((IPHeader->DstAddr >> 8) & 0xFF),
54 ((IPHeader->DstAddr >> 16) & 0xFF), ((IPHeader->DstAddr >> 24) & 0xFF));
55}
56
57#endif
58
60 PIP_PACKET IPPacket)
61{
62#if DBG
64 PCHAR CharBuffer;
65
66 /* DbgQueryDebugFilterState returns (NTSTATUS)TRUE, (NTSTATUS)FALSE or a failure status code */
69 return;
70 }
71
72 if (!IPPacket) {
73 TI_DbgPrint(MIN_TRACE, ("Cannot display null packet.\n"));
74 return;
75 }
76
77 TI_DbgPrint(MIN_TRACE, ("IPPacket is at (0x%X).\n", IPPacket));
78 TI_DbgPrint(MIN_TRACE, ("Header buffer is at (0x%X).\n", IPPacket->Header));
79 TI_DbgPrint(MIN_TRACE, ("Header size is (%d).\n", IPPacket->HeaderSize));
80 TI_DbgPrint(MIN_TRACE, ("TotalSize (%d).\n", IPPacket->TotalSize));
81 TI_DbgPrint(MIN_TRACE, ("NdisPacket (0x%X).\n", IPPacket->NdisPacket));
82
83 CharBuffer = IPPacket->Header;
84 Length = IPPacket->HeaderSize;
85 DisplayIPHeader(CharBuffer, Length);
86#endif
87}
88
#define WN2H(w)
Definition: addrconv.c:35
LONG NTSTATUS
Definition: precomp.h:26
#define MIN_TRACE
Definition: debug.h:14
Definition: Header.h:9
#define TRUE
Definition: types.h:120
@ DPFLTR_TCPIP_ID
Definition: dpfilter.h:58
#define DEBUG_PBUFFER
Definition: debug.h:20
#define DEBUG_IP
Definition: debug.h:26
#define TI_DbgPrint(_t_, _x_)
Definition: debug.h:45
#define IPv4_MF_MASK
Definition: ip.h:66
#define IPv4_DF_MASK
Definition: ip.h:67
#define IPv4_FRAGOFS_MASK
Definition: ip.h:65
struct IPv4_HEADER * PIPv4_HEADER
#define DbgPrint
Definition: hal.h:12
unsigned int UINT
Definition: ndis.h:50
#define DPFLTR_MASK
Definition: kdtypes.h:34
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
Definition: ip.h:77
PNDIS_PACKET NdisPacket
Definition: ip.h:88
UINT HeaderSize
Definition: ip.h:84
PVOID Header
Definition: ip.h:83
UINT TotalSize
Definition: ip.h:86
static UINT RandomNumber
Definition: routines.c:13
VOID DisplayIPPacket(PIP_PACKET IPPacket)
Definition: routines.c:59
UINT Random(VOID)
Definition: routines.c:16
char * PCHAR
Definition: typedefs.h:51
NTSYSAPI NTSTATUS NTAPI DbgQueryDebugFilterState(_In_ ULONG ComponentId, _In_ ULONG Level)