summaryrefslogtreecommitdiff
path: root/paramiko/message.py
diff options
context:
space:
mode:
authorJeremy T. Bouse <jbouse@debian.org>2014-09-22 09:21:39 -0400
committerJeremy T. Bouse <jbouse@debian.org>2014-09-22 09:21:39 -0400
commitccd643cdbd7ba752727d62051058a4454451414d (patch)
tree9bc89a6629132f474b3297735069d025145a965c /paramiko/message.py
parent588a4823436454e8968ee36ae95ff92e1cddc3f7 (diff)
downloadpython-paramiko-ccd643cdbd7ba752727d62051058a4454451414d.tar
python-paramiko-ccd643cdbd7ba752727d62051058a4454451414d.tar.gz
Imported Upstream version 1.15.0upstream/1.15.0
Diffstat (limited to 'paramiko/message.py')
-rw-r--r--paramiko/message.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/paramiko/message.py b/paramiko/message.py
index da6acf8..b893e76 100644
--- a/paramiko/message.py
+++ b/paramiko/message.py
@@ -148,6 +148,19 @@ class Message (object):
@return: a 32-bit unsigned integer.
@rtype: int
"""
+ byte = self.get_bytes(1)
+ if byte == max_byte:
+ return util.inflate_long(self.get_binary())
+ byte += self.get_bytes(3)
+ return struct.unpack('>I', byte)[0]
+
+ def get_size(self):
+ """
+ Fetch an int from the stream.
+
+ @return: a 32-bit unsigned integer.
+ @rtype: int
+ """
return struct.unpack('>I', self.get_bytes(4))[0]
def get_int64(self):
@@ -257,6 +270,20 @@ class Message (object):
self.packet.write(struct.pack('>I', n))
return self
+ def add_int(self, n):
+ """
+ Add an integer to the stream.
+
+ @param n: integer to add
+ @type n: int
+ """
+ if n >= Message.big_int:
+ self.packet.write(max_byte)
+ self.add_string(util.deflate_long(n))
+ else:
+ self.packet.write(struct.pack('>I', n))
+ return self
+
def add_int64(self, n):
"""
Add a 64-bit int to the stream.