1 // Copyright Joyent, Inc. and other Node contributors.
3 // Permission is hereby granted, free of charge, to any person obtaining a
4 // copy of this software and associated documentation files (the
5 // "Software"), to deal in the Software without restriction, including
6 // without limitation the rights to use, copy, modify, merge, publish,
7 // distribute, sublicense, and/or sell copies of the Software, and to permit
8 // persons to whom the Software is furnished to do so, subject to the
9 // following conditions:
11 // The above copyright notice and this permission notice shall be included
12 // in all copies or substantial portions of the Software.
14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
17 // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18 // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19 // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20 // USE OR OTHER DEALINGS IN THE SOFTWARE.
22 #ifndef SRC_UDP_WRAP_H_
23 #define SRC_UDP_WRAP_H_
26 #include "handle_wrap.h"
33 class UDPWrap: public HandleWrap {
35 static void Initialize(v8::Handle<v8::Object> target,
36 v8::Handle<v8::Value> unused,
37 v8::Handle<v8::Context> context);
38 static void GetFD(v8::Local<v8::String>,
39 const v8::PropertyCallbackInfo<v8::Value>&);
40 static void New(const v8::FunctionCallbackInfo<v8::Value>& args);
41 static void Bind(const v8::FunctionCallbackInfo<v8::Value>& args);
42 static void Send(const v8::FunctionCallbackInfo<v8::Value>& args);
43 static void Bind6(const v8::FunctionCallbackInfo<v8::Value>& args);
44 static void Send6(const v8::FunctionCallbackInfo<v8::Value>& args);
45 static void RecvStart(const v8::FunctionCallbackInfo<v8::Value>& args);
46 static void RecvStop(const v8::FunctionCallbackInfo<v8::Value>& args);
47 static void GetSockName(const v8::FunctionCallbackInfo<v8::Value>& args);
48 static void AddMembership(const v8::FunctionCallbackInfo<v8::Value>& args);
49 static void DropMembership(const v8::FunctionCallbackInfo<v8::Value>& args);
50 static void SetMulticastTTL(const v8::FunctionCallbackInfo<v8::Value>& args);
51 static void SetMulticastLoopback(
52 const v8::FunctionCallbackInfo<v8::Value>& args);
53 static void SetBroadcast(const v8::FunctionCallbackInfo<v8::Value>& args);
54 static void SetTTL(const v8::FunctionCallbackInfo<v8::Value>& args);
56 static v8::Local<v8::Object> Instantiate(Environment* env);
60 UDPWrap(Environment* env, v8::Handle<v8::Object> object);
63 static void DoBind(const v8::FunctionCallbackInfo<v8::Value>& args,
65 static void DoSend(const v8::FunctionCallbackInfo<v8::Value>& args,
67 static void SetMembership(const v8::FunctionCallbackInfo<v8::Value>& args,
68 uv_membership membership);
70 static void OnAlloc(uv_handle_t* handle,
71 size_t suggested_size,
73 static void OnSend(uv_udp_send_t* req, int status);
74 static void OnRecv(uv_udp_t* handle,
77 const struct sockaddr* addr,
85 #endif // SRC_UDP_WRAP_H_