libssh  0.10.90
The SSH library
Loading...
Searching...
No Matches
Macros | Functions
The SSH buffer functions
Collaboration diagram for The SSH buffer functions:

Macros

#define buffer_verify(x)
 

Functions

struct ssh_buffer_struct * ssh_buffer_new (void)
 Create a new SSH buffer.
 
void ssh_buffer_free (struct ssh_buffer_struct *buffer)
 Deallocate a SSH buffer.
 
void ssh_buffer_set_secure (ssh_buffer buffer)
 Sets the buffer as secure.
 
int ssh_buffer_reinit (struct ssh_buffer_struct *buffer)
 Reinitialize a SSH buffer.
 
int ssh_buffer_add_data (struct ssh_buffer_struct *buffer, const void *data, uint32_t len)
 Add data at the tail of a buffer.
 
int ssh_buffer_allocate_size (struct ssh_buffer_struct *buffer, uint32_t len)
 Ensure the buffer has at least a certain preallocated size.
 
void * ssh_buffer_allocate (struct ssh_buffer_struct *buffer, uint32_t len)
 
int ssh_buffer_add_ssh_string (struct ssh_buffer_struct *buffer, struct ssh_string_struct *string)
 
int ssh_buffer_add_u32 (struct ssh_buffer_struct *buffer, uint32_t data)
 
int ssh_buffer_add_u16 (struct ssh_buffer_struct *buffer, uint16_t data)
 
int ssh_buffer_add_u64 (struct ssh_buffer_struct *buffer, uint64_t data)
 
int ssh_buffer_add_u8 (struct ssh_buffer_struct *buffer, uint8_t data)
 
int ssh_buffer_prepend_data (struct ssh_buffer_struct *buffer, const void *data, uint32_t len)
 
int ssh_buffer_add_buffer (struct ssh_buffer_struct *buffer, struct ssh_buffer_struct *source)
 
void * ssh_buffer_get (struct ssh_buffer_struct *buffer)
 Get a pointer to the head of a buffer at the current position.
 
uint32_t ssh_buffer_get_len (struct ssh_buffer_struct *buffer)
 Get the length of the buffer from the current position.
 
uint32_t ssh_buffer_pass_bytes (struct ssh_buffer_struct *buffer, uint32_t len)
 
uint32_t ssh_buffer_pass_bytes_end (struct ssh_buffer_struct *buffer, uint32_t len)
 
uint32_t ssh_buffer_get_data (struct ssh_buffer_struct *buffer, void *data, uint32_t len)
 Get the remaining data out of the buffer and adjust the read pointer.
 
uint32_t ssh_buffer_get_u8 (struct ssh_buffer_struct *buffer, uint8_t *data)
 
uint32_t ssh_buffer_get_u32 (struct ssh_buffer_struct *buffer, uint32_t *data)
 
uint32_t ssh_buffer_get_u64 (struct ssh_buffer_struct *buffer, uint64_t *data)
 
int ssh_buffer_validate_length (struct ssh_buffer_struct *buffer, size_t len)
 Validates that the given length can be obtained from the buffer.
 
struct ssh_string_struct * ssh_buffer_get_ssh_string (struct ssh_buffer_struct *buffer)
 
int ssh_buffer_pack_va (struct ssh_buffer_struct *buffer, const char *format, size_t argc, va_list ap)
 
int _ssh_buffer_pack (struct ssh_buffer_struct *buffer, const char *format, size_t argc,...)
 
int ssh_buffer_unpack_va (struct ssh_buffer_struct *buffer, const char *format, size_t argc, va_list ap)
 
int _ssh_buffer_unpack (struct ssh_buffer_struct *buffer, const char *format, size_t argc,...)
 

Detailed Description

Functions to handle SSH buffers.

Function Documentation

◆ ssh_buffer_add_data()

int ssh_buffer_add_data ( struct ssh_buffer_struct * buffer,
const void * data,
uint32_t len )

Add data at the tail of a buffer.

Parameters
[in]bufferThe buffer to add the data.
[in]dataA pointer to the data to add.
[in]lenThe length of the data to add.
Returns
0 on success, < 0 on error.

◆ ssh_buffer_allocate_size()

int ssh_buffer_allocate_size ( struct ssh_buffer_struct * buffer,
uint32_t len )

Ensure the buffer has at least a certain preallocated size.

Parameters
[in]bufferThe buffer to enlarge.
[in]lenThe length to ensure as allocated.
Returns
0 on success, < 0 on error.

◆ ssh_buffer_free()

void ssh_buffer_free ( struct ssh_buffer_struct * buffer)

Deallocate a SSH buffer.

Parameters
[in]bufferThe buffer to free.

◆ ssh_buffer_get()

void * ssh_buffer_get ( struct ssh_buffer_struct * buffer)

Get a pointer to the head of a buffer at the current position.

Parameters
[in]bufferThe buffer to get the head pointer.
Returns
A pointer to the data from current position.
See also
ssh_buffer_get_len()

◆ ssh_buffer_get_data()

uint32_t ssh_buffer_get_data ( struct ssh_buffer_struct * buffer,
void * data,
uint32_t len )

Get the remaining data out of the buffer and adjust the read pointer.

Parameters
[in]bufferThe buffer to read.
[in]dataThe data buffer where to store the data.
[in]lenThe length to read from the buffer.
Returns
0 if there is not enough data in buffer, len otherwise.

◆ ssh_buffer_get_len()

uint32_t ssh_buffer_get_len ( struct ssh_buffer_struct * buffer)

Get the length of the buffer from the current position.

Parameters
[in]bufferThe buffer to get the length from.
Returns
The length of the buffer.
See also
ssh_buffer_get()

◆ ssh_buffer_new()

struct ssh_buffer_struct * ssh_buffer_new ( void )

Create a new SSH buffer.

Returns
A newly initialized SSH buffer, NULL on error.

◆ ssh_buffer_reinit()

int ssh_buffer_reinit ( struct ssh_buffer_struct * buffer)

Reinitialize a SSH buffer.

In case the buffer has exceeded 64K in size, the buffer will be reallocated to 64K.

Parameters
[in]bufferThe buffer to reinitialize.
Returns
0 on success, < 0 on error.

◆ ssh_buffer_set_secure()

void ssh_buffer_set_secure ( ssh_buffer buffer)

Sets the buffer as secure.

A secure buffer will never leave cleartext data in the heap after being reallocated or freed.

Parameters
[in]bufferbuffer to set secure.

◆ ssh_buffer_validate_length()

int ssh_buffer_validate_length ( struct ssh_buffer_struct * buffer,
size_t len )

Validates that the given length can be obtained from the buffer.

Parameters
[in]bufferThe buffer to read from.
[in]lenThe length to be checked.
Returns
SSH_OK if the length is valid, SSH_ERROR otherwise.