blob: 262d5eca54c897615511eefdfda683b0fb659bf2 [file] [log] [blame]
Jeff Thompson0aa754a2013-07-17 17:42:28 -07001/*
2 * File: UdpTransport.h
3 * Author: jefft0
4 *
5 * Created on July 14, 2013, 4:15 PM
Jeff Thompsonbc53c522013-07-17 17:11:48 -07006 */
7
8#ifndef NDN_UDPTRANSPORT_H
9#define NDN_UDPTRANSPORT_H
10
Jeff Thompson0aa754a2013-07-17 17:42:28 -070011#include "SocketTransport.h"
Jeff Thompsonbc53c522013-07-17 17:11:48 -070012
13#ifdef __cplusplus
14extern "C" {
15#endif
16
17struct ndn_UdpTransport {
Jeff Thompson0aa754a2013-07-17 17:42:28 -070018 struct ndn_SocketTransport base;
Jeff Thompsonbc53c522013-07-17 17:11:48 -070019};
20
21static inline void ndn_UdpTransport_init(struct ndn_UdpTransport *self)
22{
Jeff Thompson0aa754a2013-07-17 17:42:28 -070023 ndn_SocketTransport_init(&self->base);
Jeff Thompsonbc53c522013-07-17 17:11:48 -070024}
25
Jeff Thompson0aa754a2013-07-17 17:42:28 -070026static inline ndn_Error ndn_UdpTransport_connect(struct ndn_UdpTransport *self, char *host, unsigned short port)
27{
28 return ndn_SocketTransport_connect(&self->base, SOCKET_UDP, host, port);
29}
Jeff Thompsonbc53c522013-07-17 17:11:48 -070030
Jeff Thompson0aa754a2013-07-17 17:42:28 -070031static inline ndn_Error ndn_UdpTransport_send(struct ndn_UdpTransport *self, unsigned char *data, unsigned int dataLength)
32{
33 return ndn_SocketTransport_send(&self->base, data, dataLength);
34}
Jeff Thompsonbc53c522013-07-17 17:11:48 -070035
Jeff Thompson0aa754a2013-07-17 17:42:28 -070036static inline ndn_Error ndn_UdpTransport_receive
37 (struct ndn_UdpTransport *self, unsigned char *buffer, unsigned int bufferLength, unsigned int *nBytes)
38{
39 return ndn_SocketTransport_receive(&self->base, buffer, bufferLength, nBytes);
40}
Jeff Thompsonbc53c522013-07-17 17:11:48 -070041
42#ifdef __cplusplus
43}
44#endif
45
46#endif