github.com/binkynet/BinkyNet@v1.12.1-0.20240421190447-da4e34c20be0/proto_vendor/golang.org/x/net/ipv6/control_unix.go (about) 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 aix darwin dragonfly freebsd linux netbsd openbsd solaris 6 7 package ipv6 8 9 import "golang.org/x/net/internal/socket" 10 11 func setControlMessage(c *socket.Conn, opt *rawOpt, cf ControlFlags, on bool) error { 12 opt.Lock() 13 defer opt.Unlock() 14 if so, ok := sockOpts[ssoReceiveTrafficClass]; ok && cf&FlagTrafficClass != 0 { 15 if err := so.SetInt(c, boolint(on)); err != nil { 16 return err 17 } 18 if on { 19 opt.set(FlagTrafficClass) 20 } else { 21 opt.clear(FlagTrafficClass) 22 } 23 } 24 if so, ok := sockOpts[ssoReceiveHopLimit]; ok && cf&FlagHopLimit != 0 { 25 if err := so.SetInt(c, boolint(on)); err != nil { 26 return err 27 } 28 if on { 29 opt.set(FlagHopLimit) 30 } else { 31 opt.clear(FlagHopLimit) 32 } 33 } 34 if so, ok := sockOpts[ssoReceivePacketInfo]; ok && cf&flagPacketInfo != 0 { 35 if err := so.SetInt(c, boolint(on)); err != nil { 36 return err 37 } 38 if on { 39 opt.set(cf & flagPacketInfo) 40 } else { 41 opt.clear(cf & flagPacketInfo) 42 } 43 } 44 if so, ok := sockOpts[ssoReceivePathMTU]; ok && cf&FlagPathMTU != 0 { 45 if err := so.SetInt(c, boolint(on)); err != nil { 46 return err 47 } 48 if on { 49 opt.set(FlagPathMTU) 50 } else { 51 opt.clear(FlagPathMTU) 52 } 53 } 54 return nil 55 }