17ec681f3Smrg#!/usr/bin/python3 27ec681f3Smrg 37ec681f3Smrgimport re 47ec681f3Smrgimport sys 57ec681f3Smrg 67ec681f3Smrgdef main(): 77ec681f3Smrg if len(sys.argv) != 3: 87ec681f3Smrg print("Missing arguments: ./radv_check_va.py <bo_history> <64-bit VA>") 97ec681f3Smrg sys.exit(1) 107ec681f3Smrg 117ec681f3Smrg bo_history = str(sys.argv[1]) 127ec681f3Smrg va = int(sys.argv[2], 16) 137ec681f3Smrg 147ec681f3Smrg va_found = False 157ec681f3Smrg with open(bo_history) as f: 167ec681f3Smrg for line in f: 177ec681f3Smrg p = re.compile('timestamp=(.*), VA=(.*)-(.*), destroyed=(.*), is_virtual=(.*)') 187ec681f3Smrg m = p.match(line) 197ec681f3Smrg if m == None: 207ec681f3Smrg continue 217ec681f3Smrg 227ec681f3Smrg va_start = int(m.group(2), 16) 237ec681f3Smrg va_end = int(m.group(3), 16) 247ec681f3Smrg 257ec681f3Smrg # Check if the given VA was ever valid and print info. 267ec681f3Smrg if va >= va_start and va < va_end: 277ec681f3Smrg print("VA found: %s" % line, end='') 287ec681f3Smrg va_found = True 297ec681f3Smrg if not va_found: 307ec681f3Smrg print("VA not found!") 317ec681f3Smrg 327ec681f3Smrgif __name__ == '__main__': 337ec681f3Smrg main() 34