]> begriffs open source - freertos/blob - FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/protocols/include/FreeRTOS_TCP_server.h
Added +TCP code to main repo.
[freertos] / FreeRTOS-Plus / Source / FreeRTOS-Plus-TCP / protocols / include / FreeRTOS_TCP_server.h
1 /*\r
2  * FreeRTOS+TCP Labs Build 160919 (C) 2016 Real Time Engineers ltd.\r
3  * Authors include Hein Tibosch and Richard Barry\r
4  *\r
5  *******************************************************************************\r
6  ***** NOTE ******* NOTE ******* NOTE ******* NOTE ******* NOTE ******* NOTE ***\r
7  ***                                                                         ***\r
8  ***                                                                         ***\r
9  ***   FREERTOS+TCP IS STILL IN THE LAB (mainly because the FTP and HTTP     ***\r
10  ***   demos have a dependency on FreeRTOS+FAT, which is only in the Labs    ***\r
11  ***   download):                                                            ***\r
12  ***                                                                         ***\r
13  ***   FreeRTOS+TCP is functional and has been used in commercial products   ***\r
14  ***   for some time.  Be aware however that we are still refining its       ***\r
15  ***   design, the source code does not yet quite conform to the strict      ***\r
16  ***   coding and style standards mandated by Real Time Engineers ltd., and  ***\r
17  ***   the documentation and testing is not necessarily complete.            ***\r
18  ***                                                                         ***\r
19  ***   PLEASE REPORT EXPERIENCES USING THE SUPPORT RESOURCES FOUND ON THE    ***\r
20  ***   URL: http://www.FreeRTOS.org/contact  Active early adopters may, at   ***\r
21  ***   the sole discretion of Real Time Engineers Ltd., be offered versions  ***\r
22  ***   under a license other than that described below.                      ***\r
23  ***                                                                         ***\r
24  ***                                                                         ***\r
25  ***** NOTE ******* NOTE ******* NOTE ******* NOTE ******* NOTE ******* NOTE ***\r
26  *******************************************************************************\r
27  *\r
28  * FreeRTOS+TCP can be used under two different free open source licenses.  The\r
29  * license that applies is dependent on the processor on which FreeRTOS+TCP is\r
30  * executed, as follows:\r
31  *\r
32  * If FreeRTOS+TCP is executed on one of the processors listed under the Special\r
33  * License Arrangements heading of the FreeRTOS+TCP license information web\r
34  * page, then it can be used under the terms of the FreeRTOS Open Source\r
35  * License.  If FreeRTOS+TCP is used on any other processor, then it can be used\r
36  * under the terms of the GNU General Public License V2.  Links to the relevant\r
37  * licenses follow:\r
38  *\r
39  * The FreeRTOS+TCP License Information Page: http://www.FreeRTOS.org/tcp_license\r
40  * The FreeRTOS Open Source License: http://www.FreeRTOS.org/license\r
41  * The GNU General Public License Version 2: http://www.FreeRTOS.org/gpl-2.0.txt\r
42  *\r
43  * FreeRTOS+TCP is distributed in the hope that it will be useful.  You cannot\r
44  * use FreeRTOS+TCP unless you agree that you use the software 'as is'.\r
45  * FreeRTOS+TCP is provided WITHOUT ANY WARRANTY; without even the implied\r
46  * warranties of NON-INFRINGEMENT, MERCHANTABILITY or FITNESS FOR A PARTICULAR\r
47  * PURPOSE. Real Time Engineers Ltd. disclaims all conditions and terms, be they\r
48  * implied, expressed, or statutory.\r
49  *\r
50  * 1 tab == 4 spaces!\r
51  *\r
52  * http://www.FreeRTOS.org\r
53  * http://www.FreeRTOS.org/plus\r
54  * http://www.FreeRTOS.org/labs\r
55  *\r
56  */\r
57 \r
58 /*\r
59         Some code which is common to TCP servers like HTTP en FTP\r
60 */\r
61 \r
62 #ifndef FREERTOS_TCP_SERVER_H\r
63 #define FREERTOS_TCP_SERVER_H\r
64 \r
65 #ifdef __cplusplus\r
66 extern "C" {\r
67 #endif\r
68 \r
69 #ifndef FTP_SERVER_USES_RELATIVE_DIRECTORY\r
70         #define FTP_SERVER_USES_RELATIVE_DIRECTORY              0\r
71 #endif\r
72 \r
73 enum eSERVER_TYPE\r
74 {\r
75         eSERVER_NONE,\r
76         eSERVER_HTTP,\r
77         eSERVER_FTP,\r
78 };\r
79 \r
80 struct xFTP_CLIENT;\r
81 \r
82 #if( ipconfigFTP_HAS_RECEIVED_HOOK != 0 )\r
83         extern void vApplicationFTPReceivedHook( const char *pcFileName, uint32_t ulSize, struct xFTP_CLIENT *pxFTPClient );\r
84         extern void vFTPReplyMessage( struct xFTP_CLIENT *pxFTPClient, const char *pcMessage );\r
85 #endif /* ipconfigFTP_HAS_RECEIVED_HOOK != 0 */\r
86 \r
87 #if( ipconfigFTP_HAS_USER_PASSWORD_HOOK != 0 )\r
88         /*\r
89          * Function is called when a user name has been submitted.\r
90          * The function may return a string such as: "331 Please enter your password"\r
91          * or return NULL to use the default reply.\r
92          */\r
93         extern const char *pcApplicationFTPUserHook( const char *pcUserName );\r
94 #endif /* ipconfigFTP_HAS_USER_PASSWORD_HOOK */\r
95 \r
96 #if( ipconfigFTP_HAS_USER_PASSWORD_HOOK != 0 )\r
97         /*\r
98          * Function is called when a password was received.\r
99          * Return positive value to allow the user\r
100          */\r
101         extern BaseType_t xApplicationFTPPasswordHook( const char *pcUserName, const char *pcPassword );\r
102 #endif /* ipconfigFTP_HAS_USER_PASSWORD_HOOK */\r
103 \r
104 #if( ipconfigFTP_HAS_USER_PROPERTIES_HOOK != 0 )\r
105         /*\r
106          * The FTP server is asking for user-specific properties\r
107          */\r
108         typedef struct\r
109         {\r
110                 uint16_t usPortNumber;  /* For reference only. Host-endian. */\r
111                 const char *pcRootDir;\r
112                 BaseType_t xReadOnly;\r
113         }\r
114         FTPUserProperties_t;\r
115         extern void vApplicationFTPUserPropertiesHook( const char *pcUserName, FTPUserProperties_t *pxProperties );\r
116 #endif /* ipconfigFTP_HAS_USER_PASSWORD_HOOK */\r
117 \r
118 #if( ipconfigHTTP_HAS_HANDLE_REQUEST_HOOK != 0 )\r
119         /*\r
120          * A GET request is received containing a special character,\r
121          * usually a question mark.\r
122          * const char *pcURLData;       // A request, e.g. "/request?limit=75"\r
123          * char *pcBuffer;                      // Here the answer can be written\r
124          * size_t uxBufferLength;       // Size of the buffer\r
125          *\r
126          */\r
127         extern size_t uxApplicationHTTPHandleRequestHook( const char *pcURLData, char *pcBuffer, size_t uxBufferLength );\r
128 #endif /* ipconfigHTTP_HAS_HANDLE_REQUEST_HOOK */\r
129 \r
130 struct xSERVER_CONFIG\r
131 {\r
132         enum eSERVER_TYPE eType;                /* eSERVER_HTTP | eSERVER_FTP */\r
133         BaseType_t xPortNumber;                 /* e.g. 80, 8080, 21 */\r
134         BaseType_t xBackLog;                    /* e.g. 10, maximum number of connected TCP clients */\r
135         const char * const pcRootDir;   /* Treat this directory as the root directory */\r
136 };\r
137 \r
138 struct xTCP_SERVER;\r
139 typedef struct xTCP_SERVER TCPServer_t;\r
140 \r
141 TCPServer_t *FreeRTOS_CreateTCPServer( const struct xSERVER_CONFIG *pxConfigs, BaseType_t xCount );\r
142 void FreeRTOS_TCPServerWork( TCPServer_t *pxServer, TickType_t xBlockingTime );\r
143 \r
144 #if( ipconfigSUPPORT_SIGNALS != 0 )\r
145         /* FreeRTOS_TCPServerWork() calls select().\r
146         The two functions below provide a possibility to interrupt\r
147         the call to select(). After the interruption, resume\r
148         by calling FreeRTOS_TCPServerWork() again. */\r
149         BaseType_t FreeRTOS_TCPServerSignal( TCPServer_t *pxServer );\r
150         BaseType_t FreeRTOS_TCPServerSignalFromISR( TCPServer_t *pxServer, BaseType_t *pxHigherPriorityTaskWoken );\r
151 #endif\r
152 \r
153 #ifdef __cplusplus\r
154 } /* extern "C" */\r
155 #endif\r
156 \r
157 #endif /* FREERTOS_TCP_SERVER_H */\r