~ubuntu-branches/ubuntu/trusty/libssh/trusty

« back to all changes in this revision

Viewing changes to include/libssh/server.h

  • Committer: Bazaar Package Importer
  • Author(s): Laurent Bigonville
  • Date: 2009-12-12 14:29:12 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20091212142912-ha5g2iibt6nfnjq8
Tags: 0.4.0-1
* New upstream release.
  - Bump soname
  - Adjust .symbols file
* Readd static library in -dev package
* Let dh_lintian install override file
* debian/README.Debian: Update file
* debian/rules: Add list-missing rule

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Public include file for server support */
1
2
/*
2
3
 * This file is part of the SSH Library
3
4
 *
35
36
extern "C" {
36
37
#endif
37
38
 
38
 
typedef struct ssh_bind_struct SSH_BIND;
 
39
enum ssh_bind_options_e {
 
40
  SSH_BIND_OPTIONS_BINDADDR,
 
41
  SSH_BIND_OPTIONS_BINDPORT,
 
42
  SSH_BIND_OPTIONS_BINDPORT_STR,
 
43
  SSH_BIND_OPTIONS_HOSTKEY,
 
44
  SSH_BIND_OPTIONS_DSAKEY,
 
45
  SSH_BIND_OPTIONS_RSAKEY,
 
46
  SSH_BIND_OPTIONS_BANNER,
 
47
  SSH_BIND_OPTIONS_LOG_VERBOSITY,
 
48
  SSH_BIND_OPTIONS_LOG_VERBOSITY_STR
 
49
};
 
50
 
 
51
//typedef struct ssh_bind_struct SSH_BIND;
 
52
typedef struct ssh_bind_struct* ssh_bind;
39
53
 
40
54
/**
41
55
 * @brief Creates a new SSH server bind.
42
56
 *
43
57
 * @return A newly allocated ssh_bind session pointer.
44
58
 */
45
 
SSH_BIND *ssh_bind_new(void);
 
59
LIBSSH_API ssh_bind ssh_bind_new(void);
46
60
 
47
61
/**
48
62
 * @brief Set the opitons for the current SSH server bind.
51
65
 *
52
66
 * @param  options      The option structure to set.
53
67
 */
54
 
void ssh_bind_set_options(SSH_BIND *ssh_bind, SSH_OPTIONS *options);
 
68
LIBSSH_API int ssh_bind_options_set(ssh_bind sshbind,
 
69
    enum ssh_bind_options_e type, const void *value);
55
70
 
56
71
/**
57
72
 * @brief Start listening to the socket.
58
73
 *
59
 
 * @param  ssh_bind     The ssh server bind to use.
 
74
 * @param  ssh_bind_o     The ssh server bind to use.
60
75
 *
61
76
 * @return 0 on success, < 0 on error.
62
77
 */
63
 
int ssh_bind_listen(SSH_BIND *ssh_bind);
 
78
LIBSSH_API int ssh_bind_listen(ssh_bind ssh_bind_o);
64
79
 
65
80
/**
66
81
 * @brief  Set the session to blocking/nonblocking mode.
67
82
 *
68
 
 * @param  ssh_bind     The ssh server bind to use.
 
83
 * @param  ssh_bind_o     The ssh server bind to use.
69
84
 *
70
85
 * @param  blocking     Zero for nonblocking mode.
71
86
 */
72
 
void ssh_bind_set_blocking(SSH_BIND *ssh_bind, int blocking);
 
87
LIBSSH_API void ssh_bind_set_blocking(ssh_bind ssh_bind_o, int blocking);
73
88
 
74
89
/**
75
90
 * @brief Recover the file descriptor from the session.
76
91
 *
77
 
 * @param  ssh_bind     The ssh server bind to get the fd from.
 
92
 * @param  ssh_bind_o     The ssh server bind to get the fd from.
78
93
 *
79
94
 * @return The file descriptor.
80
95
 */
81
 
socket_t ssh_bind_get_fd(SSH_BIND *ssh_bind);
 
96
LIBSSH_API socket_t ssh_bind_get_fd(ssh_bind ssh_bind_o);
82
97
 
