public class Switch extends java.lang.Object implements Layer2Listener
Constructor and Description |
---|
Switch(int numports)
Create a Switch with the given number of ports.
|
Modifier and Type | Method and Description |
---|---|
void |
addOrUpdateBySrcMac(int macAddr,
SwitchPort s)
used when checking if a source mac is recorded in the macAddr table.
|
void |
attachPort(SwitchPort pt,
SwitchLightPanel panel)
Add the given SwitchPort/SwitchLightPanel to our collection of
ports/panels.
|
void |
enQueueOnAllPortsExceptOne(SwitchPort port2Skip,
Layer2Frame fr)
send the given frame on all registered ports, except port2Skip.
|
Switch.MacTableEntry |
findEntryByMac(int macAddr)
return the entry for the given mac, or null if no entry exists.
|
void |
frameReceived(Layer2Handler handler,
Layer2Frame frame)
Handle frames received on a switch port.
|
int |
getNumPorts()
return numPorts value
|
SwitchLightPanel |
getPanel(int i)
return the ith switch port panel
|
java.lang.String |
macAddrTableString()
return the MacAddrTable as a long string, one entry per line.
|
void |
setListener(SwitchListener l)
Store an object to receive a callback when a port is attached.
|
public Switch(int numports)
public void attachPort(SwitchPort pt, SwitchLightPanel panel)
public Switch.MacTableEntry findEntryByMac(int macAddr)
public void addOrUpdateBySrcMac(int macAddr, SwitchPort s)
public void enQueueOnAllPortsExceptOne(SwitchPort port2Skip, Layer2Frame fr)
public void frameReceived(Layer2Handler handler, Layer2Frame frame)
frameReceived
in interface Layer2Listener
public int getNumPorts()
public SwitchLightPanel getPanel(int i)
public void setListener(SwitchListener l)
public java.lang.String macAddrTableString()