1
1

doxygen fixes. Mostly typos and some comments.

sftp must be fully documented !


git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@187 7dcaeef0-15fb-0310-b436-a5af3365683c
Этот коммит содержится в:
Aris Adamantiadis 2008-11-04 21:59:12 +00:00
родитель 90bb81f7b0
Коммит 64e73b8d8a
12 изменённых файлов: 162 добавлений и 71 удалений

Просмотреть файл

@ -51,7 +51,7 @@ static int send_username(SSH_SESSION *session, char *username){
STRING *user;
/* returns SSH_AUTH_SUCCESS or SSH_AUTH_DENIED */
if(session->auth_service_asked)
return session->auth_service_asked;
return session->auth_service_asked;
buffer_add_u8(session->out_buffer,SSH_CMSG_USER);
if(!username)
if(!(username=session->options->username)){
@ -112,6 +112,9 @@ int ssh_userauth_offer_pubkey(SSH_SESSION *session, char *username,int type, STR
return err;
}
*/
/** \internal
* \todo implement ssh1 public key
*/
int ssh_userauth1_offer_pubkey(SSH_SESSION *session, char *username, int type,
STRING *pubkey){
return SSH_AUTH_DENIED;
@ -138,8 +141,8 @@ int ssh_userauth_pubkey(SSH_SESSION *session, char *username, STRING *publickey,
service=string_from_char("ssh-connection");
method=string_from_char("publickey");
algo=string_from_char(ssh_type_to_char(privatekey->type));
*/ /* we said previously the public key was accepted */
/* packet_clear_out(session);
buffer_add_u8(session->out_buffer,SSH2_MSG_USERAUTH_REQUEST);
@ -196,7 +199,7 @@ int ssh_userauth1_password(SSH_SESSION *session,char *username,char *password){
string_burn(password_s);
free(password_s);
packet_send(session);
return wait_auth1_status(session);
return wait_auth1_status(session);
}
#endif /* HAVE_SSH1 */

Просмотреть файл

@ -44,8 +44,12 @@ static int get_equals(char *string);
/* first part : base 64 to binary */
/* base64_to_bin translates a base64 string into a binary one. important, if something went wrong (ie incorrect char)*/
/* it returns NULL */
/** \brief base64_to_bin translates a base64 string into a binary one. important,
* \returns NULL if something went wrong (ie incorrect char)
* \returns BUFFER containing the decoded string
* \internal
*/
BUFFER *base64_to_bin(char *source){
int len;
int equals;
@ -120,7 +124,7 @@ BUFFER *base64_to_bin(char *source){
}
return NULL;
}
#define BLOCK(letter,n) do { ptr=strchr(alphabet,source[n]);\
if(!ptr) return -1;\
i=ptr-alphabet;\
@ -144,7 +148,7 @@ static int to_block4(unsigned long *block, char *source,int num){
return 0;
}
/* num = numbers of final bytes to be decoded */
/* num = numbers of final bytes to be decoded */
static int _base64_to_bin(unsigned char dest[3], char *source,int num){
unsigned long block;
if(to_block4(&block,source,num))
@ -164,7 +168,7 @@ static int get_equals(char *string){
*ptr=0;
ptr++;
}
return num;
}
@ -181,18 +185,21 @@ static void _bin_to_base64(unsigned char *dest, unsigned char source[3], int len
case 2:
dest[0]=alphabet[source[0]>>2];
dest[1]=alphabet[(source[1]>>4) | ((source[0] & BITS(2)) << 4)];
dest[2]=alphabet[(source[1]&BITS(4)) << 2];
dest[2]=alphabet[(source[1]&BITS(4)) << 2];
dest[3]='=';
break;
case 3:
dest[0]=alphabet[(source[0]>>2)];
dest[0]=alphabet[(source[0]>>2)];
dest[1]=alphabet[(source[1]>>4) | ((source[0] & BITS(2)) << 4)];
dest[2]=alphabet[ (source[2] >> 6) | (source[1]&BITS(4)) << 2];
dest[2]=alphabet[ (source[2] >> 6) | (source[1]&BITS(4)) << 2];
dest[3]=alphabet[source[2]&BITS(6)];
break;
}
}
/** \brief Converts binary data to a base64 string
* \returns the converted string
* \internal
*/
unsigned char *bin_to_base64(unsigned char *source, int len){
int flen=len + (3 - (len %3)); /* round to upper 3 multiple */
unsigned char *buffer;

Просмотреть файл

@ -39,7 +39,7 @@ BUFFER *buffer_new(){
return buffer;
}
/** \brief desallocate a buffer
/** \brief deallocate a buffer
* \param buffer buffer to free
*/
void buffer_free(BUFFER *buffer){
@ -90,19 +90,36 @@ void buffer_add_data(BUFFER *buffer,const void *data,int len){
buffer->used+=len;
}
/** \internal
* \brief add a SSH string to the tail of buffer
* \param buffer buffer
* \param string SSH String to add
*/
void buffer_add_ssh_string(BUFFER *buffer,STRING *string){
u32 len=ntohl(string->size);
buffer_add_data(buffer,string,len+sizeof(u32));
}
/** \internal
* \brief add a 32 bits unsigned integer to the tail of buffer
* \param buffer buffer
* \param data 32 bits integer
*/
void buffer_add_u32(BUFFER *buffer,u32 data){
buffer_add_data(buffer,&data,sizeof(data));
}
/** \internal
* \brief add a 64 bits unsigned integer to the tail of buffer
* \param buffer buffer
* \param data 64 bits integer
*/
void buffer_add_u64(BUFFER *buffer,u64 data){
buffer_add_data(buffer,&data,sizeof(data));
}
/** \internal
* \brief add a 8 bits unsigned integer to the tail of buffer
* \param buffer buffer
* \param data 8 bits integer
*/
void buffer_add_u8(BUFFER *buffer,u8 data){
buffer_add_data(buffer,&data,sizeof(u8));
}
@ -203,6 +220,14 @@ int buffer_pass_bytes_end(BUFFER *buffer,int len){
return len;
}
/** \internal
* \brief gets remaining data out of the buffer. Adjust the read pointer.
* \param buffer Buffer to read
* \param data data buffer where to store the data
* \param len length to read from the buffer
* \returns 0 if there is not enough data in buffer
* \returns len otherwise.
*/
int buffer_get_data(BUFFER *buffer, void *data, int len){
if(buffer->pos+len>buffer->used)
return 0; /*no enough data in buffer */
@ -210,19 +235,43 @@ int buffer_get_data(BUFFER *buffer, void *data, int len){
buffer->pos+=len;
return len; /* no yet support for partial reads (is it really needed ?? ) */
}
/** \internal
* \brief gets a 8 bits unsigned int out of the buffer. Adjusts the read pointer.
* \param buffer Buffer to read
* \param data pointer to a u8 where to store the data
* \returns 0 if there is not enough data in buffer
* \returns 1 otherwise.
*/
int buffer_get_u8(BUFFER *buffer, u8 *data){
return buffer_get_data(buffer,data,sizeof(u8));
}
/** \internal
* \brief gets a 32 bits unsigned int out of the buffer. Adjusts the read pointer.
* \param buffer Buffer to read
* \param data pointer to a u32 where to store the data
* \returns 0 if there is not enough data in buffer
* \returns 4 otherwise.
*/
int buffer_get_u32(BUFFER *buffer, u32 *data){
return buffer_get_data(buffer,data,sizeof(u32));
}
/** \internal
* \brief gets a 64 bits unsigned int out of the buffer. Adjusts the read pointer.
* \param buffer Buffer to read
* \param data pointer to a u64 where to store the data
* \returns 0 if there is not enough data in buffer
* \returns 8 otherwise.
*/
int buffer_get_u64(BUFFER *buffer, u64 *data){
return buffer_get_data(buffer,data,sizeof(u64));
}
/** \internal
* \brief gets a SSH String out of the buffer. Adjusts the read pointer.
* \param buffer Buffer to read
* \returns The SSH String read
* \returns NULL otherwise.
*/
STRING *buffer_get_ssh_string(BUFFER *buffer){
u32 stringlen;
u32 hostlen;
@ -241,8 +290,14 @@ STRING *buffer_get_ssh_string(BUFFER *buffer){
}
return str;
}
/** \internal
* \brief gets a mpint out of the buffer. Adjusts the read pointer.
* SSH-1 only
* \param buffer Buffer to read
* \returns the SSH String containing the mpint
* \returns NULL otherwise
*/
/* this one is SSH-1 only */
STRING *buffer_get_mpint(BUFFER *buffer){
u16 bits;
u32 len;

Просмотреть файл

@ -382,7 +382,7 @@ void channel_default_bufferize(CHANNEL *channel, void *data, int len, int is_std
}
}
/** \brief open a session channel (suited for a shell. Not tcp)
/** \brief open a session channel (suited for a shell. Not tcp Forwarding)
* \param channel an allocated channel (see channel_new())
* \return SSH_OK on success\n
* SSH_ERROR on error
@ -401,7 +401,7 @@ int channel_open_session(CHANNEL *channel){
else
return channel_open_session1(channel);
#endif
}
}
/** \brief open a TCP/IP forwarding channel.
* \param channel an allocated channel (see channel_new())
@ -461,7 +461,7 @@ void channel_free(CHANNEL *channel){
leave_function();
}
/** it doesn't close the channel. You may still read from it but not write.
/** it doesn't close the channel. You may still read from it but not write.
* \brief send an end of file on the channel
* \param channel channel
* \return SSH_ERROR on error\n
@ -723,7 +723,7 @@ int channel_change_pty_size(CHANNEL *channel,int cols,int rows){
buffer_free(buffer);
leave_function();
return err;
}
}
/** \brief requests a shell
* \param channel
@ -756,7 +756,7 @@ int channel_request_subsystem(CHANNEL *channel, char *system){
buffer_free(buffer);
return ret;
}
int channel_request_sftp( CHANNEL *channel){
return channel_request_subsystem(channel, "sftp");
}
@ -835,9 +835,9 @@ int channel_read(CHANNEL *channel, BUFFER *buffer,int bytes,int is_stderr){
/* maybe i should always set a buffer to avoid races between channel_default_bufferize and channel_read */
if(is_stderr)
stdbuf=channel->stderr_buffer;
else
else
stdbuf=channel->stdout_buffer;
/* We may have problem if the window is too small to accept as much data as asked */
ssh_log(session,SSH_LOG_PROTOCOL,"Read (%d) buffered : %d bytes. Window: %d",bytes,buffer_get_rest_len(stdbuf),channel->local_window);
if(bytes > buffer_get_rest_len(stdbuf) + channel->local_window)
@ -890,9 +890,9 @@ int channel_poll(CHANNEL *channel, int is_stderr){
enter_function();
if(is_stderr)
buffer=channel->stderr_buffer;
else
else
buffer=channel->stdout_buffer;
while(buffer_get_rest_len(buffer)==0 && !channel->remote_eof){
r=ssh_handle_packets(channel->session);
if(r<=0)
@ -918,7 +918,7 @@ int channel_poll(CHANNEL *channel, int is_stderr){
* \return number of bytes read\n
* 0 if nothing is available\n
* SSH_ERROR on error
* \warning don't forget to check for EOF as it would
* \warning don't forget to check for EOF as it would
* return 0 here
* \see channel_is_eof()
*/
@ -1015,7 +1015,7 @@ static int count_ptrs(CHANNEL **ptrs){
* \return SSH_SUCCESS operation successful\n
* SSH_EINTR select(2) syscall was interrupted, relaunch the function
*/
int channel_select(CHANNEL **readchans, CHANNEL **writechans, CHANNEL **exceptchans, struct
int channel_select(CHANNEL **readchans, CHANNEL **writechans, CHANNEL **exceptchans, struct
timeval * timeout){
fd_set rset;
fd_set wset;

Просмотреть файл

@ -87,10 +87,9 @@ int ssh_analyze_banner(SSH_SESSION *session, int *ssh1, int *ssh2){
return 0;
}
/* ssh_send_banner sends a SSH banner to the server */
/* TODO select a banner compatible with server version */
/* switch SSH1/1.5/2 */
/* and quit when the server is SSH1 only */
/** \internal
* \brief ssh_send_banner sends a SSH banner to the server
*/
int ssh_send_banner(SSH_SESSION *session,int server){
char *banner;
@ -269,12 +268,12 @@ int ssh_connect(SSH_SESSION *session){
ssh_set_error(session,SSH_FATAL,"Hostname required");
leave_function();
return SSH_ERROR;
}
}
if(options->fd != -1)
fd=options->fd;
else
fd=ssh_connect_host(session,options->host,options->bindaddr,options->port,
options->timeout,options->timeout_usec);
options->timeout,options->timeout_usec);
if(fd<0){
leave_function();
return -1;
@ -336,7 +335,7 @@ int ssh_connect(SSH_SESSION *session){
session->alive=0;
leave_function();
return -1;
}
}
set_status(options,1.0);
session->connected=1;
break;
@ -349,14 +348,14 @@ int ssh_connect(SSH_SESSION *session){
}
set_status(options,0.6);
session->connected=1;
break;
break;
}
leave_function();
return 0;
}
/** this is the banner showing a disclaimer to users who log in,
* typicaly their right or the fact that they will be monitored
* typically their right or the fact that they will be monitored
* \brief get the issue banner from the server
* \param session ssh session
* \return NULL if there is no issue banner, else a string containing it.

Просмотреть файл

@ -136,9 +136,12 @@ int ssh_connect_ai_timeout(SSH_SESSION *session, const char *host, int port, str
return s;
}
/* connect_host connects to an IPv4 (or IPv6) host */
/* specified by its IP address or hostname. */
/* output is the file descriptor, <0 if failed. */
/** \internal
* \brief connect_host connects to an IPv4 (or IPv6) host
* specified by its IP address or hostname.
* \returns file descriptor
* \returns less than 0 value
*/
socket_t ssh_connect_host(SSH_SESSION *session, const char *host, const char
*bind_addr, int port,long timeout, long usec){

Просмотреть файл

@ -25,7 +25,14 @@ MA 02111-1307, USA. */
#ifdef _WIN32
#include <winsock2.h>
#endif
/**
* \addtogroup ssh_session
* @{
*/
/**
* \brief finalize and cleanup all libssh and cryptographic data structures
* \returns 0
*/
int ssh_finalize()
{
ssh_crypto_finalize();
@ -39,3 +46,7 @@ int ssh_finalize()
#endif
return 0;
}
/**
* @}
*/

Просмотреть файл

@ -93,7 +93,7 @@ u32 asn1_get_len(BUFFER *buffer)
{
u32 len;
unsigned char tmp[4];
if (!buffer_get_data(buffer,tmp,1))
return 0;
if (tmp[0] > 127)
@ -115,7 +115,7 @@ STRING *asn1_get_int(BUFFER *buffer)
STRING *ret;
unsigned char type;
u32 size;
if (!buffer_get_data(buffer,&type,1) || type != ASN1_INTEGER)
return NULL;
size=asn1_get_len(buffer);
@ -201,7 +201,7 @@ int privatekey_decrypt(int algo, int mode, unsigned int key_len,
unsigned char key[MAX_KEY_SIZE];
unsigned char *tmp;
gcry_error_t err;
if (!algo)
return 1;
passphrase_len=cb(passphrase, MAX_PASSPHRASE_SIZE, 0, desc);
@ -221,12 +221,12 @@ int privatekey_decrypt(int algo, int mode, unsigned int key_len,
memcpy(buffer_get(data), tmp, buffer_get_len(data));
gcry_cipher_close(cipher);
return 1;
}
}
int privatekey_dek_header(char *header, unsigned int header_len, int *algo, int *mode, unsigned int *key_len, unsigned char **iv, unsigned int *iv_len)
{
unsigned int iv_pos;
if (header_len > 13 && !strncmp("DES-EDE3-CBC", header, 12))
{
*algo = GCRY_CIPHER_3DES;
@ -376,7 +376,7 @@ int read_rsa_privatekey(FILE *fp, gcry_sexp_t *r,
STRING *u;
STRING *v;
BUFFER *buffer;
if (!(buffer=privatekey_file_to_buffer(fp, TYPE_RSA, cb, desc)))
return 0;
if (!asn1_check_sequence(buffer))
@ -423,7 +423,7 @@ int read_dsa_privatekey(FILE *fp, gcry_sexp_t *r, int cb(char *, int , int , cha
STRING *x;
STRING *v;
BUFFER *buffer;
if (!(buffer=privatekey_file_to_buffer(fp, TYPE_DSS, cb, desc)))
return 0;
if (!asn1_check_sequence(buffer))
@ -554,8 +554,8 @@ PRIVATE_KEY *privatekey_from_file(SSH_SESSION *session,char *filename,int type,
} else {
ssh_set_error(session,SSH_FATAL,"Invalid private key type %d",type);
return NULL;
}
}
privkey=malloc(sizeof(PRIVATE_KEY));
privkey->type=type;
privkey->dsa_priv=dsa;
@ -623,7 +623,7 @@ PRIVATE_KEY *_privatekey_from_file(void *session,char *filename,int type){
return privkey;
}
/** \brief Desallocate a private key
/** \brief deallocate a private key
* \param prv a PRIVATE_KEY object
*/
void private_key_free(PRIVATE_KEY *prv){
@ -731,7 +731,7 @@ STRING *publickey_from_next_file(SSH_SESSION *session,char **pub_keys_path,char
if(!ssh_file_readaccess_ok(public)){
ssh_log(session,SSH_LOG_PACKET,"Failed");
return publickey_from_next_file(session,pub_keys_path,keys_path,privkeyfile,type,count);
}
}
snprintf(private,256,priv,home);
ssh_log(session,SSH_LOG_PACKET,"Trying to open private key %s",private);
if(!ssh_file_readaccess_ok(private)){
@ -812,7 +812,7 @@ static char **ssh_parse_knownhost(char *filename, char *hostname, char *type){
/* we allow spaces or ',' to follow the hostname. It's generaly an IP */
/* we don't care about ip, if the host key match there is no problem with ip */
if(strncasecmp(ptr,hostname,strlen(hostname))==0){
if(ptr[strlen(hostname)]==' ' || ptr[strlen(hostname)]=='\0'
if(ptr[strlen(hostname)]==' ' || ptr[strlen(hostname)]=='\0'
|| ptr[strlen(hostname)]==','){
if(strcasecmp(found_type, type)==0){
fclose(file);
@ -929,7 +929,7 @@ int ssh_is_server_known(SSH_SESSION *session){
return SSH_SERVER_KNOWN_OK;
}
/** You generaly use it when ssh_is_server_known() answered SSH_SERVER_NOT_KNOWN
/** You generaly use it when ssh_is_server_known() answered SSH_SERVER_NOT_KNOWN
* \brief write the current server as known in the known hosts file
* \param session ssh session
* \return 0 on success, -1 on error

Просмотреть файл

@ -18,13 +18,16 @@ You should have received a copy of the GNU Lesser General Public License
along with the SSH Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
/* this file contains the Message parsing utilities for server programs using
* libssh. The main loop of the program will call ssh_message_get(session) to
/** \defgroup ssh_messages SSH Messages
* this file contains the Message parsing utilities for server programs using
* libssh. The main loop of the program will call ssh_message_get(session) to
* get messages as they come. they are not 1-1 with the protocol messages.
* then, the user will know what kind of a message it is and use the appropriate
* functions to handle it (or use the default handlers if she doesn't know what to
* do */
* do
* \addtogroup ssh_messages
* @{
*/
#include <string.h>
#include <stdlib.h>
@ -143,7 +146,7 @@ static int ssh_message_auth_reply_default(SSH_MESSAGE *msg,int partial){
strcat(methods_c,"password,");
if(session->auth_methods & SSH_AUTH_HOSTBASED)
strcat(methods_c,"hostbased,");
methods_c[strlen(methods_c)-1]=0; // strip the comma. We are sure there is at
methods_c[strlen(methods_c)-1]=0; // strip the comma. We are sure there is at
// least one word into the list
ssh_say(2,"Sending a auth failure. methods that can continue : %s\n",methods_c);
methods=string_from_char(methods_c);
@ -296,7 +299,7 @@ static SSH_MESSAGE *handle_channel_request(SSH_SESSION *session){
leave_function();
return msg;
}
msg->channel_request.type=SSH_CHANNEL_UNKNOWN;
free(type_c);
leave_function();
@ -444,3 +447,5 @@ void ssh_message_free(SSH_MESSAGE *msg){
}
memset(msg,0,sizeof(*msg));
}
/** @}
*/

Просмотреть файл

@ -19,8 +19,11 @@ along with the SSH Library; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
/* from times to times, you need to serve your friends */
/* and, perhaps, ssh connections. */
/**
* \defgroup ssh_server SSH Server
* \addtogroup ssh_server
* @{
*/
#include <fcntl.h>
#include <unistd.h>
@ -63,7 +66,7 @@ static socket_t bind_socket(SSH_BIND *ssh_bind,char *hostname, int port) {
close(s);
return -1;
}
memset(&myaddr, 0, sizeof(myaddr));
memcpy(&myaddr.sin_addr,hp->h_addr,hp->h_length);
myaddr.sin_family=hp->h_addrtype;
@ -296,4 +299,5 @@ int ssh_accept(SSH_SESSION *session){
session->connected=1;
return 0;
}
/** @}
*/

Просмотреть файл

@ -23,6 +23,7 @@ MA 02111-1307, USA. */
/** \defgroup ssh_sftp SFTP functions
* \brief SFTP handling functions
* \bug Write docs !
*/
/** \addtogroup ssh_sftp
* @{ */

Просмотреть файл

@ -28,7 +28,7 @@ MA 02111-1307, USA. */
/** \addtogroup ssh_string
* @{ */
/**
/**
* \brief Creates a new SSH String object
* \param size size of the string
* \return the newly allocated string
@ -71,7 +71,7 @@ int string_len(STRING *str){
* \brief convert a SSH string to a C nul-terminated string
* \param str the input SSH string
* \return a malloc'ed string pointer.
* \warning If the input SSH string contains zeroes, some parts of
* \warning If the input SSH string contains zeroes, some parts of
* the output string may not be readable with regular libc functions.
*/
char *string_to_char(STRING *str){
@ -89,6 +89,9 @@ STRING *string_copy(STRING *str){
return ret;
}
/** \brief destroy data in a string so it couldn't appear in a core dump
* \param s string to burn
*/
void string_burn(STRING *s){
memset(s->string,'X',string_len(s));
}
@ -98,7 +101,7 @@ void *string_data(STRING *s){
}
/**
* \brief desallocate a STRING object
* \brief deallocate a STRING object
* \param s String to delete
*/
void string_free(STRING *s){