• Welcome to Valhalla Legends Archive.
 

[C -> S] 0x51

Started by Trunning, May 07, 2010, 10:24 PM

Previous topic - Next topic
|

Trunning

Quote from: l)ragon on May 12, 2010, 03:16 AM
CString str_ip = inet_ntoa(addr);

Tried this, but it won't let me typecast a string to in_addr or whatever.

rabbit

Quote from: Hdx on May 12, 2010, 02:27 AM
(unsigned byte)buffer[17]; should work.
All bytes are unsigned.  (uint8) buffer[17];
Grif: Yeah, and the people in the red states are mad because the people in the blue states are mean to them and want them to pay money for roads and schools instead of cool things like NASCAR and shotguns.  Also, there's something about ketchup in there.

Trunning

Thanks to Rabbit I fixed the signed / unsigned problem.

Now I'm printing out: 241.83.18.23.

Here are the 4 bytes: 3f f1 53 12

And the real IP based on my conversion: 63.241.83.18

I noticed the "241.83.18" is in both the printed version, and my conversion. So how can I convert it in C++?

Trunning

I've made no progress with this :(

Hdx

printf("\n%d.%d.%d.%d\n", buffer[17], buffer[18], buffer[19], buffer[20]);
   241.83.18.23
3f  f1 53 12
63.241.83.18
Seems obvious where the bug is to me..

Proud host of the JBLS server www.JBLS.org.
JBLS.org Status:
JBLS/BNLS Server Status

Trunning

Oh wow simple.

Fixed that, but now I'm having problems putting the IP in a variable its self. I've tried sprintf, memcpy, strcpy, neither worked. How can I do it properly?

Hdx


Proud host of the JBLS server www.JBLS.org.
JBLS.org Status:
JBLS/BNLS Server Status

|