Added UdpTransport
diff --git a/ndn-cpp/c/errors.c b/ndn-cpp/c/errors.c
index 89f30a1..af32008 100644
--- a/ndn-cpp/c/errors.c
+++ b/ndn-cpp/c/errors.c
@@ -62,6 +62,16 @@
return "TcpTransport error in send";
case NDN_ERROR_TcpTransport_error_in_recv:
return "TcpTransport error in recv";
+ case NDN_ERROR_UdpTransport_error_in_getaddrinfo:
+ return "UdpTransport error in getaddrinfo";
+ case NDN_ERROR_UdpTransport_cannot_connect_to_socket:
+ return "UdpTransport cannot connect to socket";
+ case NDN_ERROR_UdpTransport_socket_is_not_open:
+ return "UdpTransport socket is not open";
+ case NDN_ERROR_UdpTransport_error_in_send:
+ return "UdpTransport error in send";
+ case NDN_ERROR_UdpTransport_error_in_recv:
+ return "UdpTransport error in recv";
default:
return "unrecognized ndn_Error code";
}
diff --git a/ndn-cpp/c/errors.h b/ndn-cpp/c/errors.h
index 56f509c..f574b6a 100644
--- a/ndn-cpp/c/errors.h
+++ b/ndn-cpp/c/errors.h
@@ -38,7 +38,12 @@
NDN_ERROR_TcpTransport_cannot_connect_to_socket,
NDN_ERROR_TcpTransport_socket_is_not_open,
NDN_ERROR_TcpTransport_error_in_send,
- NDN_ERROR_TcpTransport_error_in_recv
+ NDN_ERROR_TcpTransport_error_in_recv,
+ NDN_ERROR_UdpTransport_error_in_getaddrinfo,
+ NDN_ERROR_UdpTransport_cannot_connect_to_socket,
+ NDN_ERROR_UdpTransport_socket_is_not_open,
+ NDN_ERROR_UdpTransport_error_in_send,
+ NDN_ERROR_UdpTransport_error_in_recv
} ndn_Error;
/**
diff --git a/ndn-cpp/c/transport/UdpTransport.h b/ndn-cpp/c/transport/UdpTransport.h
new file mode 100644
index 0000000..924e4a7
--- /dev/null
+++ b/ndn-cpp/c/transport/UdpTransport.h
@@ -0,0 +1,35 @@
+/**
+ * @author: Jeff Thompson
+ * See COPYING for copyright and distribution information.
+ */
+
+#ifndef NDN_UDPTRANSPORT_H
+#define NDN_UDPTRANSPORT_H
+
+#include "../errors.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct ndn_UdpTransport {
+ int socketDescriptor; /**< -1 if not connected */
+};
+
+static inline void ndn_UdpTransport_init(struct ndn_UdpTransport *self)
+{
+ self->socketDescriptor = -1;
+}
+
+ndn_Error ndn_UdpTransport_connect(struct ndn_UdpTransport *self, char *host, unsigned short port);
+
+ndn_Error ndn_UdpTransport_send(struct ndn_UdpTransport *self, unsigned char *data, unsigned int dataLength);
+
+ndn_Error ndn_UdpTransport_receive
+ (struct ndn_UdpTransport *self, unsigned char *buffer, unsigned int bufferLength, unsigned int *nBytes);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif