Source code of Windows XP (NT5)
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.

77 lines
1.6 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. pInfo->dwId = IP_NETROW;
  25. pinme->dwIndex = dwIfIndex;
  26. pinme->dwAddr = dwAddress;
  27. pinme->dwPhysAddrLen = dwMacAddrLength;
  28. RtlCopyMemory(
  29. pinme->bPhysAddr,
  30. pbMacAddr,
  31. dwMacAddrLength
  32. );
  33. dwSize = MIB_INFO_SIZE(MIB_IPNETROW);
  34. pinme->dwType = INME_TYPE_DYNAMIC;
  35. dwErr = pFunctions->MIBEntryCreate(
  36. IPRTRMGR_PID,
  37. dwSize,
  38. pInfo
  39. );
  40. }
  41. else {
  42. PMIB_OPAQUE_QUERY lproqQuery;
  43. BYTE pBuffer[
  44. FIELD_OFFSET(MIB_OPAQUE_QUERY, rgdwVarIndex) + 2 * sizeof(DWORD)
  45. ];
  46. lproqQuery = (PMIB_OPAQUE_QUERY)pBuffer;
  47. lproqQuery->dwVarId = IP_NETROW;
  48. lproqQuery->rgdwVarIndex[0] = dwIfIndex;
  49. lproqQuery->rgdwVarIndex[1] = dwAddress;
  50. dwSize = sizeof(pBuffer);
  51. dwErr = pFunctions->MIBEntryDelete(
  52. IPRTRMGR_PID,
  53. dwSize,
  54. (PVOID)lproqQuery
  55. );
  56. }
  57. return dwErr;
  58. }
  59. }