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

Side by Side Diff: ipv4/helper_posix.go

Issue 6482044: code review 6482044: go.net/ipv4: new package (Closed)
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:
View unified diff | Download patch
« no previous file with comments | « ipv4/helper_plan9.go ('k') | ipv4/helper_unix.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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 // +build darwin freebsd linux netbsd openbsd windows
6
7 package ipv4
8
9 import (
10 "bytes"
11 "net"
12 "syscall"
13 )
14
15 func setSyscallIPMreq(mreq *syscall.IPMreq, ifi *net.Interface) error {
16 if ifi == nil {
17 return nil
18 }
19 ifat, err := ifi.Addrs()
20 if err != nil {
21 return err
22 }
23 for _, ifa := range ifat {
24 switch v := ifa.(type) {
25 case *net.IPAddr:
26 if a := v.IP.To4(); a != nil {
27 copy(mreq.Interface[:], a)
28 goto done
29 }
30 case *net.IPNet:
31 if a := v.IP.To4(); a != nil {
32 copy(mreq.Interface[:], a)
33 goto done
34 }
35 }
36 }
37 done:
38 if bytes.Equal(mreq.Multiaddr[:], net.IPv4zero.To4()) {
39 return errNoSuchMulticastInterface
40 }
41 return nil
42 }
OLDNEW
« no previous file with comments | « ipv4/helper_plan9.go ('k') | ipv4/helper_unix.go » ('j') | no next file with comments »

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