mirror of
				https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
				synced 2025-10-31 18:58:01 +00:00 
			
		
		
		
	Added PacketFilter class for working with pcaps
This commit is contained in:
		| @@ -13,6 +13,7 @@ from LANforge.lfcli_base import LFCliBase | |||||||
| from generic_cx import GenericCx | from generic_cx import GenericCx | ||||||
| from LANforge import add_monitor | from LANforge import add_monitor | ||||||
| from LANforge.add_monitor import * | from LANforge.add_monitor import * | ||||||
|  | import os | ||||||
| import datetime | import datetime | ||||||
|  |  | ||||||
|  |  | ||||||
| @@ -2088,6 +2089,30 @@ class FIOCXProfile(LFCliBase): | |||||||
|             self.local_realm.json_post(url, cx_data, debug_=debug_, suppress_related_commands_=suppress_related_commands_) |             self.local_realm.json_post(url, cx_data, debug_=debug_, suppress_related_commands_=suppress_related_commands_) | ||||||
|             time.sleep(sleep_time) |             time.sleep(sleep_time) | ||||||
|  |  | ||||||
|  | class PacketFilter(): | ||||||
|  |  | ||||||
|  |     def get_filter_wlan_assoc_packets(self, ap_mac, sta_mac): | ||||||
|  |         filter = "-T fields -e wlan.fc.type_subtype -e wlan.addr -e wlan.fc.pwrmgt " \ | ||||||
|  |                  "-Y \"(wlan.addr==%s or wlan.addr==%s) and wlan.fc.type_subtype<=3\" " % (ap_mac, sta_mac) | ||||||
|  |         return filter | ||||||
|  |  | ||||||
|  |     def get_filter_wlan_null_packets(self, ap_mac, sta_mac): | ||||||
|  |         filter = "-T fields -e wlan.fc.type_subtype -e wlan.addr -e wlan.fc.pwrmgt " \ | ||||||
|  |                  "-Y \"(wlan.addr==%s or wlan.addr==%s) and wlan.fc.type_subtype==44\" " % (ap_mac, sta_mac) | ||||||
|  |         return filter | ||||||
|  |  | ||||||
|  |     def run_filter(self, pcap_file, filter): | ||||||
|  |         filename = "/tmp/tshark_dump.txt" | ||||||
|  |         cmd = "tshark -r %s %s > %s" % (pcap_file, filter, filename) | ||||||
|  |         # print("CMD: ", cmd) | ||||||
|  |         os.system(cmd) | ||||||
|  |         lines = [] | ||||||
|  |         with open(filename) as tshark_file: | ||||||
|  |             for line in tshark_file: | ||||||
|  |                 lines.append(line.rstrip()) | ||||||
|  |  | ||||||
|  |         return lines | ||||||
|  |  | ||||||
| class PortUtils(): | class PortUtils(): | ||||||
|     def __init__(self, local_realm): |     def __init__(self, local_realm): | ||||||
|         self.local_realm = local_realm |         self.local_realm = local_realm | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 LoganLipke
					LoganLipke