1Net::SSH::Perl::Packet(U3s)er Contributed Perl DocumentatNieotn::SSH::Perl::Packet(3)
2
3
4

NAME

6       Net::SSH::Perl::Packet - Packet layer of SSH protocol
7

SYNOPSIS

9           use Net::SSH::Perl::Packet;
10
11           # Send a packet to an ssh daemon.
12           my $pack = Net::SSH::Perl::Packet->new($ssh, type => SSH_MSG_NONE);
13           $pack->send;
14
15           # Receive a packet.
16           my $pack = Net::SSH::Perl::Packet->read($ssh);
17

DESCRIPTION

19       Net::SSH::Perl::Packet implements the packet-layer piece of the SSH
20       protocol. Messages between server and client are sent as binary data
21       packets, which are encrypted (once the two sides have agreed on the
22       encryption cipher, that is).
23
24       Packets are made up primarily of a packet type, which describes the
25       type of message and data contained therein, and the data itself. In
26       addition, each packet: indicates its length in a 32-bit unsigned inte‐
27       ger; contains padding to pad the length of the packet to a multiple of
28       8 bytes; and is verified by a 32-bit crc checksum.
29
30       Refer to the SSH RFC for more details on the packet protocol and the
31       SSH protocol in general.
32

USAGE

34       Net::SSH::Perl::Packet->new($ssh, %params)
35
36       Creates/starts a new packet in memory. $ssh is a Net::SSH::Perl object,
37       which should already be connected to an ssh daemon. %params can contain
38       the following keys:
39
40       * type
41           The message type of this packet. This should be one of the values
42           exported by Net::SSH::Perl::Constants from the msg tag; for exam‐
43           ple, SSH_MSG_NONE.
44
45       * data
46           A Net::SSH::Perl::Buffer object containing the data in this packet.
47           Realistically, there aren't many times you'll need to supply this
48           argument: when sending a packet, it will be created automatically;
49           and when receiving a packet, the read method (see below) will cre‐
50           ate the buffer automatically, as well.
51
52       Net::SSH::Perl::Packet->read($ssh)
53
54       Reads a packet from the ssh daemon and returns that packet.
55
56       This method will block until an entire packet has been read.  The
57       socket itself is non-blocking, but the method waits (using select) for
58       data on the incoming socket, then processes that data when it comes in.
59       If the data makes up a complete packet, the packet is returned to the
60       caller. Otherwise read continues to try to read more data.
61
62       Net::SSH::Perl::Packet->read_poll($ssh)
63
64       Checks the data that's been read from the sshd to see if that data com‐
65       prises a complete packet. If so, that packet is returned. If not,
66       returns "undef".
67
68       This method does not block.
69
70       Net::SSH::Perl::Packet->read_expect($ssh, $type)
71
72       Reads the next packet from the daemon and dies if the packet type does
73       not match $type. Otherwise returns the read packet.
74
75       $packet->send([ $data ])
76
77       Sends a packet to the ssh daemon. $data is optional, and if supplied
78       specifies the buffer to be sent in the packet (should be a
79       Net::SSH::Perl::Buffer object).  In addition, $data, if specified, must
80       include the packed message type.
81
82       If $data is not specified, send sends the buffer internal to the
83       packet, which you've presumably filled by calling the put_* methods
84       (see below).
85
86       $packet->type
87
88       Returns the message type of the packet $packet.
89
90       $packet->data
91
92       Returns the message buffer from the packet $packet; a
93       Net::SSH::Perl::Buffer object.
94
95       Net::SSH::Perl::Buffer methods
96
97       Calling methods from the Net::SSH::Perl::Buffer class on your
98       Net::SSH::Perl::Packet object will automatically invoke those methods
99       on the buffer object internal to your packet object (which is created
100       when your object is constructed). For example, if you executed the fol‐
101       lowing code:
102
103           my $packet = Net::SSH::Perl::Packet->new($ssh, type => SSH_CMSG_USER);
104           $packet->put_str($user);
105
106       this would construct a new packet object $packet, then fill its inter‐
107       nal buffer by calling the put_str method on it.
108
109       Refer to the Net::SSH::Perl::Buffer documentation (the GET AND PUT
110       METHODS section) for more details on those methods.
111

AUTHOR & COPYRIGHTS

113       Please see the Net::SSH::Perl manpage for author, copyright, and
114       license information.
115
116
117
118perl v5.8.8                       2003-12-03         Net::SSH::Perl::Packet(3)
Impressum