GCC Code Coverage Report
Directory: ../ Exec Total Coverage
File: /home/iojs/build/workspace/node-test-commit-linux-coverage-daily/nodes/benchmark/out/../src/node_crypto_clienthello-inl.h Lines: 33 33 100.0 %
Date: 2019-09-26 22:31:05 Branches: 4 8 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_NODE_CRYPTO_CLIENTHELLO_INL_H_
23
#define SRC_NODE_CRYPTO_CLIENTHELLO_INL_H_
24
25
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
26
27
#include "node_crypto_clienthello.h"
28
#include "util.h"
29
30
namespace node {
31
namespace crypto {
32
33
12243
inline ClientHelloParser::ClientHelloParser()
34
    : state_(kEnded),
35
      onhello_cb_(nullptr),
36
      onend_cb_(nullptr),
37
12243
      cb_arg_(nullptr) {
38
12243
  Reset();
39
12243
}
40
41
12263
inline void ClientHelloParser::Reset() {
42
12263
  frame_len_ = 0;
43
12263
  body_offset_ = 0;
44
12263
  extension_offset_ = 0;
45
12263
  session_size_ = 0;
46
12263
  session_id_ = nullptr;
47
12263
  tls_ticket_size_ = -1;
48
12263
  tls_ticket_ = nullptr;
49
12263
  servername_size_ = 0;
50
12263
  servername_ = nullptr;
51
12263
}
52
53
20
inline void ClientHelloParser::Start(ClientHelloParser::OnHelloCb onhello_cb,
54
                                     ClientHelloParser::OnEndCb onend_cb,
55
                                     void* onend_arg) {
56
20
  if (!IsEnded())
57
20
    return;
58
20
  Reset();
59
60
20
  CHECK_NOT_NULL(onhello_cb);
61
62
20
  state_ = kWaiting;
63
20
  onhello_cb_ = onhello_cb;
64
20
  onend_cb_ = onend_cb;
65
20
  cb_arg_ = onend_arg;
66
}
67
68
19
inline void ClientHelloParser::End() {
69
19
  if (state_ == kEnded)
70
19
    return;
71
19
  state_ = kEnded;
72
19
  if (onend_cb_ != nullptr) {
73
19
    onend_cb_(cb_arg_);
74
19
    onend_cb_ = nullptr;
75
  }
76
}
77
78
52185
inline bool ClientHelloParser::IsEnded() const {
79
52185
  return state_ == kEnded;
80
}
81
82
inline bool ClientHelloParser::IsPaused() const {
83
  return state_ == kPaused;
84
}
85
86
}  // namespace crypto
87
}  // namespace node
88
89
#endif  // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
90
91
#endif  // SRC_NODE_CRYPTO_CLIENTHELLO_INL_H_