src/network/core/udp.c
changeset 5572 a98ffa55b19c
parent 5552 527df7300907
equal deleted inserted replaced
5571:ba832eb30a68 5572:a98ffa55b19c
   114 	client_len = sizeof(client_addr);
   114 	client_len = sizeof(client_addr);
   115 
   115 
   116 	/* Try to receive anything */
   116 	/* Try to receive anything */
   117 	nbytes = recvfrom(udp, p.buffer, packet_len, 0, (struct sockaddr *)&client_addr, &client_len);
   117 	nbytes = recvfrom(udp, p.buffer, packet_len, 0, (struct sockaddr *)&client_addr, &client_len);
   118 
   118 
   119 	/* We got some bytes for the base header of the packet.
   119 	/* We got some bytes for the base header of the packet. */
   120 	 * Assume we received the whole packet. */
       
   121 	if (nbytes > 2) {
   120 	if (nbytes > 2) {
   122 		NetworkRecv_ReadPacketSize(&p);
   121 		NetworkRecv_ReadPacketSize(&p);
       
   122 
       
   123 		/* If the size does not match the packet must be corrupted.
       
   124 		 * Otherwise it will be marked as corrupted later on. */
       
   125 		if (nbytes != p.size) {
       
   126 			DEBUG(net, 1, "received a packet with mismatching size from %s:%d",
       
   127 					inet_ntoa(client_addr.sin_addr), ntohs(client_addr.sin_port));
       
   128 
       
   129 			return;
       
   130 		}
   123 
   131 
   124 		/* Put the position on the right place */
   132 		/* Put the position on the right place */
   125 		p.pos = 2;
   133 		p.pos = 2;
   126 		p.next = NULL;
   134 		p.next = NULL;
   127 
   135