mirror of
https://github.com/apache/nuttx.git
synced 2026-06-04 14:53:47 +08:00
Added basic TFTP client support
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@879 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
+10
-5
@@ -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 $@
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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];
|
||||
|
||||
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user