Correct PPTP server firewall rules chain.
[tomato/davidwu.git] / release / src / router / dropbear / channel.h
blob714669723df804b510f5a5e2a356a9b333dee0b3
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:
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
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. */
25 #ifndef _CHANNEL_H_
26 #define _CHANNEL_H_
28 #include "includes.h"
29 #include "buffer.h"
30 #include "circbuffer.h"
32 /* channel->type values */
33 #define CHANNEL_ID_NONE 0
34 #define CHANNEL_ID_SESSION 1
35 #define CHANNEL_ID_X11 2
36 #define CHANNEL_ID_AGENT 3
37 #define CHANNEL_ID_TCPDIRECT 4
38 #define CHANNEL_ID_TCPFORWARDED 5
40 #define SSH_OPEN_ADMINISTRATIVELY_PROHIBITED 1
41 #define SSH_OPEN_CONNECT_FAILED 2
42 #define SSH_OPEN_UNKNOWN_CHANNEL_TYPE 3
43 #define SSH_OPEN_RESOURCE_SHORTAGE 4
45 /* Not a real type */
46 #define SSH_OPEN_IN_PROGRESS 99
48 #define CHAN_EXTEND_SIZE 3 /* how many extra slots to add when we need more */
50 struct ChanType;
52 struct Channel {
54 unsigned int index; /* the local channel index */
55 unsigned int remotechan;
56 unsigned int recvwindow, transwindow;
57 unsigned int recvdonelen;
58 unsigned int recvmaxpacket, transmaxpacket;
59 void* typedata; /* a pointer to type specific data */
60 int writefd; /* read from wire, written to insecure side */
61 int readfd; /* read from insecure side, written to wire */
62 int errfd; /* used like writefd or readfd, depending if it's client or server.
63 Doesn't exactly belong here, but is cleaner here */
64 circbuffer *writebuf; /* data from the wire, for local consumption. Can be
65 initially NULL */
66 circbuffer *extrabuf; /* extended-data for the program - used like writebuf
67 but for stderr */
69 /* whether close/eof messages have been exchanged */
70 int sent_close, recv_close;
71 int recv_eof, sent_eof;
73 /* Set after running the ChanType-specific close hander
74 * to ensure we don't run it twice (nor type->checkclose()). */
75 int close_handler_done;
77 int initconn; /* used for TCP forwarding, whether the channel has been
78 fully initialised */
80 int await_open; /* flag indicating whether we've sent an open request
81 for this channel (and are awaiting a confirmation
82 or failure). */
84 int flushing;
86 /* Used by client chansession to handle ~ escaping, NULL ignored otherwise */
87 void (*read_mangler)(struct Channel*, unsigned char* bytes, int *len);
89 const struct ChanType* type;
92 struct ChanType {
94 int sepfds; /* Whether this channel has seperate pipes for in/out or not */
95 char *name;
96 int (*inithandler)(struct Channel*);
97 int (*check_close)(struct Channel*);
98 void (*reqhandler)(struct Channel*);
99 void (*closehandler)(struct Channel*);
103 void chaninitialise(const struct ChanType *chantypes[]);
104 void chancleanup();
105 void setchannelfds(fd_set *readfd, fd_set *writefd);
106 void channelio(fd_set *readfd, fd_set *writefd);
107 struct Channel* getchannel();
109 void recv_msg_channel_open();
110 void recv_msg_channel_request();
111 void send_msg_channel_failure(struct Channel *channel);
112 void send_msg_channel_success(struct Channel *channel);
113 void recv_msg_channel_data();
114 void recv_msg_channel_extended_data();
115 void recv_msg_channel_window_adjust();
116 void recv_msg_channel_close();
117 void recv_msg_channel_eof();
119 void common_recv_msg_channel_data(struct Channel *channel, int fd,
120 circbuffer * buf);
122 #ifdef DROPBEAR_CLIENT
123 extern const struct ChanType clichansess;
124 #endif
126 #if defined(USING_LISTENERS) || defined(DROPBEAR_CLIENT)
127 int send_msg_channel_open_init(int fd, const struct ChanType *type);
128 void recv_msg_channel_open_confirmation();
129 void recv_msg_channel_open_failure();
130 #endif
132 #endif /* _CHANNEL_H_ */