echo.h
Go to the documentation of this file.
1 /**
2  * @file echo.h
3  * @brief Echo protocol
4  *
5  * @section License
6  *
7  * Copyright (C) 2010-2018 Oryx Embedded SARL. All rights reserved.
8  *
9  * This file is part of CycloneTCP Open.
10  *
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License
13  * as published by the Free Software Foundation; either version 2
14  * of the License, or (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software Foundation,
23  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24  *
25  * @author Oryx Embedded SARL (www.oryx-embedded.com)
26  * @version 1.9.0
27  **/
28 
29 #ifndef _ECHO_H
30 #define _ECHO_H
31 
32 //Dependencies
33 #include "core/net.h"
34 #include "core/socket.h"
35 
36 //Stack size required to run the echo service
37 #ifndef ECHO_SERVICE_STACK_SIZE
38  #define ECHO_SERVICE_STACK_SIZE 600
39 #elif (ECHO_SERVICE_STACK_SIZE < 1)
40  #error ECHO_SERVICE_STACK_SIZE parameter is not valid
41 #endif
42 
43 //Priority at which the echo service should run
44 #ifndef ECHO_SERVICE_PRIORITY
45  #define ECHO_SERVICE_PRIORITY OS_TASK_PRIORITY_NORMAL
46 #endif
47 
48 //Size of the buffer for input/output operations
49 #ifndef ECHO_BUFFER_SIZE
50  #define ECHO_BUFFER_SIZE 1500
51 #elif (ECHO_BUFFER_SIZE < 1)
52  #error ECHO_BUFFER_SIZE parameter is not valid
53 #endif
54 
55 //Maximum time the TCP echo server will wait before closing the connection
56 #ifndef ECHO_TIMEOUT
57  #define ECHO_TIMEOUT 20000
58 #elif (ECHO_TIMEOUT < 1)
59  #error ECHO_TIMEOUT parameter is not valid
60 #endif
61 
62 //Echo service port
63 #define ECHO_PORT 7
64 
65 //C++ guard
66 #ifdef __cplusplus
67  extern "C" {
68 #endif
69 
70 
71 /**
72  * @brief Echo service context
73  **/
74 
75 typedef struct
76 {
80 
81 
82 //TCP echo service related functions
83 error_t tcpEchoStart(void);
84 void tcpEchoListenerTask(void *param);
85 void tcpEchoConnectionTask(void *param);
86 
87 //UDP echo service related functions
88 error_t udpEchoStart(void);
89 void udpEchoTask(void *param);
90 
91 //C++ guard
92 #ifdef __cplusplus
93  }
94 #endif
95 
96 #endif
char char_t
Definition: compiler_port.h:41
TCP/IP stack core.
void udpEchoTask(void *param)
UDP echo service implementation.
Definition: echo.c:403
error_t tcpEchoStart(void)
Start TCP echo service.
Definition: echo.c:57
#define ECHO_BUFFER_SIZE
Definition: echo.h:50
#define Socket
Definition: socket.h:34
void tcpEchoListenerTask(void *param)
Task handling connection requests.
Definition: echo.c:119
Socket * socket
Definition: echo.h:77
void tcpEchoConnectionTask(void *param)
TCP echo service implementation.
Definition: echo.c:193
Echo service context.
Definition: echo.h:75
error_t
Error codes.
Definition: error.h:40
Socket API.
error_t udpEchoStart(void)
Start UDP echo service.
Definition: echo.c:325