...

Source file src/net/interface_bsd_test.go

Documentation: net

		 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  //go:build darwin || dragonfly || freebsd || netbsd || openbsd
		 6  // +build darwin dragonfly freebsd netbsd openbsd
		 7  
		 8  package net
		 9  
		10  import (
		11  	"errors"
		12  	"fmt"
		13  	"os/exec"
		14  	"runtime"
		15  )
		16  
		17  func (ti *testInterface) setBroadcast(vid int) error {
		18  	if runtime.GOOS == "openbsd" {
		19  		ti.name = fmt.Sprintf("vether%d", vid)
		20  	} else {
		21  		ti.name = fmt.Sprintf("vlan%d", vid)
		22  	}
		23  	xname, err := exec.LookPath("ifconfig")
		24  	if err != nil {
		25  		return err
		26  	}
		27  	ti.setupCmds = append(ti.setupCmds, &exec.Cmd{
		28  		Path: xname,
		29  		Args: []string{"ifconfig", ti.name, "create"},
		30  	})
		31  	ti.teardownCmds = append(ti.teardownCmds, &exec.Cmd{
		32  		Path: xname,
		33  		Args: []string{"ifconfig", ti.name, "destroy"},
		34  	})
		35  	return nil
		36  }
		37  
		38  func (ti *testInterface) setPointToPoint(suffix int) error {
		39  	ti.name = fmt.Sprintf("gif%d", suffix)
		40  	xname, err := exec.LookPath("ifconfig")
		41  	if err != nil {
		42  		return err
		43  	}
		44  	ti.setupCmds = append(ti.setupCmds, &exec.Cmd{
		45  		Path: xname,
		46  		Args: []string{"ifconfig", ti.name, "create"},
		47  	})
		48  	ti.setupCmds = append(ti.setupCmds, &exec.Cmd{
		49  		Path: xname,
		50  		Args: []string{"ifconfig", ti.name, "inet", ti.local, ti.remote},
		51  	})
		52  	ti.teardownCmds = append(ti.teardownCmds, &exec.Cmd{
		53  		Path: xname,
		54  		Args: []string{"ifconfig", ti.name, "destroy"},
		55  	})
		56  	return nil
		57  }
		58  
		59  func (ti *testInterface) setLinkLocal(suffix int) error {
		60  	return errors.New("not yet implemented for BSD")
		61  }
		62  

View as plain text