Upload packaging folder
[platform/upstream/iotjs.git] / src / module / iotjs_module_udp.h
1 /* Copyright 2015-present Samsung Electronics Co., Ltd. and other contributors
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15
16
17 #ifndef IOTJS_MODULE_UDP_H
18 #define IOTJS_MODULE_UDP_H
19
20
21 #include "iotjs_def.h"
22 #include "iotjs_handlewrap.h"
23 #include "iotjs_reqwrap.h"
24
25
26 typedef struct {
27   iotjs_handlewrap_t handlewrap;
28   uv_udp_t handle;
29 } IOTJS_VALIDATED_STRUCT(iotjs_udpwrap_t);
30
31
32 iotjs_udpwrap_t* iotjs_udpwrap_create(const iotjs_jval_t* judp);
33
34 iotjs_udpwrap_t* iotjs_udpwrap_from_handle(uv_udp_t* handle);
35 iotjs_udpwrap_t* iotjs_udpwrap_from_jobject(const iotjs_jval_t* judp);
36
37 uv_udp_t* iotjs_udpwrap_udp_handle(iotjs_udpwrap_t* udpwrap);
38 iotjs_jval_t* iotjs_udpwrap_jobject(iotjs_udpwrap_t* udpwrap);
39
40
41 typedef struct {
42   iotjs_reqwrap_t reqwrap;
43   uv_udp_send_t req;
44   size_t msg_size;
45 } IOTJS_VALIDATED_STRUCT(iotjs_send_reqwrap_t);
46
47 #define THIS iotjs_send_reqwrap_t* send_reqwrap
48
49 iotjs_send_reqwrap_t* iotjs_send_reqwrap_create(const iotjs_jval_t* jcallback,
50                                                 const size_t msg_size);
51
52 void iotjs_send_reqwrap_dispatched(THIS);
53
54 uv_udp_send_t* iotjs_send_reqwrap_req(THIS);
55 const iotjs_jval_t* iotjs_send_reqwrap_jcallback(THIS);
56
57 #undef THIS
58
59
60 #endif /* IOTJS_MODULE_UDP_H */