~ubuntu-branches/ubuntu/saucy/juju-core/saucy-proposed

« back to all changes in this revision

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

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2013-07-11 17:18:27 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20130711171827-vjqkg40r0dlf7ys2
Tags: 1.11.2-0ubuntu1
* New upstream release.
* Make juju-core the default juju (LP: #1190634):
  - d/control: Add virtual package juju -> juju-core.
  - d/juju-core.postinst.in: Bump priority of alternatives over that of
    python juju packages.
* Enable for all architectures (LP: #1172505):
  - d/control: Version BD on golang-go to >= 2:1.1.1 to ensure CGO
    support for non-x86 archs, make juju-core Arch: any.
  - d/README.source: Dropped - no longer required.
* d/watch: Updated for new upstream tarball naming.

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