unix-transport.h
1 /*
2  * Copyright (C) 2014-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_UNIX_TRANSPORT_H
22 #define NDN_UNIX_TRANSPORT_H
23 
24 #include "socket-transport.h"
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
41 static __inline void ndn_UnixTransport_initialize
42  (struct ndn_UnixTransport *self, struct ndn_DynamicUInt8Array *buffer)
43 {
44  ndn_SocketTransport_initialize(&self->base, buffer);
45 }
46 
52 static __inline int
53 ndn_UnixTransport_isLocal() { return 1; }
54 
64 static __inline ndn_Error ndn_UnixTransport_connect
65  (struct ndn_UnixTransport *self, char *filePath,
66  struct ndn_ElementListener *elementListener)
67 {
68  return ndn_SocketTransport_connect
69  (&self->base, SOCKET_UNIX, filePath, 0, elementListener);
70 }
71 
79 static __inline ndn_Error ndn_UnixTransport_send
80  (struct ndn_UnixTransport *self, const uint8_t *data, size_t dataLength)
81 {
82  return ndn_SocketTransport_send(&self->base, data, dataLength);
83 }
84 
100 static __inline ndn_Error
101 ndn_UnixTransport_processEvents
102  (struct ndn_UnixTransport *self, uint8_t *buffer, size_t bufferLength)
103 {
104  return ndn_SocketTransport_processEvents(&self->base, buffer, bufferLength);
105 }
106 
112 static __inline ndn_Error ndn_UnixTransport_close(struct ndn_UnixTransport *self)
113 {
114  return ndn_SocketTransport_close(&self->base);
115 }
116 
117 #ifdef __cplusplus
118 }
119 #endif
120 
121 #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:43