// // Supernode udp user request // int snode_udp_reqsearch(char *destip, u16 destport, char *our_public_ip, char *skypeuser) { u16 seqnum; u32 rnd; char resp[0x1000]; int resp_len; char pkt[0x1000]; int pkt_len; int retcode; char *mainbuf; u32 mainbuf_len; u32 mainbuf_alloc; mainbuf=malloc(0x1000); mainbuf_len=0; mainbuf_alloc=0x1000; seqnum=rand() % 0x10000; rnd=rand() % 0x10000; rnd+=(rand() % 0x10000)*0x10000; // pkt1 retcode=make_udp_profile_pkt1(our_public_ip,destip,seqnum,rnd,skypeuser,(char *)pkt,&pkt_len); if (retcode==-1) { //printf("prepare error\n"); free(mainbuf); return -1; }; resp_len=udp_talk(destip,destport,pkt,pkt_len,resp,sizeof(resp)); if (resp_len<0) { //printf("socket comm error\n"); free(mainbuf); return -1; }; if (resp_len==0) { //printf("timeout\n"); free(mainbuf); return -2; }; retcode=process_udp_search_pkt1(resp,resp_len,our_public_ip,destip, mainbuf, &mainbuf_len); if (retcode==-1) { //printf("not skype\n"); free(mainbuf); return -3; }; mainbuf_alloc+=0x1000; mainbuf=realloc(mainbuf,mainbuf_alloc); do { resp_len=udp_recv(destip,destport,resp,sizeof(resp)); if (resp_len<0) { //printf("socket comm error\n"); //return -1; break; }; if (resp_len==0) { //printf("timeout\n"); //return -2; if (mainbuf_len<0x188){ free(mainbuf); return -2; }; break; }; retcode=process_udp_search_pkt1(resp,resp_len,our_public_ip,destip, mainbuf, &mainbuf_len); if (retcode==-1) { //printf("not skype\n"); //return -3; break; }; mainbuf_alloc+=0x1000; mainbuf=realloc(mainbuf,mainbuf_alloc); } while(resp_len>0); get_profiles(mainbuf, mainbuf_len); main_unpack(mainbuf, mainbuf_len); if (0){ u32 last_recv_pkt_num; process_pkt(mainbuf, mainbuf_len, 1, &last_recv_pkt_num); }; free(mainbuf); //printf("our public ip: %s\n",our_public_ip); //printf("this is supernode\n"); return 1; }
bool application::has_profile()const { return get_profiles().size() != 0; }