diff options
author | David Doan <daviddoan@Davids-MacBook-Pro-70.local> | 2023-10-05 23:32:06 -0400 |
---|---|---|
committer | David Doan <daviddoan@Davids-MacBook-Pro-70.local> | 2023-10-05 23:32:06 -0400 |
commit | 770a08b747233942fb19da529763f61987a804d6 (patch) | |
tree | 3c822fde32750780fe38f46b6f25e9642c1cec0f /cmd/vrouter/main.go | |
parent | 7bb2015a1f2de7a31c3f2b3092a574602a2a3d53 (diff) |
file importing
Diffstat (limited to 'cmd/vrouter/main.go')
-rw-r--r-- | cmd/vrouter/main.go | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/cmd/vrouter/main.go b/cmd/vrouter/main.go index 82b8195..158016a 100644 --- a/cmd/vrouter/main.go +++ b/cmd/vrouter/main.go @@ -4,9 +4,37 @@ import ( "bufio" "fmt" "os" + "time" ) +func SendUpdates() { + for _, iface := range myInterfaces { + // send RIP updates to all neighbors + for _, neighbor := range myNeighbors { + iface.udp.Write(neighbor, data) + // wait for response for 12 seconds + response := make([]byte, 512) + iface.udp.Read(response) + time.Sleep(12 * time.Second) + if len(response) == 0 { + RemoveNeighbor(neighbor) + } + } + } + time.Sleep(5 * time.Second) +} + func main() { + if len(os.Args) != 2 { + fmt.Printf("Usage: %s <configFile>\n", os.Args[0]) + os.Exit(1) + } + + fileName := os.Args[1] + + initialize(fileName) + go SendUpdates() + scanner := bufio.NewScanner(os.Stdin) |