]> begriffs open source - freertos/blob - FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/protocols/include/FreeRTOS_TCP_server.h
Update to MIT licensed FreeRTOS V10.0.0 - see https://www.freertos.org/History.txt
[freertos] / FreeRTOS-Plus / Source / FreeRTOS-Plus-TCP / protocols / include / FreeRTOS_TCP_server.h
1 /*\r
2  * FreeRTOS+TCP V2.0.0\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. If you wish to use our Amazon\r
14  * FreeRTOS name, please do so in a fair use way that does not cause confusion.\r
15  *\r
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\r
18  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\r
19  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\r
20  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
21  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
22  *\r
23  * http://www.FreeRTOS.org\r
24  * http://aws.amazon.com/freertos\r
25  *\r
26  * 1 tab == 4 spaces!\r
27  */\r
28 \r
29 /*\r
30         Some code which is common to TCP servers like HTTP en FTP\r
31 */\r
32 \r
33 #ifndef FREERTOS_TCP_SERVER_H\r
34 #define FREERTOS_TCP_SERVER_H\r
35 \r
36 #ifdef __cplusplus\r
37 extern "C" {\r
38 #endif\r
39 \r
40 #ifndef FTP_SERVER_USES_RELATIVE_DIRECTORY\r
41         #define FTP_SERVER_USES_RELATIVE_DIRECTORY              0\r
42 #endif\r
43 \r
44 enum eSERVER_TYPE\r
45 {\r
46         eSERVER_NONE,\r
47         eSERVER_HTTP,\r
48         eSERVER_FTP,\r
49 };\r
50 \r
51 struct xFTP_CLIENT;\r
52 \r
53 #if( ipconfigFTP_HAS_RECEIVED_HOOK != 0 )\r
54         extern void vApplicationFTPReceivedHook( const char *pcFileName, uint32_t ulSize, struct xFTP_CLIENT *pxFTPClient );\r
55         extern void vFTPReplyMessage( struct xFTP_CLIENT *pxFTPClient, const char *pcMessage );\r
56 #endif /* ipconfigFTP_HAS_RECEIVED_HOOK != 0 */\r
57 \r
58 #if( ipconfigFTP_HAS_USER_PASSWORD_HOOK != 0 )\r
59         /*\r
60          * Function is called when a user name has been submitted.\r
61          * The function may return a string such as: "331 Please enter your password"\r
62          * or return NULL to use the default reply.\r
63          */\r
64         extern const char *pcApplicationFTPUserHook( const char *pcUserName );\r
65 #endif /* ipconfigFTP_HAS_USER_PASSWORD_HOOK */\r
66 \r
67 #if( ipconfigFTP_HAS_USER_PASSWORD_HOOK != 0 )\r
68         /*\r
69          * Function is called when a password was received.\r
70          * Return positive value to allow the user\r
71          */\r
72         extern BaseType_t xApplicationFTPPasswordHook( const char *pcUserName, const char *pcPassword );\r
73 #endif /* ipconfigFTP_HAS_USER_PASSWORD_HOOK */\r
74 \r
75 #if( ipconfigFTP_HAS_USER_PROPERTIES_HOOK != 0 )\r
76         /*\r
77          * The FTP server is asking for user-specific properties\r
78          */\r
79         typedef struct\r
80         {\r
81                 uint16_t usPortNumber;  /* For reference only. Host-endian. */\r
82                 const char *pcRootDir;\r
83                 BaseType_t xReadOnly;\r
84         }\r
85         FTPUserProperties_t;\r
86         extern void vApplicationFTPUserPropertiesHook( const char *pcUserName, FTPUserProperties_t *pxProperties );\r
87 #endif /* ipconfigFTP_HAS_USER_PASSWORD_HOOK */\r
88 \r
89 #if( ipconfigHTTP_HAS_HANDLE_REQUEST_HOOK != 0 )\r
90         /*\r
91          * A GET request is received containing a special character,\r
92          * usually a question mark.\r
93          * const char *pcURLData;       // A request, e.g. "/request?limit=75"\r
94          * char *pcBuffer;                      // Here the answer can be written\r
95          * size_t uxBufferLength;       // Size of the buffer\r
96          *\r
97          */\r
98         extern size_t uxApplicationHTTPHandleRequestHook( const char *pcURLData, char *pcBuffer, size_t uxBufferLength );\r
99 #endif /* ipconfigHTTP_HAS_HANDLE_REQUEST_HOOK */\r
100 \r
101 struct xSERVER_CONFIG\r
102 {\r
103         enum eSERVER_TYPE eType;                /* eSERVER_HTTP | eSERVER_FTP */\r
104         BaseType_t xPortNumber;                 /* e.g. 80, 8080, 21 */\r
105         BaseType_t xBackLog;                    /* e.g. 10, maximum number of connected TCP clients */\r
106         const char * const pcRootDir;   /* Treat this directory as the root directory */\r
107 };\r
108 \r
109 struct xTCP_SERVER;\r
110 typedef struct xTCP_SERVER TCPServer_t;\r
111 \r
112 TCPServer_t *FreeRTOS_CreateTCPServer( const struct xSERVER_CONFIG *pxConfigs, BaseType_t xCount );\r
113 void FreeRTOS_TCPServerWork( TCPServer_t *pxServer, TickType_t xBlockingTime );\r
114 \r
115 #if( ipconfigSUPPORT_SIGNALS != 0 )\r
116         /* FreeRTOS_TCPServerWork() calls select().\r
117         The two functions below provide a possibility to interrupt\r
118         the call to select(). After the interruption, resume\r
119         by calling FreeRTOS_TCPServerWork() again. */\r
120         BaseType_t FreeRTOS_TCPServerSignal( TCPServer_t *pxServer );\r
121         BaseType_t FreeRTOS_TCPServerSignalFromISR( TCPServer_t *pxServer, BaseType_t *pxHigherPriorityTaskWoken );\r
122 #endif\r
123 \r
124 #ifdef __cplusplus\r
125 } /* extern "C" */\r
126 #endif\r
127 \r
128 #endif /* FREERTOS_TCP_SERVER_H */\r