1libssh2_session_supported_algs(3)libssh2 manuallibssh2_session_supported_algs(3)
2
3
4
6 libssh2_session_supported_algs - get list of supported algorithms
7
9 #include <libssh2.h>
10
11 int libssh2_session_supported_algs(LIBSSH2_SESSION* session,
12 int method_type,
13 const char*** algs);
14
16 session - An instance of initialized LIBSSH2_SESSION (the function will
17 use its pointer to the memory allocation function). method_type -
18 Method type. See .BR libssh2_session_method_pref(3). algs - Address of
19 a pointer that will point to an array of returned algorithms
20
21 Get a list of supported algorithms for the given method_type. The
22 method_type parameter is equivalent to method_type in libssh2_ses‐
23 sion_method_pref(3). If successful, the function will allocate the
24 appropriate amount of memory. When not needed anymore, it must be deal‐
25 located by calling libssh2_free(3). When this function is unsuccessful,
26 this must not be done.
27
28 In order to get a list of all supported compression algorithms, lib‐
29 ssh2_session_flag(session, LIBSSH2_FLAG_COMPRESS, 1) must be called
30 before calling this function, otherwise only "none" will be returned.
31
32 If successful, the function will allocate and fill the array with sup‐
33 ported algorithms (the same names as defined in RFC 4253). The array
34 is not NULL terminated.
35
37 #include "libssh2.h"
38
39 const char **algorithms;
40 int rc, i;
41 LIBSSH2_SESSION *session;
42
43 /* initialize session */
44 session = libssh2_session_init();
45 rc = libssh2_session_supported_algs(session,
46 LIBSSH2_METHOD_CRYPT_CS,
47 &algorithms);
48 if (rc>0) {
49 /* the call succeeded, do sth. with the list of algorithms
50 (e.g. list them)... */
51 printf("Supported symmetric algorithms:0);
52 for ( i=0; i<rc; i++ )
53 printf("%s0, algorithms[i]);
54
55 /* ... and free the allocated memory when not needed anymore */
56 libssh2_free(session, algorithms);
57 }
58 else {
59 /* call failed, error handling */
60 }
61
63 On success, a number of returned algorithms (i.e a positive number will
64 be returned). In case of a failure, an error code (a negative number,
65 see below) is returned. 0 should never be returned.
66
68 LIBSSH2_ERROR_BAD_USE - Invalid address of algs.
69
70 LIBSSH2_ERROR_METHOD_NOT_SUPPORTED - Unknown method type.
71
72 LIBSSH2_ERROR_INVAL - Internal error (normally should not occur).
73
74 LIBSSH2_ERROR_ALLOC - Allocation of memory failed.
75
77 Added in 1.4.0
78
80 libssh2_session_methods(3), libssh2_session_method_pref(3) lib‐
81 ssh2_free(3)
82
83
84
85libssh2 1.4.0 23 Oct 2011libssh2_session_supported_algs(3)