26 #include "libssh/libssh.h" 34 struct ssh_buffer_struct {
42 #define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3) 49 int buffer_add_ssh_string(ssh_buffer buffer, ssh_string
string);
50 int buffer_add_u8(ssh_buffer buffer, uint8_t data);
51 int buffer_add_u16(ssh_buffer buffer, uint16_t data);
52 int buffer_add_u32(ssh_buffer buffer, uint32_t data);
53 int buffer_add_u64(ssh_buffer buffer, uint64_t data);
54 int ssh_buffer_add_data(ssh_buffer buffer,
const void *data, uint32_t len);
58 int ssh_buffer_pack_va(
struct ssh_buffer_struct *buffer,
62 int _ssh_buffer_pack(
struct ssh_buffer_struct *buffer,
66 #define ssh_buffer_pack(buffer, format, ...) \ 67 _ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END) 69 int ssh_buffer_unpack_va(
struct ssh_buffer_struct *buffer,
70 const char *format,
int argc,
72 int _ssh_buffer_unpack(
struct ssh_buffer_struct *buffer,
76 #define ssh_buffer_unpack(buffer, format, ...) \ 77 _ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END) 79 int buffer_prepend_data(ssh_buffer buffer,
const void *data, uint32_t len);
80 int buffer_add_buffer(ssh_buffer buffer, ssh_buffer source);
81 int ssh_buffer_reinit(ssh_buffer buffer);
84 void *buffer_get_rest(ssh_buffer buffer);
86 uint32_t buffer_get_rest_len(ssh_buffer buffer);
89 int buffer_get_u8(ssh_buffer buffer, uint8_t *data);
90 int buffer_get_u32(ssh_buffer buffer, uint32_t *data);
91 int buffer_get_u64(ssh_buffer buffer, uint64_t *data);
93 uint32_t buffer_get_data(ssh_buffer buffer,
void *data, uint32_t requestedlen);
95 ssh_string buffer_get_ssh_string(ssh_buffer buffer);
97 ssh_string buffer_get_mpint(ssh_buffer buffer);
99 uint32_t buffer_pass_bytes_end(ssh_buffer buffer, uint32_t len);
100 uint32_t buffer_pass_bytes(ssh_buffer buffer, uint32_t len);
int ssh_buffer_validate_length(struct ssh_buffer_struct *buffer, size_t len)
Valdiates that the given length can be obtained from the buffer.
Definition: buffer.c:632
void ssh_buffer_free(struct ssh_buffer_struct *buffer)
Deallocate a SSH buffer.
Definition: buffer.c:102
void * ssh_buffer_get_begin(struct ssh_buffer_struct *buffer)
Get a pointer on the head of a buffer.
Definition: buffer.c:450
uint32_t ssh_buffer_get_len(struct ssh_buffer_struct *buffer)
Get the length of the buffer, not counting position.
Definition: buffer.c:479
LIBSSH_API ssh_buffer ssh_buffer_new(void)
Create a new SSH buffer.
Definition: buffer.c:86
void ssh_buffer_set_secure(ssh_buffer buffer)
Sets the buffer as secure.
Definition: buffer.c:125