5773044 [rkeene@sledge /home/rkeene/projects/libssh-win32/v0.11/src/libssh-0.11/include/libssh]$ cat -n libssh.h
  1 /*
  2 Copyright 2003,04 Aris Adamantiadis
  3 
  4 This file is part of the SSH Library
  5 
  6 The SSH Library is free software; you can redistribute it and/or modify
  7 it under the terms of the GNU Lesser General Public License as published by
  8 the Free Software Foundation; either version 2.1 of the License, or (at your
  9 option) any later version.
 10 
 11 The SSH Library is distributed in the hope that it will be useful, but
 12 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 13 or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
 14 License for more details.
 15 
 16 You should have received a copy of the GNU Lesser General Public License
 17 along with the SSH Library; see the file COPYING.  If not, write to
 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
 19 MA 02111-1307, USA. */
 20 
 21 #ifndef _LIBSSH_H
 22 #define _LIBSSH_H
 23 #include <libssh/config.h>
 24 #include <unistd.h>
 25 #include <sys/select.h> /* for fd_set * */
 26 #include <sys/types.h>
 27 #define LIBSSH_VERSION "libssh-0.11"
 28 
 29 #ifdef __cplusplus
 30 extern "C" {
 31 #endif
 32 
 33 typedef struct string_struct STRING;
 34 typedef struct buffer_struct BUFFER;
 35 typedef struct public_key_struct PUBLIC_KEY;
 36 typedef struct private_key_struct PRIVATE_KEY;
 37 typedef struct ssh_options_struct SSH_OPTIONS;
 38 typedef struct channel_struct CHANNEL;
 39 typedef struct ssh_session SSH_SESSION;
 40 typedef struct ssh_kbdint SSH_KBDINT;
 41 
 42 /* integer values */
 43 typedef u_int32_t u32;
 44 typedef u_int16_t u16;
 45 typedef u_int64_t u64;
 46 typedef u_int8_t u8;
 47 
 48 /* the offsets of methods */
 49 #define KEX_ALGO 0
 50 #define KEX_HOSTKEY 1
 51 #define KEX_CRYPT_C_S 2
 52 #define KEX_CRYPT_S_C 3
 53 #define KEX_MAC_C_S 4
 54 #define KEX_MAC_S_C 5
 55 #define KEX_COMP_C_S 6
 56 #define KEX_COMP_S_C 7
 57 #define KEX_LANG_C_S 8
 58 #define KEX_LANG_S_C 9
 59 
 60 #define SSH_AUTH_SUCCESS 0
 61 #define SSH_AUTH_DENIED 1
 62 #define SSH_AUTH_PARTIAL 2
 63 #define SSH_AUTH_INFO 3
 64 #define SSH_AUTH_ERROR -1
 65 
 66 #define SSH_SERVER_ERROR -1
 67 #define SSH_SERVER_NOT_KNOWN 0
 68 #define SSH_SERVER_KNOWN_OK 1
 69 #define SSH_SERVER_KNOWN_CHANGED 2
 70 #define SSH_SERVER_FOUND_OTHER 3
 71 
 72 #ifndef MD5_DIGEST_LEN
 73     #define MD5_DIGEST_LEN 16
 74 #endif
 75 /* errors */
 76 
 77 enum ssh_error {SSH_NO_ERROR, SSH_REQUEST_DENIED, SSH_INVALID_REQUEST,
	SSH_CONNECTION_LOST,SSH_FATAL,SSH_INVALID_DATA,SSH_EINTR};
 78 char *ssh_get_error(SSH_SESSION *session); /* returns a static char array */
 79 enum ssh_error ssh_error_code(SSH_SESSION *session);
 80 void ssh_say(int priority,char *format,...);
 81 void ssh_set_verbosity(int num);
 82 
 83  /* There is a verbosity level */
 84  /* 3 : packet level */
 85  /* 2 : protocol level */
 86  /* 1 : functions level */
 87  /* 0 : important messages only */
 88  /* -1 : no messages */
 89 
 90 /* in client.c */
 91 
 92 SSH_SESSION *ssh_connect(SSH_OPTIONS *options);
 93 void ssh_disconnect(SSH_SESSION *session);
 94 int ssh_service_request(SSH_SESSION *session,char *service);
 95 char *ssh_get_issue_banner(SSH_SESSION *session);
 96 /* get copyright informations */
 97 const char *ssh_copyright();
 98 /* string.h */
 99 
100 /* You can use these functions, they won't change */
101 /* makestring returns a newly allocated string from a char * ptr */
102 STRING *string_from_char(char *what);
103 /* it returns the string len in host byte orders. str->size is big endian warning ! */
104 int string_len(STRING *str);
105 STRING *string_new(u32 size);
106 /* string_fill copies the data in the string. it does NOT check for boundary so allocate enough place with new_string */
107 /* right before */
108 void string_fill(STRING *str,void *data,int len);
109 /* returns a newly allocated char array with the str string and a final nul caracter */
110 char *string_to_char(STRING *str);
111 STRING *string_copy(STRING *str);
112 
113 /* deprecated */
114 void ssh_crypto_init();
115 
116 /* useful for debug */
117 void ssh_print_hexa(char *descr,unsigned char *what, int len);
118 void ssh_get_random(void *,int);
119 
120 /* this one can be called by the client to see the hash of the public key before accepting it */
121 int ssh_get_pubkey_hash(SSH_SESSION *session,char hash[MD5_DIGEST_LEN]);
122 STRING *ssh_get_pubkey(SSH_SESSION *session);
123 
124 /* deprecated */
125 int pubkey_get_hash(SSH_SESSION *session,char hash[MD5_DIGEST_LEN]);
126 
127 /* in connect.c */
128 int ssh_fd_poll(SSH_SESSION *session);
129 int ssh_select(CHANNEL **channels,CHANNEL **outchannels, int maxfd, fd_set *readfds, struct timeval *timeout);
130 
131 void publickey_free(PUBLIC_KEY *key);
132 
133 /* in keyfiles.c */
134 
135 PRIVATE_KEY *privatekey_from_file(SSH_SESSION *session,char *filename,int type,char *passphrase);
136 void private_key_free(PRIVATE_KEY *prv);
137 STRING *publickey_from_file(char *filename,int *_type);
138 STRING *publickey_from_next_file(SSH_SESSION *session,char **pub_keys_path,char **keys_path,
139                             char **privkeyfile,int *type,int *count);
140 int ssh_is_server_known(SSH_SESSION *session);
141 int ssh_write_knownhost(SSH_SESSION *session);
142 
143 /* in channels.c */
144 
145 /* this one is deprecated */
146 CHANNEL *open_session_channel(SSH_SESSION *session,int window,int maxpacket);
147 CHANNEL *channel_open_forward(SSH_SESSION *session,char *remotehost, int remoteport, char *sourcehost, int localport);
148 CHANNEL *channel_open_session(SSH_SESSION *session);
149 void channel_free(CHANNEL *channel);
150 int channel_request_pty(CHANNEL *channel);
151 int channel_request_pty_size(CHANNEL *channel, char *term,int cols, int rows);
152 int channel_change_pty_size(CHANNEL *channel,int cols,int rows);
153 int channel_request_shell(CHANNEL *channel);
154 int channel_request_subsystem(CHANNEL *channel, char *system);
155 int channel_request_env(CHANNEL *channel,char *name, char *value);
156 int channel_request_exec(CHANNEL *channel, char *cmd);
157 int channel_request_sftp(CHANNEL *channel);
158 int channel_write(CHANNEL *channel,void *data,int len);
159 int channel_set_write_handler(CHANNEL *channel,
160     void (*write_fct)(CHANNEL *channel, void *data, int len, void *userdefined),
161     void *user);
162 int channel_set_stderr_write_handler(CHANNEL *channel,
163     void (*write_err_fct)(CHANNEL *channel, void *data, int len, void *userdefined),
164     void *user);
165 int channel_send_eof(CHANNEL *channel);
166 int channel_read(CHANNEL *channel, BUFFER *buffer,int bytes,int is_stderr);
167 int channel_poll(CHANNEL *channel, int is_stderr);
168 int channel_close(CHANNEL *channel);
169 int channel_read_nonblocking(CHANNEL *channel, char *dest, int len, int is_stderr);
170 int channel_is_open(CHANNEL *channel);
171 /* in options.c */
172 
173 SSH_OPTIONS *options_new();
174 SSH_OPTIONS *options_copy(SSH_OPTIONS *opt);
175 int options_set_wanted_method(SSH_OPTIONS *opt,int method, char *list);
176 void options_set_username(SSH_OPTIONS *opt,char *username);
177 void options_set_port(SSH_OPTIONS *opt, unsigned int port);
178 SSH_OPTIONS *ssh_getopt(int *argcptr, char **argv);
179 void options_set_host(SSH_OPTIONS *opt, const char *host);
180 /* don't connect to host, use fd instead */
181 void options_set_fd(SSH_OPTIONS *opt, int fd);
182 void options_set_bindaddr(SSH_OPTIONS *opt, char *bindaddr);
183 void options_set_identity(SSH_OPTIONS *opt, char *identity);
184 void options_set_status_callback(SSH_OPTIONS *opt, void (*callback)(void *arg, float status), void *arg);
185 void options_set_timeout(SSH_OPTIONS *opt, long seconds, long usec);
186 void options_set_ssh_dir(SSH_OPTIONS *opt, char *dir);
187 void options_set_known_hosts_file(SSH_OPTIONS *opt, char *dir);
188 /* buffer.c */
189 
190 BUFFER *buffer_new();
191 void buffer_free(BUFFER *buffer);
192 /* buffer_get returns a pointer to the begining of the buffer. no position is taken into account */
193 void *buffer_get(BUFFER *buffer);
194 /* same here */
195 int buffer_get_len(BUFFER *buffer);
196 
197 
198 /* in auth.c */
199 /* these functions returns AUTH_ERROR is some serious error has happened,
200   AUTH_SUCCESS if success,
201   AUTH_PARTIAL if partial success,
202   AUTH_DENIED if refused */
203 int ssh_userauth_none(SSH_SESSION *session,char *username);
204 int ssh_userauth_password(SSH_SESSION *session,char *username,char *password);
205 int ssh_userauth_offer_pubkey(SSH_SESSION *session, char *username,int type, STRING *publickey);
206 int ssh_userauth_pubkey(SSH_SESSION *session, char *username, STRING *publickey, PRIVATE_KEY *privatekey);
207 int ssh_userauth_autopubkey(SSH_SESSION *session);
208 int ssh_userauth_kbdint(SSH_SESSION *session, char *user, char *submethods);
209 int ssh_userauth_kbdint_getnprompts(SSH_SESSION *session);
210 char *ssh_userauth_kbdint_getname(SSH_SESSION *session);
211 char *ssh_userauth_kbdint_getinstruction(SSH_SESSION *session);
212 char *ssh_userauth_kbdint_getprompt(SSH_SESSION *session, int i, char *echo);
213 void ssh_userauth_kbdint_setanswer(SSH_SESSION *session, unsigned int i, char *answer);
214 
215 #ifdef __cplusplus
216 } ;
217 #endif
218 #endif /* _LIBSSH_H */
5773045 [rkeene@sledge /home/rkeene/projects/libssh-win32/v0.11/src/libssh-0.11/include/libssh]$

Click here to go back to the directory listing.
Click here to download this file.
last modified: 2005-03-04 19:54:59