PDA

View Full Version : Gadu-gadu Protocol - logging



Trok
20th February 2010, 00:22
Hi, I have a trouble during the logging by gg protocol from http://toxygen.net/libgadu/protocol/. I connect with server and receive seed, but after sent packet and structure to login, don't receive any message(even package with any wrong communique). That my code:


struct gg_header {
int type; /* typ pakietu */
int length; /* długość reszty pakietu */
};

struct gg_login80 {
int uin; /* numer Gadu-Gadu */ (gg number)
char* language; /* język: "pl" */
char hash_type; /* rodzaj funkcji skrótu hasła */
char* hash; /* skrót hasła dopełniony \0 */
int status; /* początkowy status połączenia */
int flags; /* początkowe flagi połączenia */
int features; /* opcje protokołu (0x00000007)*/(protocol option)
int local_ip; /* lokalny adres połączeń bezpośrednich (nieużywany) */
short local_port; /* lokalny port połączeń bezpośrednich (nieużywany) */
int external_ip; /* zewnętrzny adres (nieużywany) */
short external_port; /* zewnętrzny port (nieużywany) */
char image_size; /* maksymalny rozmiar grafiki w KB */
char unknown2; /* 0x64 */(idk)
int version_len; /* długość ciągu z wersją (0x21) */
char* version; /* "Gadu-Gadu Client build 8.0.0.7669" (bez \0) */
int description_size; /* rozmiar opisu */
};




void MainWindow::login_GG(){
gg_login80 *login = new gg_login80();

//example structure
login->uin = 1234567;
login->language = "pl";
login->hash_type = GG_LOGIN_HASH_GG32;
login->hash = "";
login->status = GG_STATUS_AVAIL;
login->flags = 0;
login->features = 0x7;
login->local_ip = 0;
login->local_port = 0;
login->external_ip = 0;
login->external_port = 0;
login->image_size = 0;
login->unknown2 = 0x64;
login->version_len = sizeof(login->version);
login->version = "";
login->description_size = 0;

gg_header *header = new gg_header;
header->type = GG_LOGIN80;
header->length = sizeof(GG_LOGIN80);

connect(socket, SIGNAL(readyRead()), this, SLOT(s_read()));
socket->write((char*)header, sizeof(gg_header));
socket->write((char*)login, sizeof(gg_login80));
}

void MainWindow::s_read(){
//That function doesn't call forth because server doesn't receive any package to read
qDebug () << "Receive packet.";
}

I test by tcpdump and appropriate functons in Qt, that packages are sending to server, unfortunately i don't recive anything (size of packet is 0).

Fenix Voltres
20th February 2010, 01:05
EDITED

Login packet has it's own structure. When you send wrong structure, server may not respond at all.
You're making some mistakes:
1) You can't use sizeof operator in header->length, because gg_login80 struct contains pointers to data, and you will send the data, not the pointers; (what's more, you meant "gg_login80" instead of const "GG_LOGIN80");
2) hash variable has to be 64 bytes long, (and, BTW, are you counting it anywhere?).
3) check if second's write method returns number equals to what you sent in header->length - when you sent less bytes, server will still wait for the rest.
4) Casting header and login to char* for 95% will return crap (but not sure of it) - same bug with sizeof here, also.

Generally, I advise you to log every packet (bytes) that you send / receive in order to check it's correctness.