-
- /* receive packet */
-
- memset(&from, 0, sizeof(from));
- fromlen = sizeof(from);
-
- tv.tv_sec = TFTP_TIMEOUT;
- tv.tv_usec = 0;
-
- FD_ZERO(&rfds);
- FD_SET(socketfd, &rfds);
-
- switch (select(socketfd + 1, &rfds, NULL, NULL, &tv)) {
- case 1:
- len = recvfrom(socketfd, buf, tftp_bufsize, 0,
- (struct sockaddr *) &from, &fromlen);
-
- if (len < 0) {
- bb_perror_msg("recvfrom");
- break;
- }
-
- timeout = 0;
-
- if (sa.sin_port == port) {
- sa.sin_port = from.sin_port;
- }
- if (sa.sin_port == from.sin_port) {
- break;
- }
-
- /* fall-through for bad packets! */
- /* discard the packet - treat as timeout */
- timeout = TFTP_NUM_RETRIES;
- case 0: