Webserver+3d print
cyclone_tcp/std_services/discard.h@0:8918a71cdbe9, 2017-02-04 (annotated)
- Committer:
- Sergunb
- Date:
- Sat Feb 04 18:15:49 2017 +0000
- Revision:
- 0:8918a71cdbe9
nothing else
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Sergunb | 0:8918a71cdbe9 | 1 | /** |
Sergunb | 0:8918a71cdbe9 | 2 | * @file discard.h |
Sergunb | 0:8918a71cdbe9 | 3 | * @brief Discard protocol |
Sergunb | 0:8918a71cdbe9 | 4 | * |
Sergunb | 0:8918a71cdbe9 | 5 | * @section License |
Sergunb | 0:8918a71cdbe9 | 6 | * |
Sergunb | 0:8918a71cdbe9 | 7 | * Copyright (C) 2010-2017 Oryx Embedded SARL. All rights reserved. |
Sergunb | 0:8918a71cdbe9 | 8 | * |
Sergunb | 0:8918a71cdbe9 | 9 | * This file is part of CycloneTCP Open. |
Sergunb | 0:8918a71cdbe9 | 10 | * |
Sergunb | 0:8918a71cdbe9 | 11 | * This program is free software; you can redistribute it and/or |
Sergunb | 0:8918a71cdbe9 | 12 | * modify it under the terms of the GNU General Public License |
Sergunb | 0:8918a71cdbe9 | 13 | * as published by the Free Software Foundation; either version 2 |
Sergunb | 0:8918a71cdbe9 | 14 | * of the License, or (at your option) any later version. |
Sergunb | 0:8918a71cdbe9 | 15 | * |
Sergunb | 0:8918a71cdbe9 | 16 | * This program is distributed in the hope that it will be useful, |
Sergunb | 0:8918a71cdbe9 | 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
Sergunb | 0:8918a71cdbe9 | 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
Sergunb | 0:8918a71cdbe9 | 19 | * GNU General Public License for more details. |
Sergunb | 0:8918a71cdbe9 | 20 | * |
Sergunb | 0:8918a71cdbe9 | 21 | * You should have received a copy of the GNU General Public License |
Sergunb | 0:8918a71cdbe9 | 22 | * along with this program; if not, write to the Free Software Foundation, |
Sergunb | 0:8918a71cdbe9 | 23 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
Sergunb | 0:8918a71cdbe9 | 24 | * |
Sergunb | 0:8918a71cdbe9 | 25 | * @author Oryx Embedded SARL (www.oryx-embedded.com) |
Sergunb | 0:8918a71cdbe9 | 26 | * @version 1.7.6 |
Sergunb | 0:8918a71cdbe9 | 27 | **/ |
Sergunb | 0:8918a71cdbe9 | 28 | |
Sergunb | 0:8918a71cdbe9 | 29 | #ifndef _DISCARD_H |
Sergunb | 0:8918a71cdbe9 | 30 | #define _DISCARD_H |
Sergunb | 0:8918a71cdbe9 | 31 | |
Sergunb | 0:8918a71cdbe9 | 32 | //Dependencies |
Sergunb | 0:8918a71cdbe9 | 33 | #include "core/net.h" |
Sergunb | 0:8918a71cdbe9 | 34 | #include "core/socket.h" |
Sergunb | 0:8918a71cdbe9 | 35 | |
Sergunb | 0:8918a71cdbe9 | 36 | //Stack size required to run the discard service |
Sergunb | 0:8918a71cdbe9 | 37 | #ifndef DISCARD_SERVICE_STACK_SIZE |
Sergunb | 0:8918a71cdbe9 | 38 | #define DISCARD_SERVICE_STACK_SIZE 600 |
Sergunb | 0:8918a71cdbe9 | 39 | #elif (DISCARD_SERVICE_STACK_SIZE < 1) |
Sergunb | 0:8918a71cdbe9 | 40 | #error DISCARD_SERVICE_STACK_SIZE parameter is not valid |
Sergunb | 0:8918a71cdbe9 | 41 | #endif |
Sergunb | 0:8918a71cdbe9 | 42 | |
Sergunb | 0:8918a71cdbe9 | 43 | //Priority at which the discard service should run |
Sergunb | 0:8918a71cdbe9 | 44 | #ifndef DISCARD_SERVICE_PRIORITY |
Sergunb | 0:8918a71cdbe9 | 45 | #define DISCARD_SERVICE_PRIORITY OS_TASK_PRIORITY_NORMAL |
Sergunb | 0:8918a71cdbe9 | 46 | #endif |
Sergunb | 0:8918a71cdbe9 | 47 | |
Sergunb | 0:8918a71cdbe9 | 48 | //Size of the buffer for input/output operations |
Sergunb | 0:8918a71cdbe9 | 49 | #ifndef DISCARD_BUFFER_SIZE |
Sergunb | 0:8918a71cdbe9 | 50 | #define DISCARD_BUFFER_SIZE 1500 |
Sergunb | 0:8918a71cdbe9 | 51 | #elif (DISCARD_BUFFER_SIZE < 1) |
Sergunb | 0:8918a71cdbe9 | 52 | #error DISCARD_BUFFER_SIZE parameter is not valid |
Sergunb | 0:8918a71cdbe9 | 53 | #endif |
Sergunb | 0:8918a71cdbe9 | 54 | |
Sergunb | 0:8918a71cdbe9 | 55 | //Maximum time the TCP discard server will wait before closing the connection |
Sergunb | 0:8918a71cdbe9 | 56 | #ifndef DISCARD_TIMEOUT |
Sergunb | 0:8918a71cdbe9 | 57 | #define DISCARD_TIMEOUT 20000 |
Sergunb | 0:8918a71cdbe9 | 58 | #elif (DISCARD_TIMEOUT < 1) |
Sergunb | 0:8918a71cdbe9 | 59 | #error DISCARD_TIMEOUT parameter is not valid |
Sergunb | 0:8918a71cdbe9 | 60 | #endif |
Sergunb | 0:8918a71cdbe9 | 61 | |
Sergunb | 0:8918a71cdbe9 | 62 | //Discard service port |
Sergunb | 0:8918a71cdbe9 | 63 | #define DISCARD_PORT 9 |
Sergunb | 0:8918a71cdbe9 | 64 | |
Sergunb | 0:8918a71cdbe9 | 65 | |
Sergunb | 0:8918a71cdbe9 | 66 | /** |
Sergunb | 0:8918a71cdbe9 | 67 | * @brief Discard service context |
Sergunb | 0:8918a71cdbe9 | 68 | **/ |
Sergunb | 0:8918a71cdbe9 | 69 | |
Sergunb | 0:8918a71cdbe9 | 70 | typedef struct |
Sergunb | 0:8918a71cdbe9 | 71 | { |
Sergunb | 0:8918a71cdbe9 | 72 | Socket *socket; |
Sergunb | 0:8918a71cdbe9 | 73 | char_t buffer[DISCARD_BUFFER_SIZE]; |
Sergunb | 0:8918a71cdbe9 | 74 | } DiscardServiceContext; |
Sergunb | 0:8918a71cdbe9 | 75 | |
Sergunb | 0:8918a71cdbe9 | 76 | |
Sergunb | 0:8918a71cdbe9 | 77 | //TCP discard service related functions |
Sergunb | 0:8918a71cdbe9 | 78 | error_t tcpDiscardStart(void); |
Sergunb | 0:8918a71cdbe9 | 79 | void tcpDiscardListenerTask(void *param); |
Sergunb | 0:8918a71cdbe9 | 80 | void tcpDiscardConnectionTask(void *param); |
Sergunb | 0:8918a71cdbe9 | 81 | |
Sergunb | 0:8918a71cdbe9 | 82 | //UDP discard service related functions |
Sergunb | 0:8918a71cdbe9 | 83 | error_t udpDiscardStart(void); |
Sergunb | 0:8918a71cdbe9 | 84 | void udpDiscardTask(void *param); |
Sergunb | 0:8918a71cdbe9 | 85 | |
Sergunb | 0:8918a71cdbe9 | 86 | #endif |
Sergunb | 0:8918a71cdbe9 | 87 |