#226: Server ID string missing --------------------------+------------------------------------------------- Reporter: dzejk | Owner: Type: enhancement | Status: new Priority: normal | Milestone: 1.3.0 Component: API | Version: 1.2.8 Keywords: server id | Blocks: Blocked By: | --------------------------+------------------------------------------------- Sometimes a user may be interested in server's ID ("remote banner"), for instance, some SSH servers don't support all functionality etc...
In my opinion, the API should have a function that returns this server ID string. In fact this is very simple since it is stored in session->remote.banner. My implementation: Put the following anywhere in src/session.c: {{{ /* libssh2_remote_banner_get * Get the remote banner (server ID string) */ LIBSSH2_API const char* libssh2_remote_banner_get(LIBSSH2_SESSION* session) { /* Open question: if not set, can NULL be returned and the user should handle it? Open question: to introduce any checks if the session is established (and the banner makes sense)? */ /* to avoid a coredump when session is NULL */ if ( NULL == session ) { return NULL; } if ( NULL==session->remote.banner ) { return NULL; } return (const char *) session->remote.banner; } }}} As long as this function is not used by other library functions, there is no need to declare it in src/session.h. It must be declared, however, anywhere in include/libssh2.h, so it is available to a client application: {{{ LIBSSH2_API const char* libssh2_remote_banner_get(LIBSSH2_SESSION* session); }}} I have successfully built it on FreeBSD 8.2/i386 with libssh2 1.2.9. I have tested it connectiing to two SSH servers: OpenSSH and WinSSHD and received expected results: "SSH-2.0-OpenSSH_5.4p1 FreeBSD-20100308" and "SSH-2.0-1.09 FlowSsh: WinSSHD 5.23", respectively. When the function's name and its interface are finally agreed, its man page should be prepared as well. (BTW, IMHO both libssh2_banner_set and this function should be placed into "namespace" '''session''') PS: I wanted to choose version 1.2.9, but only 1.2.8. is available. -- Ticket URL: <http://trac.libssh2.org/ticket/226> libssh2 <http://trac.libssh2.org/> C library for writing portable SSH2 clients _______________________________________________ libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel