GCC Code Coverage Report
Directory: ../ Exec Total Coverage
File: /home/iojs/build/workspace/node-test-commit-linux-coverage/nodes/benchmark/out/../src/udp_wrap.h Lines: 1 2 50.0 %
Date: 2017-12-18 Branches: 1 2 50.0 %

Line Branch Exec Source
1
// Copyright Joyent, Inc. and other Node contributors.
2
//
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:
10
//
11
// The above copyright notice and this permission notice shall be included
12
// in all copies or substantial portions of the Software.
13
//
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.
21
22
#ifndef SRC_UDP_WRAP_H_
23
#define SRC_UDP_WRAP_H_
24
25
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
26
27
#include "async_wrap.h"
28
#include "env.h"
29
#include "handle_wrap.h"
30
#include "req_wrap-inl.h"
31
#include "uv.h"
32
#include "v8.h"
33
34
namespace node {
35
36
280
class UDPWrap: public HandleWrap {
37
 public:
38
  enum SocketType {
39
    SOCKET
40
  };
41
  static void Initialize(v8::Local<v8::Object> target,
42
                         v8::Local<v8::Value> unused,
43
                         v8::Local<v8::Context> context);
44
  static void GetFD(const v8::FunctionCallbackInfo<v8::Value>& args);
45
  static void New(const v8::FunctionCallbackInfo<v8::Value>& args);
46
  static void Bind(const v8::FunctionCallbackInfo<v8::Value>& args);
47
  static void Send(const v8::FunctionCallbackInfo<v8::Value>& args);
48
  static void Bind6(const v8::FunctionCallbackInfo<v8::Value>& args);
49
  static void Send6(const v8::FunctionCallbackInfo<v8::Value>& args);
50
  static void RecvStart(const v8::FunctionCallbackInfo<v8::Value>& args);
51
  static void RecvStop(const v8::FunctionCallbackInfo<v8::Value>& args);
52
  static void AddMembership(const v8::FunctionCallbackInfo<v8::Value>& args);
53
  static void DropMembership(const v8::FunctionCallbackInfo<v8::Value>& args);
54
  static void SetMulticastInterface(
55
      const v8::FunctionCallbackInfo<v8::Value>& args);
56
  static void SetMulticastTTL(const v8::FunctionCallbackInfo<v8::Value>& args);
57
  static void SetMulticastLoopback(
58
      const v8::FunctionCallbackInfo<v8::Value>& args);
59
  static void SetBroadcast(const v8::FunctionCallbackInfo<v8::Value>& args);
60
  static void SetTTL(const v8::FunctionCallbackInfo<v8::Value>& args);
61
  static void BufferSize(const v8::FunctionCallbackInfo<v8::Value>& args);
62
63
  static v8::Local<v8::Object> Instantiate(Environment* env,
64
                                           AsyncWrap* parent,
65
                                           SocketType type);
66
  uv_udp_t* UVHandle();
67
68
  size_t self_size() const override { return sizeof(*this); }
69
70
 private:
71
  typedef uv_udp_t HandleType;
72
73
  template <typename T,
74
            int (*F)(const typename T::HandleType*, sockaddr*, int*)>
75
  friend void GetSockOrPeerName(const v8::FunctionCallbackInfo<v8::Value>&);
76
77
  UDPWrap(Environment* env, v8::Local<v8::Object> object);
78
79
  static void DoBind(const v8::FunctionCallbackInfo<v8::Value>& args,
80
                     int family);
81
  static void DoSend(const v8::FunctionCallbackInfo<v8::Value>& args,
82
                     int family);
83
  static void SetMembership(const v8::FunctionCallbackInfo<v8::Value>& args,
84
                            uv_membership membership);
85
86
  static void OnAlloc(uv_handle_t* handle,
87
                      size_t suggested_size,
88
                      uv_buf_t* buf);
89
  static void OnSend(uv_udp_send_t* req, int status);
90
  static void OnRecv(uv_udp_t* handle,
91
                     ssize_t nread,
92
                     const uv_buf_t* buf,
93
                     const struct sockaddr* addr,
94
                     unsigned int flags);
95
96
  uv_udp_t handle_;
97
};
98
99
}  // namespace node
100
101
#endif  // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
102
103
#endif  // SRC_UDP_WRAP_H_