zhangmeng
2020-08-04 4acab9cb4dae6ddc881e6bd5454715063c1a7d4b
libcsoftbus.c
@@ -57,6 +57,14 @@
    fn_shm_init(size);
}
int wrap_fn_shm_alloc_key(hcsoftbus lib){
    if (!fn_shm_alloc_key){
        fn_shm_alloc_key = (tfn_shm_alloc_key)dlsym(lib, l_shm_alloc_key);
        check_with_ret(fn_shm_alloc_key, lib, -1);
    }
    return fn_shm_alloc_key();
}
void wrap_fn_shm_destroy(hcsoftbus lib){
    if (!fn_shm_destroy){
        printf("shm destroy failed\n");
@@ -257,3 +265,186 @@
    return fn_socket_port(s);
}
////////////////////////////////////////////
// dgram socket mode
////////////////////////////////////////////
void *wrap_fn_dgram_socket_open(hcsoftbus lib){
    if (!fn_dgram_socket_open){
        fn_dgram_socket_open = (tfn_dgram_socket_open)dlsym(lib , l_dgram_socket_open);
        check_with_ret(fn_dgram_socket_open, lib, NULL);
    }
    return fn_dgram_socket_open();
}
int wrap_fn_dgram_socket_close(hcsoftbus lib, void *s){
    if (!fn_dgram_socket_close){
        fn_dgram_socket_close = (tfn_dgram_socket_close)dlsym(lib, l_dgram_socket_close);
        check_with_ret(fn_dgram_socket_close, lib, -1);
    }
    return fn_dgram_socket_close(s);
}
int wrap_fn_dgram_socket_bind(hcsoftbus lib, void *s, int port){
    if (!fn_dgram_socket_bind){
        fn_dgram_socket_bind = (tfn_dgram_socket_bind)dlsym(lib, l_dgram_socket_bind);
        check_with_ret(fn_dgram_socket_bind, lib, -1);
    }
    return fn_dgram_socket_bind(s, port);
}
int wrap_fn_dgram_socket_force_bind(hcsoftbus lib, void *s, int port){
    if (!fn_dgram_socket_force_bind){
        fn_dgram_socket_force_bind = (tfn_dgram_socket_force_bind)dlsym(lib, l_dgram_socket_force_bind);
        check_with_ret(fn_dgram_socket_force_bind, lib, -1);
    }
    return fn_dgram_socket_force_bind(s, port);
}
int wrap_fn_dgram_socket_sendto(hcsoftbus lib, void *s, const void *buf, const int size, const int port){
    if (!fn_dgram_socket_sendto){
        fn_dgram_socket_sendto = (tfn_dgram_socket_sendto)dlsym(lib, l_dgram_socket_sendto);
        check_with_ret(fn_dgram_socket_sendto, lib, -1);
    }
    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);
        check_with_ret(fn_dgram_socket_recvfrom, lib, -1);
    }
    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){
    if (!fn_dgram_socket_start_bus){
        fn_dgram_socket_start_bus = (tfn_dgram_socket_start_bus)dlsym(lib, l_dgram_socket_start_bus);
        check_with_ret(fn_dgram_socket_start_bus, lib, -1);
    }
    return fn_dgram_socket_start_bus(s);
}
int wrap_fn_dgram_socket_sub(hcsoftbus lib, void *s, void *topic, int size, int port){
    if (!fn_dgram_socket_sub){
        fn_dgram_socket_sub = (tfn_dgram_socket_sub)dlsym(lib, l_dgram_socket_sub);
        check_with_ret(fn_dgram_socket_sub, lib, -1);
    }
    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);
        check_with_ret(fn_dgram_socket_pub, lib, -1);
    }
    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);
        check_with_ret(fn_dgram_socket_port, lib, -1);
    }
    return fn_dgram_socket_port(s);
}
void wrap_fn_dgram_socket_free(hcsoftbus lib, void *buf){
    if (!fn_dgram_socket_free){
        fn_dgram_socket_free = (tfn_dgram_socket_free)dlsym(lib, l_dgram_socket_free);
    }
    if (fn_dgram_socket_free){
        fn_dgram_socket_free(buf);
    }else{
        free(buf);
    }
}