* gcc-interface/decl.c (warn_on_field_placement): Issue the warning
[official-gcc.git] / libgo / go / net / main_posix_test.go
blobead311c3cddb7d8862586ac36570ab6f855291d3
1 // Copyright 2015 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.
5 // +build !plan9
7 package net
9 import (
10 "net/internal/socktest"
11 "strings"
12 "syscall"
15 func enableSocketConnect() {
16 sw.Set(socktest.FilterConnect, nil)
19 func disableSocketConnect(network string) {
20 ss := strings.Split(network, ":")
21 sw.Set(socktest.FilterConnect, func(so *socktest.Status) (socktest.AfterFilter, error) {
22 switch ss[0] {
23 case "tcp4":
24 if so.Cookie.Family() == syscall.AF_INET && so.Cookie.Type() == syscall.SOCK_STREAM {
25 return nil, syscall.EHOSTUNREACH
27 case "udp4":
28 if so.Cookie.Family() == syscall.AF_INET && so.Cookie.Type() == syscall.SOCK_DGRAM {
29 return nil, syscall.EHOSTUNREACH
31 case "ip4":
32 if so.Cookie.Family() == syscall.AF_INET && so.Cookie.Type() == syscall.SOCK_RAW {
33 return nil, syscall.EHOSTUNREACH
35 case "tcp6":
36 if so.Cookie.Family() == syscall.AF_INET6 && so.Cookie.Type() == syscall.SOCK_STREAM {
37 return nil, syscall.EHOSTUNREACH
39 case "udp6":
40 if so.Cookie.Family() == syscall.AF_INET6 && so.Cookie.Type() == syscall.SOCK_DGRAM {
41 return nil, syscall.EHOSTUNREACH
43 case "ip6":
44 if so.Cookie.Family() == syscall.AF_INET6 && so.Cookie.Type() == syscall.SOCK_RAW {
45 return nil, syscall.EHOSTUNREACH
48 return nil, nil