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

Click here to go back to the directory listing.
Click here to download this file.
last modified: 2007-02-17 17:46:50