diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2012-02-04 21:02:45 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2012-02-04 21:02:45 +0000 |
commit | e82f3f21bff1cf021e036ce3e67d5cc12eb41ebe (patch) | |
tree | f564a8e1329d499be76176d46618c76225e04b37 /nuttx/lib | |
parent | 07944e1dd7c38a2de22861c695b295156ea8cafd (diff) | |
download | px4-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/lib')
-rw-r--r-- | nuttx/lib/net/lib_inetntop.c | 5 | ||||
-rw-r--r-- | nuttx/lib/net/lib_inetpton.c | 53 |
2 files changed, 35 insertions, 23 deletions
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) |