udp-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_UDP_TRANSPORT_H
22 #define NDN_UDP_TRANSPORT_H
23 
24 #include "socket-transport.h"
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
41 static __inline void ndn_UdpTransport_initialize
42  (struct ndn_UdpTransport *self, struct ndn_DynamicUInt8Array *buffer)
43 {
44  ndn_SocketTransport_initialize(&self->base, buffer);
45 }
46 
52 static __inline int
53 ndn_UdpTransport_isLocal() { return 0; }
54 
65 static __inline ndn_Error ndn_UdpTransport_connect
66  (struct ndn_UdpTransport *self, const char *host, unsigned short port,
67  struct ndn_ElementListener *elementListener)
68 {
69  return ndn_SocketTransport_connect
70  (&self->base, SOCKET_UDP, host, port, elementListener);
71 }
72 
80 static __inline ndn_Error ndn_UdpTransport_send
81  (struct ndn_UdpTransport *self, const uint8_t *data, size_t dataLength)
82 {
83  return ndn_SocketTransport_send(&self->base, data, dataLength);
84 }
85 
101 static __inline ndn_Error
102 ndn_UdpTransport_processEvents
103  (struct ndn_UdpTransport *self, uint8_t *buffer, size_t bufferLength)
104 {
105  return ndn_SocketTransport_processEvents(&self->base, buffer, bufferLength);
106 }
107 
113 static __inline ndn_Error ndn_UdpTransport_close(struct ndn_UdpTransport *self)
114 {
115  return ndn_SocketTransport_close(&self->base);
116 }
117 
118 #ifdef __cplusplus
119 }
120 #endif
121 
122 #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:39