Package frc.lib5k.networking
Class PortManager
- java.lang.Object
-
- frc.lib5k.networking.PortManager
-
public class PortManager extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description PortManager()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
allocateFRCPorts()
Allocate all FRC-related ports automaticallyvoid
allocatePort(Port port)
Allocate a network port for use, while obeying firewall rulesboolean
canAllocate(Port port)
Check if the specified network port can be allocatedvoid
deallocatePort(Port port)
Remove a port from the allocationstatic PortManager
getInstance()
boolean
isPortAllocated(Port port)
Check if a port is already allocatedvoid
setFirewall(IFirewall firewall)
Set a new firewall to obey.
-
-
-
Method Detail
-
getInstance
public static PortManager getInstance()
-
setFirewall
public void setFirewall(IFirewall firewall)
Set a new firewall to obey. This will not clear existing allocations- Parameters:
firewall
- New firewall rules
-
allocatePort
public void allocatePort(Port port) throws PortException
Allocate a network port for use, while obeying firewall rules- Parameters:
port
- Network port- Throws:
PortException
-
deallocatePort
public void deallocatePort(Port port)
Remove a port from the allocation- Parameters:
port
- Port to remove
-
isPortAllocated
public boolean isPortAllocated(Port port)
Check if a port is already allocated- Parameters:
port
- Port to check- Returns:
- Has it been allocated?
-
canAllocate
public boolean canAllocate(Port port)
Check if the specified network port can be allocated- Parameters:
port
-- Returns:
-
allocateFRCPorts
public void allocateFRCPorts()
Allocate all FRC-related ports automatically
-
-