github.com/yanyiwu/go@v0.0.0-20150106053140-03d6637dbb7f/src/net/interface_bsd_test.go (about)

     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  
     7  package net
     8  
     9  import (
    10  	"fmt"
    11  	"os/exec"
    12  )
    13  
    14  func (ti *testInterface) setBroadcast(suffix int) error {
    15  	ti.name = fmt.Sprintf("vlan%d", suffix)
    16  	xname, err := exec.LookPath("ifconfig")
    17  	if err != nil {
    18  		return err
    19  	}
    20  	ti.setupCmds = append(ti.setupCmds, &exec.Cmd{
    21  		Path: xname,
    22  		Args: []string{"ifconfig", ti.name, "create"},
    23  	})
    24  	ti.teardownCmds = append(ti.teardownCmds, &exec.Cmd{
    25  		Path: xname,
    26  		Args: []string{"ifconfig", ti.name, "destroy"},
    27  	})
    28  	return nil
    29  }
    30  
    31  func (ti *testInterface) setPointToPoint(suffix int, local, remote string) error {
    32  	ti.name = fmt.Sprintf("gif%d", suffix)
    33  	ti.local = local
    34  	ti.remote = remote
    35  	xname, err := exec.LookPath("ifconfig")
    36  	if err != nil {
    37  		return err
    38  	}
    39  	ti.setupCmds = append(ti.setupCmds, &exec.Cmd{
    40  		Path: xname,
    41  		Args: []string{"ifconfig", ti.name, "create"},
    42  	})
    43  	ti.setupCmds = append(ti.setupCmds, &exec.Cmd{
    44  		Path: xname,
    45  		Args: []string{"ifconfig", ti.name, "inet", ti.local, ti.remote},
    46  	})
    47  	ti.teardownCmds = append(ti.teardownCmds, &exec.Cmd{
    48  		Path: xname,
    49  		Args: []string{"ifconfig", ti.name, "destroy"},
    50  	})
    51  	return nil
    52  }