...
Run Format

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

View as plain text