~ubuntu-branches/ubuntu/vivid/juju-core/vivid-updates

« back to all changes in this revision

Viewing changes to src/code.google.com/p/go.net/ipv6/helper_windows.go

  • Committer: Package Import Robot
  • Author(s): Curtis C. Hovey
  • Date: 2015-09-29 19:43:29 UTC
  • mfrom: (47.1.4 wily-proposed)
  • Revision ID: package-import@ubuntu.com-20150929194329-9y496tbic30hc7vp
Tags: 1.24.6-0ubuntu1~15.04.1
Backport of 1.24.6 from wily. (LP: #1500916, #1497087)

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
 
package ipv6
6
 
 
7
 
import (
8
 
        "net"
9
 
        "reflect"
10
 
        "syscall"
11
 
)
12
 
 
13
 
func (c *genericOpt) sysfd() (syscall.Handle, error) {
14
 
        switch p := c.Conn.(type) {
15
 
        case *net.TCPConn, *net.UDPConn, *net.IPConn:
16
 
                return sysfd(p)
17
 
        }
18
 
        return syscall.InvalidHandle, errInvalidConnType
19
 
}
20
 
 
21
 
func (c *dgramOpt) sysfd() (syscall.Handle, error) {
22
 
        switch p := c.PacketConn.(type) {
23
 
        case *net.UDPConn, *net.IPConn:
24
 
                return sysfd(p.(net.Conn))
25
 
        }
26
 
        return syscall.InvalidHandle, errInvalidConnType
27
 
}
28
 
 
29
 
func (c *payloadHandler) sysfd() (syscall.Handle, error) {
30
 
        return sysfd(c.PacketConn.(net.Conn))
31
 
}
32
 
 
33
 
func sysfd(c net.Conn) (syscall.Handle, error) {
34
 
        cv := reflect.ValueOf(c)
35
 
        switch ce := cv.Elem(); ce.Kind() {
36
 
        case reflect.Struct:
37
 
                netfd := ce.FieldByName("conn").FieldByName("fd")
38
 
                switch fe := netfd.Elem(); fe.Kind() {
39
 
                case reflect.Struct:
40
 
                        fd := fe.FieldByName("sysfd")
41
 
                        return syscall.Handle(fd.Uint()), nil
42
 
                }
43
 
        }
44
 
        return syscall.InvalidHandle, errInvalidConnType
45
 
}