introduce API_CMD_IDS

This commit is contained in:
Gregor Michels 2025-06-26 21:59:10 +02:00
parent 53216ad344
commit cb712cdd04

15
main.py
View file

@ -11,6 +11,13 @@ from enum import Enum
IP = "192.168.42.100"
class API_CMD_IDS(Enum):
READ_PORTS = 768
READ_VLANS = 1283
READ_VLAN_PORTS = 1290
READ_VLAN_PORT_CFG = 1293 # this needs vid as a parameter and is parsed by parse_vlan_ports
READ_STP_PORTS = 4098
class VLAN_PORT_MODE(Enum):
GENERAL = 0
@ -140,6 +147,8 @@ if __name__ == "__main__":
cookie = get_login_cookie(IP, "admin", os.environ.get("ADMIN_PW"))
print(dictify(extract_data_from_table(get_cmd(IP, cookie, 1283)), "VLAN ID"))
print(dictify(extract_data_from_table(get_cmd(IP, cookie, 1290)), "Port"))
print(parse_vlan_ports(get_cmd(IP, cookie, 1293, vid=2)))
print(dictify(extract_data_from_table(get_cmd(IP, cookie, API_CMD_IDS.READ_PORTS.value)), "Port"))
print(dictify(extract_data_from_table(get_cmd(IP, cookie, API_CMD_IDS.READ_VLANS.value)), "VLAN ID"))
print(dictify(extract_data_from_table(get_cmd(IP, cookie, API_CMD_IDS.READ_VLAN_PORTS.value)), "Port"))
print(dictify(extract_data_from_table(get_cmd(IP, cookie, API_CMD_IDS.READ_STP_PORTS.value)), "Port"))
print(parse_vlan_ports(get_cmd(IP, cookie, API_CMD_IDS.READ_VLAN_PORT_CFG.value, vid=2)))