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.

81 lines
1.8 KiB

  1. extern "C" {
  2. #include <nt.h>
  3. #include <ntrtl.h>
  4. #include <nturtl.h>
  5. #include <windows.h>
  6. #include <winsvc.h>
  7. #include <ipexport.h>
  8. #include <ipinfo.h>
  9. #include <llinfo.h>
  10. #include <routprot.h>
  11. #include <iprtrmib.h>
  12. DWORD
  13. UpdateArpCache(
  14. DWORD dwIfIndex,
  15. DWORD dwAddress,
  16. PBYTE pbMacAddr,
  17. DWORD dwMacAddrLength,
  18. BOOL bAddEntry,
  19. SUPPORT_FUNCTIONS *pFunctions
  20. ) {
  21. DWORD dwErr, dwSize;
  22. if (bAddEntry) {
  23. DEFINE_MIB_BUFFER(pInfo, MIB_IPNETROW, pinme);
  24. if ( dwMacAddrLength > sizeof(pinme->bPhysAddr) ) {
  25. return ERROR_INVALID_PARAMETER;
  26. }
  27. pInfo->dwId = IP_NETROW;
  28. pinme->dwIndex = dwIfIndex;
  29. pinme->dwAddr = dwAddress;
  30. pinme->dwPhysAddrLen = dwMacAddrLength;
  31. RtlCopyMemory(
  32. pinme->bPhysAddr,
  33. pbMacAddr,
  34. dwMacAddrLength
  35. );
  36. dwSize = MIB_INFO_SIZE(MIB_IPNETROW);
  37. pinme->dwType = INME_TYPE_DYNAMIC;
  38. dwErr = pFunctions->MIBEntryCreate(
  39. IPRTRMGR_PID,
  40. dwSize,
  41. pInfo
  42. );
  43. }
  44. else {
  45. PMIB_OPAQUE_QUERY lproqQuery;
  46. BYTE pBuffer[
  47. FIELD_OFFSET(MIB_OPAQUE_QUERY, rgdwVarIndex) + 2 * sizeof(DWORD)
  48. ];
  49. lproqQuery = (PMIB_OPAQUE_QUERY)pBuffer;
  50. lproqQuery->dwVarId = IP_NETROW;
  51. lproqQuery->rgdwVarIndex[0] = dwIfIndex;
  52. lproqQuery->rgdwVarIndex[1] = dwAddress;
  53. dwSize = sizeof(pBuffer);
  54. dwErr = pFunctions->MIBEntryDelete(
  55. IPRTRMGR_PID,
  56. dwSize,
  57. (PVOID)lproqQuery
  58. );
  59. }
  60. return dwErr;
  61. }
  62. }