1// Copyright 2013 The Go Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
5// +build darwin dragonfly freebsd netbsd openbsd
6
7package net
8
9import (
10	"errors"
11	"fmt"
12	"os/exec"
13	"runtime"
14)
15
16func (ti *testInterface) setBroadcast(vid int) error {
17	if runtime.GOOS == "openbsd" {
18		ti.name = fmt.Sprintf("vether%d", vid)
19	} else {
20		ti.name = fmt.Sprintf("vlan%d", vid)
21	}
22	xname, err := exec.LookPath("ifconfig")
23	if err != nil {
24		return err
25	}
26	ti.setupCmds = append(ti.setupCmds, &exec.Cmd{
27		Path: xname,
28		Args: []string{"ifconfig", ti.name, "create"},
29	})
30	ti.teardownCmds = append(ti.teardownCmds, &exec.Cmd{
31		Path: xname,
32		Args: []string{"ifconfig", ti.name, "destroy"},
33	})
34	return nil
35}
36
37func (ti *testInterface) setPointToPoint(suffix int) error {
38	ti.name = fmt.Sprintf("gif%d", suffix)
39	xname, err := exec.LookPath("ifconfig")
40	if err != nil {
41		return err
42	}
43	ti.setupCmds = append(ti.setupCmds, &exec.Cmd{
44		Path: xname,
45		Args: []string{"ifconfig", ti.name, "create"},
46	})
47	ti.setupCmds = append(ti.setupCmds, &exec.Cmd{
48		Path: xname,
49		Args: []string{"ifconfig", ti.name, "inet", ti.local, ti.remote},
50	})
51	ti.teardownCmds = append(ti.teardownCmds, &exec.Cmd{
52		Path: xname,
53		Args: []string{"ifconfig", ti.name, "destroy"},
54	})
55	return nil
56}
57
58func (ti *testInterface) setLinkLocal(suffix int) error {
59	return errors.New("not yet implemented for BSD")
60}
61