54 lines
1.1 KiB
Python
Executable File
54 lines
1.1 KiB
Python
Executable File
#!/usr/bin/python
|
|
|
|
__author__ = "Daniel Egger"
|
|
__date__ = "22 March 2002"
|
|
__email__ = "egger@interearth.com"
|
|
__version__ = "$Revision: 1.1 $"[11:-2]
|
|
|
|
from cany_tpdu import CANY_TPDU
|
|
from tpdu import TPDU_CR
|
|
|
|
__all__ = ["fromstring", "CR_TPDU"]
|
|
|
|
|
|
def fromstring (data):
|
|
"""
|
|
Decode the binary representation of a TPDU from the given
|
|
parameter and note the data in the instance of the object.
|
|
|
|
Parameters:
|
|
data: The binary form of the TPDU
|
|
"""
|
|
tpdu = CR_TPDU ()
|
|
tpdu.fromstring (data)
|
|
return tpdu
|
|
|
|
class CR_TPDU (CANY_TPDU):
|
|
def __init__ (self, srctsap = "", dsttsap = "", *args, **args2):
|
|
CANY_TPDU.__init__ (self, TPDU_CR, srctsap, dsttsap, *args, **args2)
|
|
return
|
|
|
|
|
|
def identify (self):
|
|
"""
|
|
This method can be used to identify a TPDU by string.
|
|
"""
|
|
return "CR TPDU (Connection request)\n"
|
|
|
|
|
|
# Integrated tests start here
|
|
if __name__ == '__main__':
|
|
testnum = 1
|
|
|
|
tpdu = CR_TPDU ("SOURCE", "DEST")
|
|
print "Test %0d sucessful" % testnum
|
|
testnum += 1
|
|
|
|
tpdu = CR_TPDU ("TCP-1", "TCP", srcref=0x0005)
|
|
print "Test %0d sucessful" % testnum
|
|
testnum += 1
|
|
|
|
print tpdu
|
|
print "Test %0d sucessful" % testnum
|
|
testnum += 1
|