Author: cgutman
Date: Wed Jul 15 05:14:13 2009
New Revision: 41962
URL:
http://svn.reactos.org/svn/reactos?rev=41962&view=rev
Log:
- Start reporting packet statistics
- We currently only report received bytes, sent bytes, discarded packets due to unknown
protocol, send errors, and receive errors
- The network adapter properties window now shows correct send/receive bytes info
Modified:
trunk/reactos/drivers/network/tcpip/include/ip.h
trunk/reactos/drivers/network/tcpip/tcpip/iinfo.c
trunk/reactos/lib/drivers/ip/network/ip.c
trunk/reactos/lib/drivers/ip/network/receive.c
trunk/reactos/lib/drivers/ip/network/transmit.c
Modified: trunk/reactos/drivers/network/tcpip/include/ip.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/tcpip/incl…
==============================================================================
--- trunk/reactos/drivers/network/tcpip/include/ip.h [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/tcpip/include/ip.h [iso-8859-1] Wed Jul 15 05:14:13
2009
@@ -134,6 +134,19 @@
LL_TRANSMIT_ROUTINE Transmit; /* Transmit function for this interface */
} LLIP_BIND_INFO, *PLLIP_BIND_INFO;
+typedef struct _SEND_RECV_STATS {
+ UINT InBytes;
+ UINT InUnicast;
+ UINT InNUnicast;
+ UINT InDiscarded;
+ UINT InErrors;
+ UINT InDiscardedUnknownProto;
+ UINT OutBytes;
+ UINT OutUnicast;
+ UINT OutNUnicast;
+ UINT OutDiscarded;
+ UINT OutErrors;
+} SEND_RECV_STATS, *PSEND_RECV_STATS;
/* Information about an IP interface */
typedef struct _IP_INTERFACE {
@@ -157,6 +170,7 @@
UINT Index; /* Index of adapter (used to add ip addr) */
LL_TRANSMIT_ROUTINE Transmit; /* Pointer to transmit function */
PVOID TCPContext; /* TCP Content for this interface */
+ SEND_RECV_STATS Stats; /* Send/Receive statistics */
} IP_INTERFACE, *PIP_INTERFACE;
typedef struct _IP_SET_ADDRESS {
Modified: trunk/reactos/drivers/network/tcpip/tcpip/iinfo.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/tcpip/tcpi…
==============================================================================
--- trunk/reactos/drivers/network/tcpip/tcpip/iinfo.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/tcpip/tcpip/iinfo.c [iso-8859-1] Wed Jul 15 05:14:13
2009
@@ -20,6 +20,7 @@
PCHAR IFDescr;
ULONG Size;
UINT DescrLenMax = MAX_IFDESCR_LEN - 1;
+ NDIS_STATUS NdisStatus;
TI_DbgPrint(DEBUG_INFO,
("Getting IFEntry MIB (IF %08x LA %08x) (%04x:%d)\n",
@@ -57,6 +58,28 @@
("IF Speed = %d * 100bps\n", OutData->Speed));
memcpy(OutData->PhysAddr,Interface->Address,Interface->AddressLength);
TI_DbgPrint(DEBUG_INFO, ("Got HWAddr\n"));
+
+ memcpy(&OutData->InOctets, &Interface->Stats,
sizeof(SEND_RECV_STATS));
+
+ NdisStatus = NDISCall(IF,
+ NdisRequestQueryInformation,
+ OID_GEN_XMIT_ERROR,
+ &OutData->OutErrors,
+ sizeof(ULONG));
+ if (NdisStatus != NDIS_STATUS_SUCCESS)
+ OutData->OutErrors = 0;
+
+ TI_DbgPrint(DEBUG_INFO, ("OutErrors = %d\n", OutData->OutErrors));
+
+ NdisStatus = NDISCall(IF,
+ NdisRequestQueryInformation,
+ OID_GEN_RCV_ERROR,
+ &OutData->InErrors,
+ sizeof(ULONG));
+ if (NdisStatus != NDIS_STATUS_SUCCESS)
+ OutData->InErrors = 0;
+
+ TI_DbgPrint(DEBUG_INFO, ("InErrors = %d\n", OutData->InErrors));
}
GetInterfaceName( Interface, IFDescr, MAX_IFDESCR_LEN - 1 );
Modified: trunk/reactos/lib/drivers/ip/network/ip.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/ip/network/ip.…
==============================================================================
--- trunk/reactos/lib/drivers/ip/network/ip.c [iso-8859-1] (original)
+++ trunk/reactos/lib/drivers/ip/network/ip.c [iso-8859-1] Wed Jul 15 05:14:13 2009
@@ -323,6 +323,8 @@
{
TI_DbgPrint(MID_TRACE, ("[IF %x] Packet of unknown Internet protocol "
"discarded.\n", Interface));
+
+ Interface->Stats.InDiscardedUnknownProto++;
}
Modified: trunk/reactos/lib/drivers/ip/network/receive.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/ip/network/rec…
==============================================================================
--- trunk/reactos/lib/drivers/ip/network/receive.c [iso-8859-1] (original)
+++ trunk/reactos/lib/drivers/ip/network/receive.c [iso-8859-1] Wed Jul 15 05:14:13 2009
@@ -463,6 +463,8 @@
/* Give the packet to the protocol dispatcher */
IPDispatchProtocol(IF, &Datagram);
+
+ IF->Stats.InBytes += Datagram.TotalSize;
/* We're done with this datagram */
exFreePool(Datagram.Header);
Modified: trunk/reactos/lib/drivers/ip/network/transmit.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/ip/network/tra…
==============================================================================
--- trunk/reactos/lib/drivers/ip/network/transmit.c [iso-8859-1] (original)
+++ trunk/reactos/lib/drivers/ip/network/transmit.c [iso-8859-1] Wed Jul 15 05:14:13 2009
@@ -240,6 +240,8 @@
* send routine (IPSendFragment)
*/
{
+ UINT PacketSize;
+
TI_DbgPrint(MAX_TRACE, ("Called. IPPacket (0x%X) NCE (0x%X)\n", IPPacket,
NCE));
DISPLAY_IP_PACKET(IPPacket);
@@ -264,6 +266,14 @@
IPPacket->Flags));
}
+ NdisQueryPacket(IPPacket->NdisPacket,
+ NULL,
+ NULL,
+ NULL,
+ &PacketSize);
+
+ NCE->Interface->Stats.OutBytes += PacketSize;
+
return SendFragments(IPPacket, NCE, NCE->Interface->MTU,
Complete, Context);
}