2 * FreeRTOS+TCP V2.0.3
\r
3 * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
\r
5 * Permission is hereby granted, free of charge, to any person obtaining a copy of
\r
6 * this software and associated documentation files (the "Software"), to deal in
\r
7 * the Software without restriction, including without limitation the rights to
\r
8 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
\r
9 * the Software, and to permit persons to whom the Software is furnished to do so,
\r
10 * subject to the following conditions:
\r
12 * The above copyright notice and this permission notice shall be included in all
\r
13 * copies or substantial portions of the Software.
\r
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
\r
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
\r
17 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
\r
18 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
\r
19 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
\r
20 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\r
22 * http://aws.amazon.com/freertos
\r
23 * http://www.FreeRTOS.org
\r
27 Some code which is common to TCP servers like HTTP en FTP
\r
30 #ifndef FREERTOS_TCP_SERVER_H
\r
31 #define FREERTOS_TCP_SERVER_H
\r
37 #ifndef FTP_SERVER_USES_RELATIVE_DIRECTORY
\r
38 #define FTP_SERVER_USES_RELATIVE_DIRECTORY 0
\r
50 #if( ipconfigFTP_HAS_RECEIVED_HOOK != 0 )
\r
51 extern void vApplicationFTPReceivedHook( const char *pcFileName, uint32_t ulSize, struct xFTP_CLIENT *pxFTPClient );
\r
52 extern void vFTPReplyMessage( struct xFTP_CLIENT *pxFTPClient, const char *pcMessage );
\r
53 #endif /* ipconfigFTP_HAS_RECEIVED_HOOK != 0 */
\r
55 #if( ipconfigFTP_HAS_USER_PASSWORD_HOOK != 0 )
\r
57 * Function is called when a user name has been submitted.
\r
58 * The function may return a string such as: "331 Please enter your password"
\r
59 * or return NULL to use the default reply.
\r
61 extern const char *pcApplicationFTPUserHook( const char *pcUserName );
\r
62 #endif /* ipconfigFTP_HAS_USER_PASSWORD_HOOK */
\r
64 #if( ipconfigFTP_HAS_USER_PASSWORD_HOOK != 0 )
\r
66 * Function is called when a password was received.
\r
67 * Return positive value to allow the user
\r
69 extern BaseType_t xApplicationFTPPasswordHook( const char *pcUserName, const char *pcPassword );
\r
70 #endif /* ipconfigFTP_HAS_USER_PASSWORD_HOOK */
\r
72 #if( ipconfigFTP_HAS_USER_PROPERTIES_HOOK != 0 )
\r
74 * The FTP server is asking for user-specific properties
\r
78 uint16_t usPortNumber; /* For reference only. Host-endian. */
\r
79 const char *pcRootDir;
\r
80 BaseType_t xReadOnly;
\r
82 FTPUserProperties_t;
\r
83 extern void vApplicationFTPUserPropertiesHook( const char *pcUserName, FTPUserProperties_t *pxProperties );
\r
84 #endif /* ipconfigFTP_HAS_USER_PASSWORD_HOOK */
\r
86 #if( ipconfigHTTP_HAS_HANDLE_REQUEST_HOOK != 0 )
\r
88 * A GET request is received containing a special character,
\r
89 * usually a question mark.
\r
90 * const char *pcURLData; // A request, e.g. "/request?limit=75"
\r
91 * char *pcBuffer; // Here the answer can be written
\r
92 * size_t uxBufferLength; // Size of the buffer
\r
95 extern size_t uxApplicationHTTPHandleRequestHook( const char *pcURLData, char *pcBuffer, size_t uxBufferLength );
\r
96 #endif /* ipconfigHTTP_HAS_HANDLE_REQUEST_HOOK */
\r
98 struct xSERVER_CONFIG
\r
100 enum eSERVER_TYPE eType; /* eSERVER_HTTP | eSERVER_FTP */
\r
101 BaseType_t xPortNumber; /* e.g. 80, 8080, 21 */
\r
102 BaseType_t xBackLog; /* e.g. 10, maximum number of connected TCP clients */
\r
103 const char * const pcRootDir; /* Treat this directory as the root directory */
\r
106 struct xTCP_SERVER;
\r
107 typedef struct xTCP_SERVER TCPServer_t;
\r
109 TCPServer_t *FreeRTOS_CreateTCPServer( const struct xSERVER_CONFIG *pxConfigs, BaseType_t xCount );
\r
110 void FreeRTOS_TCPServerWork( TCPServer_t *pxServer, TickType_t xBlockingTime );
\r
112 #if( ipconfigSUPPORT_SIGNALS != 0 )
\r
113 /* FreeRTOS_TCPServerWork() calls select().
\r
114 The two functions below provide a possibility to interrupt
\r
115 the call to select(). After the interruption, resume
\r
116 by calling FreeRTOS_TCPServerWork() again. */
\r
117 BaseType_t FreeRTOS_TCPServerSignal( TCPServer_t *pxServer );
\r
118 BaseType_t FreeRTOS_TCPServerSignalFromISR( TCPServer_t *pxServer, BaseType_t *pxHigherPriorityTaskWoken );
\r
125 #endif /* FREERTOS_TCP_SERVER_H */
\r