comparison channel.h @ 107:d3eb1fa8484e

Nasty.
author Matt Johnston <matt@ucc.asn.au>
date Tue, 24 Aug 2004 18:12:18 +0000
parents b0316ce64e4b
children 10f4d3319780
comparison
equal deleted inserted replaced
106:e13f8a712a1c 107:d3eb1fa8484e
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
48 connection, so can't be _too_ small */ 49 connection, so can't be _too_ small */
49 50
50 #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 */
51 52
52 #define RECV_MAXWINDOW 6000 /* tweak */ 53 #define RECV_MAXWINDOW 6000 /* tweak */
54 #define RECV_WINDOWEXTEND (RECV_MAXWINDOW/2) /* We send a "window extend" every
55 RECV_WINDOWEXTEND bytes */
53 #define RECV_MAXPACKET 1400 /* tweak */ 56 #define RECV_MAXPACKET 1400 /* tweak */
54 #define RECV_MINWINDOW 19000 /* when we get below this, we send a windowadjust */ 57 #define RECV_MINWINDOW 19000 /* when we get below this, we send a windowadjust */
55 58
56 struct ChanType; 59 struct ChanType;
57 60
60 unsigned int index; /* the local channel index */ 63 unsigned int index; /* the local channel index */
61 unsigned int remotechan; 64 unsigned int remotechan;
62 unsigned int recvwindow, transwindow; 65 unsigned int recvwindow, transwindow;
63 unsigned int recvmaxpacket, transmaxpacket; 66 unsigned int recvmaxpacket, transmaxpacket;
64 void* typedata; /* a pointer to type specific data */ 67 void* typedata; /* a pointer to type specific data */
65 int infd; /* stdin for the program, we write to this */ 68 int infd; /* data to send over the wire */
66 int outfd; /* stdout for the program, we read from this */ 69 int outfd; /* data for consumption, what was in writebuf */
67 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.
68 but makes the code a lot tidyer without being too bad. This 71 Doesn't exactly belong here, but is cleaner here */
69 is -1 for channels which don't requre it. Currently only 72 circbuffer *writebuf; /* data from the wire, for local consumption */
70 a 'session' without a pty will use it */ 73 circbuffer *extrabuf; /* extended-data for the program - used like writebuf
71 buffer *writebuf; /* data for the program */ 74 but for stderr */
72 75
73 int sentclosed, recvclosed; 76 int sentclosed, recvclosed;
74 77
75 /* this is set when we receive/send a channel eof packet */ 78 /* this is set when we receive/send a channel eof packet */
76 int recveof, senteof; 79 int recveof, senteof;
95 98
96 void chaninitialise(); 99 void chaninitialise();
97 void chancleanup(); 100 void chancleanup();
98 void setchannelfds(fd_set *readfd, fd_set *writefd); 101 void setchannelfds(fd_set *readfd, fd_set *writefd);
99 void channelio(fd_set *readfd, fd_set *writefd); 102 void channelio(fd_set *readfd, fd_set *writefd);
103 struct Channel* getchannel(unsigned int chan);
100 struct Channel* newchannel(unsigned int remotechan, 104 struct Channel* newchannel(unsigned int remotechan,
101 const struct ChanType *type, 105 const struct ChanType *type,
102 unsigned int transwindow, unsigned int transmaxpacket); 106 unsigned int transwindow, unsigned int transmaxpacket);
103 107
104 void recv_msg_channel_open(); 108 void recv_msg_channel_open();
105 void recv_msg_channel_request(); 109 void recv_msg_channel_request();
106 void send_msg_channel_failure(struct Channel *channel); 110 void send_msg_channel_failure(struct Channel *channel);
107 void send_msg_channel_success(struct Channel *channel); 111 void send_msg_channel_success(struct Channel *channel);
108 void recv_msg_channel_data(); 112 void recv_msg_channel_data();
113 void recv_msg_channel_extended_data();
109 void recv_msg_channel_window_adjust(); 114 void recv_msg_channel_window_adjust();
110 void recv_msg_channel_close(); 115 void recv_msg_channel_close();
111 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;
112 122
113 #ifdef USING_LISTENERS 123 #ifdef USING_LISTENERS
114 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);
115 void recv_msg_channel_open_confirmation(); 125 void recv_msg_channel_open_confirmation();
116 void recv_msg_channel_open_failure(); 126 void recv_msg_channel_open_failure();