libssh  0.8.4
The SSH library
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 "libssh/wrapper.h"
25 
26 struct ssh_socket_struct;
27 
28 /* this structure should go someday */
29 typedef struct packet_struct {
30  int valid;
31  uint32_t len;
32  uint8_t type;
33 } PACKET;
34 
36 enum ssh_packet_state_e {
38  PACKET_STATE_INIT,
40  PACKET_STATE_SIZEREAD,
43  PACKET_STATE_PROCESSING
44 };
45 
46 enum ssh_packet_filter_result_e {
47  SSH_PACKET_UNKNOWN,
48  SSH_PACKET_ALLOWED,
49  SSH_PACKET_DENIED
50 };
51 
52 int ssh_packet_send(ssh_session session);
53 
54 SSH_PACKET_CALLBACK(ssh_packet_unimplemented);
55 SSH_PACKET_CALLBACK(ssh_packet_disconnect_callback);
56 SSH_PACKET_CALLBACK(ssh_packet_ignore_callback);
57 SSH_PACKET_CALLBACK(ssh_packet_dh_reply);
58 SSH_PACKET_CALLBACK(ssh_packet_newkeys);
59 SSH_PACKET_CALLBACK(ssh_packet_service_accept);
60 SSH_PACKET_CALLBACK(ssh_packet_ext_info);
61 
62 #ifdef WITH_SERVER
63 SSH_PACKET_CALLBACK(ssh_packet_kexdh_init);
64 #endif
65 
66 int ssh_packet_send_unimplemented(ssh_session session, uint32_t seqnum);
67 int ssh_packet_parse_type(ssh_session session);
68 //int packet_flush(ssh_session session, int enforce_blocking);
69 
70 int ssh_packet_socket_callback(const void *data, size_t len, void *user);
71 void ssh_packet_register_socket_callback(ssh_session session, struct ssh_socket_struct *s);
72 void ssh_packet_set_callbacks(ssh_session session, ssh_packet_callbacks callbacks);
73 void ssh_packet_set_default_callbacks(ssh_session session);
74 void ssh_packet_process(ssh_session session, uint8_t type);
75 
76 /* PACKET CRYPT */
77 uint32_t ssh_packet_decrypt_len(ssh_session session, uint8_t *destination, uint8_t *source);
78 int ssh_packet_decrypt(ssh_session session, uint8_t *destination, uint8_t *source,
79  size_t start, size_t encrypted_size);
80 unsigned char *ssh_packet_encrypt(ssh_session session,
81  void *packet,
82  unsigned int len);
83 int ssh_packet_hmac_verify(ssh_session session,ssh_buffer buffer,
84  unsigned char *mac, enum ssh_hmac_e type);
85 
86 #endif /* PACKET_H_ */
Definition: callbacks.h:530
Definition: session.h:102
Definition: packet.h:29
#define SSH_PACKET_CALLBACK(name)
This macro declares a packet callback handler.
Definition: callbacks.h:527
Definition: socket.c:76
Definition: buffer.c:47