Sergey Pastor / 1

Dependents:   Nucleo

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers echo.h Source File

echo.h

Go to the documentation of this file.
00001 /**
00002  * @file echo.h
00003  * @brief Echo protocol
00004  *
00005  * @section License
00006  *
00007  * Copyright (C) 2010-2017 Oryx Embedded SARL. All rights reserved.
00008  *
00009  * This file is part of CycloneTCP Open.
00010  *
00011  * This program is free software; you can redistribute it and/or
00012  * modify it under the terms of the GNU General Public License
00013  * as published by the Free Software Foundation; either version 2
00014  * of the License, or (at your option) any later version.
00015  *
00016  * This program is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  * GNU General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU General Public License
00022  * along with this program; if not, write to the Free Software Foundation,
00023  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00024  *
00025  * @author Oryx Embedded SARL (www.oryx-embedded.com)
00026  * @version 1.7.6
00027  **/
00028 
00029 #ifndef _ECHO_H
00030 #define _ECHO_H
00031 
00032 //Dependencies
00033 #include "core/net.h"
00034 #include "core/socket.h"
00035 
00036 //Stack size required to run the echo service
00037 #ifndef ECHO_SERVICE_STACK_SIZE
00038    #define ECHO_SERVICE_STACK_SIZE 600
00039 #elif (ECHO_SERVICE_STACK_SIZE < 1)
00040    #error ECHO_SERVICE_STACK_SIZE parameter is not valid
00041 #endif
00042 
00043 //Priority at which the echo service should run
00044 #ifndef ECHO_SERVICE_PRIORITY
00045    #define ECHO_SERVICE_PRIORITY OS_TASK_PRIORITY_NORMAL
00046 #endif
00047 
00048 //Size of the buffer for input/output operations
00049 #ifndef ECHO_BUFFER_SIZE
00050    #define ECHO_BUFFER_SIZE 1500
00051 #elif (ECHO_BUFFER_SIZE < 1)
00052    #error ECHO_BUFFER_SIZE parameter is not valid
00053 #endif
00054 
00055 //Maximum time the TCP echo server will wait before closing the connection
00056 #ifndef ECHO_TIMEOUT
00057    #define ECHO_TIMEOUT 20000
00058 #elif (ECHO_TIMEOUT < 1)
00059    #error ECHO_TIMEOUT parameter is not valid
00060 #endif
00061 
00062 //Echo service port
00063 #define ECHO_PORT 7
00064 
00065 
00066 /**
00067  * @brief Echo service context
00068  **/
00069 
00070 typedef struct
00071 {
00072    Socket *socket;
00073    char_t buffer[ECHO_BUFFER_SIZE];
00074 } EchoServiceContext;
00075 
00076 
00077 //TCP echo service related functions
00078 error_t tcpEchoStart(void);
00079 void tcpEchoListenerTask(void *param);
00080 void tcpEchoConnectionTask(void *param);
00081 
00082 //UDP echo service related functions
00083 error_t udpEchoStart(void);
00084 void udpEchoTask(void *param);
00085 
00086 #endif
00087