83
98
/**
84
99
 * @brief Set the file descriptor for a session.
85
100
 *
86
 
 * @param  ssh_bind     The ssh server bind to set the fd.
 
101
 * @param  ssh_bind_o     The ssh server bind to set the fd.
87
102
 *
88
 
 * @param  fd           The file descriptor.
 
103
 * @param  fd           The file descriptssh_bind B
89
104
 */
90
 
void ssh_bind_set_fd(SSH_BIND *ssh_bind, socket_t fd);
 
105
LIBSSH_API void ssh_bind_set_fd(ssh_bind ssh_bind_o, socket_t fd);
91
106
 
92
107
/**
93
108
 * @brief Allow the file descriptor to accept new sessions.
94
109
 *
95
 
 * @param  ssh_bind     The ssh server bind to use.
 
110
 * @param  ssh_bind_o     The ssh server bind to use.
96
111
 */
97
 
void ssh_bind_fd_toaccept(SSH_BIND *ssh_bind);
 
112
LIBSSH_API void ssh_bind_fd_toaccept(ssh_bind ssh_bind_o);
98
113
 
99
114
/**
100
115
 * @brief Accept an incoming ssh connection and initialize the session.
101
116
 *
102
 
 * @param  ssh_bind     The ssh server bind to accept a connection.
103
 
 *
 
117
 * @param  ssh_bind_o     The ssh server bind to accept a connection.
 
118
 * @param  session                      A preallocated ssh session
 
119
 * @see ssh_new
104
120
 * @return A newly allocated ssh session, NULL on error.
105
121
 */
106
 
SSH_SESSION *ssh_bind_accept(SSH_BIND *ssh_bind);
 
122
LIBSSH_API int ssh_bind_accept(ssh_bind ssh_bind_o, ssh_session session);
107
123
 
108
124
/**
109
125
 * @brief Free a ssh servers bind.
110
126
 *
111
 
 * @param  ssh_bind     The ssh server bind to free.
 
127
 * @param  ssh_bind_o     The ssh server bind to free.
112
128
 */
113
 
void ssh_bind_free(SSH_BIND *ssh_bind);
 
129
LIBSSH_API void ssh_bind_free(ssh_bind ssh_bind_o);
114
130
 
115
131
/**
116
132
 * @brief Exchange the banner and cryptographic keys.
119
135
 *
120
136
 * @return 0 on success, < 0 on error.
121
137
 */
122
 
int ssh_accept(SSH_SESSION *session);
 
138
LIBSSH_API int ssh_accept(ssh_session session);
 
139
 
 
140
LIBSSH_API int channel_write_stderr(ssh_channel channel, const void *data, uint32_t len);
123
141
 
124
142
/* messages.c */
125
 
 
126
 
#define SSH_AUTH_REQUEST 1
127
 
#define SSH_CHANNEL_REQUEST_OPEN 2
128
 
#define SSH_CHANNEL_REQUEST 3
129
 
 
130
 
#define SSH_AUTH_NONE (1<<0)
131
 
#define SSH_AUTH_PASSWORD (1<<1)
132
 
#define SSH_AUTH_HOSTBASED (1<<2)
133
 
#define SSH_AUTH_PUBLICKEY (1<<3)
134
 
#define SSH_AUTH_KEYBINT (1<<4)
135
 
#define SSH_AUTH_UNKNOWN 0
136
 
 
137
 
#define SSH_CHANNEL_SESSION 1
138
 
#define SSH_CHANNEL_TCPIP 2
139
 
#define SSH_CHANNEL_X11 3
140
 
#define SSH_CHANNEL_UNKNOWN 4
141
 
 
142
 
#define SSH_CHANNEL_REQUEST_PTY 1
143
 
#define SSH_CHANNEL_REQUEST_EXEC 2
144
 
#define SSH_CHANNEL_REQUEST_SHELL 3
145
 
#define SSH_CHANNEL_REQUEST_ENV 4
146
 
#define SSH_CHANNEL_REQUEST_SUBSYSTEM 5
147
 
#define SSH_CHANNEL_REQUEST_WINDOW_CHANGE 6
148
 
