Compare commits
No commits in common. 'master' and 'v1.0' have entirely different histories.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,19 +1,43 @@
|
||||
import socket
|
||||
|
||||
def is_same_subnet(ip1, ip2):
|
||||
# 将IP地址和子网掩码转换为整数列表
|
||||
ip1_parts = [int(part) for part in ip1.split('.')]
|
||||
ip2_parts = [int(part) for part in ip2.split('.')]
|
||||
subnet_mask_parts = [int(part) for part in "255.255.255.0".split('.')]
|
||||
|
||||
# 计算网络地址
|
||||
network1 = [ip1_parts[i] & subnet_mask_parts[i] for i in range(4)]
|
||||
network2 = [ip2_parts[i] & subnet_mask_parts[i] for i in range(4)]
|
||||
AllSimObj = [
|
||||
{"ObjID": "SHO1", "ObjType": 1, "ObjLabel": "A", "ObjX": 100, "ObjY": 100, "ConfigCorrect": 0},
|
||||
{"ObjID": "SHO2", "ObjType": 1, "ObjLabel": "B", "ObjX": 100, "ObjY": 100, "ConfigCorrect": 0},
|
||||
{"ObjID": "SHO3", "ObjType": 1, "ObjLabel": "C", "ObjX": 100, "ObjY": 100, "ConfigCorrect": 0},
|
||||
{"ObjID": "SHO4", "ObjType": 1, "ObjLabel": "D", "ObjX": 100, "ObjY": 100, "ConfigCorrect": 0},
|
||||
{"ObjID": "SHO5", "ObjType": 1, "ObjLabel": "E", "ObjX": 100, "ObjY": 100, "ConfigCorrect": 0},
|
||||
{"ObjID": "SHO6", "ObjType": 1, "ObjLabel": "F", "ObjX": 100, "ObjY": 100, "ConfigCorrect": 0},
|
||||
{"ObjID": "SHO7", "ObjType": 1, "ObjLabel": "G", "ObjX": 100, "ObjY": 100, "ConfigCorrect": 0},
|
||||
{"ObjID": "SHO8", "ObjType": 1, "ObjLabel": "H", "ObjX": 100, "ObjY": 100, "ConfigCorrect": 0},
|
||||
{"ObjID": "SRO1", "ObjType": 2, "ObjLabel": "R1", "ObjX": 100, "ObjY": 100, "ConfigCorrect": 0},
|
||||
{"ObjID": "SRO2", "ObjType": 2, "ObjLabel": "R2", "ObjX": 100, "ObjY": 100, "ConfigCorrect": 0},
|
||||
{"ObjID": "SRO3", "ObjType": 2, "ObjLabel": "R3", "ObjX": 100, "ObjY": 100, "ConfigCorrect": 0},
|
||||
{"ObjID": "SRO4", "ObjType": 2, "ObjLabel": "R4", "ObjX": 100, "ObjY": 100, "ConfigCorrect": 0},
|
||||
{"ObjID": "SRO5", "ObjType": 2, "ObjLabel": "R5", "ObjX": 100, "ObjY": 100, "ConfigCorrect": 0},
|
||||
{"ObjID": "SRO6", "ObjType": 2, "ObjLabel": "R6", "ObjX": 100, "ObjY": 100, "ConfigCorrect": 0},
|
||||
{"ObjID": "SRO7", "ObjType": 2, "ObjLabel": "R7", "ObjX": 100, "ObjY": 100, "ConfigCorrect": 0},
|
||||
{"ObjID": "SWO1", "ObjType": 3, "ObjLabel": "S1", "ObjX": 100, "ObjY": 100, "ConfigCorrect": 0},
|
||||
{"ObjID": "SHub1", "ObjType": 4, "ObjLabel": "Hub1", "ObjX": 100, "ObjY": 100, "ConfigCorrect": 0},
|
||||
]
|
||||
|
||||
# 比较网络地址是否相同
|
||||
return network1 == network2
|
||||
AllSimConn = [
|
||||
{"ConnObjID": "conn1", "NobjS": "SHO1", "IfsS": 1, "NobjE": "SRO1", "IfsE": 1, "ConfigCorrect": 0},
|
||||
{"ConnObjID": "conn1", "NobjS": "SHO2", "IfsS": 1, "NobjE": "SRO1", "IfsE": 2, "ConfigCorrect": 0},
|
||||
{"ConnObjID": "conn1", "NobjS": "SRO2", "IfsS": 1, "NobjE": "SRO1", "IfsE": 4, "ConfigCorrect": 0},
|
||||
{"ConnObjID": "conn1", "NobjS": "SWO1", "IfsS": 1, "NobjE": "SRO1", "IfsE": 3, "ConfigCorrect": 0},
|
||||
{"ConnObjID": "conn1", "NobjS": "SHO2", "IfsS": 1, "NobjE": "SWO1", "IfsE": 2, "ConfigCorrect": 0},
|
||||
{"ConnObjID": "conn1", "NobjS": "SRO2", "IfsS": 2, "NobjE": "SRO4", "IfsE": 1, "ConfigCorrect": 0},
|
||||
{"ConnObjID": "conn1", "NobjS": "SRO2", "IfsS": 3, "NobjE": "SRO3", "IfsE": 1, "ConfigCorrect": 0},
|
||||
{"ConnObjID": "conn1", "NobjS": "SRO3", "IfsS": 2, "NobjE": "SRO4", "IfsE": 2, "ConfigCorrect": 0},
|
||||
{"ConnObjID": "conn1", "NobjS": "SRO3", "IfsS": 3, "NobjE": "SRO5", "IfsE": 1, "ConfigCorrect": 0},
|
||||
{"ConnObjID": "conn1", "NobjS": "SRO4", "IfsS": 4, "NobjE": "SHO5", "IfsE": 1, "ConfigCorrect": 0},
|
||||
{"ConnObjID": "conn1", "NobjS": "SRO4", "IfsS": 3, "NobjE": "SRO5", "IfsE": 2, "ConfigCorrect": 0},
|
||||
{"ConnObjID": "conn1", "NobjS": "SRO5", "IfsS": 3, "NobjE": "SHO6", "IfsE": 1, "ConfigCorrect": 0},
|
||||
{"ConnObjID": "conn1", "NobjS": "SRO5", "IfsS": 4, "NobjE": "SRO6", "IfsE": 2, "ConfigCorrect": 0},
|
||||
{"ConnObjID": "conn1", "NobjS": "SRO6", "IfsS": 3, "NobjE": "SHO3", "IfsE": 2, "ConfigCorrect": 0},
|
||||
{"ConnObjID": "conn1", "NobjS": "SRO6", "IfsS": 1, "NobjE": "SRO7", "IfsE": 2, "ConfigCorrect": 0},
|
||||
{"ConnObjID": "conn1", "NobjS": "SRO7", "IfsS": 1, "NobjE": "SHub1", "IfsE": 1, "ConfigCorrect": 0},
|
||||
{"ConnObjID": "conn1", "NobjS": "SRO7", "IfsS": 3, "NobjE": "SHO4", "IfsE": 1, "ConfigCorrect": 0},
|
||||
{"ConnObjID": "conn1", "NobjS": "SHub1", "IfsS": 2, "NobjE": "SHO4", "IfsE": 1, "ConfigCorrect": 0},
|
||||
]
|
||||
|
||||
|
||||
|
||||
|
||||
print(is_same_subnet("192.168.10.23", "192.12.10.21"))
|
Before Width: | Height: | Size: 187 KiB |
Before Width: | Height: | Size: 198 KiB |
Loading…
Reference in new issue