]> git.sur5r.net Git - freertos/blob - FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/protocols/include/FreeRTOS_TCP_server.h
Roll up the minor changes checked into svn since V10.0.0 into new V10.0.1 ready for...
[freertos] / FreeRTOS-Plus / Source / FreeRTOS-Plus-TCP / protocols / include / FreeRTOS_TCP_server.h
1 /*\r
2  * FreeRTOS+TCP V2.0.1\r
3  * Copyright (C) 2017 Amazon.com, Inc. or its affiliates.  All Rights Reserved.\r
4  *\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
11  *\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
14  *\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
21  *\r
22  * http://www.FreeRTOS.org\r
23  * http://aws.amazon.com/freertos\r
24  *\r
25  * 1 tab == 4 spaces!\r
26  */\r
27 \r
28 /*\r
29         Some code which is common to TCP servers like HTTP en FTP\r
30 */\r
31 \r
32 #ifndef FREERTOS_TCP_SERVER_H\r
33 #define FREERTOS_TCP_SERVER_H\r
34 \r
35 #ifdef __cplusplus\r
36 extern "C" {\r
37 #endif\r
38 \r
39 #ifndef FTP_SERVER_USES_RELATIVE_DIRECTORY\r
40         #define FTP_SERVER_USES_RELATIVE_DIRECTORY              0\r
41 #endif\r
42 \r
43 enum eSERVER_TYPE\r
44 {\r
45         eSERVER_NONE,\r
46         eSERVER_HTTP,\r
47         eSERVER_FTP,\r
48 };\r
49 \r
50 struct xFTP_CLIENT;\r
51 \r
52 #if( ipconfigFTP_HAS_RECEIVED_HOOK != 0 )\r
53         extern void vApplicationFTPReceivedHook( const char *pcFileName, uint32_t ulSize, struct xFTP_CLIENT *pxFTPClient );\r
54         extern void vFTPReplyMessage( struct xFTP_CLIENT *pxFTPClient, const char *pcMessage );\r
55 #endif /* ipconfigFTP_HAS_RECEIVED_HOOK != 0 */\r
56 \r
57 #if( ipconfigFTP_HAS_USER_PASSWORD_HOOK != 0 )\r
58         /*\r
59          * Function is called when a user name has been submitted.\r
60          * The function may return a string such as: "331 Please enter your password"\r
61          * or return NULL to use the default reply.\r
62          */\r
63         extern const char *pcApplicationFTPUserHook( const char *pcUserName );\r
64 #endif /* ipconfigFTP_HAS_USER_PASSWORD_HOOK */\r
65 \r
66 #if( ipconfigFTP_HAS_USER_PASSWORD_HOOK != 0 )\r
67         /*\r
68          * Function is called when a password was received.\r
69          * Return positive value to allow the user\r
70          */\r
71         extern BaseType_t xApplicationFTPPasswordHook( const char *pcUserName, const char *pcPassword );\r
72 #endif /* ipconfigFTP_HAS_USER_PASSWORD_HOOK */\r
73 \r
74 #if( ipconfigFTP_HAS_USER_PROPERTIES_HOOK != 0 )\r
75         /*\r
76          * The FTP server is asking for user-specific properties\r
77          */\r
78         typedef struct\r
79         {\r
80                 uint16_t usPortNumber;  /* For reference only. Host-endian. */\r
81                 const char *pcRootDir;\r
82                 BaseType_t xReadOnly;\r
83         }\r
84         FTPUserProperties_t;\r
85         extern void vApplicationFTPUserPropertiesHook( const char *pcUserName, FTPUserProperties_t *pxProperties );\r
86 #endif /* ipconfigFTP_HAS_USER_PASSWORD_HOOK */\r
87 \r
88 #if( ipconfigHTTP_HAS_HANDLE_REQUEST_HOOK != 0 )\r
89         /*\r
90          * A GET request is received containing a special character,\r
91          * usually a question mark.\r
92          * const char *pcURLData;       // A request, e.g. "/request?limit=75"\r
93          * char *pcBuffer;                      // Here the answer can be written\r
94          * size_t uxBufferLength;       // Size of the buffer\r
95          *\r
96          */\r
97         extern size_t uxApplicationHTTPHandleRequestHook( const char *pcURLData, char *pcBuffer, size_t uxBufferLength );\r
98 #endif /* ipconfigHTTP_HAS_HANDLE_REQUEST_HOOK */\r
99 \r
100 struct xSERVER_CONFIG\r
101 {\r
102         enum eSERVER_TYPE eType;                /* eSERVER_HTTP | eSERVER_FTP */\r
103         BaseType_t xPortNumber;                 /* e.g. 80, 8080, 21 */\r
104         BaseType_t xBackLog;                    /* e.g. 10, maximum number of connected TCP clients */\r
105         const char * const pcRootDir;   /* Treat this directory as the root directory */\r
106 };\r
107 \r
108 struct xTCP_SERVER;\r
109 typedef struct xTCP_SERVER TCPServer_t;\r
110 \r
111 TCPServer_t *FreeRTOS_CreateTCPServer( const struct xSERVER_CONFIG *pxConfigs, BaseType_t xCount );\r
112 void FreeRTOS_TCPServerWork( TCPServer_t *pxServer, TickType_t xBlockingTime );\r
113 \r
114 #if( ipconfigSUPPORT_SIGNALS != 0 )\r
115         /* FreeRTOS_TCPServerWork() calls select().\r
116         The two functions below provide a possibility to interrupt\r
117         the call to select(). After the interruption, resume\r
118         by calling FreeRTOS_TCPServerWork() again. */\r
119         BaseType_t FreeRTOS_TCPServerSignal( TCPServer_t *pxServer );\r
120         BaseType_t FreeRTOS_TCPServerSignalFromISR( TCPServer_t *pxServer, BaseType_t *pxHigherPriorityTaskWoken );\r
121 #endif\r
122 \r
123 #ifdef __cplusplus\r
124 } /* extern "C" */\r
125 #endif\r
126 \r
127 #endif /* FREERTOS_TCP_SERVER_H */\r