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.

63 lines
1.0 KiB

  1. /*++
  2. Copyright (c) 1992 Microsoft Corporation
  3. Module Name:
  4. util.c
  5. Abstract:
  6. Utility functions for IP Address resource.
  7. Author:
  8. Mike Massa (mikemas) 29-Dec-1995
  9. Revision History:
  10. --*/
  11. #include <nt.h>
  12. #include <ntrtl.h>
  13. #include <nturtl.h>
  14. #include <windows.h>
  15. #include <winsock.h>
  16. #define IP_ADDRESS_STRING_LENGTH 16
  17. BOOLEAN
  18. UnicodeInetAddr(
  19. PWCHAR AddressString,
  20. PULONG Address
  21. )
  22. {
  23. UNICODE_STRING uString;
  24. STRING aString;
  25. UCHAR addressBuffer[IP_ADDRESS_STRING_LENGTH];
  26. NTSTATUS status;
  27. aString.Length = 0;
  28. aString.MaximumLength = IP_ADDRESS_STRING_LENGTH;
  29. aString.Buffer = addressBuffer;
  30. RtlInitUnicodeString(&uString, AddressString);
  31. status = RtlUnicodeStringToAnsiString(
  32. &aString,
  33. &uString,
  34. FALSE
  35. );
  36. if (!NT_SUCCESS(status)) {
  37. return(FALSE);
  38. }
  39. *Address = inet_addr(addressBuffer);
  40. return(TRUE);
  41. }