tcp-transport.h
1 /*
2  * Copyright (C) 2013-2016 Regents of the University of California.
3  * @author: Jeff Thompson <jefft0@remap.ucla.edu>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Lesser General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version, with the additional exemption that
9  * compiling, linking, and/or using OpenSSL is allowed.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  * A copy of the GNU Lesser General Public License is in the file COPYING.
19  */
20 
21 #ifndef NDN_TCP_TRANSPORT_H
22 #define NDN_TCP_TRANSPORT_H
23 
24 #include "socket-transport.h"
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
41 static __inline void ndn_TcpTransport_initialize
42  (struct ndn_TcpTransport *self, struct ndn_DynamicUInt8Array *buffer)
43 {
44  ndn_SocketTransport_initialize(&self->base, buffer);
45 }
46 
59 ndn_Error
60 ndn_TcpTransport_isLocal(const char *host, int *result);
61 
72 static __inline ndn_Error ndn_TcpTransport_connect
73  (struct ndn_TcpTransport *self, const char *host, unsigned short port,
74  struct ndn_ElementListener *elementListener)
75 {
76  return ndn_SocketTransport_connect
77  (&self->base, SOCKET_TCP, host, port, elementListener);
78 }
79 
87 static __inline ndn_Error ndn_TcpTransport_send
88  (struct ndn_TcpTransport *self, const uint8_t *data, size_t dataLength)
89 {
90  return ndn_SocketTransport_send(&self->base, data, dataLength);
91 }
92 
108 static __inline ndn_Error
109 ndn_TcpTransport_processEvents
110  (struct ndn_TcpTransport *self, uint8_t *buffer, size_t bufferLength)
111 {
112  return ndn_SocketTransport_processEvents(&self->base, buffer, bufferLength);
113 }
114 
120 static __inline ndn_Error ndn_TcpTransport_close(struct ndn_TcpTransport *self)
121 {
122  return ndn_SocketTransport_close(&self->base);
123 }
124 
125 #ifdef __cplusplus
126 }
127 #endif
128 
129 #endif
An ndn_ElementListener struct holds a function pointer onReceivedElement.
Definition: element-reader-types.h:37
A struct ndn_DynamicUInt8Array holds a pointer to an allocated array, the length of the allocated arr...
Definition: dynamic-uint8-array-types.h:40
Definition: transport-types.h:35