comparison common-channel.c @ 9:7f77962de998

- Reworked non-channel fd handling to listener.c - More channel cleaning up
author Matt Johnston <matt@ucc.asn.au>
date Thu, 03 Jun 2004 16:45:53 +0000
parents 425ed5c20157
children db2c8e6fb284
comparison
equal deleted inserted replaced
7:425ed5c20157 9:7f77962de998
30 #include "ssh.h" 30 #include "ssh.h"
31 #include "buffer.h" 31 #include "buffer.h"
32 #include "dbutil.h" 32 #include "dbutil.h"
33 #include "channel.h" 33 #include "channel.h"
34 #include "ssh.h" 34 #include "ssh.h"
35 #include "localtcpfwd.h" 35 #include "tcpfwd-direct.h"
36 #include "remotetcpfwd.h" 36 #include "tcpfwd-remote.h"
37 #include "tcpfwd.h" 37 #include "listener.h"
38 38
39 static void send_msg_channel_open_failure(unsigned int remotechan, int reason, 39 static void send_msg_channel_open_failure(unsigned int remotechan, int reason,
40 const unsigned char *text, const unsigned char *lang); 40 const unsigned char *text, const unsigned char *lang);
41 static void send_msg_channel_open_confirmation(struct Channel* channel, 41 static void send_msg_channel_open_confirmation(struct Channel* channel,
42 unsigned int recvwindow, 42 unsigned int recvwindow,
68 ses.chansize = 1; 68 ses.chansize = 1;
69 ses.channels[0] = NULL; 69 ses.channels[0] = NULL;
70 70
71 ses.chantypes = chantypes; 71 ses.chantypes = chantypes;
72 72
73 #ifdef USING_TCP_LISTENERS 73 #ifdef USING_LISTENERS
74 tcp_fwd_initialise(); 74 listeners_initialise();
75 #endif 75 #endif
76 76
77 } 77 }
78 78
79 /* Clean up channels, freeing allocated memory */ 79 /* Clean up channels, freeing allocated memory */
217 /* now handle any of the channel-closing type stuff */ 217 /* now handle any of the channel-closing type stuff */
218 checkclose(channel); 218 checkclose(channel);
219 219
220 } /* foreach channel */ 220 } /* foreach channel */
221 221
222 /* Not channel specific */ 222 /* Listeners such as TCP, X11, agent-auth */
223 #ifdef USING_TCP_LISTENERS 223 #ifdef USING_LISTENERS
224 handle_tcp_fwd(readfd); 224 handle_listeners(readfd);
225 #endif 225 #endif
226 } 226 }
227 227
228 228
229 /* do all the EOF/close type stuff checking for a channel */ 229 /* do all the EOF/close type stuff checking for a channel */
427 FD_SET(channel->infd, writefd); 427 FD_SET(channel->infd, writefd);
428 } 428 }
429 429
430 } /* foreach channel */ 430 } /* foreach channel */
431 431
432 #ifdef USING_TCP_LISTENERS 432 #ifdef USING_LISTENERS
433 set_tcp_fwd_fds(readfd); 433 set_listener_fds(readfd);
434 #endif 434 #endif
435 435
436 } 436 }
437 437
438 /* handle the channel EOF event, by closing the channel filedescriptor. The 438 /* handle the channel EOF event, by closing the channel filedescriptor. The
893 /* Create a new channel, and start the open request. This is intended 893 /* Create a new channel, and start the open request. This is intended
894 * for X11, agent, tcp forwarding, and should be filled with channel-specific 894 * for X11, agent, tcp forwarding, and should be filled with channel-specific
895 * options, with the calling function calling encrypt_packet() after 895 * options, with the calling function calling encrypt_packet() after
896 * completion. It is mandatory for the caller to encrypt_packet() if 896 * completion. It is mandatory for the caller to encrypt_packet() if
897 * DROPBEAR_SUCCESS is returned */ 897 * DROPBEAR_SUCCESS is returned */
898 int send_msg_channel_open_init(int fd, struct ChanType *type, 898 int send_msg_channel_open_init(int fd, const struct ChanType *type) {
899 const char * typestring) {
900 899
901 struct Channel* chan; 900 struct Channel* chan;
902 901
903 TRACE(("enter send_msg_channel_open_init()")); 902 TRACE(("enter send_msg_channel_open_init()"));
904 chan = newchannel(0, type, 0, 0); 903 chan = newchannel(0, type, 0, 0);
918 917
919 /* now open the channel connection */ 918 /* now open the channel connection */
920 CHECKCLEARTOWRITE(); 919 CHECKCLEARTOWRITE();
921 920
922 buf_putbyte(ses.writepayload, SSH_MSG_CHANNEL_OPEN); 921 buf_putbyte(ses.writepayload, SSH_MSG_CHANNEL_OPEN);
923 buf_putstring(ses.writepayload, typestring, strlen(typestring)); 922 buf_putstring(ses.writepayload, type->name, strlen(type->name));
924 buf_putint(ses.writepayload, chan->index); 923 buf_putint(ses.writepayload, chan->index);
925 buf_putint(ses.writepayload, RECV_MAXWINDOW); 924 buf_putint(ses.writepayload, RECV_MAXWINDOW);
926 buf_putint(ses.writepayload, RECV_MAXPACKET); 925 buf_putint(ses.writepayload, RECV_MAXPACKET);
927 926
928 TRACE(("leave send_msg_channel_open_init()")); 927 TRACE(("leave send_msg_channel_open_init()"));