Skip to content

Commit 3f729a8

Browse files
author
Pan
committed
Added gssapi, poll, priv, socket and session definitions. Updated callbacks and channels.
1 parent d8947d9 commit 3f729a8

File tree

8 files changed

+604
-3
lines changed

8 files changed

+604
-3
lines changed

ssh/c_callbacks.pxd

Lines changed: 217 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,229 @@
1414
# License along with this library; if not, write to the Free Software
1515
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-130
1616

17-
from c_ssh cimport ssh_session, ssh_buffer, ssh_string, uint8_t
17+
from c_ssh cimport ssh_session, ssh_channel, ssh_buffer, ssh_string, \
18+
uint32_t, uint8_t, ssh_key_struct, ssh_auth_callback, ssh_message
1819

1920
cdef extern from "libssh/include/callbacks.h" nogil:
21+
ctypedef void (*ssh_callback_int) (int code, void *user)
22+
ctypedef int (*ssh_callback_data) (const void *data, size_t len, void *user)
23+
ctypedef void (*ssh_callback_int_int) (
24+
int code, int errno_code, void *user)
25+
ctypedef int (*ssh_message_callback) (
26+
ssh_session, ssh_message message, void *user)
27+
ctypedef int (*ssh_channel_callback_int) (
28+
ssh_channel channel, int code, void *user)
29+
ctypedef int (*ssh_channel_callback_data) (
30+
ssh_channel channel, int code, void *data, size_t len, void *user)
31+
32+
ctypedef void (*ssh_log_callback) (ssh_session session, int priority,
33+
const char *message, void *userdata)
34+
ctypedef void (*ssh_logging_callback) (int priority,
35+
const char *function,
36+
const char *buffer,
37+
void *userdata)
38+
39+
ctypedef void (*ssh_status_callback) (ssh_session session, float status,
40+
void *userdata)
41+
42+
ctypedef void (*ssh_global_request_callback) (ssh_session session,
43+
ssh_message message, void *userdata)
44+
45+
ctypedef ssh_channel (*ssh_channel_open_request_x11_callback) (
46+
ssh_session session,
47+
const char * originator_address, int originator_port, void *userdata)
48+
49+
ctypedef ssh_channel (*ssh_channel_open_request_auth_agent_callback) (
50+
ssh_session session, void *userdata)
51+
52+
struct ssh_callbacks_struct:
53+
size_t size
54+
void *userdata
55+
ssh_auth_callback auth_function
56+
ssh_log_callback log_function
57+
void (*connect_status_function)(void *userdata, float status)
58+
ssh_global_request_callback global_request_function
59+
ssh_channel_open_request_x11_callback channel_open_request_x11_function
60+
ssh_channel_open_request_auth_agent_callback channel_open_request_auth_agent_function
61+
ctypedef ssh_callbacks_struct *ssh_callbacks
62+
63+
ctypedef int (*ssh_auth_password_callback) (
64+
ssh_session session, const char *user, const char *password,
65+
void *userdata)
66+
ctypedef int (*ssh_auth_none_callback) (
67+
ssh_session session, const char *user, void *userdata)
68+
ctypedef int (*ssh_auth_gssapi_mic_callback) (
69+
ssh_session session, const char *user, const char *principal,
70+
void *userdata)
71+
ctypedef int (*ssh_auth_pubkey_callback) (
72+
ssh_session session, const char *user, ssh_key_struct *pubkey,
73+
char signature_state, void *userdata)
74+
ctypedef int (*ssh_service_request_callback) (
75+
ssh_session session, const char *service, void *userdata)
76+
ctypedef ssh_channel (*ssh_channel_open_request_session_callback) (
77+
ssh_session session, void *userdata)
78+
2079
ctypedef ssh_string (*void) (ssh_session, const char*,
2180
int, ssh_string *, void *)
22-
ctypedef int (*ssh_packet_callback) (ssh_session session, uint8_t type, ssh_buffer packet, void *user)
81+
ctypedef int (*ssh_gssapi_accept_sec_ctx_callback) (ssh_session session,
82+
ssh_string input_token, ssh_string *output_token, void *userdata)
83+
ctypedef int (*ssh_gssapi_verify_mic_callback) (
84+
ssh_session session,
85+
ssh_string mic, void *mic_buffer, size_t mic_buffer_size, void *userdata)
86+
87+
ctypedef ssh_string (*ssh_gssapi_select_oid_callback) (
88+
ssh_session session, const char *user,
89+
int n_oid, ssh_string *oids, void *userdata)
90+
91+
struct ssh_server_callbacks_struct:
92+
size_t size
93+
void *userdata
94+
ssh_auth_password_callback auth_password_function
95+
ssh_auth_none_callback auth_none_function
96+
ssh_auth_gssapi_mic_callback auth_gssapi_mic_function
97+
ssh_auth_pubkey_callback auth_pubkey_function
98+
ssh_service_request_callback service_request_function
99+
ssh_channel_open_request_session_callback channel_open_request_session_function
100+
ssh_gssapi_select_oid_callback gssapi_select_oid_function
101+
ssh_gssapi_accept_sec_ctx_callback gssapi_accept_sec_ctx_function
102+
ssh_gssapi_verify_mic_callback gssapi_verify_mic_function
103+
ctypedef ssh_server_callbacks_struct *ssh_server_callbacks
104+
int ssh_set_server_callbacks(ssh_session session, ssh_server_callbacks cb)
105+
struct ssh_socket_callbacks_struct:
106+
void *userdata
107+
ssh_callback_data data
108+
ssh_callback_int controlflow
109+
ssh_callback_int_int exception
110+
ssh_callback_int_int connected
111+
ctypedef ssh_socket_callbacks_struct *ssh_socket_callbacks
112+
113+
enum:
114+
SSH_SOCKET_FLOW_WRITEWILLBLOCK
115+
SSH_SOCKET_FLOW_WRITEWONTBLOCK
116+
SSH_SOCKET_EXCEPTION_EOF
117+
SSH_SOCKET_EXCEPTION_ERROR
118+
SSH_SOCKET_CONNECTED_OK
119+
SSH_SOCKET_CONNECTED_ERROR
120+
SSH_SOCKET_CONNECTED_TIMEOUT
121+
ctypedef int (*ssh_packet_callback) (
122+
ssh_session session, uint8_t type, ssh_buffer packet, void *user)
123+
enum:
124+
SSH_PACKET_USED
125+
SSH_PACKET_NOT_USED
126+
23127
struct ssh_packet_callbacks_struct:
24128
uint8_t start
25129
uint8_t n_callbacks
130+
ssh_packet_callback *callbacks
26131
void *user
27132
ctypedef ssh_packet_callbacks_struct *ssh_packet_callbacks
133+
int ssh_set_callbacks(ssh_session session, ssh_callbacks cb)
134+
ctypedef int (*ssh_channel_data_callback) (ssh_session session,
135+
ssh_channel channel,
136+
void *data,
137+
uint32_t len,
138+
int is_stderr,
139+
void *userdata)
140+
ctypedef void (*ssh_channel_eof_callback) (ssh_session session,
141+
ssh_channel channel,
142+
void *userdata)
143+
ctypedef void (*ssh_channel_close_callback) (ssh_session session,
144+
ssh_channel channel,
145+
void *userdata)
146+
ctypedef void (*ssh_channel_signal_callback) (ssh_session session,
147+
ssh_channel channel,
148+
const char *signal,
149+
void *userdata)
150+
ctypedef void (*ssh_channel_exit_status_callback) (ssh_session session,
151+
ssh_channel channel,
152+
int exit_status,
153+
void *userdata)
154+
ctypedef void (*ssh_channel_exit_signal_callback) (ssh_session session,
155+
ssh_channel channel,
156+
const char *signal,
157+
int core,
158+
const char *errmsg,
159+
const char *lang,
160+
void *userdata)
161+
ctypedef int (*ssh_channel_pty_request_callback) (ssh_session session,
162+
ssh_channel channel,
163+
const char *term,
164+
int width, int height,
165+
int pxwidth, int pwheight,
166+
void *userdata)
167+
ctypedef int (*ssh_channel_shell_request_callback) (ssh_session session,
168+
ssh_channel channel,
169+
void *userdata)
170+
ctypedef void (*ssh_channel_auth_agent_req_callback) (ssh_session session,
171+
ssh_channel channel,
172+
void *userdata)
173+
ctypedef void (*ssh_channel_x11_req_callback) (ssh_session session,
174+
ssh_channel channel,
175+
int single_connection,
176+
const char *auth_protocol,
177+
const char *auth_cookie,
178+
uint32_t screen_number,
179+
void *userdata)
180+
ctypedef int (*ssh_channel_pty_window_change_callback) (
181+
ssh_session session, ssh_channel channel, int width, int height,
182+
int pxwidth, int pwheight, void *userdata);
183+
ctypedef int (*ssh_channel_exec_request_callback) (ssh_session session,
184+
ssh_channel channel,
185+
const char *command,
186+
void *userdata)
187+
188+
ctypedef int (*ssh_channel_env_request_callback) (ssh_session session,
189+
ssh_channel channel,
190+
const char *env_name,
191+
const char *env_value,
192+
void *userdata)
193+
194+
ctypedef int (*ssh_channel_subsystem_request_callback) (ssh_session session,
195+
ssh_channel channel,
196+
const char *subsystem,
197+
void *userdata)
198+
ctypedef int (*ssh_channel_write_wontblock_callback) (ssh_session session,
199+
ssh_channel channel,
200+
size_t bytes,
201+
void *userdata)
202+
203+
struct ssh_channel_callbacks_struct:
204+
size_t size
205+
void *userdata
206+
ssh_channel_data_callback channel_data_function
207+
ssh_channel_eof_callback channel_eof_function
208+
ssh_channel_close_callback channel_close_function
209+
ssh_channel_signal_callback channel_signal_function
210+
ssh_channel_exit_status_callback channel_exit_status_function
211+
ssh_channel_exit_signal_callback channel_exit_signal_function
212+
ssh_channel_pty_request_callback channel_pty_request_function
213+
ssh_channel_shell_request_callback channel_shell_request_function
214+
ssh_channel_auth_agent_req_callback channel_auth_agent_req_function
215+
ssh_channel_x11_req_callback channel_x11_req_function
216+
ssh_channel_pty_window_change_callback channel_pty_window_change_function
217+
ssh_channel_exec_request_callback channel_exec_request_function
218+
ssh_channel_env_request_callback channel_env_request_function
219+
ssh_channel_subsystem_request_callback channel_subsystem_request_function
220+
ssh_channel_write_wontblock_callback channel_write_wontblock_function
221+
222+
ctypedef ssh_channel_callbacks_struct *ssh_channel_callbacks
223+
int ssh_set_channel_callbacks(ssh_channel channel,
224+
ssh_channel_callbacks cb)
225+
int ssh_add_channel_callbacks(ssh_channel channel,
226+
ssh_channel_callbacks cb)
227+
int ssh_remove_channel_callbacks(ssh_channel channel,
228+
ssh_channel_callbacks cb)
229+
ctypedef int (*ssh_thread_callback) (void **lock)
230+
ctypedef unsigned long (*ssh_thread_id_callback) ();
231+
struct ssh_threads_callbacks_struct:
232+
const char *type
233+
ssh_thread_callback mutex_init
234+
ssh_thread_callback mutex_destroy
235+
ssh_thread_callback mutex_lock
236+
ssh_thread_callback mutex_unlock
237+
ssh_thread_id_callback thread_id
238+
int ssh_threads_set_callbacks(ssh_threads_callbacks_struct *cb)
239+
ssh_threads_callbacks_struct *ssh_threads_get_pthread()
240+
ssh_threads_callbacks_struct *ssh_threads_get_noop()
241+
int ssh_set_log_callback(ssh_logging_callback cb)
242+
ssh_logging_callback ssh_get_log_callback()

