@@ -230,7 +230,6 @@ def __init__(self, values=None):
230230 self .stream = 0
231231 self .ssn = 0
232232 self .flags = 0
233- self .ppid = 0
234233 self .context = 0
235234 self .timetolive = 0
236235 self .tsn = 0
@@ -1006,6 +1005,10 @@ class sctpsocket(object):
10061005 associations, in seconds. A value of 0 means that no automatic close
10071006 will be done. This property does not work for TCP-style sockets.
10081007
1008+ ttl: Default timetolive value to use with sctp_send. Default set to 0.
1009+
1010+ streamid: Default SCTP stream identifier value to use with sctp_send. Default set to 0.
1011+
10091012 IMPORTANT NOTE: the maximum message size is limited both by the implementation
10101013 and by the transmission buffer (SO_SNDBUF). SCTP applications must configure
10111014 the transmission and receiving bufers accordingly to the biggest messages it
@@ -1030,6 +1033,8 @@ def __init__(self, family, style, sk):
10301033 self ._style = style
10311034 self ._sk = sk
10321035 self ._family = family
1036+ self ._ttl = 0
1037+ self ._streamid = 0
10331038
10341039 self .unexpected_event_raises_exception = False
10351040 self .initparams = initparams (self )
@@ -1107,7 +1112,7 @@ def getladdrs(self, assoc_id = 0): # -> tuple of sockaddrs as strings
11071112
11081113 return _sctp .getladdrs (self ._sk .fileno (), assoc_id )
11091114
1110- def sctp_send (self , msg , to = ("" ,0 ), ppid = 0 , flags = 0 , stream = 0 , timetolive = 0 , context = 0 ,
1115+ def sctp_send (self , msg , to = ("" ,0 ), ppid = 0 , flags = 0 , stream = None , timetolive = None , context = 0 ,
11111116 record_file_prefix = "RECORD_sctp_traffic" , datalogging = False ):
11121117 """
11131118 Sends a SCTP message. While send()/sendto() can also be used, this method also
@@ -1121,7 +1126,7 @@ def sctp_send(self, msg, to=("",0), ppid=0, flags=0, stream=0, timetolive=0, con
11211126 WARNING: identifying destination by Association ID not implemented yet!
11221127
11231128 ppid: adaptation layer value, a 32-bit metadata that is sent along the message.
1124- Defaults to 0.
1129+ Default to 0.
11251130
11261131 flags: a bitmap of MSG_* flags. For example, MSG_UNORDERED indicates that
11271132 message can be delivered out-of-order, and MSG_EOF + empty message
@@ -1130,12 +1135,13 @@ def sctp_send(self, msg, to=("",0), ppid=0, flags=0, stream=0, timetolive=0, con
11301135 It does NOT include flags like MSG_DONTROUTE or other low-level flags
11311136 that are supported by sendto().
11321137
1133- stream: stream number where the message will sent by. Defaults to 0.
1138+ stream: stream number where the message will sent by.
1139+ If not set use default value.
11341140
11351141 timetolive: time to live of the message in milisseconds. Zero means infinite
11361142 TTL. If TTL expires, the message is discarded. Discarding policy
11371143 changes whether implementation implements the PR-SCTP extension or not.
1138- Defaults to 0 (infinite) .
1144+ If not set use default value .
11391145
11401146 context: an opaque 32-bit integer that will be returned in some notification events,
11411147 if the event is directly related to this message transmission. So the
@@ -1150,6 +1156,13 @@ def sctp_send(self, msg, to=("",0), ppid=0, flags=0, stream=0, timetolive=0, con
11501156 both by the implementation and by the transmission buffer (SO_SNDBUF).
11511157 The application must configure this buffer accordingly.
11521158 """
1159+
1160+ if timetolive is None :
1161+ timetolive = self ._ttl
1162+
1163+ if stream is None :
1164+ stream = self ._streamid
1165+
11531166 if datalogging == True or self .datalogging == True :
11541167 now = datetime .datetime .now ()
11551168 recordfilename = record_file_prefix + "-" + now .strftime ("%Y%m%d%H%M%S" ) + "-c2s."
@@ -1625,6 +1638,36 @@ def set_rtoinfo(self, o):
16251638 """
16261639 _sctp .set_rtoinfo (self ._sk .fileno (), o .__dict__ )
16271640
1641+ def get_ttl (self ):
1642+ """
1643+ Read default time to live value, 0 mean infinite
1644+ """
1645+ return self ._ttl
1646+
1647+ def set_ttl (self , newVal ):
1648+ """
1649+ Write default time to live
1650+ """
1651+ if not isinstance (newVal , int ) or newVal < 0 or newVal > 255 :
1652+ raise ValueError ('TTL shall be >= 0 and <= 255' )
1653+
1654+ self ._ttl = newVal
1655+
1656+ def get_streamid (self ):
1657+ """
1658+ Read default stream identifier
1659+ """
1660+ return self ._streamid
1661+
1662+ def set_streamid (self , newVal ):
1663+ """
1664+ Write default stream identifier
1665+ """
1666+ if not isinstance (newVal , int ) or newVal < 0 or newVal > 65535 :
1667+ raise ValueError ('streamid shall be a valid unsigned 16bits integer' )
1668+
1669+ self ._streamid = newVal
1670+
16281671 # delegation
16291672
16301673 def sock (self ):
@@ -1649,6 +1692,8 @@ def __getattr__(self, name):
16491692 mappedv4 = property (get_mappedv4 , set_mappedv4 )
16501693 maxseg = property (get_maxseg , set_maxseg )
16511694 autoclose = property (get_autoclose , set_autoclose )
1695+ ttl = property (get_ttl , set_ttl )
1696+ streamid = property (get_streamid , set_streamid )
16521697
16531698class sctpsocket_tcp (sctpsocket ):
16541699 """
0 commit comments