Convert a in_addr to an IPAddr
-
In my code I'm trying to call SendARP to get the MAC address of a computer on the local network. I have their IP address in the in_addr data format, but SendARP takes it as an IPAddr. I looked on MSDN and they don't offer any explicit ways to convert between the two and google searches so far have not proven fruitful. Anyone done this before?
-
In my code I'm trying to call SendARP to get the MAC address of a computer on the local network. I have their IP address in the in_addr data format, but SendARP takes it as an IPAddr. I looked on MSDN and they don't offer any explicit ways to convert between the two and google searches so far have not proven fruitful. Anyone done this before?
I am BATMAN wrote:
In my code I'm trying to call SendARP to get the MAC address of a computer on the local network. I have their IP address in the in_addr data format, but SendARP takes it as an IPAddr. I looked on MSDN and they don't offer any explicit ways to convert between the two and google searches so far have not proven fruitful. Anyone done this before?
Have you looked at the two definitions?
IPAddr
andin_addr
? -
I am BATMAN wrote:
In my code I'm trying to call SendARP to get the MAC address of a computer on the local network. I have their IP address in the in_addr data format, but SendARP takes it as an IPAddr. I looked on MSDN and they don't offer any explicit ways to convert between the two and google searches so far have not proven fruitful. Anyone done this before?
Have you looked at the two definitions?
IPAddr
andin_addr
?yes, that was sort of vague...are you talking about how it says you can cast an IPAddr to an in_addr? I tried casting the other direction (in_addr to IPAddr) but it throws errors. Forgive me, this is basically the beginning of my windows C++ programming, up until now it's all been command line linux code. Is there a special way to cast with the win API or something?
-
I am BATMAN wrote:
In my code I'm trying to call SendARP to get the MAC address of a computer on the local network. I have their IP address in the in_addr data format, but SendARP takes it as an IPAddr. I looked on MSDN and they don't offer any explicit ways to convert between the two and google searches so far have not proven fruitful. Anyone done this before?
Have you looked at the two definitions?
IPAddr
andin_addr
?Oh ok, it worked when I saved the variable as a IPAddr the same way I was originally saving the in_addr instead of trying to cast between the two. Thanks anyways
-
yes, that was sort of vague...are you talking about how it says you can cast an IPAddr to an in_addr? I tried casting the other direction (in_addr to IPAddr) but it throws errors. Forgive me, this is basically the beginning of my windows C++ programming, up until now it's all been command line linux code. Is there a special way to cast with the win API or something?
I am BATMAN wrote:
Forgive me, this is basically the beginning of my windows C++ programming, up until now it's all been command line linux code. Is there a special way to cast with the win API or something?
Then you need to study beginners material of the language since you need to understand types, structures and unions as well as many, many other things. Trying to explain them to you in a forum is not appropriate.
typedef struct in_addr {
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;The S_addr member of the union is the same type as IPAddr.
//
// IP type definitions.
//
typedef ULONG IPAddr; // An IP address.