libssh  0.5.4
messages.h
1 /*
2  * This file is part of the SSH Library
3  *
4  * Copyright (c) 2009 by Aris Adamantiadis
5  *
6  * The SSH Library is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation; either version 2.1 of the License, or (at your
9  * option) any later version.
10  *
11  * The SSH Library is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14  * License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with the SSH Library; see the file COPYING. If not, write to
18  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
19  * MA 02111-1307, USA.
20  */
21 
22 #ifndef MESSAGES_H_
23 #define MESSAGES_H_
24 
25 #include "config.h"
26 
27 struct ssh_auth_request {
28  char *username;
29  int method;
30  char *password;
31  struct ssh_public_key_struct *public_key;
32  char signature_state;
33 };
34 
35 struct ssh_channel_request_open {
36  int type;
37  uint32_t sender;
38  uint32_t window;
39  uint32_t packet_size;
40  char *originator;
41  uint16_t originator_port;
42  char *destination;
43  uint16_t destination_port;
44 };
45 
46 struct ssh_service_request {
47  char *service;
48 };
49 
50 struct ssh_global_request {
51  int type;
52  uint8_t want_reply;
53  char *bind_address;
54  uint16_t bind_port;
55 };
56 
57 struct ssh_channel_request {
58  int type;
59  ssh_channel channel;
60  uint8_t want_reply;
61  /* pty-req type specifics */
62  char *TERM;
63  uint32_t width;
64  uint32_t height;
65  uint32_t pxwidth;
66  uint32_t pxheight;
67  ssh_string modes;
68 
69  /* env type request */
70  char *var_name;
71  char *var_value;
72  /* exec type request */
73  char *command;
74  /* subsystem */
75  char *subsystem;
76 };
77 
78 struct ssh_message_struct {
79  ssh_session session;
80  int type;
81  struct ssh_auth_request auth_request;
82  struct ssh_channel_request_open channel_request_open;
83  struct ssh_channel_request channel_request;
84  struct ssh_service_request service_request;
85  struct ssh_global_request global_request;
86 };
87 
88 SSH_PACKET_CALLBACK(ssh_packet_channel_open);
89 SSH_PACKET_CALLBACK(ssh_packet_service_request);
90 SSH_PACKET_CALLBACK(ssh_packet_userauth_request);
91 SSH_PACKET_CALLBACK(ssh_packet_global_request);
92 
93 int ssh_message_handle_channel_request(ssh_session session, ssh_channel channel, ssh_buffer packet,
94  const char *request, uint8_t want_reply);
95 void ssh_message_queue(ssh_session session, ssh_message message);
96 ssh_message ssh_message_pop_head(ssh_session session);
97 
98 #endif /* MESSAGES_H_ */