-
-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #95 from Code-Hex/add/mtu
- Loading branch information
Showing
4 changed files
with
107 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package vz_test | ||
|
||
import ( | ||
"net" | ||
"testing" | ||
|
||
"github.com/Code-Hex/vz/v2" | ||
) | ||
|
||
func TestFileHandleNetworkDeviceAttachmentMTU(t *testing.T) { | ||
if vz.MacosMajorVersionLessThan(13) { | ||
t.Skip("FileHandleNetworkDeviceAttachment.SetMaximumTransmissionUnit is supported from macOS 13") | ||
} | ||
|
||
ln, err := net.ListenUDP("udp", &net.UDPAddr{ | ||
Port: 0, | ||
IP: net.ParseIP("127.0.0.1"), | ||
}) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
defer ln.Close() | ||
|
||
f, err := ln.File() | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
attachment, err := vz.NewFileHandleNetworkDeviceAttachment(f) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
got := attachment.MaximumTransmissionUnit() | ||
if got != 1500 { | ||
t.Fatalf("want default mtu 1500 but got %d", got) | ||
} | ||
|
||
want := 2000 | ||
if err := attachment.SetMaximumTransmissionUnit(want); err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
got2 := attachment.MaximumTransmissionUnit() | ||
if got2 != want { | ||
t.Fatalf("want mtu %d but got %d", want, got) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters