From 512c4c2785e6dbf53106b5a6f60e0e1992977016 Mon Sep 17 00:00:00 2001 From: sotech117 Date: Mon, 23 Oct 2023 03:42:05 -0400 Subject: add RIP request and reponse --- cmd/vhost/main.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'cmd/vhost') diff --git a/cmd/vhost/main.go b/cmd/vhost/main.go index 17b4a02..468409d 100644 --- a/cmd/vhost/main.go +++ b/cmd/vhost/main.go @@ -58,14 +58,21 @@ func main() { messageToSendBytes := []byte(messageToSend) hop, err := ipstack.LongestPrefix(netip.MustParseAddr(ipAddr)) + if err != nil { + fmt.Println(err) + continue + } myAddr := hop.Interface.IpPrefix.Addr() for _, neighbor := range ipstack.GetNeighbors()[hop.Interface.Name] { // TODO: fix multiple send bug here on static route if neighbor.VipAddr == netip.MustParseAddr(ipAddr) || neighbor.VipAddr == hop.VIP && hop.Type == "S" { - err = ipstack.SendIP(&myAddr, neighbor, ipstack.TEST_PROTOCOL, messageToSendBytes, ipAddr, nil) + bytesWritten, err := ipstack.SendIP(&myAddr, neighbor, ipstack.TEST_PROTOCOL, messageToSendBytes, ipAddr, nil) if err != nil { fmt.Println(err) + } else { + fmt.Printf("Sent %d bytes to %s\n", bytesWritten, neighbor.VipAddr.String()) + } } } -- cgit v1.2.3-70-g09d2