arp: little clean up

This commit is contained in:
Florent Kermarrec 2015-01-30 12:06:56 +01:00
parent fa48346385
commit 41ead49c76
1 changed files with 5 additions and 12 deletions

View File

@ -2,14 +2,12 @@ from liteeth.common import *
from liteeth.generic.depacketizer import LiteEthDepacketizer from liteeth.generic.depacketizer import LiteEthDepacketizer
from liteeth.generic.packetizer import LiteEthPacketizer from liteeth.generic.packetizer import LiteEthPacketizer
def _arp_table_description(): _arp_table_layout = [
layout = [
("reply", 1), ("reply", 1),
("request", 1), ("request", 1),
("ip_address", 32), ("ip_address", 32),
("mac_address", 48) ("mac_address", 48)
] ]
return EndpointDescription(layout, packetized=False)
class LiteEthARPDepacketizer(LiteEthDepacketizer): class LiteEthARPDepacketizer(LiteEthDepacketizer):
def __init__(self): def __init__(self):
@ -27,14 +25,9 @@ class LiteEthARPPacketizer(LiteEthPacketizer):
arp_header, arp_header,
arp_header_len) arp_header_len)
class LiteSATACommandTX(Module):
def __init__(self, transport):
self.sink = sink = Sink(command_tx_description(32))
class LiteEthARPTX(Module): class LiteEthARPTX(Module):
def __init__(self, mac_address, ip_address): def __init__(self, mac_address, ip_address):
self.sink = sink = Sink(_arp_table_description()) self.sink = sink = Sink(_arp_table_layout)
self.source = Source(eth_mac_description(8)) self.source = Source(eth_mac_description(8))
### ###
packetizer = LiteEthARPPacketizer() packetizer = LiteEthARPPacketizer()
@ -91,7 +84,7 @@ class LiteEthARPTX(Module):
class LiteEthARPRX(Module): class LiteEthARPRX(Module):
def __init__(self, mac_address, ip_address): def __init__(self, mac_address, ip_address):
self.sink = Sink(eth_mac_description(8)) self.sink = Sink(eth_mac_description(8))
self.source = source = Source(_arp_table_description()) self.source = source = Source(_arp_table_layout)
### ###
depacketizer = LiteEthARPDepacketizer() depacketizer = LiteEthARPDepacketizer()
self.submodules += depacketizer self.submodules += depacketizer
@ -152,8 +145,8 @@ arp_table_response_layout = [
class LiteEthARPTable(Module): class LiteEthARPTable(Module):
def __init__(self): def __init__(self):
self.sink = sink = Sink(_arp_table_description()) # from arp_rx self.sink = sink = Sink(_arp_table_layout) # from arp_rx
self.source = source = Source(_arp_table_description()) # to arp_tx self.source = source = Source(_arp_table_layout) # to arp_tx
# Request/Response interface # Request/Response interface
self.request = request = Sink(arp_table_request_layout) self.request = request = Sink(arp_table_request_layout)