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
This commit is contained in:
parent
b2313617a2
commit
041c5430b7
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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,6 +204,17 @@ int inet_pton(int af, FAR const char *src, FAR void *dst)
|
||||
|
||||
return 0;
|
||||
#else
|
||||
size_t srcoffset;
|
||||
size_t numoffset;
|
||||
long value;
|
||||
int nsep;
|
||||
int nrsep;
|
||||
uint8_t ch;
|
||||
char numstr[5];
|
||||
uint8_t ip[sizeof(struct in6_addr)];
|
||||
uint8_t rip[sizeof(struct in6_addr)];
|
||||
bool rtime;
|
||||
|
||||
DEBUGASSERT(src && dst);
|
||||
|
||||
if (af != AF_INET6)
|
||||
@ -207,29 +223,19 @@ int inet_pton(int af, FAR const char *src, FAR void *dst)
|
||||
return -1;
|
||||
}
|
||||
|
||||
size_t srcoffset;
|
||||
size_t numoffset;
|
||||
long value;
|
||||
int nsep;
|
||||
int nrsep;
|
||||
uint8_t ch;
|
||||
char numstr[5];
|
||||
uint8_t ip[sizeof(in_addr)];
|
||||
uint8_t rip[sizeof(in_addr)];
|
||||
bool rtime;
|
||||
(void)memset(dst, 0, sizeof(struct in6_addr));
|
||||
|
||||
(void)memset(dst, 0, sizeof(in_addr));
|
||||
srcoffset = 0;
|
||||
numoffset = 0;
|
||||
nsep = 0;
|
||||
nrsep = 0;
|
||||
rtime = false;
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user