Mercurial > dropbear
comparison channel.h @ 4:fe6bca95afa7
Makefile.in contains updated files required
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Tue, 01 Jun 2004 02:46:09 +0000 |
parents | |
children | 425ed5c20157 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 4:fe6bca95afa7 |
---|---|
1 /* | |
2 * Dropbear - a SSH2 server | |
3 * | |
4 * Copyright (c) 2002,2003 Matt Johnston | |
5 * All rights reserved. | |
6 * | |
7 * Permission is hereby granted, free of charge, to any person obtaining a copy | |
8 * of this software and associated documentation files (the "Software"), to deal | |
9 * in the Software without restriction, including without limitation the rights | |
10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
11 * copies of the Software, and to permit persons to whom the Software is | |
12 * furnished to do so, subject to the following conditions: | |
13 * | |
14 * The above copyright notice and this permission notice shall be included in | |
15 * all copies or substantial portions of the Software. | |
16 * | |
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |
23 * SOFTWARE. */ | |
24 | |
25 #ifndef _CHANNEL_H_ | |
26 #define _CHANNEL_H_ | |
27 | |
28 #include "includes.h" | |
29 #include "buffer.h" | |
30 | |
31 /* channel->type values */ | |
32 #define CHANNEL_ID_NONE 0 | |
33 #define CHANNEL_ID_SESSION 1 | |
34 #define CHANNEL_ID_X11 2 | |
35 #define CHANNEL_ID_AGENT 3 | |
36 #define CHANNEL_ID_TCPDIRECT 4 | |
37 #define CHANNEL_ID_TCPFORWARDED 5 | |
38 | |
39 #define SSH_OPEN_ADMINISTRATIVELY_PROHIBITED 1 | |
40 #define SSH_OPEN_CONNECT_FAILED 2 | |
41 #define SSH_OPEN_UNKNOWN_CHANNEL_TYPE 3 | |
42 #define SSH_OPEN_RESOURCE_SHORTAGE 4 | |
43 | |
44 #define MAX_CHANNELS 60 /* simple mem restriction, includes each tcp/x11 | |
45 connection, so can't be _too_ small */ | |
46 | |
47 #define CHAN_EXTEND_SIZE 3 /* how many extra slots to add when we need more */ | |
48 | |
49 #define RECV_MAXWINDOW 6000 /* tweak */ | |
50 #define RECV_MAXPACKET 1400 /* tweak */ | |
51 #define RECV_MINWINDOW 19000 /* when we get below this, we send a windowadjust */ | |
52 | |
53 /* a simpler way to define that we need code for listeners */ | |
54 #if !defined(DISABLE_X11FWD) || !defined(DISABLE_AUTHFWD) || \ | |
55 !defined(DISABLE_REMOTETCPFWD) | |
56 #define USE_LISTENERS | |
57 #endif | |
58 | |
59 struct ChanType; | |
60 | |
61 struct Channel { | |
62 | |
63 unsigned int index; /* the local channel index */ | |
64 unsigned int remotechan; | |
65 unsigned int recvwindow, transwindow; | |
66 unsigned int recvmaxpacket, transmaxpacket; | |
67 void* typedata; /* a pointer to type specific data */ | |
68 int infd; /* stdin for the program, we write to this */ | |
69 int outfd; /* stdout for the program, we read from this */ | |
70 int errfd; /* stdout for a program. This doesn't really fit here, | |
71 but makes the code a lot tidyer without being too bad. This | |
72 is -1 for channels which don't requre it. Currently only | |
73 a 'session' without a pty will use it */ | |
74 buffer *writebuf; /* data for the program */ | |
75 | |
76 int sentclosed, recvclosed; | |
77 | |
78 /* this is set when we receive/send a channel eof packet */ | |
79 int recveof, senteof; | |
80 | |
81 int initconn; /* used for TCP forwarding, whether the channel has been | |
82 fully initialised */ | |
83 | |
84 struct ChanType* type; | |
85 | |
86 }; | |
87 | |
88 struct ChanType { | |
89 | |
90 int sepfds; /* Whether this channel has seperate pipes for in/out or not */ | |
91 char *name; | |
92 int (*inithandler)(struct Channel*); | |
93 int (*checkclose)(struct Channel*); | |
94 void (*reqhandler)(struct Channel*); | |
95 void (*closehandler)(struct Channel*); | |
96 | |
97 }; | |
98 | |
99 void chaninitialise(); | |
100 void chancleanup(); | |
101 void setchannelfds(fd_set *readfd, fd_set *writefd); | |
102 void channelio(fd_set *readfd, fd_set *writefd); | |
103 struct Channel* newchannel(unsigned int remotechan, struct ChanType *type, | |
104 unsigned int transwindow, unsigned int transmaxpacket); | |
105 | |
106 void recv_msg_channel_open(); | |
107 void recv_msg_channel_request(); | |
108 void send_msg_channel_failure(struct Channel *channel); | |
109 void send_msg_channel_success(struct Channel *channel); | |
110 void recv_msg_channel_data(); | |
111 void recv_msg_channel_window_adjust(); | |
112 void recv_msg_channel_close(); | |
113 void recv_msg_channel_eof(); | |
114 | |
115 #ifdef USE_LISTENERS | |
116 int send_msg_channel_open_init(int fd, struct ChanType *type, | |
117 const char * typestring); | |
118 void recv_msg_channel_open_confirmation(); | |
119 void recv_msg_channel_open_failure(); | |
120 #endif | |
121 | |
122 #endif /* _CHANNEL_H_ */ |