]> Cypherpunks.ru repositories - govpn.git/blobdiff - tap.go
Use A-EKE instead of EKE. Doc refactoring. Preparing for 3.0 release
[govpn.git] / tap.go
diff --git a/tap.go b/tap.go
index 6b298f713861ec621183dd4f546d00f2fd7afe77..a80795534a70adf431b183c5d339e2ca61c51706 100644 (file)
--- a/tap.go
+++ b/tap.go
@@ -24,6 +24,10 @@ import (
        "golang.org/x/crypto/poly1305"
 )
 
+const (
+       EtherSize = 14
+)
+
 type TAP struct {
        Name   string
        dev    io.ReadWriter
@@ -33,8 +37,14 @@ type TAP struct {
        synced bool
 }
 
+// Return maximal acceptable TAP interface MTU. This is daemon's MTU
+// minus nonce, MAC, packet size mark and Ethernet header sizes.
+func TAPMaxMTU() int {
+       return MTU - poly1305.TagSize - NonceSize - PktSizeSize - EtherSize
+}
+
 func NewTAP(ifaceName string) (*TAP, error) {
-       maxIfacePktSize := MTU - poly1305.TagSize - NonceSize
+       maxIfacePktSize := TAPMaxMTU() + EtherSize
        tapRaw, err := newTAPer(ifaceName)
        if err != nil {
                return nil, err