aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pkg/ipstack/ipstack.go22
-rwxr-xr-xvhostbin3101301 -> 3100381 bytes
-rwxr-xr-xvrouterbin3100357 -> 3100445 bytes
3 files changed, 17 insertions, 5 deletions
diff --git a/pkg/ipstack/ipstack.go b/pkg/ipstack/ipstack.go
index 334aab5..4a552cf 100644
--- a/pkg/ipstack/ipstack.go
+++ b/pkg/ipstack/ipstack.go
@@ -402,7 +402,21 @@ func SendIP(src *netip.Addr, dest *Neighbor, protocolNum int, message []byte, de
Options: []byte{},
}
} else {
- hdr.TTL--
+ hdr = &ipv4header.IPv4Header{
+ Version: 4,
+ Len: 20, // Header length is always 20 when no IP options
+ TOS: 0,
+ TotalLen: ipv4header.HeaderLen + len(message),
+ ID: 0,
+ Flags: 0,
+ FragOff: 0,
+ TTL: hdr.TTL - 1,
+ Protocol: protocolNum,
+ Checksum: 0, // Should be 0 until checksum is computed
+ Src: *src,
+ Dst: netip.MustParseAddr(destIP),
+ Options: []byte{},
+ }
}
// Assemble the header into a byte array
@@ -442,8 +456,6 @@ func SendIP(src *netip.Addr, dest *Neighbor, protocolNum int, message []byte, de
}
func RecvIP(iface *Interface, isOpen *bool) error {
- fmt.Printf("Receiving IP packet on %s\n", iface.Name)
-
// deconstruct interface
prefix := iface.IpPrefix
conn := iface.RecvSocket
@@ -541,7 +553,7 @@ func RecvIP(iface *Interface, isOpen *bool) error {
// if it's a local route, then the name is the interface name
for _, neighbor := range myNeighbors[hop.Interface.Name] {
if neighbor.VipAddr == hdr.Dst {
- err2 := SendIP(nil, neighbor, hdr.Protocol, message, hdr.Dst.String(), hdr)
+ err2 := SendIP(&hdr.Src, neighbor, hdr.Protocol, message, hdr.Dst.String(), hdr)
if err2 != nil {
return err2
}
@@ -554,7 +566,7 @@ func RecvIP(iface *Interface, isOpen *bool) error {
// if it's a rip route, then the check is against the hop vip
for _, neighbor := range myNeighbors[hop.Interface.Name] {
if neighbor.VipAddr == hop.VIP {
- err2 := SendIP(nil, neighbor, hdr.Protocol, message, hdr.Dst.String(), hdr)
+ err2 := SendIP(&hdr.Src, neighbor, hdr.Protocol, message, hdr.Dst.String(), hdr)
if err2 != nil {
return err2
}
diff --git a/vhost b/vhost
index d8d250a..11a27ab 100755
--- a/vhost
+++ b/vhost
Binary files differ
diff --git a/vrouter b/vrouter
index ac1beb3..cf21489 100755
--- a/vrouter
+++ b/vrouter
Binary files differ