Coverage Report

Created: 2025-06-20 06:37

/src/wpantund/src/util/SocketAdapter.cpp
Line
Count
Source (jump to first uncovered line)
1
/*
2
 *
3
 * Copyright (c) 2016 Nest Labs, Inc.
4
 * All rights reserved.
5
 *
6
 * Licensed under the Apache License, Version 2.0 (the "License");
7
 * you may not use this file except in compliance with the License.
8
 * You may obtain a copy of the License at
9
 *
10
 *     http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing, software
13
 * distributed under the License is distributed on an "AS IS" BASIS,
14
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 * See the License for the specific language governing permissions and
16
 * limitations under the License.
17
 *
18
 *    Description:
19
 *      This file contains the implementation of the SocketAdapter class,
20
 *      which is a base class for implementing "soft" sockets that
21
 *      use other sockets (for things like reliability layers, etc).
22
 *
23
 */
24
25
#if HAVE_CONFIG_H
26
#include <config.h>
27
#endif
28
29
#include "SocketAdapter.h"
30
#include <errno.h>
31
32
using namespace nl;
33
34
const boost::shared_ptr<SocketWrapper>&
35
SocketAdapter::set_parent(boost::shared_ptr<SocketWrapper> parent)
36
0
{
37
0
  return mParent = parent;
38
0
}
39
40
const boost::shared_ptr<SocketWrapper>&
41
SocketAdapter::get_parent()
42
0
{
43
0
  return mParent;
44
0
}
45
46
SocketAdapter::SocketAdapter(boost::shared_ptr<SocketWrapper> parent)
47
0
  :mParent(parent)
48
0
{
49
0
}
50
51
int
52
SocketAdapter::hibernate(void)
53
0
{
54
0
  return mParent ? mParent->hibernate() : -EINVAL;
55
0
}
56
57
ssize_t
58
SocketAdapter::write(const void* data, size_t len)
59
0
{
60
0
  return mParent ? mParent->write(data, len) : -EINVAL;
61
0
}
62
63
off_t
64
SocketAdapter::lseek(off_t offset, int whence)
65
0
{
66
0
  return mParent ? mParent->lseek(offset, whence) : -EINVAL;
67
0
}
68
69
ssize_t
70
SocketAdapter::read(void* data, size_t len)
71
0
{
72
0
  return mParent ? mParent->read(data, len) : -EINVAL;
73
0
}
74
75
bool
76
SocketAdapter::can_read(void)const
77
0
{
78
0
  return mParent ? mParent->can_read() : false;
79
0
}
80
81
bool
82
SocketAdapter::can_write(void)const
83
0
{
84
0
  return mParent ? mParent->can_write() : false;
85
0
}
86
87
int
88
SocketAdapter::get_read_fd(void)const
89
0
{
90
0
  return mParent ? mParent->get_read_fd() : -EINVAL;
91
0
}
92
93
int
94
SocketAdapter::get_write_fd(void)const
95
0
{
96
0
  return mParent ? mParent->get_write_fd() : -EINVAL;
97
0
}
98
99
int
100
SocketAdapter::process(void)
101
0
{
102
0
  return mParent ? mParent->process() : 0;
103
0
}
104
105
void
106
SocketAdapter::reset()
107
0
{
108
0
  if(mParent)
109
0
    mParent->reset();
110
0
}
111
112
void
113
SocketAdapter::send_break()
114
0
{
115
0
  if(mParent)
116
0
    mParent->send_break();
117
0
};
118
119
bool
120
SocketAdapter::did_reset()
121
0
{
122
0
  return mParent ? mParent->did_reset() : false;
123
0
}
124
125
cms_t
126
SocketAdapter::get_ms_to_next_event(void)const
127
0
{
128
0
  return mParent ? mParent->get_ms_to_next_event() : CMS_DISTANT_FUTURE;
129
0
}
130
131
int
132
SocketAdapter::update_fd_set(fd_set *read_fd_set, fd_set *write_fd_set, fd_set *error_fd_set, int *max_fd, cms_t *timeout)
133
0
{
134
0
  return mParent ? mParent->update_fd_set(read_fd_set, write_fd_set, error_fd_set, max_fd, timeout) : 0;
135
0
}