• Welcome to Valhalla Legends Archive.
 
Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - Trunning

#1
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?
#2
I've made no progress with this :(
#3
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++?
#4
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.
#5
It creates a hole lot of errors trying to type cast to "unsigned byte", any idea why?
#6
Ok then, how do I convert the decimal version to an actual IP in C++?
#7
241? What was the -15 to F1 conversion, I thought the 15 was decimal, but that's what 241 is.
#8
There's 4 DWORDS before the IP DWORD, so 17 through 20 should work, but [17] always prints out -15.

printf("\n%d.%d.%d.%d\n", buffer[17], buffer[18], buffer[19], buffer[20]);
#9
Can I get an example on how to convert the DWORD IP to an actual IP Address?

307491135 is the DWORD

3f f1 53 12 are the 4 bytes

63.241.83.18 is the actual IP
#10
Oh and real quick, is it giving me the IP and Port of the Realm Server I'm suppose to connect to or no?
#11
Oh that was stupid, and you will never guess what happened. I was failing to send packet 0x3E correctly, so I checked my packet log, seen there was an extra 4 bytes there, and fixed it by myself, so it appears I've learned something.

How can I get the IP Address from the IP DWORD? It says on the page to use ntohs() for the port, but doesn't say about the IP Address.
#12
The ID of my header is being set to 64, it should be 40. I have no idea why this is happening.

Ah, it's in decimal, lemme look at the rest of the code.

I honestly don't know what it was, but rewriting my code fixed it.
#13
Here is the received packet.

0000   ff 40 33 00 00 00 00 00 01 00 00 00 01 00 00 00  .@3.............
0010   55 53 57 65 73 74 00 52 65 61 6c 6d 20 66 6f 72  USWest.Realm for
0020   20 74 68 65 20 55 53 20 57 65 73 74 20 43 6f 61   the US West Coa
0030   73 74 00                                         st.


After analyzing the packet everything is there.

ff 40 33 00 = Header
00 00 00 00 = Unknown, usually 0
01 00 00 00 = Count
01 00 00 00 = Unknown usually 1

55 53 57 65 73 74 00 = Title
52 65 61 6c 6d 20 66 6f 72 20 74 68 65 20 55 53 20 57 65 73 74 20 43 6f 61 73 74 = Description
#14
Packet looks fine in wireshark.
#15
My title isn't pointing to the right location, I checked my packet log, I'm receiving 3 dwords after the header, and before the string.

BNCS_HEADER head;
head.Sanity = 0xFF;
head.ID = 0x40;
head.Length = sizeof(BNCS_HEADER);

send(sockBNCS, (char*)&head, head.Length, NULL);

char *buf = (char*)malloc(sizeof(BNCS_HEADER));
recv(sockBNCS, buf, sizeof(BNCS_HEADER), NULL);
BNCS_HEADER da;
memcpy(&da, buf, sizeof(BNCS_HEADER));
free(buf);

char *buffer = (char*)malloc(da.Length - sizeof(BNCS_HEADER));
int body_size = da.Length - sizeof(BNCS_HEADER);

char *title = buffer + sizeof(DWORD) * 3;
int title_len = strlen(title) + 1;
char *desc = buffer + sizeof(DWORD) * 3 + title_len;
int desc_len = strlen(desc) + 1;

printf("Title: %s\nDesc: %s\n", title, desc);

free(buffer);