callback function
This commit is contained in:
parent
71c249746f
commit
095fb9243f
7
main.go
7
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 */
|
||||
}
|
||||
|
@ -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))
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user