[aadk-commits] qwell: branch uClinux/upstreamsync r295 - in /uClinux/branches/upstreamsync/u...

aadk-commits at lists.digium.com aadk-commits at lists.digium.com
Fri Mar 30 15:26:52 MST 2007


Author: qwell
Date: Fri Mar 30 17:26:51 2007
New Revision: 295

URL: http://svn.digium.com/view/aadk?view=rev&rev=295
Log:
I really didn't want to do this, but I had to pull in some fixes from the
 upstream repository for tftp issues in busybox.

This puts us at rev 5142 for busybox.

Modified:
    uClinux/branches/upstreamsync/uClinux-dist/user/busybox/include/libbb.h
    uClinux/branches/upstreamsync/uClinux-dist/user/busybox/networking/tftp.c
    uClinux/branches/upstreamsync/uClinux-dist/user/busybox/scripts/trylink
    uClinux/branches/upstreamsync/uClinux-dist/user/busybox/sysklogd/syslogd.c

Modified: uClinux/branches/upstreamsync/uClinux-dist/user/busybox/include/libbb.h
URL: http://svn.digium.com/view/aadk/uClinux/branches/upstreamsync/uClinux-dist/user/busybox/include/libbb.h?view=diff&rev=295&r1=294&r2=295
==============================================================================
--- uClinux/branches/upstreamsync/uClinux-dist/user/busybox/include/libbb.h (original)
+++ uClinux/branches/upstreamsync/uClinux-dist/user/busybox/include/libbb.h Fri Mar 30 17:26:51 2007
@@ -290,7 +290,7 @@
 
 /* "new" (ipv4+ipv6) API */
 typedef struct len_and_sockaddr {
-	int len;
+	socklen_t len;
 	union {
 		struct sockaddr sa;
 		struct sockaddr_in sin;

Modified: uClinux/branches/upstreamsync/uClinux-dist/user/busybox/networking/tftp.c
URL: http://svn.digium.com/view/aadk/uClinux/branches/upstreamsync/uClinux-dist/user/busybox/networking/tftp.c?view=diff&rev=295&r1=294&r2=295
==============================================================================
--- uClinux/branches/upstreamsync/uClinux-dist/user/busybox/networking/tftp.c (original)
+++ uClinux/branches/upstreamsync/uClinux-dist/user/busybox/networking/tftp.c Fri Mar 30 17:26:51 2007
@@ -132,7 +132,7 @@
 #if ENABLE_FEATURE_TFTP_GET && ENABLE_FEATURE_TFTP_PUT
 		const int cmd,
 #endif
-		const len_and_sockaddr *peer_lsa,
+		len_and_sockaddr *peer_lsa,
 		const char *remotefile, const int localfd,
 		unsigned port, int tftp_bufsize)
 {
@@ -149,6 +149,9 @@
 
 	USE_FEATURE_TFTP_BLOCKSIZE(int want_option_ack = 0;)
 
+	unsigned org_port;
+	len_and_sockaddr *const from = alloca(offsetof(len_and_sockaddr, sa) + peer_lsa->len);
+
 	/* Can't use RESERVE_CONFIG_BUFFER here since the allocation
 	 * size varies meaning BUFFERS_GO_ON_STACK would fail */
 	/* We must keep the transmit and receive buffers seperate */
@@ -156,7 +159,7 @@
 	char *xbuf = xmalloc(tftp_bufsize += 4);
 	char *rbuf = xmalloc(tftp_bufsize);
 
-	port = htons(port);
+	port = org_port = htons(port);
 
 	socketfd = xsocket(peer_lsa->sa.sa_family, SOCK_DGRAM, 0);
 
@@ -167,10 +170,10 @@
 	}
 
 	while (1) {
-
 		cp = xbuf;
 
 		/* first create the opcode part */
+		/* (this 16bit store is aligned) */
 		*((uint16_t*)cp) = htons(opcode);
 		cp += 2;
 
@@ -222,6 +225,7 @@
 		/* add ack and data */
 
 		if (CMD_GET(cmd) ? (opcode == TFTP_ACK) : (opcode == TFTP_DATA)) {
+			/* TODO: unaligned access! */
 			*((uint16_t*)cp) = htons(block_nr);
 			cp += 2;
 			block_nr++;
@@ -273,28 +277,26 @@
 			FD_SET(socketfd, &rfds);
 
 			switch (select(socketfd + 1, &rfds, NULL, NULL, &tv)) {
-				struct sockaddr *from;
-				socklen_t fromlen;
-
+				unsigned from_port;
 			case 1:
-				fromlen = peer_lsa->len;
-				from = alloca(fromlen);
-				memset(from, 0, fromlen);
-
+				from->len = peer_lsa->len;
+				memset(&from->sa, 0, peer_lsa->len);
 				len = recvfrom(socketfd, rbuf, tftp_bufsize, 0,
-							from, &fromlen);
+							&from->sa, &from->len);
 				if (len < 0) {
 					bb_perror_msg("recvfrom");
 					break;
 				}
-#if ENABLE_FEATURE_IPV6
-				if (from->sa_family == AF_INET6)
-					if (((struct sockaddr_in6*)from)->sin6_port != port)
-						goto recv_again;
-#endif
-				if (from->sa_family == AF_INET)
-					if (((struct sockaddr_in*)from)->sin_port != port)
-						goto recv_again;
+				from_port = get_nport(from);
+				if (port == org_port) {
+					/* Our first query went to port 69
+					 * but reply will come from different one.
+					 * Remember and use this new port */
+					port = from_port;
+					set_nport(peer_lsa, from_port);
+				}
+				if (port != from_port)
+					goto recv_again;
 				timeout = 0;
 				break;
 			case 0:
@@ -317,6 +319,7 @@
 		}
 
 		/* process received packet */
+		/* (both accesses seems to be aligned) */
 
 		opcode = ntohs( ((uint16_t*)rbuf)[0] );
 		tmp = ntohs( ((uint16_t*)rbuf)[1] );

Modified: uClinux/branches/upstreamsync/uClinux-dist/user/busybox/scripts/trylink
URL: http://svn.digium.com/view/aadk/uClinux/branches/upstreamsync/uClinux-dist/user/busybox/scripts/trylink?view=diff&rev=295&r1=294&r2=295
==============================================================================
--- uClinux/branches/upstreamsync/uClinux-dist/user/busybox/scripts/trylink (original)
+++ uClinux/branches/upstreamsync/uClinux-dist/user/busybox/scripts/trylink Fri Mar 30 17:26:51 2007
@@ -2,7 +2,7 @@
 
 debug=false
 
-function try {
+try() {
     added="$1"
     shift
     $debug && echo "Trying: $* $added"

Modified: uClinux/branches/upstreamsync/uClinux-dist/user/busybox/sysklogd/syslogd.c
URL: http://svn.digium.com/view/aadk/uClinux/branches/upstreamsync/uClinux-dist/user/busybox/sysklogd/syslogd.c?view=diff&rev=295&r1=294&r2=295
==============================================================================
--- uClinux/branches/upstreamsync/uClinux-dist/user/busybox/sysklogd/syslogd.c (original)
+++ uClinux/branches/upstreamsync/uClinux-dist/user/busybox/sysklogd/syslogd.c Fri Mar 30 17:26:51 2007
@@ -57,7 +57,7 @@
 #endif
 
 /* We are using bb_common_bufsiz1 for buffering: */
-enum { MAX_READ = (BUFSIZ/6) & ~0xf };
+enum { MAX_READ = 256 };
 /* We recv into RECVBUF... (size: MAX_READ ~== BUFSIZ/6) */
 #define RECVBUF  bb_common_bufsiz1
 /* ...then copy to PARSEBUF, escaping control chars */



More information about the aadk-commits mailing list