From a0fcf215ee04194466305351c17a95c5764a187f Mon Sep 17 00:00:00 2001 From: Patrick Fairbank Date: Sun, 28 Aug 2016 18:46:33 -0700 Subject: [PATCH] Partially enable DHCP and fix some 2015 protocol bugs. --- ap_config.txt | 3 +++ catalyst.go | 17 ++++++++++++--- driver_station_connection.go | 6 +++++- switch_config.txt | 42 ++++++++++++++++++++++++++++++++++++ 4 files changed, 64 insertions(+), 4 deletions(-) diff --git a/ap_config.txt b/ap_config.txt index 9308e86..8fb8fde 100644 --- a/ap_config.txt +++ b/ap_config.txt @@ -284,6 +284,7 @@ interface GigabitEthernet0.15 interface GigabitEthernet0.16 encapsulation dot1Q 16 ip access-group 100 in + ip access-group 101 out no ip route-cache bridge-group 16 bridge-group 16 spanning-disabled @@ -300,6 +301,8 @@ no ip http secure-server ip http help-path http://www.cisco.com/warp/public/779/smbiz/prodconfig/help/eag access-list 100 deny udp any any eq 1120 access-list 100 permit ip any any +access-list 101 deny tcp any any eq 1750 +access-list 101 permit ip any any ! bridge 1 route ip ! diff --git a/catalyst.go b/catalyst.go index bd9b62a..3daa16d 100644 --- a/catalyst.go +++ b/catalyst.go @@ -38,9 +38,20 @@ func ConfigureTeamEthernet(red1, red2, red3, blue1, blue2, blue3 *Team) error { if oldTeamVlans[team.Id] == vlan { delete(oldTeamVlans, team.Id) } else { - addTeamVlansCommand += fmt.Sprintf("no access-list 1%d\naccess-list 1%d permit ip "+ - "10.%d.%d.0 0.0.0.255 host %s\ninterface Vlan%d\nip address 10.%d.%d.61 255.255.255.0\n", vlan, - vlan, team.Id/100, team.Id%100, driverStationTcpListenAddress, vlan, team.Id/100, team.Id%100) + addTeamVlansCommand += fmt.Sprintf( + "ip dhcp excluded-address 10.%d.%d.1 10.%d.%d.100\n"+ + "no ip dhcp pool dhcp%d\n"+ + "ip dhcp pool dhcp%d\n"+ + "network 10.%d.%d.0 255.255.255.0\n"+ + "default-router 10.%d.%d.61\n"+ + "lease 7\n"+ + "no access-list 1%d\n"+ + "access-list 1%d permit ip 10.%d.%d.0 0.0.0.255 host %s\n"+ + "access-list 1%d permit udp any eq bootpc any eq bootps\n"+ + "interface Vlan%d\nip address 10.%d.%d.61 255.255.255.0\n", + team.Id/100, team.Id%100, team.Id/100, team.Id%100, vlan, vlan, team.Id/100, team.Id%100, team.Id/100, + team.Id%100, vlan, vlan, team.Id/100, team.Id%100, driverStationTcpListenAddress, vlan, vlan, + team.Id/100, team.Id%100) } } replaceTeamVlan(red1, red1Vlan) diff --git a/driver_station_connection.go b/driver_station_connection.go index 6d39f62..eb7c423 100644 --- a/driver_station_connection.go +++ b/driver_station_connection.go @@ -16,6 +16,7 @@ const ( driverStationTcpListenPort = 1750 driverStationUdpSendPort = 1120 driverStationLinkTimeoutSec = 5 + robotLinkTimeoutSec = 1 maxTcpPacketBytes = 4096 ) @@ -206,7 +207,9 @@ func (dsConn *DriverStationConnection) sendControlPacket() error { func (dsConn *DriverStationConnection) decodeStatusPacket(data [36]byte) { if data[6]&0x01 != 0 && data[6]&0x08 == 0 { // Robot is not connected. - dsConn.RobotLinked = false + if time.Since(dsConn.lastRobotLinkedTime).Seconds() > robotLinkTimeoutSec { + dsConn.RobotLinked = false + } return } @@ -301,6 +304,7 @@ func (dsConn *DriverStationConnection) handleTcpConnection() { if err != nil { fmt.Printf("Error reading from connection for Team %d: %v\n", dsConn.TeamId, err.Error()) dsConn.Close() + mainArena.AllianceStations[dsConn.AllianceStation].DsConn = nil break } diff --git a/switch_config.txt b/switch_config.txt index a6d534d..92c6537 100644 --- a/switch_config.txt +++ b/switch_config.txt @@ -14,6 +14,12 @@ enable secret 5 $1$kKSW$fCMwnMdYvXui1TulfyYHN/ ip subnet-zero ip routing ip dhcp excluded-address 10.0.100.1 10.0.100.100 +ip dhcp excluded-address 10.0.1.1 10.0.1.100 +ip dhcp excluded-address 10.0.2.1 10.0.2.100 +ip dhcp excluded-address 10.0.3.1 10.0.3.100 +ip dhcp excluded-address 10.0.4.1 10.0.4.100 +ip dhcp excluded-address 10.0.5.1 10.0.5.100 +ip dhcp excluded-address 10.0.6.1 10.0.6.100 ! ip dhcp pool dhcppool network 10.0.100.0 255.255.255.0 @@ -22,6 +28,36 @@ ip dhcp pool dhcppool dns-server 8.8.8.8 8.8.4.4 lease 7 ! +ip dhcp pool dhcp11 + network 10.0.1.0 255.255.255.0 + default-router 10.0.1.61 + lease 7 +! +ip dhcp pool dhcp12 + network 10.0.2.0 255.255.255.0 + default-router 10.0.2.61 + lease 7 +! +ip dhcp pool dhcp13 + network 10.0.3.0 255.255.255.0 + default-router 10.0.3.61 + lease 7 +! +ip dhcp pool dhcp14 + network 10.0.4.0 255.255.255.0 + default-router 10.0.4.61 + lease 7 +! +ip dhcp pool dhcp15 + network 10.0.5.0 255.255.255.0 + default-router 10.0.5.61 + lease 7 +! +ip dhcp pool dhcp16 + network 10.0.6.0 255.255.255.0 + default-router 10.0.6.61 + lease 7 +! ! spanning-tree mode pvst spanning-tree portfast default @@ -167,11 +203,17 @@ ip classless ip http server ! access-list 111 permit ip 10.0.1.0 0.0.0.255 host 10.0.100.5 +access-list 111 permit udp any eq bootpc any eq bootps access-list 112 permit ip 10.0.2.0 0.0.0.255 host 10.0.100.5 +access-list 112 permit udp any eq bootpc any eq bootps access-list 113 permit ip 10.0.3.0 0.0.0.255 host 10.0.100.5 +access-list 113 permit udp any eq bootpc any eq bootps access-list 114 permit ip 10.0.4.0 0.0.0.255 host 10.0.100.5 +access-list 114 permit udp any eq bootpc any eq bootps access-list 115 permit ip 10.0.5.0 0.0.0.255 host 10.0.100.5 +access-list 115 permit udp any eq bootpc any eq bootps access-list 116 permit ip 10.0.6.0 0.0.0.255 host 10.0.100.5 +access-list 116 permit udp any eq bootpc any eq bootps ! snmp-server community 1234Five RO !