GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: crypto/crypto_clienthello-inl.h Lines: 31 33 93.9 %
Date: 2022-09-19 04:21:54 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_CRYPTO_CRYPTO_CLIENTHELLO_INL_H_
23
#define SRC_CRYPTO_CRYPTO_CLIENTHELLO_INL_H_
24
25
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
26
27
#include "crypto/crypto_clienthello.h"
28
#include "util.h"
29
30
namespace node {
31
namespace crypto {
32
12400
inline ClientHelloParser::ClientHelloParser()
33
    : state_(kEnded),
34
      onhello_cb_(nullptr),
35
      onend_cb_(nullptr),
36
12400
      cb_arg_(nullptr) {
37
12400
  Reset();
38
12400
}
39
40
12421
inline void ClientHelloParser::Reset() {
41
12421
  frame_len_ = 0;
42
12421
  body_offset_ = 0;
43
12421
  extension_offset_ = 0;
44
12421
  session_size_ = 0;
45
12421
  session_id_ = nullptr;
46
12421
  tls_ticket_size_ = -1;
47
12421
  tls_ticket_ = nullptr;
48
12421
  servername_size_ = 0;
49
12421
  servername_ = nullptr;
50
12421
}
51
52
21
inline void ClientHelloParser::Start(ClientHelloParser::OnHelloCb onhello_cb,
53
                                     ClientHelloParser::OnEndCb onend_cb,
54
                                     void* cb_arg) {
55
21
  if (!IsEnded())
56
    return;
57
21
  Reset();
58
59
21
  CHECK_NOT_NULL(onhello_cb);
60
61
21
  state_ = kWaiting;
62
21
  onhello_cb_ = onhello_cb;
63
21
  onend_cb_ = onend_cb;
64
21
  cb_arg_ = cb_arg;
65
}
66
67
20
inline void ClientHelloParser::End() {
68
20
  if (state_ == kEnded)
69
    return;
70
20
  state_ = kEnded;
71
20
  if (onend_cb_ != nullptr) {
72
20
    onend_cb_(cb_arg_);
73
20
    onend_cb_ = nullptr;
74
  }
75
}
76
77
48594
inline bool ClientHelloParser::IsEnded() const {
78
48594
  return state_ == kEnded;
79
}
80
81
inline bool ClientHelloParser::IsPaused() const {
82
  return state_ == kPaused;
83
}
84
85
}  // namespace crypto
86
}  // namespace node
87
88
#endif  // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
89
90
#endif  // SRC_CRYPTO_CRYPTO_CLIENTHELLO_INL_H_