Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
LSH
lsh
Commits
2cfcc789
Commit
2cfcc789
authored
Nov 18, 1998
by
Niels Möller
Browse files
Added eof and close callbacks to channels.
Rev: src/channel.c:1.12 Rev: src/channel.h:1.14
parent
6f57ea82
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/channel.c
View file @
2cfcc789
...
...
@@ -233,6 +233,9 @@ static int channel_process_status(struct channel_table *table,
{
/* Clear this bit */
status
&=
~
LSH_CHANNEL_FINISHED
;
if
(
table
->
channels
[
channel
]
->
close
)
CHANNEL_CLOSE
(
table
->
channels
[
channel
]);
dealloc_channel
(
table
,
channel
);
...
...
@@ -653,6 +656,8 @@ static int do_channel_eof(struct packet_handler *c,
if
(
channel
)
{
int
res
=
0
;
if
(
channel
->
flags
&
(
CHANNEL_RECIEVED_EOF
|
CHANNEL_RECIEVED_CLOSE
))
{
werror
(
"Recieving EOF on channel on closed channel.
\n
"
);
...
...
@@ -660,24 +665,23 @@ static int do_channel_eof(struct packet_handler *c,
}
channel
->
flags
|=
CHANNEL_RECIEVED_EOF
;
if
(
channel
->
flags
&
CHANNEL_SENT_CLOSE
)
/* Do nothing */
return
LSH_OK
|
LSH_GOON
;
if
(
channel
->
flags
&
CHANNEL_SENT_EOF
)
if
(
channel
->
eof
)
res
=
CHANNEL_EOF
(
channel
);
if
(
!
LSH_CLOSEDP
(
res
)
&&
!
(
channel
->
flags
&
CHANNEL_SENT_CLOSE
)
&&
(
channel
->
flags
&
CHANNEL_SENT_EOF
))
{
/* Both parties have sent EOF. Initiate close, if we
* havn't done that already. */
if
(
channel
->
flags
&
CHANNEL_SENT_CLOSE
)
return
LSH_OK
|
LSH_GOON
;
else
return
channel_process_status
(
closure
->
table
,
channel_number
,
channel_close
(
channel
));
res
|=
channel_close
(
channel
);
}
return
LSH_OK
|
LSH_GOON
;
return
channel_process_status
(
closure
->
table
,
channel_number
,
res
);
}
werror
(
"EOF on non-existant channel %d
\n
"
,
channel_number
);
...
...
@@ -726,6 +730,10 @@ static int do_channel_close(struct packet_handler *c,
{
werror
(
"Unexpected channel CLOSE.
\n
"
);
}
if
(
!
(
channel
->
flags
&
(
CHANNEL_RECIEVED_EOF
))
&&
channel
->
eof
)
CHANNEL_EOF
(
channel
);
return
channel_process_status
(
closure
->
table
,
channel_number
,
...
...
@@ -1049,7 +1057,7 @@ int channel_eof(struct ssh_channel *channel)
if
(
LSH_CLOSEDP
(
res
))
return
res
;
if
(
channel
->
flags
&
(
CHANNEL_RECIEVED_EOF
|
CHANNEL_CLOSE_AT_E
ND_OF_FILE
))
if
(
channel
->
flags
&
(
CHANNEL_RECIEVED_EOF
|
CHANNEL_CLOSE_AT_E
OF
))
{
/* Initiate close */
res
|=
channel_close
(
channel
);
...
...
@@ -1069,10 +1077,10 @@ void init_channel(struct ssh_channel *channel)
channel
->
request_types
=
NULL
;
channel
->
recieve
=
NULL
;
channel
->
send
=
NULL
;
#if 0
channel
->
close
=
NULL
;
channel
->
eof
=
NULL
;
#endif
channel
->
open_confirm
=
NULL
;
channel
->
open_failure
=
NULL
;
channel
->
channel_success
=
NULL
;
...
...
src/channel.h
View file @
2cfcc789
...
...
@@ -31,7 +31,7 @@
#define CHANNEL_RECIEVED_EOF 8
/* Means that we should send close immediately after sending eof. */
#define CHANNEL_CLOSE_AT_E
ND_OF_FILE
0x10
#define CHANNEL_CLOSE_AT_E
OF
0x10
struct
ssh_channel
{
...
...
@@ -71,10 +71,12 @@ struct ssh_channel
/* Called when we are allowed to send data on the channel. */
int
(
*
send
)(
struct
ssh_channel
*
self
);
#if 0
int (*close)(struct ssh_channel *self);
/* Called when the channel is closed */
void
(
*
close
)(
struct
ssh_channel
*
self
);
/* Called when eof is recieved on the channel (or when it is closed,
* whatever happens first). */
int
(
*
eof
)(
struct
ssh_channel
*
self
);
#endif
/* Reply from SSH_MSG_CHANNEL_OPEN_REQUEST */
int
(
*
open_confirm
)(
struct
ssh_channel
*
self
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment