summaryrefslogtreecommitdiff
path: root/nuttx
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-02-04 21:02:45 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-02-04 21:02:45 +0000
commite82f3f21bff1cf021e036ce3e67d5cc12eb41ebe (patch)
treef564a8e1329d499be76176d46618c76225e04b37 /nuttx
parent07944e1dd7c38a2de22861c695b295156ea8cafd (diff)
downloadpx4-nuttx-e82f3f21bff1cf021e036ce3e67d5cc12eb41ebe.tar.gz
px4-nuttx-e82f3f21bff1cf021e036ce3e67d5cc12eb41ebe.tar.bz2
px4-nuttx-e82f3f21bff1cf021e036ce3e67d5cc12eb41ebe.zip
Add the beginnings of an FTP server
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4368 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx')
-rw-r--r--nuttx/fs/fs_poll.c4
-rw-r--r--nuttx/include/sys/socket.h4
-rw-r--r--nuttx/lib/net/lib_inetntop.c5
-rw-r--r--nuttx/lib/net/lib_inetpton.c53
4 files changed, 40 insertions, 26 deletions
diff --git a/nuttx/fs/fs_poll.c b/nuttx/fs/fs_poll.c
index f5aa9dcf0..b81a4d3c6 100644
--- a/nuttx/fs/fs_poll.c
+++ b/nuttx/fs/fs_poll.c
@@ -1,8 +1,8 @@
/****************************************************************************
* fs/fs_poll.c
*
- * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved.
- * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ * Copyright (C) 2008-2009, 2012 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
diff --git a/nuttx/include/sys/socket.h b/nuttx/include/sys/socket.h
index 68888eaa7..7613d00cd 100644
--- a/nuttx/include/sys/socket.h
+++ b/nuttx/include/sys/socket.h
@@ -52,7 +52,8 @@
/* Protocol families */
-#define PF_UNIX 0 /* Local communication */
+#define PF_UNSPEC 0 /* Protocol family unspecified */
+#define PF_UNIX 1 /* Local communication */
#define PF_LOCAL 1 /* Local communication */
#define PF_INET 2 /* IPv4 Internet protocols */
#define PF_INET6 3 /* IPv6 Internet protocols */
@@ -66,6 +67,7 @@
/* Address families */
+#define AF_UNSPEC PF_UNSPEC
#define AF_UNIX PF_UNIX
#define AF_LOCAL PF_LOCAL
#define AF_INET PF_INET
diff --git a/nuttx/lib/net/lib_inetntop.c b/nuttx/lib/net/lib_inetntop.c
index b48cd5d11..3c8eb936a 100644
--- a/nuttx/lib/net/lib_inetntop.c
+++ b/nuttx/lib/net/lib_inetntop.c
@@ -5,7 +5,10 @@
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Includes some logic extracted from hwport_ftpd, written by Jaehyuk Cho
- * <minzkn@minzkn.com> which has a BSD license (but no file headers).
+ * <minzkn@minzkn.com> which was released under the BSD license.
+ *
+ * Copyright (C) HWPORT.COM. All rights reserved.
+ * Author: JAEHYUK CHO <mailto:minzkn@minzkn.com>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
diff --git a/nuttx/lib/net/lib_inetpton.c b/nuttx/lib/net/lib_inetpton.c
index 195e96b60..281d03d40 100644
--- a/nuttx/lib/net/lib_inetpton.c
+++ b/nuttx/lib/net/lib_inetpton.c
@@ -5,7 +5,10 @@
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Includes some logic extracted from hwport_ftpd, written by Jaehyuk Cho
- * <minzkn@minzkn.com> which has a BSD license (but no file headers).
+ * <minzkn@minzkn.com> which was released under the BSD license.
+ *
+ * Copyright (C) HWPORT.COM. All rights reserved.
+ * Author: JAEHYUK CHO <mailto:minzkn@minzkn.com>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -123,6 +126,8 @@ int inet_pton(int af, FAR const char *src, FAR void *dst)
return -1;
}
+ (void)memset(dst, 0, sizeof(struct in_addr));
+
ip = (uint8_t *)dst;
srcoffset = 0;
numoffset = 0;
@@ -199,14 +204,6 @@ int inet_pton(int af, FAR const char *src, FAR void *dst)
return 0;
#else
- DEBUGASSERT(src && dst);
-
- if (af != AF_INET6)
- {
- set_errno(EAFNOSUPPORT);
- return -1;
- }
-
size_t srcoffset;
size_t numoffset;
long value;
@@ -214,22 +211,31 @@ int inet_pton(int af, FAR const char *src, FAR void *dst)
int nrsep;
uint8_t ch;
char numstr[5];
- uint8_t ip[sizeof(in_addr)];
- uint8_t rip[sizeof(in_addr)];
+ uint8_t ip[sizeof(struct in6_addr)];
+ uint8_t rip[sizeof(struct in6_addr)];
bool rtime;
- (void)memset(dst, 0, sizeof(in_addr));
- srcoffset = 0;
- numoffset = 0;
- nsep = 0;
- nrsep = 0;
- rtime = false;
+ DEBUGASSERT(src && dst);
+
+ if (af != AF_INET6)
+ {
+ set_errno(EAFNOSUPPORT);
+ return -1;
+ }
+
+ (void)memset(dst, 0, sizeof(struct in6_addr));
+
+ srcoffset = 0;
+ numoffset = 0;
+ nsep = 0;
+ nrsep = 0;
+ rtime = false;
for(;;)
{
ch = (uint8_t)src[srcoffset++];
- if (ch == ':' || ch == '\0' /* || ch == '/' */ )
+ if (ch == ':' || ch == '\0')
{
if (ch == ':' && (nsep + nrsep) >= 8)
{
@@ -242,7 +248,7 @@ int inet_pton(int af, FAR const char *src, FAR void *dst)
{
/* Empty numeric string */
- if (rtime != 0 && nrsep > 1)
+ if (rtime && nrsep > 1)
{
/* dup simple */
@@ -251,7 +257,6 @@ int inet_pton(int af, FAR const char *src, FAR void *dst)
numoffset = 0;
rtime = true;
-
continue;
}
@@ -281,7 +286,9 @@ int inet_pton(int af, FAR const char *src, FAR void *dst)
if (ch == '\0' /* || ch == '/' */)
{
- if ((nsep <= 1 && nrsep <= 0) || (nsep + nrsep) < 1 || (nsep + nrsep) > 8)
+ if ((nsep <= 1 && nrsep <= 0) ||
+ (nsep + nrsep) < 1 ||
+ (nsep + nrsep) > 8)
{
/* Separator count problem */
@@ -303,7 +310,9 @@ int inet_pton(int af, FAR const char *src, FAR void *dst)
return 0;
}
}
- else if ((ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'f') || (ch >= 'A' && ch <= 'F'))
+ else if ((ch >= '0' && ch <= '9') ||
+ (ch >= 'a' && ch <= 'f') ||
+ (ch >= 'A' && ch <= 'F'))
{
numstr[numoffset++] = ch;
if (numoffset >= 5)