assh/assh_packet.h header reference
Description [link]
This header provides functions used to build and parse the packet format used the ssh2 protocol.
See also assh/assh_buffer.h.
Header inclusion [link]
Members [link]
Types [link]
- enum assh_ssh_disconnect_e
- enum assh_ssh_msg_e
- struct assh_packet_head_s
- struct assh_packet_s
- enum assh_padding_policy_e
- enum assh_ssh_msg_ranges_e
Functions [link]
- void assh_packet_collect(struct assh_context_s *c)
- assh_status_t assh_packet_add_array(struct assh_packet_s *p, size_t len, uint8_t **result)
- assh_status_t assh_packet_add_string(struct assh_packet_s *p, size_t len, uint8_t **result)
- assh_status_t assh_packet_add_u32(struct assh_packet_s *p, uint32_t value)
- assh_status_t assh_packet_alloc(struct assh_context_s *c, uint8_t msg, size_t payload_size_m1, struct assh_packet_s **result)
- assh_status_t assh_packet_alloc_raw(struct assh_context_s *c, size_t raw_size, struct assh_packet_s **p)
- assh_status_t assh_packet_check_array(const struct assh_packet_s *p, const uint8_t *array, size_t array_len, const uint8_t **next)
- assh_status_t assh_packet_check_string(const struct assh_packet_s *p, const uint8_t *str, const uint8_t **next)
- assh_status_t assh_packet_check_u32(const struct assh_packet_s *p, uint32_t *u32, const uint8_t *data, const uint8_t **next)
- assh_status_t assh_packet_dup(struct assh_packet_s *p, struct assh_packet_s **copy)
- assh_status_t assh_packet_enlarge_string(struct assh_packet_s *p, uint8_t *str, size_t len, uint8_t **result)
- void assh_packet_queue_cleanup(struct assh_queue_s *q)
- assh_status_t assh_packet_realloc_raw(struct assh_context_s *c, struct assh_packet_s **p_, size_t raw_size)
- struct assh_packet_s * assh_packet_refinc(struct assh_packet_s *p)
- void assh_packet_release(struct assh_packet_s *p)
- void assh_packet_shrink_string(struct assh_packet_s *p, uint8_t *str, size_t new_len)
- void assh_packet_string_resized(struct assh_packet_s *p, uint8_t *str)
Macros [link]
Members detail [link]
void assh_packet_collect(struct assh_context_s *c) [link]
This function is declared in assh/assh_packet.h source file, line 242.
This function forces garbage collect of packets. This does nothing when CONFIG_ASSH_PACKET_POOL is not defined.
enum assh_ssh_disconnect_e [link]
This enum is declared in assh/assh_packet.h source file, line 199.
This enum specifies standard ssh2 disconnect reasons.
Identifier | Value | Description |
---|---|---|
SSH_DISCONNECT_HOST_NOT_ALLOWED_TO_CONNECT | 1 | |
SSH_DISCONNECT_PROTOCOL_ERROR | 2 | |
SSH_DISCONNECT_KEY_EXCHANGE_FAILED | 3 | |
SSH_DISCONNECT_RESERVED | 4 | |
SSH_DISCONNECT_MAC_ERROR | 5 | |
SSH_DISCONNECT_COMPRESSION_ERROR | 6 | |
SSH_DISCONNECT_SERVICE_NOT_AVAILABLE | 7 | |
SSH_DISCONNECT_PROTOCOL_VERSION_NOT_SUPPORTED | 8 | |
SSH_DISCONNECT_HOST_KEY_NOT_VERIFIABLE | 9 | |
SSH_DISCONNECT_CONNECTION_LOST | 10 | |
SSH_DISCONNECT_BY_APPLICATION | 11 | |
SSH_DISCONNECT_TOO_MANY_CONNECTIONS | 12 | |
SSH_DISCONNECT_AUTH_CANCELLED_BY_USER | 13 | |
SSH_DISCONNECT_NO_MORE_AUTH_METHODS_AVAILABLE | 14 | |
SSH_DISCONNECT_ILLEGAL_USER_NAME | 15 | |
SSH_DISCONNECT_PRIVATE | 0xfe000000 |
enum assh_ssh_msg_e [link]
This enum is declared in assh/assh_packet.h source file, line 139.
This enum specifies the standard values for ssh2 message ids.
Identifier | Value | Description |
---|---|---|
SSH_MSG_INVALID | 0 | |
SSH_MSG_DISCONNECT | 1 | Transport layer related message |
SSH_MSG_IGNORE | 2 | Transport layer related message |
SSH_MSG_UNIMPLEMENTED | 3 | Transport layer related message |
SSH_MSG_DEBUG | 4 | Transport layer related message |
SSH_MSG_SERVICE_REQUEST | 5 | Transport layer related message |
SSH_MSG_SERVICE_ACCEPT | 6 | Transport layer related message |
SSH_MSG_KEXINIT | 20 | Generic key-exchange message |
SSH_MSG_NEWKEYS | 21 | Generic key-exchange message |
SSH_MSG_KEX_DH_REQUEST | 30 | Method specific key-exchange message |
SSH_MSG_KEX_DH_REPLY | 31 | Method specific key-exchange message |
SSH_MSG_KEX_ECDH_INIT | 30 | Method specific key-exchange message |
SSH_MSG_KEX_ECDH_REPLY | 31 | Method specific key-exchange message |
SSH_MSG_KEX_DH_GEX_REQUEST_OLD | 30 | Method specific key-exchange message |
SSH_MSG_KEX_DH_GEX_GROUP | 31 | Method specific key-exchange message |
SSH_MSG_KEX_DH_GEX_INIT | 32 | Method specific key-exchange message |
SSH_MSG_KEX_DH_GEX_REPLY | 33 | Method specific key-exchange message |
SSH_MSG_KEX_DH_GEX_REQUEST | 34 | Method specific key-exchange message |
SSH_MSG_KEXRSA_PUBKEY | 30 | Method specific key-exchange message |
SSH_MSG_KEXRSA_SECRET | 31 | Method specific key-exchange message |
SSH_MSG_KEXRSA_DONE | 32 | Method specific key-exchange message |
SSH_MSG_USERAUTH_REQUEST | 50 | User authentication related message |
SSH_MSG_USERAUTH_FAILURE | 51 | User authentication related message |
SSH_MSG_USERAUTH_SUCCESS | 52 | User authentication related message |
SSH_MSG_USERAUTH_BANNER | 53 | User authentication related message |
SSH_MSG_USERAUTH_PK_OK | 60 | User authentication related message |
SSH_MSG_USERAUTH_PASSWD_CHANGEREQ | 60 | User authentication related message |
SSH_MSG_USERAUTH_INFO_REQUEST | 60 | User authentication related message |
SSH_MSG_USERAUTH_INFO_RESPONSE | 61 | User authentication related message |
SSH_MSG_GLOBAL_REQUEST | 80 | Connection protocol related message |
SSH_MSG_REQUEST_SUCCESS | 81 | Connection protocol related message |
SSH_MSG_REQUEST_FAILURE | 82 | Connection protocol related message |
SSH_MSG_CHANNEL_OPEN | 90 | Connection protocol related message |
SSH_MSG_CHANNEL_OPEN_CONFIRMATION | 91 | Connection protocol related message |
SSH_MSG_CHANNEL_OPEN_FAILURE | 92 | Connection protocol related message |
SSH_MSG_CHANNEL_WINDOW_ADJUST | 93 | Connection protocol related message |
SSH_MSG_CHANNEL_DATA | 94 | Connection protocol related message |
SSH_MSG_CHANNEL_EXTENDED_DATA | 95 | Connection protocol related message |
SSH_MSG_CHANNEL_EOF | 96 | Connection protocol related message |
SSH_MSG_CHANNEL_CLOSE | 97 | Connection protocol related message |
SSH_MSG_CHANNEL_REQUEST | 98 | Connection protocol related message |
SSH_MSG_CHANNEL_SUCCESS | 99 | Connection protocol related message |
SSH_MSG_CHANNEL_FAILURE | 100 | Connection protocol related message |
#define ASSH_PACKET_MAX_OVERHEAD [link]
This macro is for internal use only.
This macro is declared in assh/assh_packet.h source file, line 257.
This macro specifies the maximum difference between the size of the packet payload and the size of the whole packet buffer.
This macro expands to:
#define ASSH_PACKET_MIN_OVERHEAD [link]
This macro is for internal use only.
This macro is declared in assh/assh_packet.h source file, line 264.
This macro specifies the maximum difference between the size of the packet payload and the size of the whole packet buffer when minimal padding policy is used. When the padding len is <= 3, we will add at most ASSH_MAX_BLOCK_SIZE bytes.
This macro expands to:
#define ASSH_PACKET_OVERHEAD(pad_len, mac_len) [link]
This macro is for internal use only.
This macro is declared in assh/assh_packet.h source file, line 252.
This macro specifies the difference between the size of the packet payload and the size of the whole packet buffer.
This macro expands to:
(ASSH_PACKET_HEADLEN + pad_len + mac_len)
assh_status_t assh_packet_add_array(struct assh_packet_s *p, size_t len, uint8_t **result) [link]
This function is for internal use only.
This function is declared in assh/assh_packet.h source file, line 290.
This function allocates an array of bytes in a packet and returns a pointer to the array. If there is not enough space left in the packet, an error is returned.
assh_status_t assh_packet_add_string(struct assh_packet_s *p, size_t len, uint8_t **result) [link]
This function is for internal use only.
This function is declared in assh/assh_packet.h source file, line 302.
This function allocates a string in a packet and returns a pointer to the first char of the string. If there is not enough space left in the packet, and error is returned.
assh_status_t assh_packet_add_u32(struct assh_packet_s *p, uint32_t value) [link]
This function is for internal use only.
This function is declared in assh/assh_packet.h source file, line 296.
This function allocates an unsigned 32 bits integer in a packet and sets its value. If there is not enough space left in the packet, an error is returned.
assh_status_t assh_packet_alloc(struct assh_context_s *c, uint8_t msg, size_t payload_size_m1, struct assh_packet_s **result) [link]
This function is for internal use only.
This function is declared in assh/assh_packet.h source file, line 238.
This function allocates a new packet. The payload_size_m1 parameter specifies the size of the payload minus one. This is amount of bytes between the message id and the padding.
assh_status_t assh_packet_alloc_raw(struct assh_context_s *c, size_t raw_size, struct assh_packet_s **p) [link]
This function is for internal use only.
This function is declared in assh/assh_packet.h source file, line 222.
This function allocates a new packet. The buffer_size parameter specifies total allocated size. The size is not limited.
assh_status_t assh_packet_check_array(const struct assh_packet_s *p, const uint8_t *array, size_t array_len, const uint8_t **next) [link]
This function is for internal use only.
This function is declared in assh/assh_packet.h source file, line 336.
This function checks that an array is well inside packet bounds.
See also assh_check_array.
assh_status_t assh_packet_check_string(const struct assh_packet_s *p, const uint8_t *str, const uint8_t **next) [link]
This function is for internal use only.
This function is declared in assh/assh_packet.h source file, line 330.
This function checks that a string is well inside packet bounds.
See also assh_check_string.
assh_status_t assh_packet_check_u32(const struct assh_packet_s *p, uint32_t *u32, const uint8_t *data, const uint8_t **next) [link]
This function is for internal use only.
This function is declared in assh/assh_packet.h source file, line 343.
This function checks that a 32 bits integer is well inside packet bounds and converts the value from network byte order.
See also assh_packet_check_array.
assh_status_t assh_packet_dup(struct assh_packet_s *p, struct assh_packet_s **copy) [link]
This function is for internal use only.
This function is declared in assh/assh_packet.h source file, line 284.
This function creates a copy of a packet.
assh_status_t assh_packet_enlarge_string(struct assh_packet_s *p, uint8_t *str, size_t len, uint8_t **result) [link]
This function is for internal use only.
This function is declared in assh/assh_packet.h source file, line 311.
This function enlarges a string previously allocated in a packet and returns a pointer to the first additional char of the string. If there is not enough space left in the packet, an error is returned. The string must be the last allocated thing in the packet when this function is called.
struct assh_packet_head_s [link]
This struct is for internal use only.
This struct is declared in assh/assh_packet.h source file, line 45.
ssh2 protocol packet header
void assh_packet_queue_cleanup(struct assh_queue_s *q) [link]
This function is for internal use only.
This function is declared in assh/assh_packet.h source file, line 275.
This function removes all packets from the queue and calls the assh_packet_release function for each packet.
assh_status_t assh_packet_realloc_raw(struct assh_context_s *c, struct assh_packet_s **p_, size_t raw_size) [link]
This function is for internal use only.
This function is declared in assh/assh_packet.h source file, line 230.
This function allocates a new packet is the specified size can't be stored in the current packet. The original packet is not released and the data are not copied.
struct assh_packet_s * assh_packet_refinc(struct assh_packet_s *p) [link]
This function is for internal use only.
This function is declared in assh/assh_packet.h source file, line 279.
This function increase the reference counter of the packet.
void assh_packet_release(struct assh_packet_s *p) [link]
This function is for internal use only.
This function is declared in assh/assh_packet.h source file, line 271.
This function decreases the reference counter of the packet and release the packet if the new counter value is zero.
struct assh_packet_s [link]
This struct is for internal use only.
This struct is declared in assh/assh_packet.h source file, line 65.
ssh2 packet object
Field | Description |
---|---|
union <anonymous> { | |
struct assh_queue_entry_s entry; | Packet queue entry, valid when packet is allocated. |
struct assh_packet_s * pool_next; | Spare packet pool entry, valid when packet has been released. |
}; | |
struct assh_context_s * ctx; | Associated assh context |
uint32_t buffer_size; | Size of the pre-allocated packet data buffer. |
uint32_t alloc_size; | Size of the allocated packet data buffer. |
uint32_t data_size; | Amount of valid packet data. This value is increased when adding data to the packet and is used when the packet is finally sent out. |
uint32_t seq; | For output packets, this is the output sequence number, valid only after sending. For input packets, this is the input sequence number. For input SSH_MSG_UNIMPLEMENTED packets, this is changed to the output sequence number of the associated packet before dispatch to the service or kex layer. See also sent. |
uint8_t sent:1; | This is set when the packet has been sent, indicating that the seq field is valid. The packet is released when this happens, unless the assh_packet_refinc function has been used. |
uint8_t last:1; | This is set for outgoing SSH_MSG_DISCONNECT packets before encryption. |
uint8_t ref_count:5; | Number of references to this packet. |
enum assh_padding_policy_e padding:2; | Padding size policy |
union <anonymous> { | |
uint8_t data[0]; | |
struct assh_packet_head_s head; | |
}; |
void assh_packet_shrink_string(struct assh_packet_s *p, uint8_t *str, size_t new_len) [link]
This function is for internal use only.
This function is declared in assh/assh_packet.h source file, line 318.
This function reduces the size of a string previously allocated in a packet. The string must be the last allocated thing in the packet when this function is called.
void assh_packet_string_resized(struct assh_packet_s *p, uint8_t *str) [link]
This function is for internal use only.
This function is declared in assh/assh_packet.h source file, line 324.
This function update the size of the packet using the size header of the string. The string must be the last allocated thing in the packet when this function is called.
enum assh_padding_policy_e [link]
This enum is for internal use only.
This enum is declared in assh/assh_packet.h source file, line 54.
Specifies the ssh2 packet padding size policy
Identifier | Value | Description |
---|---|---|
ASSH_PADDING_MIN | 0 | Minimal padding size |
ASSH_PADDING_MAX | 1 | Use maximal padding size according to allocated buffer size. This allows hiding the size of actual data in the enciphered packet. |
enum assh_ssh_msg_ranges_e [link]
This enum is for internal use only.
This enum is declared in assh/assh_packet.h source file, line 122.
This enum specifies ranges of ssh2 message ids.
Identifier | Value | Description |
---|---|---|
SSH_MSG_TRGENERIC_FIRST | 1 | Transport layer generic messages |
SSH_MSG_TRGENERIC_LAST | 19 | Transport layer generic messages |
SSH_MSG_ALGONEG_FIRST | 20 | Algorithm negotiation messages |
SSH_MSG_ALGONEG_LAST | 29 | Algorithm negotiation messages |
SSH_MSG_KEXSPEC_FIRST | 30 | Specific key exchange method messages |
SSH_MSG_KEXSPEC_LAST | 49 | Specific key exchange method messages |
SSH_MSG_SERVICE_FIRST | 50 | Service messages |