crip/main.go
Jim Colderwood 83bbd52cee Route slice
2024-04-10 16:33:33 +01:00

45 lines
731 B
Go

package main
import (
"fmt"
"log"
"net"
"github.com/crip/ripv2"
"github.com/crip/ripv2/routes"
)
func main() {
rip := ripv2.New()
routes := routes.New()
addr := net.UDPAddr{
Port: 520,
IP: net.ParseIP("224.0.0.9"),
}
iface := net.Interface{
Name: "enp1s0f1",
Flags: net.FlagMulticast,
}
conn, err := net.ListenMulticastUDP("udp4", &iface, &addr)
if err != nil {
log.Fatalln(err)
}
defer conn.Close()
buff := make([]byte, 1024)
log.Println("waiting")
for {
n, UDPAddr, err := conn.ReadFromUDP(buff)
if err != nil {
log.Fatalln(err)
}
_ = UDPAddr
if err := rip.MParse(&buff, n); err != nil {
log.Fatalln(err)
}
routes.ParseRoutes(*UDPAddr, &rip.RIP)
fmt.Println(routes)
}
}