comparison common-channel.c @ 37:0913e2ee3545

we're nearly there yet
author Matt Johnston <matt@ucc.asn.au>
date Fri, 30 Jul 2004 03:02:19 +0000
parents db2c8e6fb284
children 20563735e8b5
comparison
equal deleted inserted replaced
36:a600c015562d 37:0913e2ee3545
65 65
66 /* may as well create space for a single channel */ 66 /* may as well create space for a single channel */
67 ses.channels = (struct Channel**)m_malloc(sizeof(struct Channel*)); 67 ses.channels = (struct Channel**)m_malloc(sizeof(struct Channel*));
68 ses.chansize = 1; 68 ses.chansize = 1;
69 ses.channels[0] = NULL; 69 ses.channels[0] = NULL;
70 ses.chancount = 0;
70 71
71 ses.chantypes = chantypes; 72 ses.chantypes = chantypes;
72 73
73 #ifdef USING_LISTENERS 74 #ifdef USING_LISTENERS
74 listeners_initialise(); 75 listeners_initialise();
151 newchan->writebuf = buf_new(RECV_MAXWINDOW); 152 newchan->writebuf = buf_new(RECV_MAXWINDOW);
152 newchan->recvwindow = RECV_MAXWINDOW; 153 newchan->recvwindow = RECV_MAXWINDOW;
153 newchan->recvmaxpacket = RECV_MAXPACKET; 154 newchan->recvmaxpacket = RECV_MAXPACKET;
154 155
155 ses.channels[i] = newchan; 156 ses.channels[i] = newchan;
157 ses.chancount++;
156 158
157 TRACE(("leave newchannel")); 159 TRACE(("leave newchannel"));
158 160
159 return newchan; 161 return newchan;
160 } 162 }
513 /* Remove a channel entry */ 515 /* Remove a channel entry */
514 static void deletechannel(struct Channel *channel) { 516 static void deletechannel(struct Channel *channel) {
515 517
516 ses.channels[channel->index] = NULL; 518 ses.channels[channel->index] = NULL;
517 m_free(channel); 519 m_free(channel);
520 ses.chancount--;
518 521
519 } 522 }
520 523
521 524
522 /* Handle channel specific requests, passing off to corresponding handlers 525 /* Handle channel specific requests, passing off to corresponding handlers
932 * successful*/ 935 * successful*/
933 void recv_msg_channel_open_confirmation() { 936 void recv_msg_channel_open_confirmation() {
934 937
935 unsigned int chan; 938 unsigned int chan;
936 struct Channel * channel; 939 struct Channel * channel;
940 int ret;
937 941
938 TRACE(("enter recv_msg_channel_open_confirmation")); 942 TRACE(("enter recv_msg_channel_open_confirmation"));
939 chan = buf_getint(ses.payload); 943 chan = buf_getint(ses.payload);
940 944
941 channel = getchannel(chan); 945 channel = getchannel(chan);
946 channel->remotechan = buf_getint(ses.payload); 950 channel->remotechan = buf_getint(ses.payload);
947 channel->transwindow = buf_getint(ses.payload); 951 channel->transwindow = buf_getint(ses.payload);
948 channel->transmaxpacket = buf_getint(ses.payload); 952 channel->transmaxpacket = buf_getint(ses.payload);
949 953
950 TRACE(("new chan remote %d localho %d", channel->remotechan, chan)); 954 TRACE(("new chan remote %d localho %d", channel->remotechan, chan));
955
956 /* Run the inithandler callback */
957 if (channel->type->inithandler) {
958 ret = channel->type->inithandler(channel);
959 if (ret > 0) {
960 removechannel(channel);
961 TRACE(("inithandler returned failure %d", ret));
962 }
963 }
951 964
952 965
953 TRACE(("leave recv_msg_channel_open_confirmation")); 966 TRACE(("leave recv_msg_channel_open_confirmation"));
954 } 967 }
955 968