golang.org/x/net@v0.25.1-0.20240516223405-c87a5b62e243/ipv4/sys_bsd.go (about) 1 // Copyright 2014 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 //go:build netbsd || openbsd 6 7 package ipv4 8 9 import ( 10 "net" 11 "syscall" 12 13 "golang.org/x/net/internal/iana" 14 "golang.org/x/net/internal/socket" 15 16 "golang.org/x/sys/unix" 17 ) 18 19 const sockoptReceiveInterface = unix.IP_RECVIF 20 21 var ( 22 ctlOpts = [ctlMax]ctlOpt{ 23 ctlTTL: {unix.IP_RECVTTL, 1, marshalTTL, parseTTL}, 24 ctlDst: {unix.IP_RECVDSTADDR, net.IPv4len, marshalDst, parseDst}, 25 ctlInterface: {unix.IP_RECVIF, syscall.SizeofSockaddrDatalink, marshalInterface, parseInterface}, 26 } 27 28 sockOpts = map[int]*sockOpt{ 29 ssoTOS: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_TOS, Len: 4}}, 30 ssoTTL: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_TTL, Len: 4}}, 31 ssoMulticastTTL: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_MULTICAST_TTL, Len: 1}}, 32 ssoMulticastInterface: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_MULTICAST_IF, Len: 4}}, 33 ssoMulticastLoopback: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_MULTICAST_LOOP, Len: 1}}, 34 ssoReceiveTTL: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_RECVTTL, Len: 4}}, 35 ssoReceiveDst: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_RECVDSTADDR, Len: 4}}, 36 ssoReceiveInterface: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_RECVIF, Len: 4}}, 37 ssoHeaderPrepend: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_HDRINCL, Len: 4}}, 38 ssoJoinGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_ADD_MEMBERSHIP, Len: sizeofIPMreq}, typ: ssoTypeIPMreq}, 39 ssoLeaveGroup: {Option: socket.Option{Level: iana.ProtocolIP, Name: unix.IP_DROP_MEMBERSHIP, Len: sizeofIPMreq}, typ: ssoTypeIPMreq}, 40 } 41 )