chenshijun
2020-12-07 e3d8ac1ce502e5a5f9dc762da301b0060b641811
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
#ifndef _c_libshm_queue_so_go_wrapper_h_
#define _c_libshm_queue_so_go_wrapper_h_
 
 
#ifdef __cplusplus
extern "C"{
#endif
 
#include "libcbhomebus_func.h"
#include <stddef.h>
 
// shm manipulate
static tfn_shm_init                             fn_shm_init = NULL;
static tfn_shm_alloc_key                        fn_shm_alloc_key = NULL;
static tfn_shm_destroy                          fn_shm_destroy = NULL;
 
// net mode socket
static tfn_net_mod_socket_open                  fn_socket_open = NULL;
static tfn_net_mod_socket_close                 fn_socket_close = NULL;
static tfn_net_mod_socket_bind                  fn_socket_bind = NULL;
static tfn_net_mod_socket_force_bind            fn_socket_force_bind = NULL;
static tfn_net_mod_socket_sendto                fn_socket_sendto = NULL;
static tfn_net_mod_socket_sendto_timeout        fn_socket_sendto_timeout = NULL;
static tfn_net_mod_socket_sendto_nowait         fn_socket_sendto_nowait = NULL;
static tfn_net_mod_socket_recvfrom              fn_socket_recvfrom = NULL;
static tfn_net_mod_socket_recvfrom_timeout      fn_socket_recvfrom_timeout = NULL;
static tfn_net_mod_socket_recvfrom_nowait       fn_socket_recvfrom_nowait = NULL;
static tfn_net_mod_socket_sendandrecv           fn_socket_sendandrecv = NULL;
static tfn_net_mod_socket_sendandrecv_timeout   fn_socket_sendandrecv_timeout = NULL;
static tfn_net_mod_socket_sendandrecv_nowait    fn_socket_sendandrecv_nowait = NULL;
//static tfn_net_mod_socket_start_bus             fn_socket_start_bus = NULL;
static tfn_net_mod_socket_pub                   fn_socket_pub = NULL;
static tfn_net_mod_socket_pub_timeout           fn_socket_pub_timeout = NULL;
static tfn_net_mod_socket_pub_nowait            fn_socket_pub_nowait = NULL;
static tfn_net_mod_socket_sub                   fn_socket_sub = NULL;
static tfn_net_mod_socket_sub_timeout           fn_socket_sub_timeout = NULL;
static tfn_net_mod_socket_sub_nowait            fn_socket_sub_nowait = NULL;
static tfn_net_mod_socket_desub                 fn_socket_desub = NULL;
static tfn_net_mod_socket_desub_timeout         fn_socket_desub_timeout = NULL;
static tfn_net_mod_socket_desub_nowait          fn_socket_desub_nowait = NULL;
static tfn_net_mod_socket_get_key               fn_socket_get_key = NULL;
static tfn_net_mod_socket_free_recv_msg_arr     fn_socket_free_recv_msg_arr = NULL;
static tfn_net_mod_socket_free                  fn_socket_free = NULL;
static tfn_shm_mod_socket_remove_key            fn_socket_remove_key = NULL;
static tfn_shm_mod_socket_remove_keys           fn_socket_remove_keys = NULL;
 
static tfn_net_mod_server_socket_open           fn_server_socket_open = NULL;
static tfn_net_mod_server_socket_close          fn_server_socket_close = NULL;
static tfn_net_mod_server_socket_start          fn_server_socket_start = NULL;
 
// bus
static tfn_bus_server_socket_wrapper_open           fn_bus_server_socket_open = NULL;
static tfn_bus_server_socket_wrapper_close          fn_bus_server_socket_close = NULL;
static tfn_bus_server_socket_wrapper_start_bus      fn_bus_server_socket_start = NULL;
//////////////////////////////////////////////////////////////////////
 
// labels
// shm
const static char l_shm_init[] = "shm_mm_wrapper_init";
const static char l_shm_destroy[] = "shm_mm_wrapper_destroy";
const static char l_shm_alloc_key[] = "shm_mm_wrapper_alloc_key";
 
// net mode socket
const static char l_socket_open[] = "net_mod_socket_open";
const static char l_net_mod_socket_open[] = "net_mod_socket_open";
const static char l_net_mod_socket_close[] = "net_mod_socket_close";
const static char l_net_mod_socket_bind[] = "net_mod_socket_bind";
const static char l_net_mod_socket_force_bind[] = "net_mod_socket_force_bind";
const static char l_net_mod_socket_sendto[] = "net_mod_socket_sendto";
const static char l_net_mod_socket_sendto_timeout[] = "net_mod_socket_sendto_timeout";
const static char l_net_mod_socket_sendto_nowait[] = "net_mod_socket_sendto_nowait";
const static char l_net_mod_socket_recvfrom[] = "net_mod_socket_recvfrom";
const static char l_net_mod_socket_recvfrom_timeout[] = "net_mod_socket_recvfrom_timeout";
const static char l_net_mod_socket_recvfrom_nowait[] = "net_mod_socket_recvfrom_nowait";
const static char l_net_mod_socket_sendandrecv[] = "net_mod_socket_sendandrecv";
const static char l_net_mod_socket_sendandrecv_timeout[] = "net_mod_socket_sendandrecv_timeout";
const static char l_net_mod_socket_sendandrecv_nowait[] = "net_mod_socket_sendandrecv_nowait";
//const static char l_net_mod_socket_start_bus[] = "net_mod_socket_start_bus";
const static char l_net_mod_socket_pub[] = "net_mod_socket_pub";
const static char l_net_mod_socket_pub_timeout[] = "net_mod_socket_pub_timeout";
const static char l_net_mod_socket_pub_nowait[] = "net_mod_socket_pub_nowait";
const static char l_net_mod_socket_sub[] = "net_mod_socket_sub";
const static char l_net_mod_socket_sub_timeout[] = "net_mod_socket_sub_timeout";
const static char l_net_mod_socket_sub_nowait[] = "net_mod_socket_sub_nowait";
const static char l_net_mod_socket_desub[] = "net_mod_socket_desub";
const static char l_net_mod_socket_desub_timeout[] = "net_mod_socket_desub_timeout";
const static char l_net_mod_socket_desub_nowait[] = "net_mod_socket_desub_nowait";
const static char l_net_mod_socket_get_key[] = "net_mod_socket_get_key";
const static char l_net_mod_socket_free_recv_msg_arr[] = "net_mod_socket_free_recv_msg_arr";
const static char l_net_mod_socket_free[] = "net_mod_socket_free";
const static char l_shm_mod_socket_remove_key[] = "shm_mod_socket_remove_key";
const static char l_shm_mod_socket_remove_keys[] = "shm_mod_socket_remove_keys";
 
const static char l_net_mod_server_socket_open[] = "net_mod_server_socket_open";
const static char l_net_mod_server_socket_close[] = "net_mod_server_socket_close";
const static char l_net_mod_server_socket_start[] = "net_mod_server_socket_start";
 
// bus
const static char l_bus_server_socket_wrapper_open[] = "bus_server_socket_wrapper_open";
const static char l_bus_server_socket_wrapper_close[] = "bus_server_socket_wrapper_close";
const static char l_bus_server_socket_wrapper_start_bus[] = "bus_server_socket_wrapper_start_bus";
//////////////////////////////////////////////////////////////////////
 
// dlopen dynamic library
typedef void* hbhomebus;
hbhomebus c_bhomebus_handle(const char *so);
void c_bhomebus_release(hbhomebus lib);
 
// shm manipulate
void wrap_fn_shm_init(hbhomebus lib, int size);
int wrap_fn_shm_alloc_key(hbhomebus lib);
void wrap_fn_shm_destroy(hbhomebus lib);
 
/////////////////////////////////////////////////////////
// net mode socket
void * wrap_fn_socket_open(hbhomebus lib);
void wrap_fn_socket_close(hbhomebus lib, void *_sockt);
int wrap_fn_socket_bind(hbhomebus lib, void * _socket, int key);
int wrap_fn_socket_force_bind(hbhomebus lib, void * _socket, int key);
int wrap_fn_socket_sendto(hbhomebus lib, void *_socket, const void *buf, const int size, const int key);
int wrap_fn_socket_sendto_timeout(hbhomebus lib, void *_socket, const void *buf, const int size, const int key, int sec, int nsec);
int wrap_fn_socket_sendto_nowait(hbhomebus lib, void *_socket, const void *buf, const int size, const int key);
int wrap_fn_socket_recvfrom(hbhomebus lib, void *_socket, void **buf, int *size, int *key);
int wrap_fn_socket_recvfrom_timeout(hbhomebus lib, void *_socket, void **buf, int *size, int *key, int sec, int nsec);
int wrap_fn_socket_recvfrom_nowait(hbhomebus lib, void *_socket, void **buf, int *size, int *key);
int wrap_fn_socket_sendandrecv(hbhomebus lib, void *_sockt, void *node_arr, int arrlen, void *send_buf, int send_size,
    void ** recv_arr, int *recv_arr_size) ;
int wrap_fn_socket_sendandrecv_timeout(hbhomebus lib, void *_sockt, void *node_arr, int arrlen, void *send_buf, int send_size,
    void ** recv_arr, int *recv_arr_size, int timeout);
int wrap_fn_socket_sendandrecv_nowait(hbhomebus lib, void *_sockt, void *node_arr, int arrlen, void *send_buf, int send_size,
    void ** recv_arr, int *recv_arr_size) ;
//int  wrap_fn_socket_start_bus(hbhomebus lib, void * _socket);
int wrap_fn_socket_pub(hbhomebus lib, void *_sockt, void *node_arr, int node_arr_len, char *topic, int topic_size, void *content, int content_size);
int wrap_fn_socket_pub_timeout(hbhomebus lib, void *_sockt, void *node_arr, int node_arr_len, char *topic, int topic_size, void *content, int content_size, int timeout);
int wrap_fn_socket_pub_nowait(hbhomebus lib, void *_sockt, void *node_arr, int node_arr_len, char *topic, int topic_size, void *content, int content_size);
int  wrap_fn_socket_sub(hbhomebus lib, void * _socket, void *topic, int size);
int  wrap_fn_socket_sub_timeout(hbhomebus lib, void * _socket, void *topic, int size, int sec, int nsec);
int  wrap_fn_socket_sub_nowait(hbhomebus lib, void * _socket, void *topic, int size);
int  wrap_fn_socket_desub(hbhomebus lib, void * _socket, void *topic, int size);
int  wrap_fn_socket_desub_timeout(hbhomebus lib, void * _socket, void *topic, int size, int sec, int nsec);
int  wrap_fn_socket_desub_nowait(hbhomebus lib, void * _socket, void *topic, int size);
int wrap_fn_socket_get_key(hbhomebus lib, void * _socket) ;
void  wrap_fn_socket_free_recv_msg_arr(hbhomebus lib, void * arr, int size);
void wrap_fn_socket_free(hbhomebus lib, void *buf) ;
 
int wrap_fn_socket_remove_key(hbhomebus lib, int key);
int wrap_fn_socket_remove_keys(hbhomebus lib, void *keys, int length);
 
void *wrap_fn_server_socket_open(hbhomebus lib, int port);
void wrap_fn_server_socket_close(hbhomebus lib, void* _socket);
int wrap_fn_server_socket_start(hbhomebus lib, void* _socket);
 
//bus
void *wrap_fn_bus_server_socket_open(hbhomebus lib);
void wrap_fn_bus_server_socket_close(hbhomebus lib, void* _socket);
int wrap_fn_bus_server_socket_start(hbhomebus lib, void* _socket);
 
#ifdef __cplusplus
}
#endif
 
#endif