Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1409)

Delta Between Two Patch Sets: ipv4/helper_windows.go

Issue 6482044: code review 6482044: go.net/ipv4: new package (Closed)
Left Patch Set: diff -r 147c4a6dca9b https://code.google.com/p/go.net Created 11 years, 7 months ago
Right Patch Set: diff -r 2513e9008213 https://code.google.com/p/go.net Created 11 years, 6 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « ipv4/helper_unix.go ('k') | ipv4/mockicmp_test.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 // Copyright 2012 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 ipv4
6
7 import (
8 "net"
9 "reflect"
10 "syscall"
11 )
12
13 func (c *genericOpt) sysfd() (syscall.Handle, error) {
14 switch p := c.c.(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.c.(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.c.(net.Conn))
31 }
32
33 func (c *packetHandler) sysfd() (syscall.Handle, error) {
34 return sysfd(c.c)
35 }
36
37 func sysfd(c net.Conn) (syscall.Handle, error) {
38 cv := reflect.ValueOf(c)
39 switch ce := cv.Elem(); ce.Kind() {
40 case reflect.Struct:
41 fd := ce.FieldByName("conn").FieldByName("fd")
42 switch fe := fd.Elem(); fe.Kind() {
43 case reflect.Struct:
44 sysfd := fe.FieldByName("sysfd")
45 return syscall.Handle(sysfd.Uint()), nil
46 }
47 }
48 return syscall.InvalidHandle, errInvalidConnType
49 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b