Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygennetwork.c
Go to the documentation of this file.
00001 /* 00002 * COPYRIGHT: See COPYING in the top level directory 00003 * PROJECT: ReactOS Runtime Library 00004 * PURPOSE: Network Address Translation implementation 00005 * PROGRAMMER: Alex Ionescu (alexi@tinykrnl.org) 00006 */ 00007 00008 /* INCLUDES *****************************************************************/ 00009 00010 #include <rtl.h> 00011 00012 #define NDEBUG 00013 #include <debug.h> 00014 00015 /* maximum length of an ipv4 address expressed as a string */ 00016 #define IPV4_ADDR_STRING_MAX_LEN 16 00017 00018 /* maximum length of an ipv4 port expressed as a string */ 00019 #define IPV4_PORT_STRING_MAX_LEN 7 /* with the leading ':' */ 00020 00021 /* network to host order conversion for little endian machines */ 00022 #define WN2H(w) (((w & 0xFF00) >> 8) | ((w & 0x00FF) << 8)) 00023 00024 /* FUNCTIONS ***************************************************************/ 00025 00026 /* 00027 * @implemented 00028 */ 00029 LPSTR 00030 NTAPI 00031 RtlIpv4AddressToStringA(IN struct in_addr *Addr, 00032 OUT PCHAR S) 00033 { 00034 INT Length; 00035 00036 if (!S) return (LPSTR)~0; 00037 00038 Length = sprintf(S, "%u.%u.%u.%u", Addr->S_un.S_un_b.s_b1, 00039 Addr->S_un.S_un_b.s_b2, 00040 Addr->S_un.S_un_b.s_b3, 00041 Addr->S_un.S_un_b.s_b4); 00042 00043 return S + Length; 00044 } 00045 00046 /* 00047 * @implemented 00048 */ 00049 NTSTATUS 00050 NTAPI 00051 RtlIpv4AddressToStringExA(IN struct in_addr *Address, 00052 IN USHORT Port, 00053 OUT PCHAR AddressString, 00054 IN OUT PULONG AddressStringLength) 00055 { 00056 CHAR Buffer[IPV4_ADDR_STRING_MAX_LEN+IPV4_PORT_STRING_MAX_LEN]; 00057 ULONG Length; 00058 00059 if (!Address || !AddressString || !AddressStringLength) 00060 return STATUS_INVALID_PARAMETER; 00061 00062 Length = sprintf(Buffer, "%u.%u.%u.%u", Address->S_un.S_un_b.s_b1, 00063 Address->S_un.S_un_b.s_b2, 00064 Address->S_un.S_un_b.s_b3, 00065 Address->S_un.S_un_b.s_b4); 00066 00067 if (Port) Length += sprintf(Buffer + Length, ":%u", WN2H(Port)); 00068 00069 if (*AddressStringLength > Length) 00070 { 00071 *AddressStringLength = Length + 1; 00072 strcpy(AddressString, Buffer); 00073 return STATUS_SUCCESS; 00074 } 00075 00076 *AddressStringLength = Length + 1; 00077 return STATUS_INVALID_PARAMETER; 00078 } 00079 00080 /* 00081 * @implemented 00082 */ 00083 LPWSTR 00084 NTAPI 00085 RtlIpv4AddressToStringW(IN struct in_addr *Addr, 00086 OUT PWCHAR S) 00087 { 00088 INT Length; 00089 00090 if (!S) return (LPWSTR)~0; 00091 00092 Length = swprintf(S, L"%u.%u.%u.%u", Addr->S_un.S_un_b.s_b1, 00093 Addr->S_un.S_un_b.s_b2, 00094 Addr->S_un.S_un_b.s_b3, 00095 Addr->S_un.S_un_b.s_b4); 00096 return S + Length; 00097 } 00098 00099 /* 00100 * @implemented 00101 */ 00102 NTSTATUS 00103 NTAPI 00104 RtlIpv4AddressToStringExW(IN struct in_addr *Address, 00105 IN USHORT Port, 00106 OUT PWCHAR AddressString, 00107 IN OUT PULONG AddressStringLength) 00108 { 00109 WCHAR Buffer[IPV4_ADDR_STRING_MAX_LEN+IPV4_PORT_STRING_MAX_LEN]; 00110 ULONG Length; 00111 00112 if (!Address || !AddressString || !AddressStringLength) 00113 return STATUS_INVALID_PARAMETER; 00114 00115 Length = swprintf(Buffer, L"%u.%u.%u.%u", Address->S_un.S_un_b.s_b1, 00116 Address->S_un.S_un_b.s_b2, 00117 Address->S_un.S_un_b.s_b3, 00118 Address->S_un.S_un_b.s_b4); 00119 00120 if (Port) Length += swprintf(Buffer + Length, L":%u", WN2H(Port)); 00121 00122 if (*AddressStringLength > Length) 00123 { 00124 *AddressStringLength = Length + 1; 00125 wcscpy(AddressString, Buffer); 00126 return STATUS_SUCCESS; 00127 } 00128 00129 *AddressStringLength = Length + 1; 00130 return STATUS_INVALID_PARAMETER; 00131 } 00132 00133 /* 00134 * @unimplemented 00135 */ 00136 NTSTATUS 00137 NTAPI 00138 RtlIpv4StringToAddressA(IN PCHAR String, 00139 IN BOOLEAN Strict, 00140 OUT PCHAR *Terminator, 00141 OUT struct in_addr *Addr) 00142 { 00143 UNIMPLEMENTED; 00144 return STATUS_NOT_IMPLEMENTED; 00145 } 00146 00147 /* 00148 * @unimplemented 00149 */ 00150 NTSTATUS 00151 NTAPI 00152 RtlIpv4StringToAddressExA(IN PCHAR AddressString, 00153 IN BOOLEAN Strict, 00154 OUT struct in_addr *Address, 00155 IN PUSHORT Port) 00156 { 00157 UNIMPLEMENTED; 00158 return STATUS_NOT_IMPLEMENTED; 00159 } 00160 00161 /* 00162 * @unimplemented 00163 */ 00164 NTSTATUS 00165 NTAPI 00166 RtlIpv4StringToAddressW(IN PCWSTR String, 00167 IN BOOLEAN Strict, 00168 OUT LPWSTR *Terminator, 00169 OUT struct in_addr *Addr) 00170 { 00171 UNIMPLEMENTED; 00172 return STATUS_NOT_IMPLEMENTED; 00173 } 00174 00175 /* 00176 * @unimplemented 00177 */ 00178 NTSTATUS 00179 NTAPI 00180 RtlIpv4StringToAddressExW(IN PWCHAR AddressString, 00181 IN BOOLEAN Strict, 00182 OUT struct in_addr *Address, 00183 OUT PUSHORT Port) 00184 { 00185 UNIMPLEMENTED; 00186 return STATUS_NOT_IMPLEMENTED; 00187 } 00188 00189 /* 00190 * @unimplemented 00191 */ 00192 NTSTATUS 00193 NTAPI 00194 RtlIpv6AddressToStringA(IN struct in6_addr *Addr, 00195 OUT PCHAR S) 00196 { 00197 UNIMPLEMENTED; 00198 return STATUS_NOT_IMPLEMENTED; 00199 } 00200 00201 /* 00202 * @unimplemented 00203 */ 00204 NTSTATUS 00205 NTAPI 00206 RtlIpv6AddressToStringExA(IN struct in6_addr *Address, 00207 IN ULONG ScopeId, 00208 IN ULONG Port, 00209 OUT PCHAR AddressString, 00210 IN OUT PULONG AddressStringLength) 00211 { 00212 UNIMPLEMENTED; 00213 return STATUS_NOT_IMPLEMENTED; 00214 } 00215 00216 /* 00217 * @unimplemented 00218 */ 00219 NTSTATUS 00220 NTAPI 00221 RtlIpv6AddressToStringW(IN struct in6_addr *Addr, 00222 OUT PWCHAR S) 00223 { 00224 UNIMPLEMENTED; 00225 return STATUS_NOT_IMPLEMENTED; 00226 } 00227 00228 /* 00229 * @unimplemented 00230 */ 00231 NTSTATUS 00232 NTAPI 00233 RtlIpv6AddressToStringExW(IN struct in6_addr *Address, 00234 IN ULONG ScopeId, 00235 IN USHORT Port, 00236 IN OUT PWCHAR AddressString, 00237 IN OUT PULONG AddressStringLength) 00238 { 00239 UNIMPLEMENTED; 00240 return STATUS_NOT_IMPLEMENTED; 00241 } 00242 00243 /* 00244 * @unimplemented 00245 */ 00246 NTSTATUS 00247 NTAPI 00248 RtlIpv6StringToAddressA(IN PCHAR Name, 00249 OUT PCHAR *Terminator, 00250 OUT struct in6_addr *Addr) 00251 { 00252 UNIMPLEMENTED; 00253 return STATUS_NOT_IMPLEMENTED; 00254 } 00255 00256 /* 00257 * @unimplemented 00258 */ 00259 NTSTATUS 00260 NTAPI 00261 RtlIpv6StringToAddressExA(IN PCHAR AddressString, 00262 OUT struct in6_addr *Address, 00263 OUT PULONG ScopeId, 00264 OUT PUSHORT Port) 00265 { 00266 UNIMPLEMENTED; 00267 return STATUS_NOT_IMPLEMENTED; 00268 } 00269 00270 /* 00271 * @unimplemented 00272 */ 00273 NTSTATUS 00274 NTAPI 00275 RtlIpv6StringToAddressW(IN PWCHAR Name, 00276 OUT PCHAR *Terminator, 00277 OUT struct in6_addr *Addr) 00278 { 00279 UNIMPLEMENTED; 00280 return STATUS_NOT_IMPLEMENTED; 00281 } 00282 00283 /* 00284 * @unimplemented 00285 */ 00286 NTSTATUS 00287 NTAPI 00288 RtlIpv6StringToAddressExW(IN PWCHAR AddressName, 00289 OUT struct in6_addr *Address, 00290 OUT PULONG ScopeId, 00291 OUT PUSHORT Port) 00292 { 00293 UNIMPLEMENTED; 00294 return STATUS_NOT_IMPLEMENTED; 00295 } 00296 00297 /* EOF */ Generated on Sun May 27 2012 04:16:35 for ReactOS by
1.7.6.1
|