blob: 158016ae7c548fce1fe6b452f8bcc37850db78f1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
package main
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)
for scanner.Scan() {
line := scanner.Text()
fmt.Println(line)
}
}
|