Ejemplo n.º 1
0
    def seqMatch(seq, filterstr):
        # TODO: design filter str
        if seq["protocol"] != "Diameter":
            mylog("Wrong message to match against diameter")
            return False

        r = re.match("Diam:(.*)->(.*):(\w+)(\[(.*)\])?", filterstr)
        if r:
            (s, d) = (r.group(1), r.group(2))
            mylog("#####################", s, d)
            if not xmatch(seq["from"], s):
                return False
            if not xmatch(seq["to"], d):
                return False

        else:
            pass
            mylog("no from to section", filterstr)

        diammsg = getMessageFromSeq(seq)
        r = re.match("(.*):(\w+)", filterstr)
        if r is not None:
            command = r.group(2)
            return diammsg.match(command)
        else:
            return True
Ejemplo n.º 2
0
def match(value, expect, match_option):
    if value.__class__ == [].__class__:
        for v in value:
            if xmatch(v, expect, match_option):
                return True
        return False
    return xmatch(value, expect, match_option)
Ejemplo n.º 3
0
 def seqMatch(seq, s, d, method, code=None):
     if not xmatch(seq["from"], s):
         return False
     if not xmatch(seq["to"], d):
         return False
     sipmsg = getMessageFromSeq(seq)
     mylog("sip message to match:\n" + str(sipmsg))
     mylog("method = %s, code = %s" % (method, code))
     if code is None and sipmsg.__class__.__name__ == "SipRequest":
         return sipmsg.match(method)
     else:
         if sipmsg.__class__.__name__ == "SipResponse":
             return sipmsg.match(code, method)
         else:
             return False
Ejemplo n.º 4
0
def filterMessage(seqs, name, index):
    if index == None:
        results = []
        for s in seqs:
            if xmatch(s.choice, name):
                results.append(s)
        return results
    else:
        found_index = 0
        for s in seqs:
            if xmatch(s.choice, name):
                if found_index == index:
                    return s
                else:
                    found_index += 1
        return None
Ejemplo n.º 5
0
def testGlobInOneGroup(dict, exp_key, exp_value):
	"""Multiple counts should be same value"""
	result = False 
	for  key in dict:
		if (xmatch(key, exp_key)):
			#print  key
			result = testInOneGroup(dict, key, exp_value)	
			#print result
			if result:
				return result	
		#	if (not result):
		#		return result
	if result == False:
		#print ("FAILURE: glob key not exist:" + exp_key)
		return False
	else:
		return True
Ejemplo n.º 6
0
 def match(self, key, expect, regex):
     if regex:
         return xmatch(self.get(key), expect, "re")
     else:
         return xmatch(self.get(key), expect, "glob")