comparison channel.h @ 118:5312ca05ed48 private-rez

propagate of 717950f4061f1123659ee87c7c168805af920ab7 and 839f98f136788cc1466e4641bf796f96040a085d from branch 'matt.dbclient.authpam' to 'matt.dbclient.rez'
author Matt Johnston <matt@ucc.asn.au>
date Sun, 12 Sep 2004 04:56:50 +0000
parents 10f4d3319780
children 8c08fd2b7f5b
comparison
equal deleted inserted replaced
57:3b2a5a1c4347 118:5312ca05ed48
25 #ifndef _CHANNEL_H_ 25 #ifndef _CHANNEL_H_
26 #define _CHANNEL_H_ 26 #define _CHANNEL_H_
27 27
28 #include "includes.h" 28 #include "includes.h"
29 #include "buffer.h" 29 #include "buffer.h"
30 #include "circbuffer.h"
30 31
31 /* channel->type values */ 32 /* channel->type values */
32 #define CHANNEL_ID_NONE 0 33 #define CHANNEL_ID_NONE 0
33 #define CHANNEL_ID_SESSION 1 34 #define CHANNEL_ID_SESSION 1
34 #define CHANNEL_ID_X11 2 35 #define CHANNEL_ID_X11 2
39 #define SSH_OPEN_ADMINISTRATIVELY_PROHIBITED 1 40 #define SSH_OPEN_ADMINISTRATIVELY_PROHIBITED 1
40 #define SSH_OPEN_CONNECT_FAILED 2 41 #define SSH_OPEN_CONNECT_FAILED 2
41 #define SSH_OPEN_UNKNOWN_CHANNEL_TYPE 3 42 #define SSH_OPEN_UNKNOWN_CHANNEL_TYPE 3
42 #define SSH_OPEN_RESOURCE_SHORTAGE 4 43 #define SSH_OPEN_RESOURCE_SHORTAGE 4
43 44
44 #define MAX_CHANNELS 60 /* simple mem restriction, includes each tcp/x11 45 /* Not a real type */
46 #define SSH_OPEN_IN_PROGRESS 99
47
48 #define MAX_CHANNELS 100 /* simple mem restriction, includes each tcp/x11
45 connection, so can't be _too_ small */ 49 connection, so can't be _too_ small */
46 50
47 #define CHAN_EXTEND_SIZE 3 /* how many extra slots to add when we need more */ 51 #define CHAN_EXTEND_SIZE 3 /* how many extra slots to add when we need more */
48 52
49 #define RECV_MAXWINDOW 6000 /* tweak */ 53 #define RECV_MAXWINDOW 4000 /* tweak */
50 #define RECV_MAXPACKET 1400 /* tweak */ 54 #define RECV_WINDOWEXTEND 500 /* We send a "window extend" every
51 #define RECV_MINWINDOW 19000 /* when we get below this, we send a windowadjust */ 55 RECV_WINDOWEXTEND bytes */
56 #define RECV_MAXPACKET RECV_MAXWINDOW /* tweak */
52 57
53 struct ChanType; 58 struct ChanType;
54 59
55 struct Channel { 60 struct Channel {
56 61
57 unsigned int index; /* the local channel index */ 62 unsigned int index; /* the local channel index */
58 unsigned int remotechan; 63 unsigned int remotechan;
59 unsigned int recvwindow, transwindow; 64 unsigned int recvwindow, transwindow;
65 unsigned int recvdonelen;
60 unsigned int recvmaxpacket, transmaxpacket; 66 unsigned int recvmaxpacket, transmaxpacket;
61 void* typedata; /* a pointer to type specific data */ 67 void* typedata; /* a pointer to type specific data */
62 int infd; /* stdin for the program, we write to this */ 68 int infd; /* data to send over the wire */
63 int outfd; /* stdout for the program, we read from this */ 69 int outfd; /* data for consumption, what was in writebuf */
64 int errfd; /* stdout for a program. This doesn't really fit here, 70 int errfd; /* used like infd or errfd, depending if it's client or server.
65 but makes the code a lot tidyer without being too bad. This 71 Doesn't exactly belong here, but is cleaner here */
66 is -1 for channels which don't requre it. Currently only 72 circbuffer *writebuf; /* data from the wire, for local consumption */
67 a 'session' without a pty will use it */ 73 circbuffer *extrabuf; /* extended-data for the program - used like writebuf
68 buffer *writebuf; /* data for the program */ 74 but for stderr */
69 75
70 int sentclosed, recvclosed; 76 int sentclosed, recvclosed;
71 77
72 /* this is set when we receive/send a channel eof packet */ 78 /* this is set when we receive/send a channel eof packet */
73 int recveof, senteof; 79 int recveof, senteof;
92 98
93 void chaninitialise(); 99 void chaninitialise();
94 void chancleanup(); 100 void chancleanup();
95 void setchannelfds(fd_set *readfd, fd_set *writefd); 101 void setchannelfds(fd_set *readfd, fd_set *writefd);
96 void channelio(fd_set *readfd, fd_set *writefd); 102 void channelio(fd_set *readfd, fd_set *writefd);
103 struct Channel* getchannel(unsigned int chan);
97 struct Channel* newchannel(unsigned int remotechan, 104 struct Channel* newchannel(unsigned int remotechan,
98 const struct ChanType *type, 105 const struct ChanType *type,
99 unsigned int transwindow, unsigned int transmaxpacket); 106 unsigned int transwindow, unsigned int transmaxpacket);
100 107
101 void recv_msg_channel_open(); 108 void recv_msg_channel_open();
102 void recv_msg_channel_request(); 109 void recv_msg_channel_request();
103 void send_msg_channel_failure(struct Channel *channel); 110 void send_msg_channel_failure(struct Channel *channel);
104 void send_msg_channel_success(struct Channel *channel); 111 void send_msg_channel_success(struct Channel *channel);
105 void recv_msg_channel_data(); 112 void recv_msg_channel_data();
113 void recv_msg_channel_extended_data();
106 void recv_msg_channel_window_adjust(); 114 void recv_msg_channel_window_adjust();
107 void recv_msg_channel_close(); 115 void recv_msg_channel_close();
108 void recv_msg_channel_eof(); 116 void recv_msg_channel_eof();
117
118 void common_recv_msg_channel_data(struct Channel *channel, int fd,
119 circbuffer * buf);
120
121 const struct ChanType clichansess;
109 122
110 #ifdef USING_LISTENERS 123 #ifdef USING_LISTENERS
111 int send_msg_channel_open_init(int fd, const struct ChanType *type); 124 int send_msg_channel_open_init(int fd, const struct ChanType *type);
112 void recv_msg_channel_open_confirmation(); 125 void recv_msg_channel_open_confirmation();
113 void recv_msg_channel_open_failure(); 126 void recv_msg_channel_open_failure();