本文整理汇总了Python中sctp.types.ScAddr.seg方法的典型用法代码示例。如果您正苦于以下问题:Python ScAddr.seg方法的具体用法?Python ScAddr.seg怎么用?Python ScAddr.seg使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sctp.types.ScAddr
的用法示例。
在下文中一共展示了ScAddr.seg方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_arc
# 需要导入模块: from sctp.types import ScAddr [as 别名]
# 或者: from sctp.types.ScAddr import seg [as 别名]
def get_arc(self, arc):
"""Returns sc-addr of arc element begin
@param arc sc-addr of arc to get beign
@return If there are no any errors, then returns sc-addr of arc begin;
otherwise returns None
"""
# send request
params = struct.pack("=HH", arc.seg, arc.offset)
data = struct.pack("=BBII", SctpCommandType.SCTP_CMD_GET_ARC, 0, 0, len(params))
alldata = data + params
self.sock.send(alldata)
# receive response
data = self.receiveData(10)
cmdCode, cmdId, resCode, resSize = struct.unpack("=BIBI", data)
if resCode != SctpResultCode.SCTP_RESULT_OK:
return None
addr = ScAddr(0, 0)
data = self.receiveData(4)
addr.seg, addr.offset = struct.unpack("=HH", data)
addr2 = ScAddr(0, 0)
data = self.receiveData(4)
addr2.seg, addr2.offset = struct.unpack("=HH", data)
return (addr, addr2)
示例2: find_links_with_content
# 需要导入模块: from sctp.types import ScAddr [as 别名]
# 或者: from sctp.types.ScAddr import seg [as 别名]
def find_links_with_content(self, data):
"""Find sc-links with specified content
@param data: Content data for search
@return: Returns list of sc-addrs of founded sc-links. If there are any error, then return None
"""
# send request
params = struct.pack('=I%ds' % len(data), len(data), data)
data = struct.pack('=BBII', SctpCommandType.SCTP_CMD_FIND_LINKS, 0, 0, len(params))
alldata = data + params
self.sock.send(alldata)
# receive response
data = self.receiveData(10)
cmdCode, cmdId, resCode, resSize = struct.unpack('=BIBI', data)
if resCode != SctpResultCode.SCTP_RESULT_OK or resSize < 4:
return None
res = []
data = self.receiveData(resSize)
resCount = struct.unpack('=I', data[:4])[0]
for i in xrange(resCount):
addr = ScAddr(0, 0)
data = data[4:]
addr.seg, addr.offset = struct.unpack('=HH', data)
res.append(addr)
return res
示例3: create_arc
# 需要导入模块: from sctp.types import ScAddr [as 别名]
# 或者: from sctp.types.ScAddr import seg [as 别名]
def create_arc(self, arc_type, begin_addr, end_addr):
"""Create new arc in sc-memory with specified type and begin, end elements
@param arc_type: Type of sc-arc
@param begin_addr: sc-addr of begin arc element
@param end_addr: sc-addr of end arc element
@return: If sc-arc was created, then returns it sc-addr; otherwise return None
"""
# send request
params = struct.pack('=HHHHH', arc_type, begin_addr.seg, begin_addr.offset, end_addr.seg, end_addr.offset)
data = struct.pack('=BBII', SctpCommandType.SCTP_CMD_CREATE_ARC, 0, 0, len(params))
alldata = data + params
self.sock.send(alldata)
# receive response
data = self.receiveData(10)
cmdCode, cmdId, resCode, resSize = struct.unpack('=BIBI', data)
if resCode != SctpResultCode.SCTP_RESULT_OK:
return None
addr = ScAddr(0, 0)
data = self.receiveData(4)
addr.seg, addr.offset = struct.unpack('=HH', data)
return addr
示例4: create_link
# 需要导入模块: from sctp.types import ScAddr [as 别名]
# 或者: from sctp.types.ScAddr import seg [as 别名]
def create_link(self):
"""Create new sc-link in memory
@return: If sc-link was created, then returns it sc-addr; otherwise return None
"""
# send request
data = struct.pack('=BBII', SctpCommandType.SCTP_CMD_CREATE_LINK, 0, 0, 0)
alldata = data
self.sock.send(alldata)
# receive response
data = self.receiveData(10)
cmdCode, cmdId, resCode, resSize = struct.unpack('=BIBI', data)
if resCode != SctpResultCode.SCTP_RESULT_OK:
return None
addr = ScAddr(0, 0)
data = self.receiveData(4)
addr.seg, addr.offset = struct.unpack('=HH', data)
return addr
示例5: find_element_by_system_identifier
# 需要导入模块: from sctp.types import ScAddr [as 别名]
# 或者: from sctp.types.ScAddr import seg [as 别名]
def find_element_by_system_identifier(self, idtf_data):
"""Find sc-element by it system identifier
@param idtf_data: Identifier data for search
@return: Returns sc-addrs of founded sc-element.
If there are any error or sc-element wasn't found, then return None
"""
# send request
params = struct.pack('=I%ds' % len(idtf_data), len(idtf_data), idtf_data)
data = struct.pack('=BBII', SctpCommandType.SCTP_CMD_FIND_ELEMENT_BY_SYSITDF, 0, 0, len(params))
alldata = data + params
self.sock.send(alldata)
# receive response
data = self.receiveData(10)
cmdCode, cmdId, resCode, resSize = struct.unpack('=BIBI', data)
if resCode != SctpResultCode.SCTP_RESULT_OK or resSize < 4:
return None
addr = ScAddr(0, 0)
data = self.receiveData(4)
addr.seg, addr.offset = struct.unpack('=HH', data)
return addr
示例6: create_node
# 需要导入模块: from sctp.types import ScAddr [as 别名]
# 或者: from sctp.types.ScAddr import seg [as 别名]
def create_node(self, el_type):
"""Create new sc-node in memory with specified type
@param el_type: Type of node that would be created
@return: If sc-node was created, then returns it sc-addr; otherwise return None
"""
# send request
params = struct.pack('=H', el_type)
data = struct.pack('=BBII', SctpCommandType.SCTP_CMD_CREATE_NODE, 0, 0, len(params))
alldata = data + params
self.sock.send(alldata)
# receive response
data = self.receiveData(10)
cmdCode, cmdId, resCode, resSize = struct.unpack('=BIBI', data)
if resCode != SctpResultCode.SCTP_RESULT_OK:
return None
addr = ScAddr(0, 0)
data = self.receiveData(4)
addr.seg, addr.offset = struct.unpack('=HH', data)
return addr
示例7: iterate_elements
# 需要导入模块: from sctp.types import ScAddr [as 别名]
# 或者: from sctp.types.ScAddr import seg [as 别名]
def iterate_elements(self, iterator_type, *args):
"""Iterate element by specified template and return results
"""
params = None
params_count = None
if iterator_type == SctpIteratorType.SCTP_ITERATOR_3A_A_F:
params_count = 3
params = struct.pack('=BHHHH', iterator_type, args[0], args[1], args[2].seg, args[2].offset)
elif iterator_type == SctpIteratorType.SCTP_ITERATOR_3F_A_A:
params_count = 3
params = struct.pack('=BHHHH', iterator_type, args[0].seg, args[0].offset, args[1], args[2])
elif iterator_type == SctpIteratorType.SCTP_ITERATOR_3F_A_F:
params_count = 3
params = struct.pack('=BHHHHH', iterator_type, args[0].seg, args[0].offset, args[1], args[2].seg, args[2].offset)
elif iterator_type == SctpIteratorType.SCTP_ITERATOR_5_A_A_F_A_A:
params_count = 5
params = struct.pack('=BHHHHHH', iterator_type, args[0], args[1], args[2].seg, args[2].offset, args[3], args[4])
elif iterator_type == SctpIteratorType.SCTP_ITERATOR_5_A_A_F_A_F:
params_count = 5
params = struct.pack('=BHHHHHHH', iterator_type, args[0], args[1], args[2].seg, args[2].offset, args[3], args[4].seg, args[4].offset)
elif iterator_type == SctpIteratorType.SCTP_ITERATOR_5_F_A_A_A_A:
params_count = 5
params = struct.pack('=BHHHHHH', iterator_type, args[0].seg, args[0].offset, args[1], args[2], args[3], args[4])
elif iterator_type == SctpIteratorType.SCTP_ITERATOR_5_F_A_F_A_A:
params_count = 5
params = struct.pack('=BHHHHHHH', iterator_type, args[0].seg, args[0].offset, args[1], args[2].seg, args[2].offset, args[3], args[4])
elif iterator_type == SctpIteratorType.SCTP_ITERATOR_5_F_A_F_A_F:
params_count = 5
params = struct.pack('=BHHHHHHHH', iterator_type, args[0].seg, args[0].offset, args[1], args[2].seg, args[2].offset, args[3], args[4].seg, args[4].offset)
elif iterator_type == SctpIteratorType.SCTP_ITERATOR_5F_A_A_A_F:
params_count = 5
params = struct.pack('=BHHHHHHH', iterator_type, args[0].seg, args[0].offset, args[1], args[2], args[3], args[4].seg, args[4].offset)
params_len = len(params)
# send request
data = struct.pack('=BBII', SctpCommandType.SCTP_CMD_ITERATE_ELEMENTS, 0, 0, params_len)
alldata = data + params
self.sock.send(alldata)
# receive response
data = self.receiveData(10)
cmdCode, cmdId, resCode, resSize = struct.unpack('=BIBI', data)
if resCode != SctpResultCode.SCTP_RESULT_OK or resSize == 0:
return None
res_count_data = self.receiveData(4)
res_count = struct.unpack('=I', res_count_data)[0]
if res_count == 0:
return None
results = []
for idx in xrange(res_count):
result_item = []
for j in xrange(params_count):
addr_data = self.receiveData(4)
addr = ScAddr(0, 0)
addr.seg, addr.offset = struct.unpack('=HH', addr_data)
result_item.append(addr)
results.append(result_item)
return results