ssh/c_channels.pxd

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
cimport c_ssh
1818
from c_ssh cimport uint32_t, ssh_channel, ssh_session, ssh_buffer, ssh_counter
1919
from c_misc cimport ssh_list
20-
# cimport c_priv
2120

2221
cdef extern from "libssh/include/channels.h" nogil:
2322
enum ssh_channel_request_state_e:

ssh/c_gssapi.pxd

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# This file is part of ssh-python.
2+
# Copyright (C) 2018 Panos Kittenis
3+
#
4+
# This library is free software; you can redistribute it and/or
5+
# modify it under the terms of the GNU Lesser General Public
6+
# License as published by the Free Software Foundation, version 2.1.
7+
#
8+
# This library is distributed in the hope that it will be useful,
9+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11+
# Lesser General Public License for more details.
12+
#
13+
# You should have received a copy of the GNU Lesser General Public
14+
# License along with this library; if not, write to the Free Software
15+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-130
16+
17+
from c_ssh cimport ssh_session, ssh_buffer, uint32_t, uint8_t, ssh_keytypes_e
18+
from c_wrapper cimport ssh_hmac_e
19+
from c_callbacks cimport ssh_packet_callbacks
20+
from c_ed25519 cimport ed25519_pubkey, ed25519_privkey
21+
22+
cdef extern from "libssh/include/gssapi.h" nogil:
23+
enum:
24+
SSH_OID_TAG
25+
struct ssh_gssapi_struct:
26+
pass
27+
ctypedef ssh_gssapi_struct *ssh_gssapi;

