summaryrefslogtreecommitdiff
path: root/nuttx
diff options
context:
space:
mode:
Diffstat (limited to 'nuttx')
-rw-r--r--nuttx/ChangeLog1
-rw-r--r--nuttx/Documentation/NuttX.html3
-rw-r--r--nuttx/include/net/uip/tftp.h73
-rw-r--r--nuttx/include/net/uip/uipopt.h12
-rw-r--r--nuttx/netutils/Makefile15
-rw-r--r--nuttx/netutils/tftpc/tftpc_get.c2
-rw-r--r--nuttx/netutils/tftpc/tftpc_internal.h4
-rw-r--r--nuttx/netutils/tftpc/tftpc_packets.c4
-rw-r--r--nuttx/netutils/tftpc/tftpc_put.c4
9 files changed, 101 insertions, 17 deletions
diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog
index 8db3fa750..f35cef7ea 100644
--- a/nuttx/ChangeLog
+++ b/nuttx/ChangeLog
@@ -449,4 +449,5 @@
* NSH: Add ping command
* Correct IP checksum calculation in ICMP and UDP message send logic.
* NSH: Created an HTML document and a more detailed README file describing NSH.
+ * Added basic TFTP client logic (netutils/tftpc). Untested as of initial check-in.
diff --git a/nuttx/Documentation/NuttX.html b/nuttx/Documentation/NuttX.html
index 28fd69ce5..d8edf1eb2 100644
--- a/nuttx/Documentation/NuttX.html
+++ b/nuttx/Documentation/NuttX.html
@@ -8,7 +8,7 @@
<tr align="center" bgcolor="#e4e4e4">
<td>
<h1><big><font color="#3c34ec"><i>NuttX RTOS</i></font></big></h1>
- <p>Last Updated: September 3, 2008</p>
+ <p>Last Updated: September 5, 2008</p>
</td>
</tr>
</table>
@@ -1076,6 +1076,7 @@ nuttx-0.3.14 2008-xx-xx Gregory Nutt &lt;spudmonkey@racsa.co.cr&gt;
* NSH: Add ping command
* Correct IP checksum calculation in ICMP and UDP message send logic.
* NSH: Created an HTML document and a more detailed README file describing NSH.
+ * Added basic TFTP client logic (netutils/tftpc). Untested as of initial check-in.
pascal-0.1.3 2008-xx-xx Gregory Nutt &lt;spudmonkey@racsa.co.cr&gt;
diff --git a/nuttx/include/net/uip/tftp.h b/nuttx/include/net/uip/tftp.h
new file mode 100644
index 000000000..888a77e77
--- /dev/null
+++ b/nuttx/include/net/uip/tftp.h
@@ -0,0 +1,73 @@
+/****************************************************************************
+ * include/net/uip/tftp.h
+ *
+ * Copyright (C) 2008 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+#ifndef __NET_UIP_TFTP_H
+#define __NET_UIP_TFTP_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <sys/types.h>
+#include <arpa/inet.h>
+
+/****************************************************************************
+ * Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Type Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Function Prototypes
+ ****************************************************************************/
+
+#ifdef __cplusplus
+#define EXTERN extern "C"
+extern "C" {
+#else
+#define EXTERN extern
+#endif
+
+EXTERN int tftpget(const char *remote, const char *local, in_addr_t addr, boolean binary);
+EXTERN int tftpput(const char *local, const char *remote, in_addr_t addr, boolean binary);
+
+#undef EXTERN
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __NET_UIP_TFTP_H */ \ No newline at end of file
diff --git a/nuttx/include/net/uip/uipopt.h b/nuttx/include/net/uip/uipopt.h
index e71ae00df..55ab124c6 100644
--- a/nuttx/include/net/uip/uipopt.h
+++ b/nuttx/include/net/uip/uipopt.h
@@ -116,6 +116,12 @@
# endif
#endif
+/* The UDP maximum packet size. This is should not be to set to more
+ * than CONFIG_NET_BUFSIZE - UIP_LLH_LEN - UIP_IPUDPH_LEN.
+ */
+
+#define UIP_UDP_MSS (CONFIG_NET_BUFSIZE - UIP_LLH_LEN - UIP_IPUDPH_LEN)
+
/* TCP configuration options */
/* The maximum number of simultaneously open TCP connections.
@@ -175,10 +181,8 @@
#define UIP_MAXSYNRTX 5
-/* The TCP maximum segment size.
- *
- * This is should not be to set to more than
- * CONFIG_NET_BUFSIZE - UIP_LLH_LEN - UIP_TCPIP_HLEN.
+/* The TCP maximum segment size. This is should not be to set to more
+ * than CONFIG_NET_BUFSIZE - UIP_LLH_LEN - UIP_TCPIP_HLEN.
*/
#define UIP_TCP_MSS (CONFIG_NET_BUFSIZE - UIP_LLH_LEN - UIP_TCPIP_HLEN)
diff --git a/nuttx/netutils/Makefile b/nuttx/netutils/Makefile
index 710643cf4..97cff97fe 100644
--- a/nuttx/netutils/Makefile
+++ b/nuttx/netutils/Makefile
@@ -47,17 +47,22 @@ ifeq ($(CONFIG_NET_UDP),y)
include dhcpc/Make.defs
include dhcpd/Make.defs
include resolv/Make.defs
+ifneq ($(CONFIG_NFILE_DESCRIPTORS),0)
+include tftpc/Make.defs
+endif
endif
endif
-SUBDIRS = uiplib dhcpc dhcpd resolv smtp telnetd webclient webserver
+SUBDIRS = uiplib dhcpc dhcpd resolv smtp telnetd webclient webserver tftpc
ASRCS = $(UIPLIB_ASRCS) $(DHCPC_ASRCS) $(DHCPD_ASRCS) $(RESOLV_ASRCS) \
- $(SMTP_ASRCS) $(TELNETD_ASRCS) $(WEBCLIENT_ASRCS) $(WEBSERVER_ASRCS)
+ $(SMTP_ASRCS) $(TELNETD_ASRCS) $(WEBCLIENT_ASRCS) $(WEBSERVER_ASRCS) \
+ $(TFTPC_ASRCS)
AOBJS = $(ASRCS:.S=$(OBJEXT))
CSRCS = $(UIPLIB_CSRCS) $(DHCPC_CSRCS) $(DHCPD_CSRCS) $(RESOLV_CSRCS) \
- $(SMTP_CSRCS) $(TELNETD_CSRCS) $(WEBCLIENT_CSRCS) $(WEBSERVER_CSRCS)
+ $(SMTP_CSRCS) $(TELNETD_CSRCS) $(WEBCLIENT_CSRCS) $(WEBSERVER_CSRCS) \
+ $(TFTPC_CSRCS)
COBJS = $(CSRCS:.c=$(OBJEXT))
SRCS = $(ASRCS) $(CSRCS)
@@ -65,7 +70,7 @@ OBJS = $(AOBJS) $(COBJS)
BIN = libnetutils$(LIBEXT)
-VPATH = uiplib:dhcpc:dhcpd:resolv:smtp:telnetd:webclient:webserver
+VPATH = uiplib:dhcpc:dhcpd:resolv:smtp:telnetd:webclient:webserver:tftpc
all: $(BIN)
@@ -84,7 +89,7 @@ $(BIN): $(OBJS)
ifeq ($(CONFIG_NET),y)
@$(MKDEP) --dep-path . --dep-path uiplib --dep-path dhcpc --dep-path dhcpd \
--dep-path smtp --dep-path webclient --dep-path resolv \
- --dep-path telnetd --dep-path webserver \
+ --dep-path telnetd --dep-path webserver --dep-path tftpc \
$(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep
endif
@touch $@
diff --git a/nuttx/netutils/tftpc/tftpc_get.c b/nuttx/netutils/tftpc/tftpc_get.c
index dfbcef851..49c39a2cb 100644
--- a/nuttx/netutils/tftpc/tftpc_get.c
+++ b/nuttx/netutils/tftpc/tftpc_get.c
@@ -120,7 +120,7 @@ static inline int tftp_parsedatapacket(const ubyte *packet,
*blockno = (uint16)packet[2] << 8 | (uint16)packet[3];
return OK;
}
-#if CONFIG_DEBUG
+#if defined(CONFIG_DEBUG) && defined(CONFIG_DEBUG_NET)
else if (*opcode == TFTP_ERR)
{
(void)tftp_parseerrpacket(packet);
diff --git a/nuttx/netutils/tftpc/tftpc_internal.h b/nuttx/netutils/tftpc/tftpc_internal.h
index 4030aa8ba..801165204 100644
--- a/nuttx/netutils/tftpc/tftpc_internal.h
+++ b/nuttx/netutils/tftpc/tftpc_internal.h
@@ -142,7 +142,7 @@
* Public Data
****************************************************************************/
-#if CONFIG_DEBUG
+#if defined(CONFIG_DEBUG) && defined(CONFIG_DEBUG_NET)
extern const char g_tftpcallfailed[];
extern const char g_tftpcalltimedout[];
extern const char g_tftpnomemory[];
@@ -161,7 +161,7 @@ extern int tftp_sockinit(struct sockaddr_in *server, in_addr_t addr);
extern int tftp_mkreqpacket(ubyte *buffer, int opcode, const char *path, boolean binary);
extern int tftp_mkackpacket(ubyte *buffer, uint16 blockno);
extern int tftp_mkerrpacket(ubyte *buffer, uint16 errorcode, const char *errormsg);
-#if CONFIG_DEBUG
+#if defined(CONFIG_DEBUG) && defined(CONFIG_DEBUG_NET)
extern int tftp_parseerrpacket(const ubyte *packet);
#endif
diff --git a/nuttx/netutils/tftpc/tftpc_packets.c b/nuttx/netutils/tftpc/tftpc_packets.c
index bbdd0b613..d3da57544 100644
--- a/nuttx/netutils/tftpc/tftpc_packets.c
+++ b/nuttx/netutils/tftpc/tftpc_packets.c
@@ -70,7 +70,7 @@
* Public Data
****************************************************************************/
-#if CONFIG_DEBUG
+#if defined(CONFIG_DEBUG) && defined(CONFIG_DEBUG_NET)
const char g_tftpcallfailed[] = "%s failed: %d\n";
const char g_tftpcalltimedout[] = "%s timed out\n";
const char g_tftpnomemory[] = "%s memory allocation failure\n";
@@ -217,7 +217,7 @@ int tftp_mkerrpacket(ubyte *buffer, uint16 errorcode, const char *errormsg)
*
****************************************************************************/
-#ifdef CONFIG_DEBUG
+#if defined(CONFIG_DEBUG) && defined(CONFIG_DEBUG_NET)
int tftp_parseerrpacket(const ubyte *buffer)
{
uint16 opcode = (uint16)buffer[0] << 8 | (uint16)buffer[1];
diff --git a/nuttx/netutils/tftpc/tftpc_put.c b/nuttx/netutils/tftpc/tftpc_put.c
index cdf878b42..73004bdbc 100644
--- a/nuttx/netutils/tftpc/tftpc_put.c
+++ b/nuttx/netutils/tftpc/tftpc_put.c
@@ -269,7 +269,7 @@ static int tftp_rcvack(int sd, ubyte *packet, struct sockaddr_in *server,
if (opcode != TFTP_ACK)
{
nvdbg("Bad opcode%d\n");
-#if CONFIG_DEBUG
+#if defined(CONFIG_DEBUG) && defined(CONFIG_DEBUG_NET)
if (opcode == TFTP_ERR)
{
(void)tftp_parseerrpacket(packet);
@@ -330,7 +330,6 @@ int tftpput(const char *local, const char *remote, in_addr_t addr, boolean binar
int sd; /* Socket descriptor for socket I/O */
int fd; /* File descriptor for file I/O */
int result = ERROR; /* Assume failure */
- int tmp; /* For temporary usage */
int ret; /* Generic return status */
#if CONFIG_NETUTILS_TFTP_ACKPACKETS > 1
@@ -338,6 +337,7 @@ int tftpput(const char *local, const char *remote, in_addr_t addr, boolean binar
int head; /* Head index into offsets[] */
int tail; /* Tail index into offsets[] */
int hblockno; /* Block number at the head of offsets[] */
+ int tmp; /* For temporary usage */
#else
off_t offset; /* Offset into source file */
off_t next; /* Offset to the next block */