#define SSH_CHANNEL_REQUEST_UNKNOWN 7
149
 
 
150
 
typedef struct ssh_message SSH_MESSAGE;
151
 
 
152
 
SSH_MESSAGE *ssh_message_get(SSH_SESSION *session);
153
 
int ssh_message_type(SSH_MESSAGE *msg);
154
 
int ssh_message_subtype(SSH_MESSAGE *msg);
155
 
int ssh_message_reply_default(SSH_MESSAGE *msg);
156
 
void ssh_message_free(SSH_MESSAGE *msg);
157
 
 
158
 
char *ssh_message_auth_user(SSH_MESSAGE *msg);
159
 
char *ssh_message_auth_password(SSH_MESSAGE *msg);
160
 
int ssh_message_auth_reply_success(SSH_MESSAGE *msg,int partial);
161
 
int ssh_message_auth_set_methods(SSH_MESSAGE *msg, int methods);
162
 
 
163
 
CHANNEL *ssh_message_channel_request_open_reply_accept(SSH_MESSAGE *msg);
164
 
 
165
 
CHANNEL *ssh_message_channel_request_channel(SSH_MESSAGE *msg);
166
 
// returns the TERM env variable
167
 
char *ssh_message_channel_request_pty_term(SSH_MESSAGE *msg);
168
 
char *ssh_message_channel_request_subsystem(SSH_MESSAGE *msg);
169
 
int ssh_message_channel_request_reply_success(SSH_MESSAGE *msg);
 
143
LIBSSH_API int ssh_message_reply_default(ssh_message msg);
 
144
 
 
145
LIBSSH_API char *ssh_message_auth_user(ssh_message msg);
 
146
LIBSSH_API char *ssh_message_auth_password(ssh_message msg);
 
147
LIBSSH_API ssh_public_key ssh_message_auth_publickey(ssh_message msg);
 
148
LIBSSH_API int ssh_message_auth_reply_success(ssh_message msg,int partial);
 
149
LIBSSH_API int ssh_message_auth_reply_pk_ok(ssh_message msg, ssh_string algo, ssh_string pubkey);
 
150
LIBSSH_API int ssh_message_auth_set_methods(ssh_message msg, int methods);
 
151
 
 
152
LIBSSH_API int ssh_message_service_reply_success(ssh_message msg);
 
153
LIBSSH_API char *ssh_message_service_service(ssh_message msg);
 
154
 
 
155
LIBSSH_API void ssh_set_message_callback(ssh_session session,
 
156
    int(*ssh_message_callback)(ssh_session session, ssh_message msg));
 
157
 
 
158
LIBSSH_API char *ssh_message_channel_request_open_originator(ssh_message msg);
 
159
LIBSSH_API int ssh_message_channel_request_open_originator_port(ssh_message msg);
 
160
LIBSSH_API char *ssh_message_channel_request_open_destination(ssh_message msg);
 
161
LIBSSH_API int ssh_message_channel_request_open_destination_port(ssh_message msg);
 
162
 
 
163
LIBSSH_API ssh_channel ssh_message_channel_request_channel(ssh_message msg);
 
164
 
 
165
LIBSSH_API char *ssh_message_channel_request_pty_term(ssh_message msg);
 
166
LIBSSH_API int ssh_message_channel_request_pty_width(ssh_message msg);
 
167
LIBSSH_API int ssh_message_channel_request_pty_height(ssh_message msg);
 
168
LIBSSH_API int ssh_message_channel_request_pty_pxwidth(ssh_message msg);
 
169
LIBSSH_API int ssh_message_channel_request_pty_pxheight(ssh_message msg);
 
170
 
 
171
LIBSSH_API char *ssh_message_channel_request_env_name(ssh_message msg);
 
172
LIBSSH_API char *ssh_message_channel_request_env_value(ssh_message msg);
 
173
 
 
174
LIBSSH_API char *ssh_message_channel_request_command(ssh_message msg);
 
175
 
 
176
LIBSSH_API char *ssh_message_channel_request_subsystem(ssh_message msg);
170
177
 
171
178
#ifdef __cplusplus
172
179
}