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

Delta Between Two Patch Sets: src/pkg/net/udpsock_posix.go

Issue 5449070: code review 5449070: net: shorten composite literal field values (Closed)
Left Patch Set: Created 12 years, 3 months ago
Right Patch Set: diff -r f91f50b96e10 https://go.googlecode.com/hg/ Created 12 years, 3 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
LEFTRIGHT
(no file at all)
1 // Copyright 2009 The Go Authors. All rights reserved. 1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 // +build darwin freebsd linux openbsd windows 5 // +build darwin freebsd linux openbsd windows
6 6
7 // UDP sockets 7 // UDP sockets
8 8
9 package net 9 package net
10 10
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 return os.EINVAL 265 return os.EINVAL
266 } 266 }
267 ip := addr.To4() 267 ip := addr.To4()
268 if ip != nil { 268 if ip != nil {
269 return leaveIPv4GroupUDP(c, ifi, ip) 269 return leaveIPv4GroupUDP(c, ifi, ip)
270 } 270 }
271 return leaveIPv6GroupUDP(c, ifi, addr) 271 return leaveIPv6GroupUDP(c, ifi, addr)
272 } 272 }
273 273
274 func joinIPv4GroupUDP(c *UDPConn, ifi *Interface, ip IP) error { 274 func joinIPv4GroupUDP(c *UDPConn, ifi *Interface, ip IP) error {
275 » mreq := &syscall.IPMreq{Multiaddr: [4]byte{ip[0], ip[1], ip[2], ip[3]}} 275 » mreq := &syscall.IPMreq{Multiaddr: {ip[0], ip[1], ip[2], ip[3]}}
gri 2011/12/02 23:06:26 I'd leave this file alone - no real win
276 if err := setIPv4InterfaceToJoin(mreq, ifi); err != nil { 276 if err := setIPv4InterfaceToJoin(mreq, ifi); err != nil {
277 return &OpError{"joinipv4group", "udp", &IPAddr{ip}, err} 277 return &OpError{"joinipv4group", "udp", &IPAddr{ip}, err}
278 } 278 }
279 if err := os.NewSyscallError("setsockopt", syscall.SetsockoptIPMreq(c.fd .sysfd, syscall.IPPROTO_IP, syscall.IP_ADD_MEMBERSHIP, mreq)); err != nil { 279 if err := os.NewSyscallError("setsockopt", syscall.SetsockoptIPMreq(c.fd .sysfd, syscall.IPPROTO_IP, syscall.IP_ADD_MEMBERSHIP, mreq)); err != nil {
280 return &OpError{"joinipv4group", "udp", &IPAddr{ip}, err} 280 return &OpError{"joinipv4group", "udp", &IPAddr{ip}, err}
281 } 281 }
282 return nil 282 return nil
283 } 283 }
284 284
285 func leaveIPv4GroupUDP(c *UDPConn, ifi *Interface, ip IP) error { 285 func leaveIPv4GroupUDP(c *UDPConn, ifi *Interface, ip IP) error {
286 » mreq := &syscall.IPMreq{Multiaddr: [4]byte{ip[0], ip[1], ip[2], ip[3]}} 286 » mreq := &syscall.IPMreq{Multiaddr: {ip[0], ip[1], ip[2], ip[3]}}
287 if err := setIPv4InterfaceToJoin(mreq, ifi); err != nil { 287 if err := setIPv4InterfaceToJoin(mreq, ifi); err != nil {
288 return &OpError{"leaveipv4group", "udp", &IPAddr{ip}, err} 288 return &OpError{"leaveipv4group", "udp", &IPAddr{ip}, err}
289 } 289 }
290 if err := os.NewSyscallError("setsockopt", syscall.SetsockoptIPMreq(c.fd .sysfd, syscall.IPPROTO_IP, syscall.IP_DROP_MEMBERSHIP, mreq)); err != nil { 290 if err := os.NewSyscallError("setsockopt", syscall.SetsockoptIPMreq(c.fd .sysfd, syscall.IPPROTO_IP, syscall.IP_DROP_MEMBERSHIP, mreq)); err != nil {
291 return &OpError{"leaveipv4group", "udp", &IPAddr{ip}, err} 291 return &OpError{"leaveipv4group", "udp", &IPAddr{ip}, err}
292 } 292 }
293 return nil 293 return nil
294 } 294 }
295 295
296 func setIPv4InterfaceToJoin(mreq *syscall.IPMreq, ifi *Interface) error { 296 func setIPv4InterfaceToJoin(mreq *syscall.IPMreq, ifi *Interface) error {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 mreq := &syscall.IPv6Mreq{} 329 mreq := &syscall.IPv6Mreq{}
330 copy(mreq.Multiaddr[:], ip) 330 copy(mreq.Multiaddr[:], ip)
331 if ifi != nil { 331 if ifi != nil {
332 mreq.Interface = uint32(ifi.Index) 332 mreq.Interface = uint32(ifi.Index)
333 } 333 }
334 if err := os.NewSyscallError("setsockopt", syscall.SetsockoptIPv6Mreq(c. fd.sysfd, syscall.IPPROTO_IPV6, syscall.IPV6_LEAVE_GROUP, mreq)); err != nil { 334 if err := os.NewSyscallError("setsockopt", syscall.SetsockoptIPv6Mreq(c. fd.sysfd, syscall.IPPROTO_IPV6, syscall.IPV6_LEAVE_GROUP, mreq)); err != nil {
335 return &OpError{"leaveipv6group", "udp", &IPAddr{ip}, err} 335 return &OpError{"leaveipv6group", "udp", &IPAddr{ip}, err}
336 } 336 }
337 return nil 337 return nil
338 } 338 }
LEFTRIGHT

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