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
|
* fs/fs_poll.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2008-2009 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2008-2009, 2012 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
|
@ -52,7 +52,8 @@
|
|||||||
|
|
||||||
/* Protocol families */
|
/* 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_LOCAL 1 /* Local communication */
|
||||||
#define PF_INET 2 /* IPv4 Internet protocols */
|
#define PF_INET 2 /* IPv4 Internet protocols */
|
||||||
#define PF_INET6 3 /* IPv6 Internet protocols */
|
#define PF_INET6 3 /* IPv6 Internet protocols */
|
||||||
@ -66,6 +67,7 @@
|
|||||||
|
|
||||||
/* Address families */
|
/* Address families */
|
||||||
|
|
||||||
|
#define AF_UNSPEC PF_UNSPEC
|
||||||
#define AF_UNIX PF_UNIX
|
#define AF_UNIX PF_UNIX
|
||||||
#define AF_LOCAL PF_LOCAL
|
#define AF_LOCAL PF_LOCAL
|
||||||
#define AF_INET PF_INET
|
#define AF_INET PF_INET
|
||||||
|
@ -5,7 +5,10 @@
|
|||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Includes some logic extracted from hwport_ftpd, written by Jaehyuk Cho
|
* 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
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
|
@ -5,7 +5,10 @@
|
|||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Includes some logic extracted from hwport_ftpd, written by Jaehyuk Cho
|
* 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
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* 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;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
(void)memset(dst, 0, sizeof(struct in_addr));
|
||||||
|
|
||||||
ip = (uint8_t *)dst;
|
ip = (uint8_t *)dst;
|
||||||
srcoffset = 0;
|
srcoffset = 0;
|
||||||
numoffset = 0;
|
numoffset = 0;
|
||||||
@ -199,6 +204,17 @@ int inet_pton(int af, FAR const char *src, FAR void *dst)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
#else
|
#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);
|
DEBUGASSERT(src && dst);
|
||||||
|
|
||||||
if (af != AF_INET6)
|
if (af != AF_INET6)
|
||||||
@ -207,18 +223,8 @@ int inet_pton(int af, FAR const char *src, FAR void *dst)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t srcoffset;
|
(void)memset(dst, 0, sizeof(struct in6_addr));
|
||||||
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(in_addr));
|
|
||||||
srcoffset = 0;
|
srcoffset = 0;
|
||||||
numoffset = 0;
|
numoffset = 0;
|
||||||
nsep = 0;
|
nsep = 0;
|
||||||
@ -229,7 +235,7 @@ int inet_pton(int af, FAR const char *src, FAR void *dst)
|
|||||||
{
|
{
|
||||||
ch = (uint8_t)src[srcoffset++];
|
ch = (uint8_t)src[srcoffset++];
|
||||||
|
|
||||||
if (ch == ':' || ch == '\0' /* || ch == '/' */ )
|
if (ch == ':' || ch == '\0')
|
||||||
{
|
{
|
||||||
if (ch == ':' && (nsep + nrsep) >= 8)
|
if (ch == ':' && (nsep + nrsep) >= 8)
|
||||||
{
|
{
|
||||||
@ -242,7 +248,7 @@ int inet_pton(int af, FAR const char *src, FAR void *dst)
|
|||||||
{
|
{
|
||||||
/* Empty numeric string */
|
/* Empty numeric string */
|
||||||
|
|
||||||
if (rtime != 0 && nrsep > 1)
|
if (rtime && nrsep > 1)
|
||||||
{
|
{
|
||||||
/* dup simple */
|
/* dup simple */
|
||||||
|
|
||||||
@ -251,7 +257,6 @@ int inet_pton(int af, FAR const char *src, FAR void *dst)
|
|||||||
|
|
||||||
numoffset = 0;
|
numoffset = 0;
|
||||||
rtime = true;
|
rtime = true;
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -281,7 +286,9 @@ int inet_pton(int af, FAR const char *src, FAR void *dst)
|
|||||||
|
|
||||||
if (ch == '\0' /* || ch == '/' */)
|
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 */
|
/* Separator count problem */
|
||||||
|
|
||||||
@ -303,7 +310,9 @@ int inet_pton(int af, FAR const char *src, FAR void *dst)
|
|||||||
return 0;
|
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;
|
numstr[numoffset++] = ch;
|
||||||
if (numoffset >= 5)
|
if (numoffset >= 5)
|
||||||
|
Loading…
Reference in New Issue
Block a user