Libtrap: Internal development docs  1.16.1
ifc_tcpip.h
Go to the documentation of this file.
1 /**
2  * \file ifc_tcpip.h
3  * \brief TRAP TCP/IP interfaces
4  * \author Tomas Cejka <cejkat@cesnet.cz>
5  * \date 2013
6  * \date 2014
7  */
8 /*
9  * Copyright (C) 2013,2014 CESNET
10  *
11  * LICENSE TERMS
12  *
13  * Redistribution and use in source and binary forms, with or without
14  * modification, are permitted provided that the following conditions
15  * are met:
16  * 1. Redistributions of source code must retain the above copyright
17  * notice, this list of conditions and the following disclaimer.
18  * 2. Redistributions in binary form must reproduce the above copyright
19  * notice, this list of conditions and the following disclaimer in
20  * the documentation and/or other materials provided with the
21  * distribution.
22  * 3. Neither the name of the Company nor the names of its contributors
23  * may be used to endorse or promote products derived from this
24  * software without specific prior written permission.
25  *
26  * ALTERNATIVELY, provided that this notice is retained in full, this
27  * product may be distributed under the terms of the GNU General Public
28  * License (GPL) version 2 or later, in which case the provisions
29  * of the GPL apply INSTEAD OF those given above.
30  *
31  * This software is provided ``as is'', and any express or implied
32  * warranties, including, but not limited to, the implied warranties of
33  * merchantability and fitness for a particular purpose are disclaimed.
34  * In no event shall the company or contributors be liable for any
35  * direct, indirect, incidental, special, exemplary, or consequential
36  * damages (including, but not limited to, procurement of substitute
37  * goods or services; loss of use, data, or profits; or business
38  * interruption) however caused and on any theory of liability, whether
39  * in contract, strict liability, or tort (including negligence or
40  * otherwise) arising in any way out of the use of this software, even
41  * if advised of the possibility of such damage.
42  *
43  */
44 #ifndef _TRAP_IFC_TCPIP_H_
45 #define _TRAP_IFC_TCPIP_H_
46 
47 #include "trap_ifc.h"
48 
49 /**
50  * Delimiter used between *params* in the *create_tcpip_sender_ifc* and *create_tcpip_receiver_ifc* functions.
51  */
52 #define TCPIP_IFC_PARAMS_DELIMITER (',')
53 
54 #ifndef DEFAULT_SOCKET_FORMAT
55 #define DEFAULT_SOCKET_FORMAT "/trap-%s.sock"
56 #endif
57 
58 #ifndef UNIX_PATH_FILENAME_FORMAT
59 /**
60  * Communication via UNIX socket needs to specify path to socket file.
61  * It is currently placed according to this format, where %s is replaced by
62  * port given as an argument of TCPIP IFC.
63  */
64 #define UNIX_PATH_FILENAME_FORMAT DEFAULTSOCKETDIR DEFAULT_SOCKET_FORMAT
65 #endif
66 
67 /**
68  * Type of socket that is used for the TRAP interface.
69  */
71  TRAP_IFC_TCPIP, ///< use TCP/IP connection
72  TRAP_IFC_TCPIP_UNIX, ///< use UNIX socket for local communication
73  TRAP_IFC_TCPIP_SERVICE ///< use UNIX socket as a service interface
74 };
75 #define TCPIP_SOCKETTYPE_STR(st) (st == TRAP_IFC_TCPIP?"TCP":(st == TRAP_IFC_TCPIP_UNIX ? "UNIX": "SERVICE"))
76 /** Create TCP/IP output interface.
77  * \param [in] ctx Pointer to the private libtrap context data (#trap_ctx_init()).
78  * \param [in] params format not decided yet
79  * \param [out] ifc Created interface for library purposes
80  * \param [in] type select the type of socket (see #tcpip_ifc_sockettype for options)
81  * \return 0 on success (TRAP_E_OK)
82  */
83 int create_tcpip_sender_ifc(trap_ctx_priv_t *ctx, const char *params, trap_output_ifc_t *ifc, uint32_t idx, enum tcpip_ifc_sockettype type);
84 
85 
86 /** Create TCP/IP input interface.
87  * \param [in] ctx Pointer to the private libtrap context data (#trap_ctx_init()).
88  * \param [in] params format not decided yet
89  * \param [out] ifc Created interface for library purposes
90  * \param [in] type select the type of socket (see #tcpip_ifc_sockettype for options)
91  * \return 0 on success (TRAP_E_OK)
92  */
93 int create_tcpip_receiver_ifc(trap_ctx_priv_t *ctx, char *params, trap_input_ifc_t *ifc, uint32_t itx, enum tcpip_ifc_sockettype type);
94 
95 #endif
int create_tcpip_receiver_ifc(trap_ctx_priv_t *ctx, char *params, trap_input_ifc_t *ifc, uint32_t itx, enum tcpip_ifc_sockettype type)
Constructor of input TCP/IP IFC module. This function is called by TRAP library to initialize one inp...
Definition: ifc_tcpip.c:636
use UNIX socket as a service interface
Definition: ifc_tcpip.h:73
use UNIX socket for local communication
Definition: ifc_tcpip.h:72
use TCP/IP connection
Definition: ifc_tcpip.h:71
int create_tcpip_sender_ifc(trap_ctx_priv_t *ctx, const char *params, trap_output_ifc_t *ifc, uint32_t idx, enum tcpip_ifc_sockettype type)
Constructor of output TCP/IP IFC module. This function is called by TRAP library to initialize one ou...
Definition: ifc_tcpip.c:1730
Interface of TRAP interfaces.
tcpip_ifc_sockettype
Definition: ifc_tcpip.h:70