- how to convert a dotted-decimal IP address into host internal IP address
- Posted by Steve on May 26th, 2004
Hi,All,
It is very convenient to use a dotted-decimal ip
address,however,TDISendDataGram requires a ULong-typed IP address.
Hence a convension is necessary.Is there any function in windows kernel
mode which can assume this duty?
- Posted by Maxim S. Shatskih on May 26th, 2004
Write inet_addr() yourself. It's trivial.
--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
maxim@storagecraft.com
http://www.storagecraft.com
"Steve" <non_stop@163.com> wrote in message
news:%23TBb6TvQEHA.132@TK2MSFTNGP09.phx.gbl...
- Posted by Alexander Grigoriev on May 26th, 2004
I think gethostbyname() should do it.
"Steve" <non_stop@163.com> wrote in message
news:%23TBb6TvQEHA.132@TK2MSFTNGP09.phx.gbl...
- Posted by Maxim S. Shatskih on May 26th, 2004
In the kernel?
Well, we have the kernel-mode DNS resolver, but it is around 2000 lines of
code or such.
--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
maxim@storagecraft.com
http://www.storagecraft.com
"Alexander Grigoriev" <alegr@earthlink.net> wrote in message
news:u%23BFBhyQEHA.3732@TK2MSFTNGP11.phx.gbl...
- Posted by on May 26th, 2004
RtlIpv4AddressToStringA
RtlIpv4AddressToStringExA
RtlIpv4AddressToStringExW
RtlIpv4AddressToStringW
RtlIpv4StringToAddressA
RtlIpv4StringToAddressExA
RtlIpv4StringToAddressExW
RtlIpv4StringToAddressW
RtlIpv6AddressToStringA
RtlIpv6AddressToStringExA
RtlIpv6AddressToStringExW
RtlIpv6AddressToStringW
RtlIpv6StringToAddressA
RtlIpv6StringToAddressExA
RtlIpv6StringToAddressExW
RtlIpv6StringToAddressW
"Steve" <non_stop@163.com> wrote in message
news:%23TBb6TvQEHA.132@TK2MSFTNGP09.phx.gbl...
- Posted by Steve on May 27th, 2004
Thank you all. But I think the functions like RtlIPv* don't work.
So I will have to write a special-purpose function like inet_addr.
<nospam@cristalink.com> дÈëÏûÏ¢
news:#cc$pB2QEHA.2704@TK2MSFTNGP10.phx.gbl...
- Posted by Tim Roberts on May 28th, 2004
"Steve" <non_stop@163.com> wrote:
I love responses like this.
What do you mean by "I think the functions like RtlIPv* don't work"? Did
you just have a bad feeling that they were flawed in some way? Did someone
tell you they didn't work? Or have you actually tried one and had it fail?
--
- Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc
- Posted by Stephan Wolf on May 28th, 2004
I thought exactly the same thing 
Another, beloved, frequently posted reply is like "problem solved,
thanks". Not that we would ever like to know *how* it got solved...
Stephan
---
On Thu, 27 May 2004 22:55:35 -0700, Tim Roberts <timr@probo.com>
wrote:
- Posted by Steve on May 29th, 2004
Hi,Stephan and Tim,
Thank you for good advice.
I think the functions like RtlIPv* don't work because I can't find them
in Windows DDK Document.
On the other hand, it is certainly trivial to write an inet_addr
function, but fortunately, the principle of the function is clear to us.
Hence, I would implement it rather than spend time in looking for it.
Steve
"Stephan Wolf" <stewo68@hotmail.com>> I thought exactly the same thing 
- Posted by Spiro Trikaliotis on May 29th, 2004
Hello Steve,
Steve <non_stop@163.com> schrieb:
Trivial? Did you consider
- getting an IP as decimal value (i.e., 127.0.0.1 as "2130706433")?
- getting an IP in octal notation (i.e., 127.0.0.1 as "0177.0.0.1")?
As there are some possibilities which are not frequently used, you might
miss a use.
Kind regards,
Spiro.
--
Spiro R. Trikaliotis
http://www.trikaliotis.net/
- Posted by Steve on May 29th, 2004
I just convert a string of "10.0.0.3" into a ULong-typed number of
0X0a000003.
so I can parse the string and calculate its corresponding value.
"Spiro Trikaliotis" <news+200405@trikaliotis.net> дÈëÏûÏ¢
news:slrncbgkju.o8r.news+200405@news.trikaliotis.n et...
- Posted by Maxim S. Shatskih on May 29th, 2004
2 or 3 screenfuls of C code even with all these things handled.
--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
maxim@storagecraft.com
http://www.storagecraft.com
- Posted by Spiro Trikaliotis on May 29th, 2004
Hello Maxim,
Maxim S. Shatskih <maxim@storagecraft.com> schrieb:
My point was that inet_addr() can process many different types of IPs,
and one does not always consider every single way of it.
If I know which options there are, I don't think it is hard to write
such a function. I only wanted to tell that the "if" part can be quite
hard. ;-)
Kind regards,
Spiro.
--
Spiro R. Trikaliotis
http://www.trikaliotis.net/
- Posted by Spiro Trikaliotis on May 29th, 2004
Hello Steve,
Steve <non_stop@163.com> schrieb:
I'm not sure if I understand you correctly:
Does your routine handle
010.0.0.3 as 0x08000003,
0177.0.017.2 as 0x7F000F02,
2130706435 as 0x7F000003,
and so on? If not, you only have a limited inet_addr() function. If you
get external inputs (i.e., from a user), this could really be a
problem.
Regards,
Spiro.
--
Spiro R. Trikaliotis
http://www.trikaliotis.net/
- Posted by Maxim S. Shatskih on May 29th, 2004
Here is the description of IP address formats understandable by inet_addr()
from StorageCraft KSockets
(http://www.storagecraft.com/products/ksockets.html). It (logic, not code) was
taken from FreeBSD IIRC.
// Possible formats:
// 1 digit group (a) - treat as is
// 2 digit groups (a.b) - treat as ( a << 24 ) | b, a must be < 256, b
must be < 16M
// 3 digit groups (a.b.c) - treat as ( a << 24 ) | ( b << 16 ) | c, a and
b must be < 256,
// c must be < 64K
// 4 digit groups (a.b.c.d) - treat as ( a << 24 ) | ( b << 16 ) | ( c <<
8 ) | d,
// all of them must be < 256
// Any digit group with trailing dot must be < 256, and the last digit
group
// must be < ( 1 << ( 32 - ( NumberOfDigitGroups - 1 ) * 8 ) )
And, surely, any digit group can have a radix of 8 ("0" prefix), 16 ("0x"
prefix) or 10 (no prefix).
--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
maxim@storagecraft.com
http://www.storagecraft.com
- Posted by Spiro Trikaliotis on May 29th, 2004
Hello Maxim,
thanks for the info.
Maxim S. Shatskih <maxim@storagecraft.com> schrieb:
*g* An xBSD would have been the place where I would have looked, too.
Regards,
Spiro.
--
Spiro R. Trikaliotis
http://www.trikaliotis.net/