def __init__(self, parent, debug=False, lowerIpVersion=AdapterIP.IPv4, version=ICMPv4, errorsOnly=False, logEventSent=True, logEventReceived=True, agentSupport=False, agent=None, shared=False, name=None): """ """ # init adapter if version == ICMPv4: __NAME__ = __NAMEV4__ if version == ICMPv6: __NAME__ = __NAMEV6__ TestAdapterLib.Adapter.__init__(self, name=__NAME__, parent=parent, realname=name, debug=debug, shared=shared, agentSupport=agentSupport, agent=agent, caller=TestAdapterLib.caller(), agentType=AGENT_TYPE_EXPECTED) self.logEventSent = logEventSent self.logEventReceived = logEventReceived # init icmp self.icmpCodec = codec4.Codec(parent=self, testcase=parent, debug=debug) # init ip layer self.ip = AdapterIP.SnifferV4(parent=parent, debug=debug, protocol2sniff=AdapterIP.ICMP, logEventSent=False, logEventReceived=False, disableArp=errorsOnly, parentName=__NAME__, agentSupport=agentSupport, agent=agent, shared=shared) self.ip.onReceiving = self.onDecodeData self.cfg = {} self.cfg['listen-errors-only'] = errorsOnly self.cfg['agent-support'] = agentSupport if agentSupport: self.cfg['agent'] = agent self.cfg['agent-name'] = agent['name'] self.__checkConfig()
def __init__(self, parent, debug=False, logEventSent=True, logEventReceived=True, ipVersion=AdapterIP.IPv4, port2sniff=codec.ALL, name=None, separatorIn='0x00', separatorOut='0x00', separatorDisabled=True, inactivityTimeout=0.0, parentName=None, agentSupport=False, agent=None, shared=False): """ This class enables to send/receive UDP data. The lower layer is based on the IP adapter. Support data separator for upper application and inactivity detection. @param parent: parent testcase @type parent: testcase @param name: adapter name used with from origin/to destination (default=None) @type name: string/none @param debug: active debug mode (default=False) @type debug: boolean @param separatorIn: data separator (default=0x00) @type separatorIn: string @param port2sniff: udp port to sniff @type port2sniff: integer @param separatorOut: data separator (default=0x00) @type separatorOut: string @param separatorDisabled: disable the separator feature, if this feature is enabled then data are buffered until the detection of the separator (default=False) @type separatorDisabled: boolean @param inactivityTimeout: feature disabled by default (value=0.0) @type inactivityTimeout: float @param agentSupport: agent support to use a remote socket (default=False) @type agentSupport: boolean @param agent: agent to use when this mode is activated @type agent: string/None @param shared: shared adapter (default=False) @type shared: boolean """ # init adapter TestAdapterLib.Adapter.__init__(self, name=client.__NAME__, parent=parent, debug=debug, shared=shared, realname=name, agentSupport=agentSupport, agent=agent, caller=TestAdapterLib.caller(), agentType=AGENT_TYPE_EXPECTED) self.logEventSent = logEventSent self.logEventReceived = logEventReceived self.port2sniff = port2sniff # udp codec self.udpCodec = codec.Codec(parent=self, testcase=parent, debug=debug, srcPort=port2sniff) # init ip layer ## TODO: version IP self.ip = AdapterIP.SnifferV4(parent=parent, debug=debug, protocol2sniff=AdapterIP.UDP, logEventSent=False, logEventReceived=False, parentName=client.__NAME__, agentSupport=agentSupport, agent=agent, name=name, shared=shared) if parentName is not None: self.ip.setname(name="%s>%s" % (parentName, client.__NAME__)) self.ip.onReceiving = self.onDecodeData self.icmp = AdapterICMP.SnifferV4(parent=parent, debug=debug, lowerIpVersion=4, errorsOnly=True, logEventSent=False, logEventReceived=False, agentSupport=agentSupport, agent=agent, name=name, shared=shared) self.icmp.onIcmpError = self.onIcmpError self.cfg = {} self.cfg['ip-version'] = ipVersion self.cfg['sep-in'] = separatorIn self.cfg['sep-out'] = separatorOut self.cfg['sep-disabled'] = separatorDisabled self.cfg['inactivity-timeout'] = inactivityTimeout self.cfg['agent-support'] = agentSupport if agentSupport: self.cfg['agent'] = agent self.cfg['agent-name'] = agent['name'] self.__checkConfig() self.buf = {}