diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2008-09-05 22:47:42 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2008-09-05 22:47:42 +0000 |
commit | 1b20fc500d738afac1cc8960b4e533b94758e4c2 (patch) | |
tree | 9615ef49ed5e048b3788f0405849c04731713121 /nuttx/netutils | |
parent | 505e4b457e81471ed08cf847a248a7ad09b34860 (diff) | |
download | px4-nuttx-1b20fc500d738afac1cc8960b4e533b94758e4c2.tar.gz px4-nuttx-1b20fc500d738afac1cc8960b4e533b94758e4c2.tar.bz2 px4-nuttx-1b20fc500d738afac1cc8960b4e533b94758e4c2.zip |
Added basic TFTP client support
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@879 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/netutils')
-rw-r--r-- | nuttx/netutils/Makefile | 15 | ||||
-rw-r--r-- | nuttx/netutils/tftpc/tftpc_get.c | 2 | ||||
-rw-r--r-- | nuttx/netutils/tftpc/tftpc_internal.h | 4 | ||||
-rw-r--r-- | nuttx/netutils/tftpc/tftpc_packets.c | 4 | ||||
-rw-r--r-- | nuttx/netutils/tftpc/tftpc_put.c | 4 |
5 files changed, 17 insertions, 12 deletions
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 */ |