summaryrefslogtreecommitdiffhomepage
path: root/src/receive.go
diff options
context:
space:
mode:
authorMathias Hall-Andersen <mathias@hall-andersen.dk>2017-11-17 17:25:45 +0100
committerMathias Hall-Andersen <mathias@hall-andersen.dk>2017-11-17 17:25:58 +0100
commitfa399a91d5da9874cbf248e00db8dbd87b587e91 (patch)
tree8aaca42f4a3cc11666c12d5077e8ed5ac35200a8 /src/receive.go
parente1227d3af480eae72639cde842b4d538c58936dc (diff)
Ported remaining netns.sh
- Ported remaining netns.sh tests - Begin work on generic implementation of bind interface
Diffstat (limited to 'src/receive.go')
-rw-r--r--src/receive.go27
1 files changed, 19 insertions, 8 deletions
diff --git a/src/receive.go b/src/receive.go
index ff3b7bd..b8b06f7 100644
--- a/src/receive.go
+++ b/src/receive.go
@@ -311,7 +311,10 @@ func (device *Device) RoutineHandshake() {
return
}
- srcBytes := elem.endpoint.SrcToBytes()
+ // endpoints destination address is the source of the datagram
+
+ srcBytes := elem.endpoint.DstToBytes()
+
if device.IsUnderLoad() {
// verify MAC2 field
@@ -320,8 +323,12 @@ func (device *Device) RoutineHandshake() {
// construct cookie reply
- logDebug.Println("Sending cookie reply to:", elem.endpoint.SrcToString())
- sender := binary.LittleEndian.Uint32(elem.packet[4:8]) // "sender" always follows "type"
+ logDebug.Println(
+ "Sending cookie reply to:",
+ elem.endpoint.DstToString(),
+ )
+
+ sender := binary.LittleEndian.Uint32(elem.packet[4:8])
reply, err := device.mac.CreateReply(elem.packet, sender, srcBytes)
if err != nil {
logError.Println("Failed to create cookie reply:", err)
@@ -555,8 +562,10 @@ func (peer *Peer) RoutineSequentialReceiver() {
src := elem.packet[IPv4offsetSrc : IPv4offsetSrc+net.IPv4len]
if device.routingTable.LookupIPv4(src) != peer {
- logInfo.Println(src)
- logInfo.Println("Packet with unallowed source IPv4 from", peer.String())
+ logInfo.Println(
+ "IPv4 packet with unallowed source address from",
+ peer.String(),
+ )
continue
}
@@ -581,8 +590,10 @@ func (peer *Peer) RoutineSequentialReceiver() {
src := elem.packet[IPv6offsetSrc : IPv6offsetSrc+net.IPv6len]
if device.routingTable.LookupIPv6(src) != peer {
- logInfo.Println(src)
- logInfo.Println("Packet with unallowed source IPv6 from", peer.String())
+ logInfo.Println(
+ "IPv6 packet with unallowed source address from",
+ peer.String(),
+ )
continue
}
@@ -591,7 +602,7 @@ func (peer *Peer) RoutineSequentialReceiver() {
continue
}
- // write to tun
+ // write to tun device
atomic.AddUint64(&peer.stats.rxBytes, uint64(len(elem.packet)))
_, err := device.tun.device.Write(elem.packet)