comparison common-channel.c @ 1459:06d52bcb8094

Pointer parameter could be declared as pointing to const
author Francois Perrad <francois.perrad@gadz.org>
date Sat, 19 Aug 2017 17:16:13 +0200
parents 0b1162fbf1c6
children 5916af64acd4
comparison
equal deleted inserted replaced
1458:bdd3802c8ac6 1459:06d52bcb8094
36 #include "runopts.h" 36 #include "runopts.h"
37 #include "netio.h" 37 #include "netio.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 char *text, const char *lang); 40 const char *text, const char *lang);
41 static void send_msg_channel_open_confirmation(struct Channel* channel, 41 static void send_msg_channel_open_confirmation(const struct Channel* channel,
42 unsigned int recvwindow, 42 unsigned int recvwindow,
43 unsigned int recvmaxpacket); 43 unsigned int recvmaxpacket);
44 static int writechannel(struct Channel* channel, int fd, circbuffer *cbuf, 44 static int writechannel(struct Channel* channel, int fd, circbuffer *cbuf,
45 const unsigned char *moredata, unsigned int *morelen); 45 const unsigned char *moredata, unsigned int *morelen);
46 static void send_msg_channel_window_adjust(struct Channel *channel, 46 static void send_msg_channel_window_adjust(const struct Channel *channel,
47 unsigned int incr); 47 unsigned int incr);
48 static void send_msg_channel_data(struct Channel *channel, int isextended); 48 static void send_msg_channel_data(struct Channel *channel, int isextended);
49 static void send_msg_channel_eof(struct Channel *channel); 49 static void send_msg_channel_eof(struct Channel *channel);
50 static void send_msg_channel_close(struct Channel *channel); 50 static void send_msg_channel_close(struct Channel *channel);
51 static void remove_channel(struct Channel *channel); 51 static void remove_channel(struct Channel *channel);
52 static unsigned int write_pending(struct Channel * channel); 52 static unsigned int write_pending(const struct Channel * channel);
53 static void check_close(struct Channel *channel); 53 static void check_close(struct Channel *channel);
54 static void close_chan_fd(struct Channel *channel, int fd, int how); 54 static void close_chan_fd(struct Channel *channel, int fd, int how);
55 55
56 #define FD_UNINIT (-2) 56 #define FD_UNINIT (-2)
57 #define FD_CLOSED (-1) 57 #define FD_CLOSED (-1)
196 struct Channel* getchannel() { 196 struct Channel* getchannel() {
197 return getchannel_msg(NULL); 197 return getchannel_msg(NULL);
198 } 198 }
199 199
200 /* Iterate through the channels, performing IO if available */ 200 /* Iterate through the channels, performing IO if available */
201 void channelio(fd_set *readfds, fd_set *writefds) { 201 void channelio(const fd_set *readfds, const fd_set *writefds) {
202 202
203 /* Listeners such as TCP, X11, agent-auth */ 203 /* Listeners such as TCP, X11, agent-auth */
204 struct Channel *channel; 204 struct Channel *channel;
205 unsigned int i; 205 unsigned int i;
206 206
260 } 260 }
261 261
262 262
263 /* Returns true if there is data remaining to be written to stdin or 263 /* Returns true if there is data remaining to be written to stdin or
264 * stderr of a channel's endpoint. */ 264 * stderr of a channel's endpoint. */
265 static unsigned int write_pending(struct Channel * channel) { 265 static unsigned int write_pending(const struct Channel * channel) {
266 266
267 if (channel->writefd >= 0 && cbuf_getused(channel->writebuf) > 0) { 267 if (channel->writefd >= 0 && cbuf_getused(channel->writebuf) > 0) {
268 return 1; 268 return 1;
269 } else if (channel->errfd >= 0 && channel->extrabuf && 269 } else if (channel->errfd >= 0 && channel->extrabuf &&
270 cbuf_getused(channel->extrabuf) > 0) { 270 cbuf_getused(channel->extrabuf) > 0) {
901 901
902 } 902 }
903 903
904 /* Increment the incoming data window for a channel, and let the remote 904 /* Increment the incoming data window for a channel, and let the remote
905 * end know */ 905 * end know */
906 static void send_msg_channel_window_adjust(struct Channel* channel, 906 static void send_msg_channel_window_adjust(const struct Channel* channel,
907 unsigned int incr) { 907 unsigned int incr) {
908 908
909 TRACE(("sending window adjust %d", incr)) 909 TRACE(("sending window adjust %d", incr))
910 CHECKCLEARTOWRITE(); 910 CHECKCLEARTOWRITE();
911 911
1006 1006
1007 TRACE(("leave recv_msg_channel_open")) 1007 TRACE(("leave recv_msg_channel_open"))
1008 } 1008 }
1009 1009
1010 /* Send a failure message */ 1010 /* Send a failure message */
1011 void send_msg_channel_failure(struct Channel *channel) { 1011 void send_msg_channel_failure(const struct Channel *channel) {
1012 1012
1013 TRACE(("enter send_msg_channel_failure")) 1013 TRACE(("enter send_msg_channel_failure"))
1014 CHECKCLEARTOWRITE(); 1014 CHECKCLEARTOWRITE();
1015 1015
1016 buf_putbyte(ses.writepayload, SSH_MSG_CHANNEL_FAILURE); 1016 buf_putbyte(ses.writepayload, SSH_MSG_CHANNEL_FAILURE);
1019 encrypt_packet(); 1019 encrypt_packet();
1020 TRACE(("leave send_msg_channel_failure")) 1020 TRACE(("leave send_msg_channel_failure"))
1021 } 1021 }
1022 1022
1023 /* Send a success message */ 1023 /* Send a success message */
1024 void send_msg_channel_success(struct Channel *channel) { 1024 void send_msg_channel_success(const struct Channel *channel) {
1025 1025
1026 TRACE(("enter send_msg_channel_success")) 1026 TRACE(("enter send_msg_channel_success"))
1027 CHECKCLEARTOWRITE(); 1027 CHECKCLEARTOWRITE();
1028 1028
1029 buf_putbyte(ses.writepayload, SSH_MSG_CHANNEL_SUCCESS); 1029 buf_putbyte(ses.writepayload, SSH_MSG_CHANNEL_SUCCESS);
1051 TRACE(("leave send_msg_channel_open_failure")) 1051 TRACE(("leave send_msg_channel_open_failure"))
1052 } 1052 }
1053 1053
1054 /* Confirm a channel open, and let the remote end know what number we've 1054 /* Confirm a channel open, and let the remote end know what number we've
1055 * allocated and the receive parameters */ 1055 * allocated and the receive parameters */
1056 static void send_msg_channel_open_confirmation(struct Channel* channel, 1056 static void send_msg_channel_open_confirmation(const struct Channel* channel,
1057 unsigned int recvwindow, 1057 unsigned int recvwindow,
1058 unsigned int recvmaxpacket) { 1058 unsigned int recvmaxpacket) {
1059 1059
1060 TRACE(("enter send_msg_channel_open_confirmation")) 1060 TRACE(("enter send_msg_channel_open_confirmation"))
1061 CHECKCLEARTOWRITE(); 1061 CHECKCLEARTOWRITE();
1237 } 1237 }
1238 } 1238 }
1239 return NULL; 1239 return NULL;
1240 } 1240 }
1241 1241
1242 void start_send_channel_request(struct Channel *channel, 1242 void start_send_channel_request(const struct Channel *channel,
1243 char *type) { 1243 const char *type) {
1244 1244
1245 CHECKCLEARTOWRITE(); 1245 CHECKCLEARTOWRITE();
1246 buf_putbyte(ses.writepayload, SSH_MSG_CHANNEL_REQUEST); 1246 buf_putbyte(ses.writepayload, SSH_MSG_CHANNEL_REQUEST);
1247 buf_putint(ses.writepayload, channel->remotechan); 1247 buf_putint(ses.writepayload, channel->remotechan);
1248 1248