-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathetherconn_win_test.go
More file actions
44 lines (36 loc) · 1.22 KB
/
etherconn_win_test.go
File metadata and controls
44 lines (36 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//go:build windows
// +build windows
// etherconn_test
/*
Test setup reuqirements:
- two interfaces name specified by argument testifA and testifB, these two interfaces are connected together
*/
package etherconn_test
import (
"context"
"fmt"
"github.com/hujun-open/etherconn"
)
const (
testifA = `\Device\NPF_{E8EE7758-DA9A-417A-BB29-3FAAF086DAAB}` //hjsw2
testifB = `\Device\NPF_{85419E30-E13A-4109-BBA5-C20F2AF23C02}` //hjsw
)
func testCreateVETHLink(a, b string) error {
return nil
}
func getRawRelay(ctx context.Context, relayType etherconn.RelayType, ifname string, mods ...etherconn.RelayOption) (*etherconn.RawSocketRelay, error) {
return etherconn.NewRawSocketRelayPcap(context.Background(), ifname, mods...)
}
func getPKTRelay(ctx context.Context, rtype etherconn.RelayType, ifname string, defaultconn, defualtconnmirror bool) (etherconn.PacketRelay, error) {
if rtype == etherconn.RelayTypePCAP {
mods := []etherconn.RelayOption{
etherconn.WithDebug(true),
etherconn.WithBPFFilter(""),
}
if defaultconn {
mods = append(mods, etherconn.WithDefaultReceival(defualtconnmirror))
}
return getRawRelay(ctx, rtype, ifname, mods...)
}
return nil, fmt.Errorf("only pcap relay is supported on windows")
}