From 09afb31c282288408eab64685f66e18ded12caeb Mon Sep 17 00:00:00 2001 From: Thomas Bluemel Date: Mon, 13 Sep 2004 20:25:26 +0000 Subject: [PATCH] implemented RtlIpv4AddressToStringA/W and made ntdll export them. svn path=/trunk/; revision=10848 --- reactos/include/ntos/rtl.h | 6 ++-- reactos/lib/ntdll/def/ntdll.def | 18 +++++++++++- reactos/lib/ntdll/def/ntdll.edf | 18 +++++++++++- reactos/lib/rtl/network.c | 49 +++++++++++++++++++++++++++------ 4 files changed, 77 insertions(+), 14 deletions(-) diff --git a/reactos/include/ntos/rtl.h b/reactos/include/ntos/rtl.h index a922f89fcdf..f46c4622701 100755 --- a/reactos/include/ntos/rtl.h +++ b/reactos/include/ntos/rtl.h @@ -1,4 +1,4 @@ -/* $Id: rtl.h,v 1.33 2004/08/12 06:04:21 ion Exp $ +/* $Id: rtl.h,v 1.34 2004/09/13 20:25:25 weiden Exp $ * */ #ifndef __DDK_RTL_H @@ -1643,7 +1643,7 @@ NTSTATUS STDCALL RtlInvertRangeList (OUT PRTL_RANGE_LIST InvertedRangeList, IN PRTL_RANGE_LIST RangeList); -NTSTATUS +LPSTR STDCALL RtlIpv4AddressToStringA( PULONG IP, @@ -1659,7 +1659,7 @@ RtlIpv4AddressToStringExA( PULONG MaxSize ); -NTSTATUS +LPWSTR STDCALL RtlIpv4AddressToStringW( PULONG IP, diff --git a/reactos/lib/ntdll/def/ntdll.def b/reactos/lib/ntdll/def/ntdll.def index 879573cc3fb..ae38e8c193a 100644 --- a/reactos/lib/ntdll/def/ntdll.def +++ b/reactos/lib/ntdll/def/ntdll.def @@ -1,4 +1,4 @@ -; $Id: ntdll.def,v 1.128 2004/09/10 23:29:18 sedwards Exp $ +; $Id: ntdll.def,v 1.129 2004/09/13 20:25:25 weiden Exp $ ; ; ReactOS Operating System ; @@ -491,6 +491,22 @@ RtlInitializeSid@12 RtlIntegerToChar@16 RtlIntegerToUnicodeString@12 RtlInvertRangeList@8 +RtlIpv4AddressToStringA@8 +RtlIpv4AddressToStringExA@16 +RtlIpv4AddressToStringExW@16 +RtlIpv4AddressToStringW@8 +RtlIpv4StringToAddressA@16 +RtlIpv4StringToAddressExA@16 +RtlIpv4StringToAddressExW@16 +RtlIpv4StringToAddressW@16 +RtlIpv6AddressToStringA@8 +RtlIpv6AddressToStringExA@16 +RtlIpv6AddressToStringExW@16 +RtlIpv6AddressToStringW@8 +RtlIpv6StringToAddressA@16 +RtlIpv6StringToAddressExA@16 +RtlIpv6StringToAddressExW@16 +RtlIpv6StringToAddressW@16 RtlIsDosDeviceName_U@4 RtlIsGenericTableEmpty@4 RtlIsNameLegalDOS8Dot3@12 diff --git a/reactos/lib/ntdll/def/ntdll.edf b/reactos/lib/ntdll/def/ntdll.edf index 52ddaf5b6c7..bd3e09edf06 100644 --- a/reactos/lib/ntdll/def/ntdll.edf +++ b/reactos/lib/ntdll/def/ntdll.edf @@ -1,4 +1,4 @@ -; $Id: ntdll.edf,v 1.118 2004/09/10 23:29:18 sedwards Exp $ +; $Id: ntdll.edf,v 1.119 2004/09/13 20:25:25 weiden Exp $ ; ; ReactOS Operating System ; @@ -491,6 +491,22 @@ RtlInt64ToUnicodeString=RtlInt64ToUnicodeString@16 RtlIntegerToChar=RtlIntegerToChar@16 RtlIntegerToUnicodeString=RtlIntegerToUnicodeString@12 RtlInvertRangeList=RtlInvertRangeList@8 +RtlIpv4AddressToStringA=RtlIpv4AddressToStringA@8 +RtlIpv4AddressToStringExA=RtlIpv4AddressToStringExA@16 +RtlIpv4AddressToStringExW=RtlIpv4AddressToStringExW@16 +RtlIpv4AddressToStringW=RtlIpv4AddressToStringW@8 +RtlIpv4StringToAddressA=RtlIpv4StringToAddressA@16 +RtlIpv4StringToAddressExA=RtlIpv4StringToAddressExA@16 +RtlIpv4StringToAddressExW=RtlIpv4StringToAddressExW@16 +RtlIpv4StringToAddressW=RtlIpv4StringToAddressW@16 +RtlIpv6AddressToStringA=RtlIpv6AddressToStringA@8 +RtlIpv6AddressToStringExA=RtlIpv6AddressToStringExA@16 +RtlIpv6AddressToStringExW=RtlIpv6AddressToStringExW@16 +RtlIpv6AddressToStringW=RtlIpv6AddressToStringW@8 +RtlIpv6StringToAddressA=RtlIpv6StringToAddressA@16 +RtlIpv6StringToAddressExA=RtlIpv6StringToAddressExA@16 +RtlIpv6StringToAddressExW=RtlIpv6StringToAddressExW@16 +RtlIpv6StringToAddressW=RtlIpv6StringToAddressW@16 RtlIsDosDeviceName_U=RtlIsDosDeviceName_U@4 ;RtlIsGenericTableEmpty RtlIsNameLegalDOS8Dot3=RtlIsNameLegalDOS8Dot3@12 diff --git a/reactos/lib/rtl/network.c b/reactos/lib/rtl/network.c index 021436685ae..14d0495690a 100644 --- a/reactos/lib/rtl/network.c +++ b/reactos/lib/rtl/network.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: network.c,v 1.1 2004/08/05 18:17:37 ion Exp $ +/* $Id: network.c,v 1.2 2004/09/13 20:25:26 weiden Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS system libraries @@ -25,23 +25,50 @@ */ #include +#include #define NDEBUG #include /* FUNCTIONS *****************************************************************/ +/* Borrow this from some headers... */ +typedef struct +{ + union + { + struct { UCHAR s_b1,s_b2,s_b3,s_b4; } S_un_b; + struct { USHORT s_w1,s_w2; } S_un_w; + ULONG S_addr; + } S_un; +} in_addr; + +typedef struct +{ + union + { + UCHAR _S6_u8[16]; + USHORT _S6_u16[8]; + ULONG _S6_u32[4]; + } S6_un; +} in6_addr; + + /* -* @unimplemented +* @implemented */ -NTSTATUS +LPSTR STDCALL RtlIpv4AddressToStringA( PULONG IP, LPSTR Buffer ) { - UNIMPLEMENTED; - return STATUS_NOT_IMPLEMENTED; + in_addr addr; + addr.S_un.S_addr = *IP; + return Buffer + sprintf(Buffer, "%u.%u.%u.%u", addr.S_un.S_un_b.s_b1, + addr.S_un.S_un_b.s_b2, + addr.S_un.S_un_b.s_b3, + addr.S_un.S_un_b.s_b4); } /* @@ -61,17 +88,21 @@ RtlIpv4AddressToStringExA( } /* -* @unimplemented +* @implemented */ -NTSTATUS +LPWSTR STDCALL RtlIpv4AddressToStringW( PULONG IP, LPWSTR Buffer ) { - UNIMPLEMENTED; - return STATUS_NOT_IMPLEMENTED; + in_addr addr; + addr.S_un.S_addr = *IP; + return Buffer + swprintf(Buffer, L"%u.%u.%u.%u", addr.S_un.S_un_b.s_b1, + addr.S_un.S_un_b.s_b2, + addr.S_un.S_un_b.s_b3, + addr.S_un.S_un_b.s_b4); } /*