From 0bde715af72b7b3d55ad3aac816d7cd153a60b42 Mon Sep 17 00:00:00 2001
From: zhangmeng <775834166@qq.com>
Date: 星期一, 03 八月 2020 13:29:21 +0800
Subject: [PATCH] add timeout api

---
 libcsoftbus.c |   81 ++++++++++++++++++++++++++++++++++++++++
 1 files changed, 81 insertions(+), 0 deletions(-)

diff --git a/libcsoftbus.c b/libcsoftbus.c
index a5a23c1..11fc582 100644
--- a/libcsoftbus.c
+++ b/libcsoftbus.c
@@ -308,6 +308,22 @@
     return fn_dgram_socket_sendto(s, buf, size, port);
 }
 
+int wrap_fn_dgram_socket_sendto_timeout(hcsoftbus lib, void *s, const void *buf, const int size, const int port, int sec, int usec){
+    if (!fn_dgram_socket_sendto_timeout){
+        fn_dgram_socket_sendto_timeout = (tfn_dgram_socket_sendto_timeout)dlsym(lib, l_dgram_socket_sendto_timeout);
+        check_with_ret(fn_dgram_socket_sendto_timeout, lib, -1);
+    }
+    return fn_dgram_socket_sendto_timeout(s, buf, size, port, sec, usec);
+}
+
+int wrap_fn_dgram_socket_sendto_nowait(hcsoftbus lib, void *s, const void *buf, const int size, const int port){
+    if (!fn_dgram_socket_sendto_nowait){
+        fn_dgram_socket_sendto_nowait = (tfn_dgram_socket_sendto_nowait)dlsym(lib, l_dgram_socket_sendto_nowait);
+        check_with_ret(fn_dgram_socket_sendto_nowait, lib, -1);
+    }
+    return fn_dgram_socket_sendto_nowait(s, buf, size, port);
+}
+
 int wrap_fn_dgram_socket_recvfrom(hcsoftbus lib, void *s, void **buf, int *size, int *port){
     if (!fn_dgram_socket_recvfrom){
         fn_dgram_socket_recvfrom = (tfn_dgram_socket_recvfrom)dlsym(lib, l_dgram_socket_recvfrom);
@@ -316,12 +332,45 @@
     return fn_dgram_socket_recvfrom(s, buf, size, port);
 }
 
+int wrap_fn_dgram_socket_recvfrom_timeout(hcsoftbus lib, void *s, void **buf, int *size, int *port, int sec, int usec){
+    if (!fn_dgram_socket_recvfrom_timeout){
+        fn_dgram_socket_recvfrom_timeout = (tfn_dgram_socket_recvfrom_timeout)dlsym(lib, l_dgram_socket_recvfrom_timeout);
+        check_with_ret(fn_dgram_socket_recvfrom_timeout, lib, -1);
+    }
+    return fn_dgram_socket_recvfrom_timeout(s, buf, size, port, sec, usec);
+}
+
+int wrap_fn_dgram_socket_recvfrom_nowait(hcsoftbus lib, void *s, void **buf, int *size, int *port){
+    if (!fn_dgram_socket_recvfrom_nowait){
+        fn_dgram_socket_recvfrom_nowait = (tfn_dgram_socket_recvfrom_nowait)dlsym(lib, l_dgram_socket_recvfrom_nowait);
+        check_with_ret(fn_dgram_socket_recvfrom_nowait, lib, -1);
+    }
+    return fn_dgram_socket_recvfrom_nowait(s, buf, size, port);
+}
+
 int wrap_fn_dgram_socket_sendandrecv(hcsoftbus lib, void *s, const void *sbuf, const int ssize, const int port, void **rbuf, int *rsize){
     if (!fn_dgram_socket_sendandrecv){
         fn_dgram_socket_sendandrecv = (tfn_dgram_socket_sendandrecv)dlsym(lib, l_dgram_socket_sendandrecv);
         check_with_ret(fn_dgram_socket_sendandrecv, lib, -1);
     }
     return fn_dgram_socket_sendandrecv(s, sbuf, ssize, port, rbuf, rsize);
+}
+
+int wrap_fn_dgram_socket_sendandrecv_timeout(hcsoftbus lib, void *s, const void *sbuf, const int ssize, const int port, void **rbuf, int *rsize, int sec, int usec){
+    if (!fn_dgram_socket_sendandrecv_timeout){
+        fn_dgram_socket_sendandrecv_timeout = (tfn_dgram_socket_sendandrecv_timeout)dlsym(lib, l_dgram_socket_sendandrecv_timeout);
+        check_with_ret(fn_dgram_socket_sendandrecv_timeout, lib, -1);
+    }
+
+    return fn_dgram_socket_sendandrecv_timeout(s, sbuf, ssize, port, rbuf, rsize, sec, usec);
+}
+
+int wrap_fn_dgram_socket_sendandrecv_nowait(hcsoftbus lib, void *s, const void *sbuf, const int ssize, const int port, void **rbuf, int *rsize){
+    if (!fn_dgram_socket_sendandrecv_nowait){
+        fn_dgram_socket_sendandrecv_nowait = (tfn_dgram_socket_sendandrecv_nowait)dlsym(lib, l_dgram_socket_sendandrecv_nowait);
+        check_with_ret(fn_dgram_socket_sendandrecv_nowait, lib, -1);
+    }
+    return fn_dgram_socket_sendandrecv_nowait(s, sbuf, ssize, port, rbuf, rsize);
 }
 
 int wrap_fn_dgram_socket_start_bus(hcsoftbus lib, void *s){
@@ -340,6 +389,22 @@
     return fn_dgram_socket_sub(s, topic, size, port);
 }
 
+int wrap_fn_dgram_socket_sub_timeout(hcsoftbus lib, void *s, void *topic, int size, int port, int sec, int usec){
+    if (!fn_dgram_socket_sub_timeout){
+        fn_dgram_socket_sub_timeout = (tfn_dgram_socket_sub_timeout)dlsym(lib, l_dgram_socket_sub_timeout);
+        check_with_ret(fn_dgram_socket_sub_timeout, lib, -1);
+    }
+    return fn_dgram_socket_sub_timeout(s, topic, size, port, sec, usec);
+}
+
+int wrap_fn_dgram_socket_sub_nowait(hcsoftbus lib, void *s, void *topic, int size, int port){
+    if (!fn_dgram_socket_sub_nowait){
+        fn_dgram_socket_sub_nowait = (tfn_dgram_socket_sub_nowait)dlsym(lib, l_dgram_socket_sub_nowait);
+        check_with_ret(fn_dgram_socket_sub_nowait, lib, -1);
+    }
+    return fn_dgram_socket_sub_nowait(s, topic, size, port);
+}
+
 int wrap_fn_dgram_socket_pub(hcsoftbus lib, void *s, void *topic, int tsize, void *content, int csize, int port){
     if (!fn_dgram_socket_pub){
         fn_dgram_socket_pub = (tfn_dgram_socket_pub)dlsym(lib, l_dgram_socket_pub);
@@ -348,6 +413,22 @@
     return fn_dgram_socket_pub(s, topic, tsize, content, csize, port);
 }
 
+int wrap_fn_dgram_socket_pub_timeout(hcsoftbus lib, void *s, void *topic, int tsize, void *content, int csize, int port, int sec, int usec){
+    if (!fn_dgram_socket_pub_timeout){
+        fn_dgram_socket_pub_timeout = (tfn_dgram_socket_pub_timeout)dlsym(lib, l_dgram_socket_pub_timeout);
+        check_with_ret(fn_dgram_socket_pub_timeout, lib, -1);
+    }
+    return fn_dgram_socket_pub_timeout(s, topic, tsize, content, csize, port, sec, usec);
+}
+
+int wrap_fn_dgram_socket_pub_nowait(hcsoftbus lib, void *s, void *topic, int tsize, void *content, int csize, int port){
+    if (!fn_dgram_socket_pub_nowait){
+        fn_dgram_socket_pub_nowait = (tfn_dgram_socket_pub_nowait)dlsym(lib, l_dgram_socket_pub_nowait);
+        check_with_ret(fn_dgram_socket_pub_nowait, lib, -1);
+    }
+    return fn_dgram_socket_pub_nowait(s, topic, tsize, content, csize, port);
+}
+
 int wrap_fn_dgram_socket_port(hcsoftbus lib, void *s){
     if (!fn_dgram_socket_port){
         fn_dgram_socket_port = (tfn_dgram_socket_port)dlsym(lib, l_dgram_socket_port);

--
Gitblit v1.8.0