diff options
author | sotech117 <michael_foiani@brown.edu> | 2023-10-23 15:08:11 -0400 |
---|---|---|
committer | sotech117 <michael_foiani@brown.edu> | 2023-10-23 15:08:11 -0400 |
commit | fbda20200bd0f54cda6c0b09bfbe6f991ee77d9f (patch) | |
tree | 8ddad44537ca8eb2ea119ae000cbe8495137fc95 | |
parent | 6fe8b91fb91882f456ebba16ee9a27f804c24e26 (diff) |
add RIP request on interface UP along with better error messages for interfaces being down & up
-rw-r--r-- | pkg/ipstack/ipstack.go | 15 | ||||
-rwxr-xr-x | vhost | bin | 3095650 -> 3105680 bytes | |||
-rwxr-xr-x | vrouter | bin | 3095650 -> 3105648 bytes |
3 files changed, 13 insertions, 2 deletions
diff --git a/pkg/ipstack/ipstack.go b/pkg/ipstack/ipstack.go index 2ab2a5f..f6c86a8 100644 --- a/pkg/ipstack/ipstack.go +++ b/pkg/ipstack/ipstack.go @@ -226,7 +226,18 @@ func InterfaceUp(iface *Interface) { ripEntries := make([]RIPEntry, 0) ripEntries = append(ripEntries, RIPEntry{iface.IpPrefix.Masked(), LOCAL_COST}) sendTriggeredUpdates(ripEntries) + + // send a request to all neighbors of this iface to get info ASAP + for _, neighbor := range myNeighbors[iface.Name] { + message := makeRipMessage(1, nil) + addr := iface.IpPrefix.Addr() + _, err := SendIP(&addr, neighbor, RIP_PROTOCOL, message, neighbor.VipAddr.String(), nil) + if err != nil { + fmt.Println("Error sending RIP request to neighbor on interfaceup", err) + } + } } + } func InterfaceUpREPL(ifaceName string) { @@ -379,7 +390,7 @@ func CleanUp() { func SendIP(src *netip.Addr, dest *Neighbor, protocolNum int, message []byte, destIP string, hdr *ipv4header.IPv4Header) (int, error) { iface, err := GetInterfaceByName(dest.Name) if !iface.State { - return -1, errors.New("error: interface is down") + return -1, errors.Errorf("error SEND: %s is down", iface.Name) } if hdr == nil { @@ -466,7 +477,7 @@ func RecvIP(iface *Interface, isOpen *bool) error { } if !*isOpen { - return errors.New("interface is down") + return errors.Errorf("error RECV: %s is down", iface.Name) } // Marshal the received byte array into a UDP header Binary files differBinary files differ |