comparison common-channel.c @ 1121:bb3a03feb31f

Merge pull request #13 from gazoo74/fix-warnings Fix warnings
author Matt Johnston <matt@ucc.asn.au>
date Thu, 04 Jun 2015 22:25:28 +0800
parents f95b6e87cd0c
children aaf576b27a10
comparison
equal deleted inserted replaced
1087:1e486f368ec3 1121:bb3a03feb31f
36 #include "listener.h" 36 #include "listener.h"
37 #include "runopts.h" 37 #include "runopts.h"
38 #include "netio.h" 38 #include "netio.h"
39 39
40 static void send_msg_channel_open_failure(unsigned int remotechan, int reason, 40 static void send_msg_channel_open_failure(unsigned int remotechan, int reason,
41 const unsigned char *text, const unsigned char *lang); 41 const char *text, const char *lang);
42 static void send_msg_channel_open_confirmation(struct Channel* channel, 42 static void send_msg_channel_open_confirmation(struct Channel* channel,
43 unsigned int recvwindow, 43 unsigned int recvwindow,
44 unsigned int recvmaxpacket); 44 unsigned int recvmaxpacket);
45 static void writechannel(struct Channel* channel, int fd, circbuffer *cbuf, 45 static void writechannel(struct Channel* channel, int fd, circbuffer *cbuf,
46 const unsigned char *moredata, unsigned int *morelen); 46 const unsigned char *moredata, unsigned int *morelen);
919 } 919 }
920 920
921 /* Handle a new channel request, performing any channel-type-specific setup */ 921 /* Handle a new channel request, performing any channel-type-specific setup */
922 void recv_msg_channel_open() { 922 void recv_msg_channel_open() {
923 923
924 unsigned char *type; 924 char *type;
925 unsigned int typelen; 925 unsigned int typelen;
926 unsigned int remotechan, transwindow, transmaxpacket; 926 unsigned int remotechan, transwindow, transmaxpacket;
927 struct Channel *channel; 927 struct Channel *channel;
928 const struct ChanType **cp; 928 const struct ChanType **cp;
929 const struct ChanType *chantype; 929 const struct ChanType *chantype;
932 932
933 933
934 TRACE(("enter recv_msg_channel_open")) 934 TRACE(("enter recv_msg_channel_open"))
935 935
936 /* get the packet contents */ 936 /* get the packet contents */
937 type = buf_getstring(ses.payload, &typelen); 937 type = (char *) buf_getstring(ses.payload, &typelen);
938 938
939 remotechan = buf_getint(ses.payload); 939 remotechan = buf_getint(ses.payload);
940 transwindow = buf_getint(ses.payload); 940 transwindow = buf_getint(ses.payload);
941 transwindow = MIN(transwindow, TRANS_MAX_WINDOW); 941 transwindow = MIN(transwindow, TRANS_MAX_WINDOW);
942 transmaxpacket = buf_getint(ses.payload); 942 transmaxpacket = buf_getint(ses.payload);
1037 } 1037 }
1038 1038
1039 /* Send a channel open failure message, with a corresponding reason 1039 /* Send a channel open failure message, with a corresponding reason
1040 * code (usually resource shortage or unknown chan type) */ 1040 * code (usually resource shortage or unknown chan type) */
1041 static void send_msg_channel_open_failure(unsigned int remotechan, 1041 static void send_msg_channel_open_failure(unsigned int remotechan,
1042 int reason, const unsigned char *text, const unsigned char *lang) { 1042 int reason, const char *text, const char *lang) {
1043 1043
1044 TRACE(("enter send_msg_channel_open_failure")) 1044 TRACE(("enter send_msg_channel_open_failure"))
1045 CHECKCLEARTOWRITE(); 1045 CHECKCLEARTOWRITE();
1046 1046
1047 buf_putbyte(ses.writepayload, SSH_MSG_CHANNEL_OPEN_FAILURE); 1047 buf_putbyte(ses.writepayload, SSH_MSG_CHANNEL_OPEN_FAILURE);
1048 buf_putint(ses.writepayload, remotechan); 1048 buf_putint(ses.writepayload, remotechan);
1049 buf_putint(ses.writepayload, reason); 1049 buf_putint(ses.writepayload, reason);
1050 buf_putstring(ses.writepayload, text, strlen((char*)text)); 1050 buf_putstring(ses.writepayload, (const unsigned char *) text, strlen(text));
1051 buf_putstring(ses.writepayload, lang, strlen((char*)lang)); 1051 buf_putstring(ses.writepayload, (const unsigned char *) lang, strlen(lang));
1052 1052
1053 encrypt_packet(); 1053 encrypt_packet();
1054 TRACE(("leave send_msg_channel_open_failure")) 1054 TRACE(("leave send_msg_channel_open_failure"))
1055 } 1055 }
1056 1056
1147 1147
1148 /* now open the channel connection */ 1148 /* now open the channel connection */
1149 CHECKCLEARTOWRITE(); 1149 CHECKCLEARTOWRITE();
1150 1150
1151 buf_putbyte(ses.writepayload, SSH_MSG_CHANNEL_OPEN); 1151 buf_putbyte(ses.writepayload, SSH_MSG_CHANNEL_OPEN);
1152 buf_putstring(ses.writepayload, type->name, strlen(type->name)); 1152 buf_putstring(ses.writepayload, (const unsigned char *) type->name, strlen(type->name));
1153 buf_putint(ses.writepayload, chan->index); 1153 buf_putint(ses.writepayload, chan->index);
1154 buf_putint(ses.writepayload, opts.recv_window); 1154 buf_putint(ses.writepayload, opts.recv_window);
1155 buf_putint(ses.writepayload, RECV_MAX_CHANNEL_DATA_LEN); 1155 buf_putint(ses.writepayload, RECV_MAX_CHANNEL_DATA_LEN);
1156 1156
1157 TRACE(("leave send_msg_channel_open_init()")) 1157 TRACE(("leave send_msg_channel_open_init()"))
1242 } 1242 }
1243 return NULL; 1243 return NULL;
1244 } 1244 }
1245 1245
1246 void start_send_channel_request(struct Channel *channel, 1246 void start_send_channel_request(struct Channel *channel,
1247 unsigned char *type) { 1247 char *type) {
1248 1248
1249 CHECKCLEARTOWRITE(); 1249 CHECKCLEARTOWRITE();
1250 buf_putbyte(ses.writepayload, SSH_MSG_CHANNEL_REQUEST); 1250 buf_putbyte(ses.writepayload, SSH_MSG_CHANNEL_REQUEST);
1251 buf_putint(ses.writepayload, channel->remotechan); 1251 buf_putint(ses.writepayload, channel->remotechan);
1252 1252
1253 buf_putstring(ses.writepayload, type, strlen(type)); 1253 buf_putstring(ses.writepayload, (const unsigned char *) type, strlen(type));
1254 1254
1255 } 1255 }