interface_bsd_test.go 1.4 KB

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