Mercurial > dropbear
comparison common-channel.c @ 7:425ed5c20157
Chantype handling is sorted
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Wed, 02 Jun 2004 04:59:49 +0000 |
parents | ab00ef513e97 |
children | 7f77962de998 |
comparison
equal
deleted
inserted
replaced
6:ab00ef513e97 | 7:425ed5c20157 |
---|---|
94 | 94 |
95 /* Create a new channel entry, send a reply confirm or failure */ | 95 /* Create a new channel entry, send a reply confirm or failure */ |
96 /* If remotechan, transwindow and transmaxpacket are not know (for a new | 96 /* If remotechan, transwindow and transmaxpacket are not know (for a new |
97 * outgoing connection, with them to be filled on confirmation), they should | 97 * outgoing connection, with them to be filled on confirmation), they should |
98 * all be set to 0 */ | 98 * all be set to 0 */ |
99 struct Channel* newchannel(unsigned int remotechan, struct ChanType *type, | 99 struct Channel* newchannel(unsigned int remotechan, |
100 const struct ChanType *type, | |
100 unsigned int transwindow, unsigned int transmaxpacket) { | 101 unsigned int transwindow, unsigned int transmaxpacket) { |
101 | 102 |
102 struct Channel * newchan; | 103 struct Channel * newchan; |
103 unsigned int i, j; | 104 unsigned int i, j; |
104 | 105 |
533 if (channel == NULL) { | 534 if (channel == NULL) { |
534 /* disconnect ? */ | 535 /* disconnect ? */ |
535 dropbear_exit("Unknown channel"); | 536 dropbear_exit("Unknown channel"); |
536 } | 537 } |
537 | 538 |
538 TRACE(("chan type is %d", channel->type)); | |
539 | |
540 if (channel->type->reqhandler) { | 539 if (channel->type->reqhandler) { |
541 channel->type->reqhandler(channel); | 540 channel->type->reqhandler(channel); |
542 } else { | 541 } else { |
543 send_msg_channel_failure(channel); | 542 send_msg_channel_failure(channel); |
544 } | 543 } |
735 | 734 |
736 unsigned char *type; | 735 unsigned char *type; |
737 unsigned int typelen; | 736 unsigned int typelen; |
738 unsigned int remotechan, transwindow, transmaxpacket; | 737 unsigned int remotechan, transwindow, transmaxpacket; |
739 struct Channel *channel; | 738 struct Channel *channel; |
739 const struct ChanType **cp; | |
740 const struct ChanType *chantype; | 740 const struct ChanType *chantype; |
741 unsigned int errtype = SSH_OPEN_UNKNOWN_CHANNEL_TYPE; | 741 unsigned int errtype = SSH_OPEN_UNKNOWN_CHANNEL_TYPE; |
742 int ret; | 742 int ret; |
743 | 743 |
744 | 744 |
756 /* figure what type of packet it is */ | 756 /* figure what type of packet it is */ |
757 if (typelen > MAX_NAME_LEN) { | 757 if (typelen > MAX_NAME_LEN) { |
758 goto failure; | 758 goto failure; |
759 } | 759 } |
760 | 760 |
761 /* Get the channel type. This will depend if it is a client or a server, | 761 /* Get the channel type. Client and server style invokation will set up a |
762 * so we iterate through the connection-specific list which was | 762 * different list for ses.chantypes at startup. We just iterate through |
763 * set up when the connection started */ | 763 * this list and find the matching name */ |
764 for (chantype = ses.chantypes[0]; chantype != NULL; chantype++) { | 764 for (cp = &ses.chantypes[0], chantype = (*cp); |
765 chantype != NULL; | |
766 cp++, chantype = (*cp)) { | |
765 if (strcmp(type, chantype->name) == 0) { | 767 if (strcmp(type, chantype->name) == 0) { |
766 break; | 768 break; |
767 } | 769 } |
768 } | 770 } |
769 | 771 |
770 if (chantype == NULL) { | 772 if (chantype == NULL) { |
773 TRACE(("No matching type for '%s'", type)); | |
771 goto failure; | 774 goto failure; |
772 } | 775 } |
776 | |
777 TRACE(("matched type '%s'", type)); | |
773 | 778 |
774 /* create the channel */ | 779 /* create the channel */ |
775 channel = newchannel(remotechan, chantype, transwindow, transmaxpacket); | 780 channel = newchannel(remotechan, chantype, transwindow, transmaxpacket); |
776 | 781 |
777 if (channel == NULL) { | 782 if (channel == NULL) { |