aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsotech117 <michael_foiani@brown.edu>2023-10-23 15:08:11 -0400
committersotech117 <michael_foiani@brown.edu>2023-10-23 15:08:11 -0400
commitfbda20200bd0f54cda6c0b09bfbe6f991ee77d9f (patch)
tree8ddad44537ca8eb2ea119ae000cbe8495137fc95
parent6fe8b91fb91882f456ebba16ee9a27f804c24e26 (diff)
add RIP request on interface UP along with better error messages for interfaces being down & up
-rw-r--r--pkg/ipstack/ipstack.go15
-rwxr-xr-xvhostbin3095650 -> 3105680 bytes
-rwxr-xr-xvrouterbin3095650 -> 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
diff --git a/vhost b/vhost
index 7ca732c..82e8ed0 100755
--- a/vhost
+++ b/vhost
Binary files differ
diff --git a/vrouter b/vrouter
index 7b61c7e..6a34548 100755
--- a/vrouter
+++ b/vrouter
Binary files differ