libssh  0.6.3
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 struct ssh_socket_struct;
25 
26 /* this structure should go someday */
27 typedef struct packet_struct {
28  int valid;
29  uint32_t len;
30  uint8_t type;
31 } PACKET;
32 
34 enum ssh_packet_state_e {
36  PACKET_STATE_INIT,
38  PACKET_STATE_SIZEREAD,
41  PACKET_STATE_PROCESSING
42 };
43 
44 int packet_send(ssh_session session);
45 
46 #ifdef WITH_SSH1
47 int packet_send1(ssh_session session) ;
48 void ssh_packet_set_default_callbacks1(ssh_session session);
49 
50 SSH_PACKET_CALLBACK(ssh_packet_disconnect1);
51 SSH_PACKET_CALLBACK(ssh_packet_smsg_success1);
52 SSH_PACKET_CALLBACK(ssh_packet_smsg_failure1);
53 int ssh_packet_socket_callback1(const void *data, size_t receivedlen, void *user);
54 
55 #endif
56 
57 SSH_PACKET_CALLBACK(ssh_packet_unimplemented);
58 SSH_PACKET_CALLBACK(ssh_packet_disconnect_callback);
59 SSH_PACKET_CALLBACK(ssh_packet_ignore_callback);
60 SSH_PACKET_CALLBACK(ssh_packet_dh_reply);
61 SSH_PACKET_CALLBACK(ssh_packet_newkeys);
62 SSH_PACKET_CALLBACK(ssh_packet_service_accept);
63 
64 #ifdef WITH_SERVER
65 SSH_PACKET_CALLBACK(ssh_packet_kexdh_init);
66 #endif
67 
68 int ssh_packet_send_unimplemented(ssh_session session, uint32_t seqnum);
69 int ssh_packet_parse_type(ssh_session session);
70 //int packet_flush(ssh_session session, int enforce_blocking);
71 
72 int ssh_packet_socket_callback(const void *data, size_t len, void *user);
73 void ssh_packet_register_socket_callback(ssh_session session, struct ssh_socket_struct *s);
74 void ssh_packet_set_callbacks(ssh_session session, ssh_packet_callbacks callbacks);
75 void ssh_packet_set_default_callbacks(ssh_session session);
76 void ssh_packet_process(ssh_session session, uint8_t type);
77 
78 /* PACKET CRYPT */
79 uint32_t packet_decrypt_len(ssh_session session, char *crypted);
80 int packet_decrypt(ssh_session session, void *packet, unsigned int len);
81 unsigned char *packet_encrypt(ssh_session session,
82  void *packet,
83  unsigned int len);
84 int packet_hmac_verify(ssh_session session,ssh_buffer buffer,
85  unsigned char *mac);
86 
87 #endif /* PACKET_H_ */
#define SSH_PACKET_CALLBACK(name)
This macro declares a packet callback handler.
Definition: callbacks.h:449