LEFT | RIGHT |
1 // Copyright 2014 The Go Authors. All rights reserved. | 1 // Copyright 2014 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 package ipv4 | 5 package ipv4 |
6 | 6 |
7 const ( | 7 import "syscall" |
8 » // See /usr/include/netinet/in.h. | 8 |
9 » sysSockoptReceiveTTL = 0x18 | 9 func init() { |
10 » sysSockoptReceiveDst = 0x7 | 10 » // Seems like kern.osreldate is veiled on latest OS X. We use |
11 » sysSockoptReceiveInterface = 0x14 | 11 » // kern.osrelease instead. |
12 » sysSockoptPacketInfo = 0x1a | 12 » osver, err := syscall.Sysctl("kern.osrelease") |
13 ) | 13 » if err != nil { |
| 14 » » return |
| 15 » } |
| 16 » var i int |
| 17 » for i = range osver { |
| 18 » » if osver[i] != '.' { |
| 19 » » » continue |
| 20 » » } |
| 21 » } |
| 22 » // The IP_PKTINFO was introduced in OS X 10.7 (Darwin |
| 23 » // 11.0.0). See http://support.apple.com/kb/HT1633. |
| 24 » if i > 2 || i == 2 && osver[0] >= '1' && osver[1] >= '1' { |
| 25 » » supportsPacketInfo = true |
| 26 » } |
| 27 } |
LEFT | RIGHT |