libssh 0.12.0
The SSH library
Loading...
Searching...
No Matches
packet.h
1/*
2 * This file is part of the SSH Library
3 *
4 * Copyright (c) 2009 by Aris Adamantiadis
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21#ifndef PACKET_H_
22#define PACKET_H_
23
24#include "config.h"
25
26#include "libssh/callbacks.h"
27#include "libssh/wrapper.h"
28
29struct ssh_socket_struct;
30
31/* this structure should go someday */
32typedef struct packet_struct {
33 int valid;
34 uint32_t len;
35 uint8_t type;
36} PACKET;
37
39enum ssh_packet_state_e {
41 PACKET_STATE_INIT,
43 PACKET_STATE_SIZEREAD,
46 PACKET_STATE_PROCESSING
47};
48
49enum ssh_packet_filter_result_e {
50 SSH_PACKET_UNKNOWN,
51 SSH_PACKET_ALLOWED,
52 SSH_PACKET_DENIED
53};
54
55int ssh_packet_send(ssh_session session);
56
57#ifdef __cplusplus
58extern "C" {
59#endif
60
61SSH_PACKET_CALLBACK(ssh_packet_unimplemented);
62SSH_PACKET_CALLBACK(ssh_packet_disconnect_callback);
63SSH_PACKET_CALLBACK(ssh_packet_ignore_callback);
64SSH_PACKET_CALLBACK(ssh_packet_debug_callback);
65SSH_PACKET_CALLBACK(ssh_packet_dh_reply);
66SSH_PACKET_CALLBACK(ssh_packet_newkeys);
67SSH_PACKET_CALLBACK(ssh_packet_service_accept);
68SSH_PACKET_CALLBACK(ssh_packet_ext_info);
69SSH_PACKET_CALLBACK(ssh_packet_ping);
70SSH_PACKET_CALLBACK(ssh_packet_pong);
71
72#ifdef WITH_SERVER
73SSH_PACKET_CALLBACK(ssh_packet_kexdh_init);
74#endif
75
76int ssh_packet_send_newkeys(ssh_session session);
77int ssh_packet_send_unimplemented(ssh_session session, uint32_t seqnum);
78int ssh_packet_parse_type(ssh_session session);
79//int packet_flush(ssh_session session, int enforce_blocking);
80
81size_t ssh_packet_socket_callback(const void *data, size_t len, void *user);
82void ssh_packet_register_socket_callback(ssh_session session, struct ssh_socket_struct *s);
83void ssh_packet_set_callbacks(ssh_session session, ssh_packet_callbacks callbacks);
84void ssh_packet_remove_callbacks(ssh_session session, ssh_packet_callbacks callbacks);
85void ssh_packet_set_default_callbacks(ssh_session session);
86void ssh_packet_process(ssh_session session, uint8_t type);
87
88/* PACKET CRYPT */
89uint32_t ssh_packet_decrypt_len(ssh_session session, uint8_t *destination, uint8_t *source);
90int ssh_packet_decrypt(ssh_session session, uint8_t *destination, uint8_t *source,
91 size_t start, size_t encrypted_size);
92unsigned char *ssh_packet_encrypt(ssh_session session,
93 void *packet,
94 size_t len);
95int ssh_packet_hmac_verify(ssh_session session, const void *data, size_t len,
96 unsigned char *mac, enum ssh_hmac_e type);
97int ssh_packet_set_newkeys(ssh_session session,
98 enum ssh_crypto_direction_e direction);
99struct ssh_crypto_struct *ssh_packet_get_current_crypto(ssh_session session,
100 enum ssh_crypto_direction_e direction);
101
102#ifdef __cplusplus
103}
104#endif
105
106#endif /* PACKET_H_ */
#define SSH_PACKET_CALLBACK(name)
This macro declares a packet callback handler.
Definition callbacks.h:650