|
Packit Service |
31306d |
/*
|
|
Packit Service |
31306d |
* This file is part of the SSH Library
|
|
Packit Service |
31306d |
*
|
|
Packit Service |
31306d |
* Copyright (c) 2009 by Aris Adamantiadis
|
|
Packit Service |
31306d |
*
|
|
Packit Service |
31306d |
* This library is free software; you can redistribute it and/or
|
|
Packit Service |
31306d |
* modify it under the terms of the GNU Lesser General Public
|
|
Packit Service |
31306d |
* License as published by the Free Software Foundation; either
|
|
Packit Service |
31306d |
* version 2.1 of the License, or (at your option) any later version.
|
|
Packit Service |
31306d |
*
|
|
Packit Service |
31306d |
* This library is distributed in the hope that it will be useful,
|
|
Packit Service |
31306d |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
31306d |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
31306d |
* Lesser General Public License for more details.
|
|
Packit Service |
31306d |
*
|
|
Packit Service |
31306d |
* You should have received a copy of the GNU Lesser General Public
|
|
Packit Service |
31306d |
* License along with this library; if not, write to the Free Software
|
|
Packit Service |
31306d |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
Packit Service |
31306d |
*/
|
|
Packit Service |
31306d |
|
|
Packit Service |
31306d |
#ifndef BUFFER_H_
|
|
Packit Service |
31306d |
#define BUFFER_H_
|
|
Packit Service |
31306d |
|
|
Packit Service |
31306d |
#include <stdarg.h>
|
|
Packit Service |
31306d |
|
|
Packit Service |
31306d |
#include "libssh/libssh.h"
|
|
Packit Service |
31306d |
|
|
Packit Service |
31306d |
#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
|
|
Packit Service |
31306d |
|
|
Packit Service |
31306d |
void ssh_buffer_set_secure(ssh_buffer buffer);
|
|
Packit Service |
31306d |
int ssh_buffer_add_ssh_string(ssh_buffer buffer, ssh_string string);
|
|
Packit Service |
31306d |
int ssh_buffer_add_u8(ssh_buffer buffer, uint8_t data);
|
|
Packit Service |
31306d |
int ssh_buffer_add_u16(ssh_buffer buffer, uint16_t data);
|
|
Packit Service |
31306d |
int ssh_buffer_add_u32(ssh_buffer buffer, uint32_t data);
|
|
Packit Service |
31306d |
int ssh_buffer_add_u64(ssh_buffer buffer, uint64_t data);
|
|
Packit Service |
31306d |
|
|
Packit Service |
31306d |
int ssh_buffer_validate_length(struct ssh_buffer_struct *buffer, size_t len);
|
|
Packit Service |
31306d |
|
|
Packit Service |
31306d |
void *ssh_buffer_allocate(struct ssh_buffer_struct *buffer, uint32_t len);
|
|
Packit Service |
31306d |
int ssh_buffer_allocate_size(struct ssh_buffer_struct *buffer, uint32_t len);
|
|
Packit Service |
31306d |
int ssh_buffer_pack_va(struct ssh_buffer_struct *buffer,
|
|
Packit Service |
31306d |
const char *format,
|
|
Packit Service |
31306d |
size_t argc,
|
|
Packit Service |
31306d |
va_list ap);
|
|
Packit Service |
31306d |
int _ssh_buffer_pack(struct ssh_buffer_struct *buffer,
|
|
Packit Service |
31306d |
const char *format,
|
|
Packit Service |
31306d |
size_t argc,
|
|
Packit Service |
31306d |
...);
|
|
Packit Service |
31306d |
#define ssh_buffer_pack(buffer, format, ...) \
|
|
Packit Service |
31306d |
_ssh_buffer_pack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
|
|
Packit Service |
31306d |
|
|
Packit Service |
31306d |
int ssh_buffer_unpack_va(struct ssh_buffer_struct *buffer,
|
|
Packit Service |
31306d |
const char *format, size_t argc,
|
|
Packit Service |
31306d |
va_list ap);
|
|
Packit Service |
31306d |
int _ssh_buffer_unpack(struct ssh_buffer_struct *buffer,
|
|
Packit Service |
31306d |
const char *format,
|
|
Packit Service |
31306d |
size_t argc,
|
|
Packit Service |
31306d |
...);
|
|
Packit Service |
31306d |
#define ssh_buffer_unpack(buffer, format, ...) \
|
|
Packit Service |
31306d |
_ssh_buffer_unpack((buffer), (format), __VA_NARG__(__VA_ARGS__), __VA_ARGS__, SSH_BUFFER_PACK_END)
|
|
Packit Service |
31306d |
|
|
Packit Service |
31306d |
int ssh_buffer_prepend_data(ssh_buffer buffer, const void *data, uint32_t len);
|
|
Packit Service |
31306d |
int ssh_buffer_add_buffer(ssh_buffer buffer, ssh_buffer source);
|
|
Packit Service |
31306d |
|
|
Packit Service |
31306d |
/* buffer_read_*() returns the number of bytes read, except for ssh strings */
|
|
Packit Service |
31306d |
int ssh_buffer_get_u8(ssh_buffer buffer, uint8_t *data);
|
|
Packit Service |
31306d |
int ssh_buffer_get_u32(ssh_buffer buffer, uint32_t *data);
|
|
Packit Service |
31306d |
int ssh_buffer_get_u64(ssh_buffer buffer, uint64_t *data);
|
|
Packit Service |
31306d |
|
|
Packit Service |
31306d |
/* ssh_buffer_get_ssh_string() is an exception. if the String read is too large or invalid, it will answer NULL. */
|
|
Packit Service |
31306d |
ssh_string ssh_buffer_get_ssh_string(ssh_buffer buffer);
|
|
Packit Service |
31306d |
|
|
Packit Service |
31306d |
/* ssh_buffer_pass_bytes acts as if len bytes have been read (used for padding) */
|
|
Packit Service |
31306d |
uint32_t ssh_buffer_pass_bytes_end(ssh_buffer buffer, uint32_t len);
|
|
Packit Service |
31306d |
uint32_t ssh_buffer_pass_bytes(ssh_buffer buffer, uint32_t len);
|
|
Packit Service |
31306d |
|
|
Packit Service |
31306d |
#endif /* BUFFER_H_ */
|