assh/assh_context.h header reference
Description
The library uses a context structure to store stuff common to multiple sessions. This header file provides declaration of the assh_context_s structure and related functions.
Header inclusion
Members
Types
- struct assh_context_s
- enum assh_context_type_e
- struct assh_packet_pool_s
Functions
- void assh_context_cleanup(assh_context_s *ctx)
- assh_status_t assh_context_create(assh_context_s **ctx, assh_context_type_e type, assh_allocator_t *alloc, void *alloc_pv, const assh_prng_s *prng, const assh_buffer_s *prng_seed)
- void * assh_context_get_pv(const assh_context_s *ctx)
- assh_status_t assh_context_init(assh_context_s *ctx, assh_context_type_e type, assh_allocator_t *alloc, void *alloc_pv, const assh_prng_s *prng, const assh_buffer_s *prng_seed)
- assh_key_s ** assh_context_keys(assh_context_s *ctx)
- void assh_context_release(assh_context_s *ctx)
- void assh_context_set_keepalive(assh_context_s *c, uint_fast16_t keepalive)
- void assh_context_set_pv(assh_context_s *ctx, void *private)
- void assh_context_set_timeouts(assh_context_s *c, uint_fast8_t transport, uint_fast8_t kex, uint_fast16_t rekex, uint_fast16_t userauth)
- assh_status_t assh_deps_init(void )
Members detail
void assh_context_cleanup(assh_context_s *ctx)
This function is declared in assh/assh_context.h source file, line 232.
This function releases resources associated with an user allocated assh_context_s instance.
Any associated assh_session_s objects must have been released when this function is called.
See also assh_context_init.
assh_status_t assh_context_create(assh_context_s **ctx, assh_context_type_e type, assh_allocator_t *alloc, void *alloc_pv, const assh_prng_s *prng, const assh_buffer_s *prng_seed)
This function is declared in assh/assh_context.h source file, line 197.
This function allocates and initializes an assh_context_s instance.
If the alloc parameter is NULL, a default memory allocator will be used provided that one have been compiled in the library.
If the prng parameter is NULL, a default random generator will be used. Some random number generator require the seed argument to be not NULL.
See also assh_context_release.
void * assh_context_get_pv(const assh_context_s *ctx)
This function is declared in assh/assh_context.h source file, line 241.
This function retrieves the user private pointer attached to the context.
See also assh_context_set_pv.
assh_status_t assh_context_init(assh_context_s *ctx, assh_context_type_e type, assh_allocator_t *alloc, void *alloc_pv, const assh_prng_s *prng, const assh_buffer_s *prng_seed)
This function is declared in assh/assh_context.h source file, line 222.
This function initializes an user allocated assh_context_s instance. When a stable ABI is needed, the assh_context_create function must be used instead.
This requires the same arguments as the assh_context_create function.
See also assh_context_cleanup.
assh_key_s ** assh_context_keys(assh_context_s *ctx)
This function is declared in assh/assh_context.h source file, line 251.
This function returns the list head of keys attached to the context. It can be used to attach more keys. The assh_key_flush function will be called on this list on context cleanup.
See also asshh_hostkey_load_file and asshh_hostkey_load_filename.
void assh_context_release(assh_context_s *ctx)
This function is declared in assh/assh_context.h source file, line 206.
This function releases an assh_context_s instance created by the assh_context_create function as well as associated resources.
All existing assh_session_s objects must have been released when this function is called.
See also assh_context_create.
This struct is declared in assh/assh_context.h source file, line 74.
This struct is the library main context structure. It is designed to store resources shared between multiple assh_session_s instances.
It stores the following resources:
the set of registered algorithms,
the memory allocator context,
the random generator context,
the user configurable protocol timeouts,
the list of server host keys.
Field | Description |
---|---|
void * user_pv; | User private data |
assh_allocator_t * f_alloc; | Memory allocator function |
void * alloc_pv; | Memory allocator private data |
const assh_prng_s * prng; | Pseudo random number generator |
union <anonymous> { | Pseudo random number generator private data, allocated by the assh_prng_init_t function and freed by assh_prng_cleanup_t. |
void * prng_pv; | |
intptr_t prng_pvl; | |
}; | |
size_t session_count; | Number of initialized sessions attached to this context. |
assh_key_s * keys; | Head of loaded keys list |
const assh_algo_s ** algos; | Registered algorithms |
size_t algo_realloc:1; | Set if algos is not a static array |
size_t algo_max:15; | Number of algorithm slots |
size_t algo_cnt:16; | Number of registered algorithms |
uint32_t pck_pool_max_bsize; | Packet pool: maximum allocated size in a single bucket. |
uint32_t pck_pool_max_size; | Packet pool: maximum byte amount of spare packets before releasing to the memory allocator. |
uint32_t pck_pool_size; | Packet pool: current byte amount of spare packets not yet released to the memory allocator. |
assh_packet_pool_s pool[(16-6)]; | Packet pool buckets of spare packets by size. |
const assh_service_s * srvs[4]; | Registered services. |
assh_context_type_e type:2; | Client/server context type. |
size_t srvs_count:6; | Number of registered services |
uint8_t safety_weight; | Indicates how algorithms safety must be favored over speed. |
uint8_t timeout_transport; | Timeout waiting for reply to the version string and service start requests. Expressed in seconds minus 1. |
uint8_t timeout_kex; | Maximum duration of a key exchange, in seconds minus 1. |
uint16_t timeout_rekex; | Duration before initiating a new key exchanges, in seconds minus 1. |
uint16_t timeout_userauth; | Maximum duration of the user authentication process, in seconds minus 1. |
uint16_t timeout_keepalive; | Delay between transmission of the SSH_MSG_IGNORE packets by the running service for keepalive purpose, in seconds. Disabled when 0. |
size_t kex_init_size:16; | Estimated size of the kex init packet, computed when new algorithms are registered. |
void assh_context_set_keepalive(assh_context_s *c, uint_fast16_t keepalive)
This function is declared in assh/assh_context.h source file, line 169.
This function sets the idle delay before transmission of a keep-alive message by the running service. No keep-alive messages are transmitted when 0.
void assh_context_set_pv(assh_context_s *ctx, void *private)
This function is declared in assh/assh_context.h source file, line 237.
This function sets the user private pointer of the context.
See also assh_context_get_pv.
void assh_context_set_timeouts(assh_context_s *c, uint_fast8_t transport, uint_fast8_t kex, uint_fast16_t rekex, uint_fast16_t userauth)
This function is declared in assh/assh_context.h source file, line 163.
This function sets various timeout delays related to the transport layer. Values are expressed in second unit. When passing 0, the delay is not changed.
This enum is declared in assh/assh_context.h source file, line 40.
This specifies the type of ssh sessions that will be created.
Identifier | Value | Description |
---|---|---|
ASSH_SERVER | 0 | Sessions associated to the context will be server side. |
ASSH_CLIENT | 1 | Sessions associated to the context will be client side. |
ASSH_CLIENT_SERVER | 2 | No session can be associated to the context. The context may still be used to perform key management operations. |
assh_status_t assh_deps_init(void )
This function is declared in assh/assh_context.h source file, line 180.
This function takes care of performing the external libraries global initialization.
The assh library does not use global variables and does not require global initialization. You do not need to call this function if you know that you use a standalone build of assh or if you already perform the initialization of the required third party libraries in your application code.
This struct is for internal use only.
This struct is declared in assh/assh_context.h source file, line 54.
This struct is the packet pool allocator bucket structure. Freed packets are inserted in the linked list of the bucket associated with their size.
Field | Description |
---|---|
assh_packet_s * pck; | |
size_t count; | |
size_t size; |