aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/libssh/libssh.h14
-rw-r--r--include/libssh/server.h46
-rw-r--r--libssh/channels.c4
-rw-r--r--libssh/messages.c43
-rw-r--r--libssh/server.c60
-rw-r--r--libssh/session.c4
-rw-r--r--samplesshd.c2
7 files changed, 86 insertions, 87 deletions
diff --git a/include/libssh/libssh.h b/include/libssh/libssh.h
index d87f70c8..d5f8c5c7 100644
--- a/include/libssh/libssh.h
+++ b/include/libssh/libssh.h
@@ -361,13 +361,13 @@ LIBSSH_API int ssh_get_status(ssh_session session);
LIBSSH_API int ssh_init(void);
LIBSSH_API int ssh_is_server_known(ssh_session session);
LIBSSH_API void ssh_log(ssh_session session, int prioriry, const char *format, ...) PRINTF_ATTRIBUTE(3, 4);
-LIBSSH_API ssh_channel ssh_message_channel_request_open_reply_accept(SSH_MESSAGE *msg);
-LIBSSH_API int ssh_message_channel_request_reply_success(SSH_MESSAGE *msg);
-LIBSSH_API void ssh_message_free(SSH_MESSAGE *msg);
-LIBSSH_API SSH_MESSAGE *ssh_message_get(ssh_session session);
-LIBSSH_API SSH_MESSAGE *ssh_message_retrieve(ssh_session session, uint32_t packettype);
-LIBSSH_API int ssh_message_subtype(SSH_MESSAGE *msg);
-LIBSSH_API int ssh_message_type(SSH_MESSAGE *msg);
+LIBSSH_API ssh_channel ssh_message_channel_request_open_reply_accept(ssh_message msg);
+LIBSSH_API int ssh_message_channel_request_reply_success(ssh_message msg);
+LIBSSH_API void ssh_message_free(ssh_message msg);
+LIBSSH_API ssh_message ssh_message_get(ssh_session session);
+LIBSSH_API ssh_message ssh_message_retrieve(ssh_session session, uint32_t packettype);
+LIBSSH_API int ssh_message_subtype(ssh_message msg);
+LIBSSH_API int ssh_message_type(ssh_message msg);
LIBSSH_API int ssh_mkdir (const char *pathname, mode_t mode);
LIBSSH_API ssh_session ssh_new(void);
LIBSSH_API ssh_options ssh_options_copy(ssh_options opt);
diff --git a/include/libssh/server.h b/include/libssh/server.h
index afe3f49c..311003cd 100644
--- a/include/libssh/server.h
+++ b/include/libssh/server.h
@@ -124,40 +124,40 @@ LIBSSH_API int ssh_accept(ssh_session session);
LIBSSH_API int channel_write_stderr(ssh_channel channel, const void *data, uint32_t len);
/* messages.c */
-LIBSSH_API int ssh_message_reply_default(SSH_MESSAGE *msg);
+LIBSSH_API int ssh_message_reply_default(ssh_message msg);
-LIBSSH_API char *ssh_message_auth_user(SSH_MESSAGE *msg);
-LIBSSH_API char *ssh_message_auth_password(SSH_MESSAGE *msg);
-LIBSSH_API ssh_public_key ssh_message_auth_publickey(SSH_MESSAGE *msg);
-LIBSSH_API int ssh_message_auth_reply_success(SSH_MESSAGE *msg,int partial);
-LIBSSH_API int ssh_message_auth_reply_pk_ok(SSH_MESSAGE *msg, ssh_string algo, ssh_string pubkey);
-LIBSSH_API int ssh_message_auth_set_methods(SSH_MESSAGE *msg, int methods);
+LIBSSH_API char *ssh_message_auth_user(ssh_message msg);
+LIBSSH_API char *ssh_message_auth_password(ssh_message msg);
+LIBSSH_API ssh_public_key ssh_message_auth_publickey(ssh_message msg);
+LIBSSH_API int ssh_message_auth_reply_success(ssh_message msg,int partial);
+LIBSSH_API int ssh_message_auth_reply_pk_ok(ssh_message msg, ssh_string algo, ssh_string pubkey);
+LIBSSH_API int ssh_message_auth_set_methods(ssh_message msg, int methods);
-LIBSSH_API int ssh_message_service_reply_success(SSH_MESSAGE *msg);
-LIBSSH_API char *ssh_message_service_service(SSH_MESSAGE *msg);
+LIBSSH_API int ssh_message_service_reply_success(ssh_message msg);
+LIBSSH_API char *ssh_message_service_service(ssh_message msg);
LIBSSH_API void ssh_set_message_callback(ssh_session session,
int(*ssh_message_callback)(ssh_session session, ssh_message msg));
-LIBSSH_API char *ssh_message_channel_request_open_originator(SSH_MESSAGE *msg);
-LIBSSH_API int ssh_message_channel_request_open_originator_port(SSH_MESSAGE *msg);
-LIBSSH_API char *ssh_message_channel_request_open_destination(SSH_MESSAGE *msg);
-LIBSSH_API int ssh_message_channel_request_open_destination_port(SSH_MESSAGE *msg);
+LIBSSH_API char *ssh_message_channel_request_open_originator(ssh_message msg);
+LIBSSH_API int ssh_message_channel_request_open_originator_port(ssh_message msg);
+LIBSSH_API char *ssh_message_channel_request_open_destination(ssh_message msg);
+LIBSSH_API int ssh_message_channel_request_open_destination_port(ssh_message msg);
-LIBSSH_API ssh_channel ssh_message_channel_request_channel(SSH_MESSAGE *msg);
+LIBSSH_API ssh_channel ssh_message_channel_request_channel(ssh_message msg);
-LIBSSH_API char *ssh_message_channel_request_pty_term(SSH_MESSAGE *msg);
-LIBSSH_API int ssh_message_channel_request_pty_width(SSH_MESSAGE *msg);
-LIBSSH_API int ssh_message_channel_request_pty_height(SSH_MESSAGE *msg);
-LIBSSH_API int ssh_message_channel_request_pty_pxwidth(SSH_MESSAGE *msg);
-LIBSSH_API int ssh_message_channel_request_pty_pxheight(SSH_MESSAGE *msg);
+LIBSSH_API char *ssh_message_channel_request_pty_term(ssh_message msg);
+LIBSSH_API int ssh_message_channel_request_pty_width(ssh_message msg);
+LIBSSH_API int ssh_message_channel_request_pty_height(ssh_message msg);
+LIBSSH_API int ssh_message_channel_request_pty_pxwidth(ssh_message msg);
+LIBSSH_API int ssh_message_channel_request_pty_pxheight(ssh_message msg);
-LIBSSH_API char *ssh_message_channel_request_env_name(SSH_MESSAGE *msg);
-LIBSSH_API char *ssh_message_channel_request_env_value(SSH_MESSAGE *msg);
+LIBSSH_API char *ssh_message_channel_request_env_name(ssh_message msg);
+LIBSSH_API char *ssh_message_channel_request_env_value(ssh_message msg);
-LIBSSH_API char *ssh_message_channel_request_command(SSH_MESSAGE *msg);
+LIBSSH_API char *ssh_message_channel_request_command(ssh_message msg);
-LIBSSH_API char *ssh_message_channel_request_subsystem(SSH_MESSAGE *msg);
+LIBSSH_API char *ssh_message_channel_request_subsystem(ssh_message msg);
#ifdef __cplusplus
}
diff --git a/libssh/channels.c b/libssh/channels.c
index c5560de9..99103708 100644
--- a/libssh/channels.c
+++ b/libssh/channels.c
@@ -1346,7 +1346,7 @@ static ssh_channel channel_accept(ssh_session session, int channeltype,
.tv_nsec = 50000000 /* 50ms */
};
#endif
- SSH_MESSAGE *msg = NULL;
+ ssh_message msg = NULL;
struct ssh_iterator *iterator;
int t;
@@ -1357,7 +1357,7 @@ static ssh_channel channel_accept(ssh_session session, int channeltype,
if (session->ssh_message_list) {
iterator = ssh_list_get_iterator(session->ssh_message_list);
while (iterator) {
- msg = (SSH_MESSAGE*)iterator->data;
+ msg = (ssh_message)iterator->data;
if (ssh_message_type(msg) == SSH_REQUEST_CHANNEL_OPEN &&
ssh_message_subtype(msg) == channeltype) {
ssh_list_remove(session->ssh_message_list, iterator);
diff --git a/libssh/messages.c b/libssh/messages.c
index 2989d0ce..22d150f0 100644
--- a/libssh/messages.c
+++ b/libssh/messages.c
@@ -44,21 +44,20 @@
#include "libssh/ssh2.h"
-static SSH_MESSAGE *message_new(ssh_session session){
- SSH_MESSAGE *msg = malloc(sizeof(SSH_MESSAGE));
+static ssh_message message_new(ssh_session session){
+ ssh_message msg = malloc(sizeof(struct ssh_message_struct));
if (msg == NULL) {
return NULL;
}
-
- memset(msg, 0, sizeof(*msg));
+ ZERO_STRUCTP(msg);
msg->session = session;
return msg;
}
-static SSH_MESSAGE *handle_service_request(ssh_session session) {
+static ssh_message handle_service_request(ssh_session session) {
ssh_string service = NULL;
char *service_c = NULL;
- SSH_MESSAGE *msg=NULL;
+ ssh_message msg=NULL;
enter_function();
@@ -98,11 +97,11 @@ static int handle_unimplemented(ssh_session session) {
return 0;
}
-static SSH_MESSAGE *handle_userauth_request(ssh_session session){
+static ssh_message handle_userauth_request(ssh_session session){
ssh_string user = NULL;
ssh_string service = NULL;
ssh_string method = NULL;
- SSH_MESSAGE *msg = NULL;
+ ssh_message msg = NULL;
char *service_c = NULL;
char *method_c = NULL;
@@ -264,8 +263,8 @@ error:
return NULL;
}
-static SSH_MESSAGE *handle_channel_request_open(ssh_session session) {
- SSH_MESSAGE *msg = NULL;
+static ssh_message handle_channel_request_open(ssh_session session) {
+ ssh_message msg = NULL;
ssh_string type = NULL, originator = NULL, destination = NULL;
char *type_c = NULL;
uint32_t sender, window, packet, originator_port, destination_port;
@@ -413,7 +412,7 @@ error:
return NULL;
}
-ssh_channel ssh_message_channel_request_open_reply_accept(SSH_MESSAGE *msg) {
+ssh_channel ssh_message_channel_request_open_reply_accept(ssh_message msg) {
ssh_session session = msg->session;
ssh_channel chan = NULL;
@@ -470,8 +469,8 @@ error:
return NULL;
}
-static SSH_MESSAGE *handle_channel_request(ssh_session session) {
- SSH_MESSAGE *msg = NULL;
+static ssh_message handle_channel_request(ssh_session session) {
+ ssh_message msg = NULL;
ssh_string type = NULL;
char *type_c = NULL;
uint32_t channel;
@@ -664,7 +663,7 @@ error:
return NULL;
}
-int ssh_message_channel_request_reply_success(SSH_MESSAGE *msg) {
+int ssh_message_channel_request_reply_success(ssh_message msg) {
uint32_t channel;
if (msg == NULL) {
@@ -693,8 +692,8 @@ int ssh_message_channel_request_reply_success(SSH_MESSAGE *msg) {
return SSH_OK;
}
-SSH_MESSAGE *ssh_message_retrieve(ssh_session session, uint32_t packettype){
- SSH_MESSAGE *msg=NULL;
+ssh_message ssh_message_retrieve(ssh_session session, uint32_t packettype){
+ ssh_message msg=NULL;
enter_function();
switch(packettype) {
case SSH2_MSG_SERVICE_REQUEST:
@@ -722,8 +721,8 @@ SSH_MESSAGE *ssh_message_retrieve(ssh_session session, uint32_t packettype){
/* \brief blocking message retrieval
* \bug does anything that is not a message, like a channel read/write
*/
-SSH_MESSAGE *ssh_message_get(ssh_session session) {
- SSH_MESSAGE *msg = NULL;
+ssh_message ssh_message_get(ssh_session session) {
+ ssh_message msg = NULL;
enter_function();
do {
if ((packet_read(session) != SSH_OK) ||
@@ -737,7 +736,7 @@ SSH_MESSAGE *ssh_message_get(ssh_session session) {
return msg;
}
-int ssh_message_type(SSH_MESSAGE *msg) {
+int ssh_message_type(ssh_message msg) {
if (msg == NULL) {
return -1;
}
@@ -745,7 +744,7 @@ int ssh_message_type(SSH_MESSAGE *msg) {
return msg->type;
}
-int ssh_message_subtype(SSH_MESSAGE *msg) {
+int ssh_message_subtype(ssh_message msg) {
if (msg == NULL) {
return -1;
}
@@ -762,7 +761,7 @@ int ssh_message_subtype(SSH_MESSAGE *msg) {
return -1;
}
-void ssh_message_free(SSH_MESSAGE *msg){
+void ssh_message_free(ssh_message msg){
if (msg == NULL) {
return;
}
@@ -800,7 +799,7 @@ void ssh_message_free(SSH_MESSAGE *msg){
* \returns nothing
*/
void message_handle(ssh_session session, uint32_t type){
- SSH_MESSAGE *msg=ssh_message_retrieve(session,type);
+ ssh_message msg=ssh_message_retrieve(session,type);
if(msg){
if(!session->ssh_message_list){
session->ssh_message_list=ssh_list_new();
diff --git a/libssh/server.c b/libssh/server.c
index b58316d4..3e37291c 100644
--- a/libssh/server.c
+++ b/libssh/server.c
@@ -528,7 +528,7 @@ int channel_write_stderr(ssh_channel channel, const void *data, uint32_t len) {
/* messages */
-static int ssh_message_auth_reply_default(SSH_MESSAGE *msg,int partial) {
+static int ssh_message_auth_reply_default(ssh_message msg,int partial) {
ssh_session session = msg->session;
char methods_c[128] = {0};
ssh_string methods = NULL;
@@ -589,7 +589,7 @@ error:
return rc;
}
-static int ssh_message_channel_request_open_reply_default(SSH_MESSAGE *msg) {
+static int ssh_message_channel_request_open_reply_default(ssh_message msg) {
ssh_log(msg->session, SSH_LOG_FUNCTIONS, "Refusing a channel");
if (buffer_add_u8(msg->session->out_buffer
@@ -618,7 +618,7 @@ error:
return SSH_ERROR;
}
-static int ssh_message_channel_request_reply_default(SSH_MESSAGE *msg) {
+static int ssh_message_channel_request_reply_default(ssh_message msg) {
uint32_t channel;
if (msg->channel_request.want_reply) {
@@ -643,12 +643,12 @@ static int ssh_message_channel_request_reply_default(SSH_MESSAGE *msg) {
return SSH_OK;
}
-static int ssh_message_service_request_reply_default(SSH_MESSAGE *msg) {
+static int ssh_message_service_request_reply_default(ssh_message msg) {
/* The only return code accepted by specifications are success or disconnect */
return ssh_message_service_reply_success(msg);
}
-int ssh_message_service_reply_success(SSH_MESSAGE *msg) {
+int ssh_message_service_reply_success(ssh_message msg) {
struct ssh_string_struct *service;
ssh_session session=msg->session;
if (msg == NULL) {
@@ -668,7 +668,7 @@ int ssh_message_service_reply_success(SSH_MESSAGE *msg) {
return packet_send(msg->session);
}
-int ssh_message_reply_default(SSH_MESSAGE *msg) {
+int ssh_message_reply_default(ssh_message msg) {
if (msg == NULL) {
return -1;
}
@@ -692,14 +692,14 @@ int ssh_message_reply_default(SSH_MESSAGE *msg) {
return -1;
}
-char *ssh_message_service_service(SSH_MESSAGE *msg){
+char *ssh_message_service_service(ssh_message msg){
if (msg == NULL) {
return NULL;
}
return msg->service_request.service;
}
-char *ssh_message_auth_user(SSH_MESSAGE *msg) {
+char *ssh_message_auth_user(ssh_message msg) {
if (msg == NULL) {
return NULL;
}
@@ -707,7 +707,7 @@ char *ssh_message_auth_user(SSH_MESSAGE *msg) {
return msg->auth_request.username;
}
-char *ssh_message_auth_password(SSH_MESSAGE *msg){
+char *ssh_message_auth_password(ssh_message msg){
if (msg == NULL) {
return NULL;
}
@@ -716,7 +716,7 @@ char *ssh_message_auth_password(SSH_MESSAGE *msg){
}
/* Get the publickey of an auth request */
-ssh_public_key ssh_message_auth_publickey(SSH_MESSAGE *msg){
+ssh_public_key ssh_message_auth_publickey(ssh_message msg){
if (msg == NULL) {
return NULL;
}
@@ -724,7 +724,7 @@ ssh_public_key ssh_message_auth_publickey(SSH_MESSAGE *msg){
return msg->auth_request.public_key;
}
-int ssh_message_auth_set_methods(SSH_MESSAGE *msg, int methods) {
+int ssh_message_auth_set_methods(ssh_message msg, int methods) {
if (msg == NULL || msg->session == NULL) {
return -1;
}
@@ -734,7 +734,7 @@ int ssh_message_auth_set_methods(SSH_MESSAGE *msg, int methods) {
return 0;
}
-int ssh_message_auth_reply_success(SSH_MESSAGE *msg, int partial) {
+int ssh_message_auth_reply_success(ssh_message msg, int partial) {
if (msg == NULL) {
return SSH_ERROR;
}
@@ -751,7 +751,7 @@ int ssh_message_auth_reply_success(SSH_MESSAGE *msg, int partial) {
}
/* Answer OK to a pubkey auth request */
-int ssh_message_auth_reply_pk_ok(SSH_MESSAGE *msg, ssh_string algo, ssh_string pubkey) {
+int ssh_message_auth_reply_pk_ok(ssh_message msg, ssh_string algo, ssh_string pubkey) {
if (msg == NULL) {
return SSH_ERROR;
}
@@ -765,59 +765,59 @@ int ssh_message_auth_reply_pk_ok(SSH_MESSAGE *msg, ssh_string algo, ssh_string p
return packet_send(msg->session);
}
-char *ssh_message_channel_request_open_originator(SSH_MESSAGE *msg){
+char *ssh_message_channel_request_open_originator(ssh_message msg){
return msg->channel_request_open.originator;
}
-int ssh_message_channel_request_open_originator_port(SSH_MESSAGE *msg){
+int ssh_message_channel_request_open_originator_port(ssh_message msg){
return msg->channel_request_open.originator_port;
}
-char *ssh_message_channel_request_open_destination(SSH_MESSAGE *msg){
+char *ssh_message_channel_request_open_destination(ssh_message msg){
return msg->channel_request_open.destination;
}
-int ssh_message_channel_request_open_destination_port(SSH_MESSAGE *msg){
+int ssh_message_channel_request_open_destination_port(ssh_message msg){
return msg->channel_request_open.destination_port;
}
-ssh_channel ssh_message_channel_request_channel(SSH_MESSAGE *msg){
+ssh_channel ssh_message_channel_request_channel(ssh_message msg){
return msg->channel_request.channel;
}
-char *ssh_message_channel_request_pty_term(SSH_MESSAGE *msg){
+char *ssh_message_channel_request_pty_term(ssh_message msg){
return msg->channel_request.TERM;
}
-int ssh_message_channel_request_pty_width(SSH_MESSAGE *msg){
+int ssh_message_channel_request_pty_width(ssh_message msg){
return msg->channel_request.width;
}
-int ssh_message_channel_request_pty_height(SSH_MESSAGE *msg){
+int ssh_message_channel_request_pty_height(ssh_message msg){
return msg->channel_request.height;
}
-int ssh_message_channel_request_pty_pxwidth(SSH_MESSAGE *msg){
+int ssh_message_channel_request_pty_pxwidth(ssh_message msg){
return msg->channel_request.pxwidth;
}
-int ssh_message_channel_request_pty_pxheight(SSH_MESSAGE *msg){
+int ssh_message_channel_request_pty_pxheight(ssh_message msg){
return msg->channel_request.pxheight;
}
-char *ssh_message_channel_request_env_name(SSH_MESSAGE *msg){
+char *ssh_message_channel_request_env_name(ssh_message msg){
return msg->channel_request.var_name;
}
-char *ssh_message_channel_request_env_value(SSH_MESSAGE *msg){
+char *ssh_message_channel_request_env_value(ssh_message msg){
return msg->channel_request.var_value;
}
-char *ssh_message_channel_request_command(SSH_MESSAGE *msg){
+char *ssh_message_channel_request_command(ssh_message msg){
return msg->channel_request.command;
}
-char *ssh_message_channel_request_subsystem(SSH_MESSAGE *msg){
+char *ssh_message_channel_request_subsystem(ssh_message msg){
return msg->channel_request.subsystem;
}
@@ -834,12 +834,12 @@ void ssh_set_message_callback(ssh_session session,
}
int ssh_execute_message_callbacks(ssh_session session){
- SSH_MESSAGE *msg=NULL;
+ ssh_message msg=NULL;
int ret;
if(!session->ssh_message_list)
return SSH_OK;
if(session->ssh_message_callback){
- while((msg=ssh_list_get_head(SSH_MESSAGE *, session->ssh_message_list)) != NULL){
+ while((msg=ssh_list_get_head(ssh_message , session->ssh_message_list)) != NULL){
ret=session->ssh_message_callback(session,msg);
if(ret==1){
ret = ssh_message_reply_default(msg);
@@ -848,7 +848,7 @@ int ssh_execute_message_callbacks(ssh_session session){
}
}
} else {
- while((msg=ssh_list_get_head(SSH_MESSAGE *, session->ssh_message_list)) != NULL){
+ while((msg=ssh_list_get_head(ssh_message , session->ssh_message_list)) != NULL){
ret = ssh_message_reply_default(msg);
if(ret != SSH_OK)
return ret;
diff --git a/libssh/session.c b/libssh/session.c
index c676cc80..4c6a81ee 100644
--- a/libssh/session.c
+++ b/libssh/session.c
@@ -127,8 +127,8 @@ void ssh_cleanup(ssh_session session) {
privatekey_free(session->dsa_key);
privatekey_free(session->rsa_key);
if(session->ssh_message_list){
- SSH_MESSAGE *msg;
- while((msg=ssh_list_get_head(SSH_MESSAGE *,session->ssh_message_list))
+ ssh_message msg;
+ while((msg=ssh_list_get_head(ssh_message ,session->ssh_message_list))
!= NULL){
ssh_message_free(msg);
}
diff --git a/samplesshd.c b/samplesshd.c
index dcd85dc6..9d6e3bb0 100644
--- a/samplesshd.c
+++ b/samplesshd.c
@@ -43,7 +43,7 @@ int main(int argc, char **argv){
ssh_options options=ssh_options_new();
ssh_session session;
SSH_BIND *ssh_bind;
- SSH_MESSAGE *message;
+ ssh_message message;
ssh_channel chan=0;
ssh_buffer buf;
int auth=0;