diff --git a/main.go b/main.go index 69cc035..5f23dd7 100644 --- a/main.go +++ b/main.go @@ -5,8 +5,13 @@ import ( "github.com/crip/config" "github.com/crip/ripv2" + "github.com/crip/rtable" ) +func callback(r *ripv2.Routes) { + rtable.Add(r) +} + func main() { config := config.Read("config.json") rip := ripv2.New() @@ -14,6 +19,6 @@ func main() { log.Println("Running") routes.Timer() - rip.Run(config) + rip.Run(config, callback) /* NOT REACHED */ } diff --git a/ripv2/ripv2.go b/ripv2/ripv2.go index 53b8b6d..d17d211 100644 --- a/ripv2/ripv2.go +++ b/ripv2/ripv2.go @@ -59,7 +59,7 @@ func (m *Message) MParse(b *[]byte, n int) error { return nil } -func (m *Message) Run(c *config.Config) { +func (m *Message) Run(c *config.Config, callback func(*Routes)) { iface := net.Interface{ Name: c.MulticastInterface, Flags: net.FlagMulticast, @@ -105,6 +105,6 @@ func (m *Message) Run(c *config.Config) { 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) + (callback(routes)) } }