about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorEric Reed <ereed@mozilla.com>2013-06-12 16:01:50 -0700
committerEric Reed <ereed@mozilla.com>2013-06-12 16:01:50 -0700
commit39a575fb43d2ba0511d295b7e1a9178b4919e348 (patch)
tree7af8c573b0b2882aed568d361d59b1879c959e12 /src/libstd
parenteb11274919f96331bc21702ce95e77e973d76109 (diff)
downloadrust-39a575fb43d2ba0511d295b7e1a9178b4919e348.tar.gz
rust-39a575fb43d2ba0511d295b7e1a9178b4919e348.zip
Added libuv UDP function bindings.
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/rt/uv/uvll.rs47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/libstd/rt/uv/uvll.rs b/src/libstd/rt/uv/uvll.rs
index ddc9040d730..8a3f02cb59b 100644
--- a/src/libstd/rt/uv/uvll.rs
+++ b/src/libstd/rt/uv/uvll.rs
@@ -56,12 +56,14 @@ pub type uv_handle_t = c_void;
 pub type uv_loop_t = c_void;
 pub type uv_idle_t = c_void;
 pub type uv_tcp_t = c_void;
+pub type uv_udp_t = c_void;
 pub type uv_connect_t = c_void;
 pub type uv_write_t = c_void;
 pub type uv_async_t = c_void;
 pub type uv_timer_t = c_void;
 pub type uv_stream_t = c_void;
 pub type uv_fs_t = c_void;
+pub type uv_udp_send_t = c_void;
 
 pub type uv_idle_cb = *u8;
 
@@ -183,6 +185,40 @@ pub unsafe fn idle_stop(handle: *uv_idle_t) -> c_int {
     rust_uv_idle_stop(handle)
 }
 
+pub unsafe fn udp_init(loop_handle: *uv_loop_t, handle: *uv_udp_t) -> c_int {
+    return rust_uv_udp_init(loop_handle, handle);
+}
+
+pub unsafe fn udp_bind(server: *uv_udp_t, addr: *sockaddr_in, flags: c_uint) -> c_int {
+    return rust_uv_udp_bind(server, addr, flags);
+}
+
+pub unsafe fn udp_bind6(server: *uv_udp_t, addr: *sockaddr_in6, flags: c_uint) -> c_int {
+    return rust_uv_udp_bind6(server, addr, flags);
+}
+
+pub unsafe fn udp_send<T>(req: *uv_udp_send_t, handle: *T, buf_in: &[uv_buf_t],
+                          addr: *sockaddr_in, cb: *u8) -> c_int {
+    let buf_ptr = vec::raw::to_ptr(buf_in);
+    let buf_cnt = buf_in.len() as i32;
+    return rust_uv_udp_send(req, handle, buf_ptr, buf_cnt, addr, cb);
+}
+
+pub unsafe fn udp_send6<T>(req: *uv_udp_send_t, handle: *T, buf_in: &[uv_buf_t],
+                          addr: *sockaddr_in6, cb: *u8) -> c_int {
+    let buf_ptr = vec::raw::to_ptr(buf_in);
+    let buf_cnt = buf_in.len() as i32;
+    return rust_uv_udp_send(req, handle, buf_ptr, buf_cnt, addr, cb);
+}
+
+pub unsafe fn udp_recv_start(server: *uv_udp_t, on_alloc: *u8, on_recv: *u8) -> c_int {
+    return rust_uv_udp_recv_start(server, on_alloc, on_recv);
+}
+
+pub unsafe fn udp_recv_stop(server: *uv_udp_t) -> c_int {
+    return rust_uv_udp_recv_stop(server);
+}
+
 pub unsafe fn tcp_init(loop_handle: *c_void, handle: *uv_tcp_t) -> c_int {
     return rust_uv_tcp_init(loop_handle, handle);
 }
@@ -417,6 +453,17 @@ extern {
                                name: *sockaddr_in) -> c_int;
     fn rust_uv_tcp_getpeername6(tcp_handle_ptr: *uv_tcp_t,
                                 name: *sockaddr_in6) ->c_int;
+
+    fn rust_uv_udp_init(loop_handle: *uv_loop_t, handle_ptr: *uv_udp_t) -> c_int;
+    fn rust_uv_udp_bind(server: *uv_udp_t, addr: *sockaddr_in, flags: c_uint) -> c_int;
+    fn rust_uv_udp_bind6(server: *uv_udp_t, addr: *sockaddr_in6, flags: c_uint) -> c_int;
+    fn rust_uv_udp_send(req: *uv_udp_send_t, handle: *uv_udp_t, buf_in: *uv_buf_t,
+                        buf_cnt: c_int, addr: *sockaddr_in, cb: *u8) -> c_int;
+    fn rust_uv_udp_send6(req: *uv_udp_send_t, handle: *uv_udp_t, buf_in: *uv_buf_t,
+                         buf_cnt: c_int, addr: *sockaddr_in6, cb: *u8) -> c_int;
+    fn rust_uv_udp_recv_start(server: *uv_udp_t, on_alloc: *u8, on_recv: *u8) -> c_int;
+    fn rust_uv_udp_recv_stop(server: *uv_udp_t) -> c_int;
+
     fn rust_uv_listen(stream: *c_void, backlog: c_int, cb: *u8) -> c_int;
     fn rust_uv_accept(server: *c_void, client: *c_void) -> c_int;
     fn rust_uv_write(req: *c_void,