ssh/c_poll.pxd

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# This file is part of ssh-python.
2+
# Copyright (C) 2018 Panos Kittenis
3+
#
4+
# This library is free software; you can redistribute it and/or
5+
# modify it under the terms of the GNU Lesser General Public
6+
# License as published by the Free Software Foundation, version 2.1.
7+
#
8+
# This library is distributed in the hope that it will be useful,
9+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11+
# Lesser General Public License for more details.
12+
#
13+
# You should have received a copy of the GNU Lesser General Public
14+
# License along with this library; if not, write to the Free Software
15+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-130
16+
17+
from c_ssh cimport ssh_session, ssh_buffer, ssh_string, uint32_t, uint8_t, ssh_event, socket_t
18+
from c_callbacks cimport ssh_packet_callbacks, ssh_packet_callbacks_struct
19+
20+
cdef extern from "libssh/include/poll.h" nogil:
21+
ctypedef unsigned long int nfds_t
22+
void ssh_poll_init();
23+
void ssh_poll_cleanup();
24+
struct pollfd:
25+
pass
26+
ctypedef pollfd ssh_pollfd_t
27+
int ssh_poll(ssh_pollfd_t *fds, nfds_t nfds, int timeout);
28+
struct ssh_poll_handle_struct:
29+
pass
30+
struct ssh_poll_ctx_struct:
31+
pass
32+
ctypedef ssh_poll_ctx_struct *ssh_poll_ctx
33+
ctypedef ssh_poll_handle_struct *ssh_poll_handle
34+
ctypedef int (*ssh_poll_callback)(ssh_poll_handle p, socket_t fd, int revents,
35+
void *userdata)
36+
struct ssh_socket_struct:
37+
pass
38+
ssh_poll_handle ssh_poll_new(socket_t fd, short events, ssh_poll_callback cb,
39+
void *userdata)
40+
void ssh_poll_free(ssh_poll_handle p)
41+
ssh_poll_ctx ssh_poll_get_ctx(ssh_poll_handle p)
42+
short ssh_poll_get_events(ssh_poll_handle p)
43+
void ssh_poll_set_events(ssh_poll_handle p, short events)
44+
void ssh_poll_add_events(ssh_poll_handle p, short events)
45+
void ssh_poll_remove_events(ssh_poll_handle p, short events)
46+
socket_t ssh_poll_get_fd(ssh_poll_handle p)
47+
void ssh_poll_set_fd(ssh_poll_handle p, socket_t fd)
48+
void ssh_poll_set_callback(ssh_poll_handle p, ssh_poll_callback cb, void *userdata)
49+
ssh_poll_ctx ssh_poll_ctx_new(size_t chunk_size)
50+
void ssh_poll_ctx_free(ssh_poll_ctx ctx)
51+
int ssh_poll_ctx_add(ssh_poll_ctx ctx, ssh_poll_handle p)
52+
int ssh_poll_ctx_add_socket (ssh_poll_ctx ctx, ssh_socket_struct *s)
53+
void ssh_poll_ctx_remove(ssh_poll_ctx ctx, ssh_poll_handle p)
54+
int ssh_poll_ctx_dopoll(ssh_poll_ctx ctx, int timeout)
55+
ssh_poll_ctx ssh_poll_get_default_ctx(ssh_session session)
56+
int ssh_event_add_poll(ssh_event event, ssh_poll_handle p)
57+
void ssh_event_remove_poll(ssh_event event, ssh_poll_handle p)

