RTRlib
 All Data Structures Functions Typedefs Enumerations Enumerator Groups Pages
transport.h
1 /*
2  * This file is part of RTRlib.
3  *
4  * RTRlib is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License as published by
6  * the Free Software Foundation; either version 3 of the License, or (at your
7  * option) any later version.
8  *
9  * RTRlib is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
12  * License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with RTRlib; see the file COPYING.LESSER.
16  *
17  * INET group, Hamburg University of Applied Sciences,
18  * CST group, Freie Universitaet Berlin
19  * Website: http://rpki.realmv6.org/
20  */
21 
35 #ifndef RTR_TRANSPORT_H
36 #define RTR_TRANSPORT_H
37 #include <time.h>
38 
42 enum tr_rtvals {
45 
47  TR_ERROR = -1,
48 
51 
53  TR_INTR = -3,
54 
56  TR_CLOSED = -4
57 };
58 
59 struct tr_socket;
60 
65 typedef void (*tr_close_fp)(void *socket);
66 
71 typedef int (*tr_open_fp)(void *socket);
72 
77 typedef void (*tr_free_fp)(struct tr_socket *tr_sock);
78 
83 typedef int (*tr_recv_fp)(const void *socket, void *pdu, const size_t len, const time_t timeout);
84 
89 typedef int (*tr_send_fp)(const void *socket, const void *pdu, const size_t len, const time_t timeout);
90 
95 typedef const char *(*tr_ident_fp)(void *socket);
96 
107 struct tr_socket {
108  void *socket;
109  tr_open_fp open_fp;
110  tr_close_fp close_fp;
111  tr_free_fp free_fp;
112  tr_send_fp send_fp;
113  tr_recv_fp recv_fp;
114  tr_ident_fp ident_fp;
115 };
116 
117 
124 int tr_open(struct tr_socket *socket);
125 
130 void tr_close(struct tr_socket *socket);
131 
137 void tr_free(struct tr_socket *socket);
138 
149 int tr_recv(const struct tr_socket *socket, void *buf, const size_t len, const time_t timeout);
150 
160 int tr_send(const struct tr_socket *socket, const void *pdu, const size_t len, const time_t timeout);
161 
172 int tr_send_all(const struct tr_socket *socket, const void *pdu, const size_t len, const time_t timeout);
173 
184 int tr_recv_all(const struct tr_socket *socket, const void *buf, const size_t len, const time_t timeout);
185 
192 const char *tr_ident(struct tr_socket *socket);
193 
194 #endif
195 /* @} */
Definition: transport.h:47
A transport socket datastructure.
Definition: transport.h:107
void tr_close(struct tr_socket *socket)
Close the socket connection.
Definition: transport.c:30
int tr_recv_all(const struct tr_socket *socket, const void *buf, const size_t len, const time_t timeout)
Definition: transport.c:75
Definition: transport.h:53
void(* tr_close_fp)(void *socket)
A function pointer to a technology specific close function.
Definition: transport.h:65
int tr_send(const struct tr_socket *socket, const void *pdu, const size_t len, const time_t timeout)
Send <= len Bytes data over the socket.
Definition: transport.c:40
int(* tr_send_fp)(const void *socket, const void *pdu, const size_t len, const time_t timeout)
A function pointer to a technology specific send function.
Definition: transport.h:89
Definition: transport.h:50
int(* tr_open_fp)(void *socket)
A function pointer to a technology specific open function.
Definition: transport.h:71
int tr_open(struct tr_socket *socket)
Establish the connection.
Definition: transport.c:25
const char * tr_ident(struct tr_socket *socket)
Definition: transport.c:50
void(* tr_free_fp)(struct tr_socket *tr_sock)
A function pointer to a technology specific free function. All memory associated with the tr_socket w...
Definition: transport.h:77
Operation was successfull.
Definition: transport.h:44
int tr_send_all(const struct tr_socket *socket, const void *pdu, const size_t len, const time_t timeout)
Definition: transport.c:55
int tr_recv(const struct tr_socket *socket, void *buf, const size_t len, const time_t timeout)
Receives <= len Bytes data from the socket.
Definition: transport.c:45
void tr_free(struct tr_socket *socket)
Deallocates all memory that the passed socket uses. Socket have to be closed before.
Definition: transport.c:35
tr_rtvals
The return values for tr_ functions.
Definition: transport.h:42
const char *(* tr_ident_fp)(void *socket)
A function pointer to a technology specific info function.
Definition: transport.h:95
int(* tr_recv_fp)(const void *socket, void *pdu, const size_t len, const time_t timeout)
A function pointer to a technology specific recv function.
Definition: transport.h:83
Definition: transport.h:56