00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef SERVER_H
00022 #define SERVER_H
00023
00024 #include "libssh/libssh.h"
00025 #include "libssh/priv.h"
00026 #define SERVERBANNER CLIENTBANNER
00027
00028 struct ssh_bind_struct {
00029 struct error_struct error;
00030 int bindfd;
00031 SSH_OPTIONS *options;
00032 int blocking;
00033 int toaccept;
00034 };
00035
00036 typedef struct ssh_bind_struct SSH_BIND;
00037
00038 SSH_BIND *ssh_bind_new();
00039 void ssh_bind_set_options(SSH_BIND *ssh_bind, SSH_OPTIONS *options);
00040 int ssh_bind_listen(SSH_BIND *ssh_bind);
00041 void ssh_bind_set_blocking(SSH_BIND *ssh_bind,int blocking);
00042 int ssh_bind_get_fd(SSH_BIND *ssh_bind);
00043 int ssh_bind_set_toaccept(SSH_BIND *ssh_bind);
00044 SSH_SESSION *ssh_bind_accept(SSH_BIND *ssh_bind);
00045 void ssh_bind_free(SSH_BIND *ssh_bind);
00046 int ssh_accept(SSH_SESSION *session);
00047
00048
00049
00050 #define SSH_AUTH_REQUEST 1
00051 #define SSH_CHANNEL_REQUEST_OPEN 2
00052 #define SSH_CHANNEL_REQUEST 3
00053
00054 #define SSH_AUTH_NONE (1<<0)
00055 #define SSH_AUTH_PASSWORD (1<<1)
00056 #define SSH_AUTH_HOSTBASED (1<<2)
00057 #define SSH_AUTH_PUBLICKEY (1<<3)
00058 #define SSH_AUTH_KEYBINT (1<<4)
00059 #define SSH_AUTH_UNKNOWN 0
00060
00061 struct ssh_auth_request {
00062 char *username;
00063 int method;
00064 char *password;
00065 };
00066
00067
00068 #define SSH_CHANNEL_SESSION 1
00069 #define SSH_CHANNEL_TCPIP 2
00070 #define SSH_CHANNEL_X11 3
00071 #define SSH_CHANNEL_UNKNOWN 4
00072 struct ssh_channel_request_open {
00073 int type;
00074 u32 sender;
00075 u32 window;
00076 u32 packet_size;
00077 char *originator;
00078 u16 orignator_port;
00079 char *destination;
00080 u16 destination_port;
00081 };
00082
00083 #define SSH_CHANNEL_REQUEST_PTY 1
00084 #define SSH_CHANNEL_REQUEST_EXEC 2
00085 #define SSH_CHANNEL_REQUEST_SHELL 3
00086 #define SSH_CHANNEL_REQUEST_ENV 4
00087 #define SSH_CHANNEL_REQUEST_SUBSYSTEM 5
00088 #define SSH_CHANNEL_REQUEST_WINDOW_CHANGE 6
00089 #define SSH_CHANNEL_REQUEST_UNKNOWN 7
00090
00091 struct ssh_channel_request {
00092 int type;
00093 CHANNEL *channel;
00094 u8 want_reply;
00095
00096 char *TERM;
00097 u32 width;
00098 u32 height;
00099 u32 pxwidth;
00100 u32 pxheight;
00101 STRING *modes;
00102
00103
00104 char *var_name;
00105 char *var_value;
00106
00107 char *command;
00108
00109 char *subsystem;
00110 };
00111
00112 struct ssh_message {
00113 SSH_SESSION *session;
00114 int type;
00115 struct ssh_auth_request auth_request;
00116 struct ssh_channel_request_open channel_request_open;
00117 struct ssh_channel_request channel_request;
00118 };
00119
00120 typedef struct ssh_message SSH_MESSAGE;
00121
00122 SSH_MESSAGE *ssh_message_get(SSH_SESSION *session);
00123 int ssh_message_type(SSH_MESSAGE *msg);
00124 int ssh_message_subtype(SSH_MESSAGE *msg);
00125 int ssh_message_reply_default(SSH_MESSAGE *msg);
00126 void ssh_message_free(SSH_MESSAGE *msg);
00127
00128 char *ssh_message_auth_user(SSH_MESSAGE *msg);
00129 char *ssh_message_auth_password(SSH_MESSAGE *msg);
00130 int ssh_message_auth_reply_success(SSH_MESSAGE *msg,int partial);
00131 void ssh_message_auth_set_methods(SSH_MESSAGE *msg, int methods);
00132
00133 CHANNEL *ssh_message_channel_request_open_reply_accept(SSH_MESSAGE *msg);
00134
00135 CHANNEL *ssh_message_channel_request_channel(SSH_MESSAGE *msg);
00136
00137 char *ssh_message_channel_request_pty_term(SSH_MESSAGE *msg);
00138 char *ssh_message_channel_request_subsystem(SSH_MESSAGE *msg);
00139 int ssh_message_channel_request_reply_success(SSH_MESSAGE *msg);
00140
00141 #endif