soc/add_ethernet: Refactor local/remote_ip configuration and add basic checks for IP address length + validity.
This commit is contained in:
parent
115e87ff4f
commit
f543b18d02
|
@ -1769,19 +1769,17 @@ class LiteXSoC(SoC):
|
||||||
assert local_ip is None
|
assert local_ip is None
|
||||||
self.add_constant("ETH_DYNAMIC_IP")
|
self.add_constant("ETH_DYNAMIC_IP")
|
||||||
|
|
||||||
|
# Local/Remote IP Configuration (optional).
|
||||||
|
def add_ip_constants(name, ip):
|
||||||
|
_ip = ip.split(".")
|
||||||
|
assert len(_ip) == 4
|
||||||
|
for n in range(4):
|
||||||
|
assert int(_ip[n]) < 256
|
||||||
|
self.add_constant(f"{name}{n+1}", _ip[n])
|
||||||
if local_ip:
|
if local_ip:
|
||||||
local_ip = local_ip.split(".")
|
add_ip_constants("LOCALIP", local_ip)
|
||||||
self.add_constant("LOCALIP1", int(local_ip[0]))
|
|
||||||
self.add_constant("LOCALIP2", int(local_ip[1]))
|
|
||||||
self.add_constant("LOCALIP3", int(local_ip[2]))
|
|
||||||
self.add_constant("LOCALIP4", int(local_ip[3]))
|
|
||||||
|
|
||||||
if remote_ip:
|
if remote_ip:
|
||||||
remote_ip = remote_ip.split(".")
|
add_ip_constants("REMOTEIP", remote_ip)
|
||||||
self.add_constant("REMOTEIP1", int(remote_ip[0]))
|
|
||||||
self.add_constant("REMOTEIP2", int(remote_ip[1]))
|
|
||||||
self.add_constant("REMOTEIP3", int(remote_ip[2]))
|
|
||||||
self.add_constant("REMOTEIP4", int(remote_ip[3]))
|
|
||||||
|
|
||||||
# Software Debug
|
# Software Debug
|
||||||
if software_debug:
|
if software_debug:
|
||||||
|
|
Loading…
Reference in New Issue