Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

78 lines
2.0 KiB

  1. /*++
  2. Copyright (c) 2001 Microsoft Corporation
  3. Module Name:
  4. info.h
  5. Abstract:
  6. This module contains the definitions for maintaining IP statistics.
  7. Author:
  8. Dave Thaler (dthaler) 10-Apr-2001
  9. --*/
  10. #pragma once
  11. extern CACHE_ALIGN IPSNMPInfo IPSInfo;
  12. extern ICMPv6Stats ICMPv6InStats;
  13. extern ICMPv6Stats ICMPv6OutStats;
  14. typedef struct CACHE_ALIGN IPInternalPerCpuStats {
  15. ulong ics_inreceives;
  16. ulong ics_indelivers;
  17. ulong ics_forwdatagrams;
  18. ulong ics_outrequests;
  19. } IPInternalPerCpuStats;
  20. #define IPS_MAX_PROCESSOR_BUCKETS 8
  21. extern IPInternalPerCpuStats IPPerCpuStats[IPS_MAX_PROCESSOR_BUCKETS];
  22. extern uint NumForwardingInterfaces;
  23. __forceinline
  24. void IPSIncrementInReceiveCount(void)
  25. {
  26. const ulong Index = KeGetCurrentProcessorNumber() % IPS_MAX_PROCESSOR_BUCKETS;
  27. IPPerCpuStats[Index].ics_inreceives++;
  28. }
  29. __forceinline
  30. void IPSIncrementInDeliverCount(void)
  31. {
  32. const ulong Index = KeGetCurrentProcessorNumber() % IPS_MAX_PROCESSOR_BUCKETS;
  33. IPPerCpuStats[Index].ics_indelivers++;
  34. }
  35. __forceinline
  36. void IPSIncrementOutRequestCount(void)
  37. {
  38. const ulong Index = KeGetCurrentProcessorNumber() % IPS_MAX_PROCESSOR_BUCKETS;
  39. IPPerCpuStats[Index].ics_outrequests++;
  40. }
  41. __forceinline
  42. void IPSIncrementForwDatagramCount(void)
  43. {
  44. const ulong Index = KeGetCurrentProcessorNumber() % IPS_MAX_PROCESSOR_BUCKETS;
  45. IPPerCpuStats[Index].ics_forwdatagrams++;
  46. }
  47. __inline
  48. void IPSGetTotalCounts(IPInternalPerCpuStats* Stats)
  49. {
  50. ulong Index;
  51. const ulong MaxIndex = MIN(KeNumberProcessors, IPS_MAX_PROCESSOR_BUCKETS);
  52. RtlZeroMemory(Stats, sizeof(IPInternalPerCpuStats));
  53. for (Index = 0; Index < MaxIndex; Index++) {
  54. Stats->ics_inreceives += IPPerCpuStats[Index].ics_inreceives;
  55. Stats->ics_indelivers += IPPerCpuStats[Index].ics_indelivers;
  56. Stats->ics_outrequests += IPPerCpuStats[Index].ics_outrequests;
  57. Stats->ics_forwdatagrams += IPPerCpuStats[Index].ics_forwdatagrams;
  58. }
  59. }