mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Cleaned up some stuff.
This commit is contained in:
parent
d0ed163914
commit
24925a24ec
|
@ -122,3 +122,12 @@ int init_networking(IP ip ,uint16_t port)
|
|||
return 0;
|
||||
|
||||
}
|
||||
|
||||
//function to cleanup networking stuff
|
||||
void shutdown_networking()
|
||||
{
|
||||
#ifdef WIN32
|
||||
WSACleanup();
|
||||
#endif
|
||||
return;
|
||||
}
|
|
@ -96,4 +96,8 @@ int recievepacket(IP_Port * ip_port, char * data, uint32_t * length);
|
|||
//returns 0 if no problems
|
||||
//TODO: add something to check if there are errors
|
||||
int init_networking(IP ip ,uint16_t port);
|
||||
|
||||
|
||||
//function to cleanup networking stuff(doesn't do much right now)
|
||||
void shutdown_networking();
|
||||
#endif
|
|
@ -80,7 +80,19 @@ void print_friendlist()
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void printpacket(char * data, uint32_t length, IP_Port ip_port)
|
||||
{
|
||||
uint32_t i;
|
||||
printf("UNHANDLED PACKET RECEIVED\nLENGTH:%u\nCONTENTS:\n", length);
|
||||
printf("--------------------BEGIN-----------------------------\n");
|
||||
for(i = 0; i < length; i++)
|
||||
{
|
||||
if(data[i] < 16)
|
||||
printf("0");
|
||||
printf("%hhX",data[i]);
|
||||
}
|
||||
printf("\n--------------------END-----------------------------\n\n\n");
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
@ -116,8 +128,6 @@ int main(int argc, char *argv[])
|
|||
char data[MAX_UDP_PACKET_SIZE];
|
||||
uint32_t length;
|
||||
|
||||
uint32_t i;
|
||||
|
||||
while(1)
|
||||
{
|
||||
|
||||
|
@ -127,15 +137,8 @@ int main(int argc, char *argv[])
|
|||
{
|
||||
if(DHT_handlepacket(data, length, ip_port))
|
||||
{
|
||||
printf("UNHANDLED PACKET RECEIVED\nLENGTH:%u\nCONTENTS:\n", length);
|
||||
printf("--------------------BEGIN-----------------------------\n");
|
||||
for(i = 0; i < length; i++)
|
||||
{
|
||||
if(data[i] < 16)
|
||||
printf("0");
|
||||
printf("%hhX",data[i]);
|
||||
}
|
||||
printf("\n--------------------END-----------------------------\n\n\n");
|
||||
//unhandled packet
|
||||
printpacket(data, length, ip_port);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -147,8 +150,6 @@ int main(int argc, char *argv[])
|
|||
c_sleep(300);
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
WSACleanup();
|
||||
#endif
|
||||
shutdown_networking();
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user