Joedb
9.1.4
The Journal-Only Embedded Database
Loading...
Searching...
No Matches
src
joedb
ssh
Forward_Channel.cpp
Go to the documentation of this file.
1
#include "
joedb/ssh/Forward_Channel.h
"
2
3
namespace
joedb::ssh
4
{
5
///////////////////////////////////////////////////////////////////////////
6
Forward_Channel_Allocation::Forward_Channel_Allocation
(
Session
&session):
7
///////////////////////////////////////////////////////////////////////////
8
channel(ssh_channel_new(session.get()))
9
{
10
check_not_null
(
channel
);
11
}
12
13
///////////////////////////////////////////////////////////////////////////
14
Forward_Channel_Allocation::~Forward_Channel_Allocation
()
15
///////////////////////////////////////////////////////////////////////////
16
{
17
ssh_channel_free(
channel
);
18
}
19
20
///////////////////////////////////////////////////////////////////////////
21
size_t
Forward_Channel::write_some(
const
char
*data,
size_t
size)
22
///////////////////////////////////////////////////////////////////////////
23
{
24
const
int
result
=
ssh_channel_write
(
channel
, data,
uint32_t
(size));
25
26
if
(
result
==
SSH_ERROR
)
27
throw
Exception
(
"Error writing to channel"
);
28
29
return
size_t
(
result
);
30
}
31
32
///////////////////////////////////////////////////////////////////////////
33
size_t
Forward_Channel::read_some(
char
*data,
size_t
size)
34
///////////////////////////////////////////////////////////////////////////
35
{
36
const
int
result
=
ssh_channel_read
(
channel
, data,
uint32_t
(size), 0);
37
38
if
(
result
==
SSH_ERROR
)
39
throw
Exception
(
"Error reading from channel"
);
40
41
if
(
result
== 0)
42
throw
Exception
(
"End of file when reading from channel"
);
43
44
return
size_t
(
result
);
45
}
46
47
///////////////////////////////////////////////////////////////////////////
48
Forward_Channel::Forward_Channel
49
///////////////////////////////////////////////////////////////////////////
50
(
51
Session
&session,
52
const
char
*remote_host,
53
uint16_t remote_port
54
):
55
Forward_Channel_Allocation
(session)
56
{
57
session.check_result
58
(
59
ssh_channel_open_forward
60
(
61
channel
,
62
remote_host
,
63
remote_port
,
64
""
,
// unused parameter
65
0
// unused parameter
66
)
67
);
68
}
69
}
70
Forward_Channel.h
joedb::Channel::read
void read(char *data, size_t size)
Definition
Channel.cpp:12
joedb::Exception
Definition
Exception.h:10
joedb::ssh::Forward_Channel_Allocation
Definition
Forward_Channel.h:12
joedb::ssh::Forward_Channel_Allocation::channel
const ssh_channel channel
Definition
Forward_Channel.h:14
joedb::ssh::Forward_Channel_Allocation::~Forward_Channel_Allocation
~Forward_Channel_Allocation()
Definition
Forward_Channel.cpp:14
joedb::ssh::Forward_Channel_Allocation::Forward_Channel_Allocation
Forward_Channel_Allocation(Session &session)
Definition
Forward_Channel.cpp:6
joedb::ssh::Forward_Channel::Forward_Channel
Forward_Channel(Session &session, const char *remote_host, uint16_t remote_port)
Definition
Forward_Channel.cpp:50
joedb::ssh::Session
Definition
Session.h:116
joedb::ssh
C++ wrappers for libssh.
Definition
Forward_Channel.cpp:4
joedb::ssh::check_not_null
void check_not_null(void *p)
Definition
ssh.h:13
Generated by
1.9.8