Skip to content

Commit da3a34c

Browse files
author
Pan
committed
Added callbacks, messages, options and packet definition files. Updated libssh definitions.
1 parent 03575a1 commit da3a34c

File tree

6 files changed

+189
-3
lines changed

6 files changed

+189
-3
lines changed

ssh/c_callbacks.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, ssh_string, uint8_t
18+
19+
cdef extern from "libssh/include/callbacks.h" nogil:
20+
ctypedef ssh_string (*void) (ssh_session, const char*,
21+
int, ssh_string *, void *)
22+
ctypedef int (*ssh_packet_callback) (ssh_session session, uint8_t type, ssh_buffer packet, void *user)
23+
struct ssh_packet_callbacks_struct:
24+
uint8_t start
25+
uint8_t n_callbacks
26+
void *user
27+
ctypedef ssh_packet_callbacks_struct *ssh_packet_callbacks

ssh/c_messages.pxd

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
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_string, ssh_message, ssh_channel, uint32_t, uint16_t, \
18+
uint8_t, ssh_key_struct, ssh_buffer
19+
20+
cdef extern from "libssh/include/messages.h" nogil:
21+
struct ssh_auth_request:
22+
char *username
23+
int method
24+
char *password
25+
ssh_key_struct *pubkey
26+
char signature_state
27+
char kbdint_response
28+
29+
struct ssh_channel_request_open:
30+
int type
31+
uint32_t sender
32+
uint32_t window
33+
uint32_t packet_size
34+
char *originator
35+
uint16_t originator_port
36+
char *destination
37+
uint16_t destination_port
38+
39+
struct ssh_service_request:
40+
char *service
41+
42+
struct ssh_global_request:
43+
int type
44+
uint8_t want_reply
45+
char *bind_address
46+
uint16_t bind_port
47+
48+
struct ssh_channel_request:
49+
int type
50+
ssh_channel channel
51+
uint8_t want_reply
52+
char *TERM
53+
uint32_t width
54+
uint32_t height
55+
uint32_t pxwidth
56+
uint32_t pxheight
57+
ssh_string modes
58+
char *var_name
59+
char *var_value
60+
char *command
61+
char *subsystem
62+
uint8_t x11_single_connection
63+
char *x11_auth_protocol
64+
char *x11_auth_cookie
65+
uint32_t x11_screen_number
66+
67+
struct ssh_message_struct:
68+
ssh_session session
69+
int type
70+
ssh_auth_request auth_request
71+
ssh_channel_request_open channel_request_open
72+
ssh_channel_request channel_request
73+
ssh_service_request service_request
74+
ssh_global_request global_request
75+
76+
int ssh_message_handle_channel_request(ssh_session session, ssh_channel channel, ssh_buffer packet,
77+
const char *request, uint8_t want_reply)
78+
void ssh_message_queue(ssh_session session, ssh_message message)
79+
ssh_message ssh_message_pop_head(ssh_session session)
80+
int ssh_message_channel_request_open_reply_accept_channel(ssh_message msg, ssh_channel chan)

ssh/c_options.pxd

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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_kex_types_e
18+
19+
cdef extern from "libssh/include/options.h" nogil:
20+
int ssh_config_parse_file(ssh_session session, const char *filename)
21+
int ssh_options_set_algo(ssh_session session, ssh_kex_types_e algo,
22+
const char *list)
23+
int ssh_options_apply(ssh_session session)

ssh/c_packet.pxd

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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
18+
from c_wrapper cimport ssh_hmac_e
19+
from c_callbacks cimport ssh_packet_callbacks
20+
21+
cdef extern from "libssh/include/packet.h" nogil:
22+
struct ssh_socket_struct:
23+
pass
24+
struct packet_struct:
25+
int valid
26+
uint32_t len
27+
uint8_t type
28+
ctypedef packet_struct PACKET
29+
enum ssh_packet_state_e:
30+
PACKET_STATE_INIT,
31+
PACKET_STATE_SIZEREAD,
32+
PACKET_STATE_PROCESSING
33+
int ssh_packet_send(ssh_session session)
34+
int ssh_packet_send_unimplemented(ssh_session session, uint32_t seqnum)
35+
int ssh_packet_parse_type(ssh_session session)
36+
37+
int ssh_packet_socket_callback(const void *data, size_t len, void *user)
38+
void ssh_packet_register_socket_callback(ssh_session session,
39+
ssh_socket_struct *s)
40+
void ssh_packet_set_callbacks(ssh_session session,
41+
ssh_packet_callbacks callbacks)
42+
void ssh_packet_set_default_callbacks(ssh_session session)
43+
void ssh_packet_process(ssh_session session, uint8_t type)
44+
uint32_t ssh_packet_decrypt_len(ssh_session session, char *crypted)
45+
int ssh_packet_decrypt(ssh_session session, void *packet, unsigned int len)
46+
unsigned char *ssh_packet_encrypt(ssh_session session,
47+
void *packet,
48+
unsigned int len)
49+
int ssh_packet_hmac_verify(ssh_session session, ssh_buffer buffer,
50+
unsigned char *mac, ssh_hmac_e type)

ssh/c_ssh.pxd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ from posix.types cimport mode_t
2020

2121

2222
cdef extern from "libssh/include/libssh.h" nogil:
23+
ctypedef unsigned char uint8_t
24+
ctypedef unsigned short uint16_t
2325
ctypedef unsigned int uint32_t
2426
ctypedef unsigned long long uint64_t
2527
ctypedef int socket_t

ssh/ssh.pyx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
# This file is part of ssh-python.
22
# Copyright (C) 2018 Panos Kittenis
3-
3+
#
44
# This library is free software; you can redistribute it and/or
55
# modify it under the terms of the GNU Lesser General Public
66
# License as published by the Free Software Foundation, version 2.1.
7-
7+
#
88
# This library is distributed in the hope that it will be useful,
99
# but WITHOUT ANY WARRANTY; without even the implied warranty of
1010
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1111
# Lesser General Public License for more details.
12-
12+
#
1313
# You should have received a copy of the GNU Lesser General Public
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
@@ -26,3 +26,7 @@ cimport c_kex
2626
cimport c_keys
2727
cimport c_knownhosts
2828
cimport c_legacy
29+
cimport c_messages
30+
cimport c_options
31+
cimport c_callbacks
32+
cimport c_packet

0 commit comments

Comments
 (0)