aboutsummaryrefslogtreecommitdiff
path: root/cmd/vrouter/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/vrouter/main.go')
-rw-r--r--cmd/vrouter/main.go28
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)