package main import ( "fmt" "log" "net" "github.com/crip/ripv2" "github.com/crip/ripv2/routes" "github.com/crip/rtable" ) 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("Running") routes.Timer() 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) for _, v := range routes.Routes { fmt.Printf("Route:%s\tSubnet:%s\tNexthop:%s\tMetric:%d\tTime: %v\n", v.Addr.String(), v.Subnet.String(), v.Nexthop.String(), v.Metric, v.TTL.Unix()) } rtable.Add(routes) fmt.Println("") } }