ssh/c_priv.pxd

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# This file is part of ssh-python.
2+
# Copyright (C) 2018 Panos Kittenis
3+
#
4+
# This library is free software; you can redistribute it and/or
5+
# modify it under the terms of the GNU Lesser General Public
6+
# License as published by the Free Software Foundation, version 2.1.
7+
#
8+
# This library is distributed in the hope that it will be useful,
9+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11+
# Lesser General Public License for more details.
12+
#
13+
# You should have received a copy of the GNU Lesser General Public
14+
# License along with this library; if not, write to the Free Software
15+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-130
16+
17+
from c_ssh cimport ssh_connector, ssh_event, ssh_buffer, ssh_session, \
18+
socket_t, ssh_key
19+
20+
cdef extern from "libssh/include/priv.h" nogil:
21+
struct timeval:
22+
pass
23+
int gettimeofday(timeval *__p, void *__t)
24+
struct ssh_common_struct:
25+
pass
26+
struct ssh_kex_struct:
27+
pass
28+
29+
enum:
30+
MAX_PACKAT_LEN
31+
MAX_PACKET_LEN
32+
ERROR_BUFFERLEN
33+
KBDINT_MAX_PROMPT
34+
MAX_BUF_SIZE
35+
int ssh_get_key_params(ssh_session session, ssh_key *privkey)
36+
void ssh_log_function(int verbosity,
37+
const char *function,
38+
const char *buffer)
39+
struct error_struct:
40+
int error_code
41+
char error_buffer[ERROR_BUFFERLEN]
42+
int ssh_auth_reply_default(ssh_session session,int partial)
43+
int ssh_auth_reply_success(ssh_session session, int partial)
44+
int ssh_send_banner(ssh_session session, int is_server)
45+
socket_t ssh_connect_host(ssh_session session, const char *host,const char
46+
*bind_addr, int port, long timeout, long usec)
47+
socket_t ssh_connect_host_nonblocking(ssh_session session, const char *host,
48+
const char *bind_addr, int port)
49+
ssh_buffer base64_to_bin(const char *source)
50+
unsigned char *bin_to_base64(const unsigned char *source, int len)
51+
int compress_buffer(ssh_session session,ssh_buffer buf)
52+
int decompress_buffer(ssh_session session,ssh_buffer buf, size_t maxlen)
53+
int match_hostname(const char *host, const char *pattern, unsigned int len)
54+
int ssh_connector_set_event(ssh_connector connector, ssh_event event)
55+
int ssh_connector_remove_event(ssh_connector connector)
56+
void ssh_agent_state_free(void *data)

0 commit comments

Comments
 (0)