SetSockOpt implements the linux syscall setsockopt(2) for sockets backed by tcpip.Endpoint.
(t *kernel.Task, level int, name int, optVal []byte)
| 684 | // SetSockOpt implements the linux syscall setsockopt(2) for sockets backed by |
| 685 | // tcpip.Endpoint. |
| 686 | func (s *sock) SetSockOpt(t *kernel.Task, level int, name int, optVal []byte) *syserr.Error { |
| 687 | // TODO(b/78348848): Unlike other socket options, SO_TIMESTAMP is |
| 688 | // implemented specifically for netstack.Socket rather than |
| 689 | // commonEndpoint. commonEndpoint should be extended to support socket |
| 690 | // options where the implementation is not shared, as unix sockets need |
| 691 | // their own support for SO_TIMESTAMP. |
| 692 | if level == linux.SOL_SOCKET && name == linux.SO_TIMESTAMP { |
| 693 | if len(optVal) < sizeOfInt32 { |
| 694 | return syserr.ErrInvalidArgument |
| 695 | } |
| 696 | s.readMu.Lock() |
| 697 | defer s.readMu.Unlock() |
| 698 | s.sockOptTimestamp = hostarch.ByteOrder.Uint32(optVal) != 0 |
| 699 | return nil |
| 700 | } |
| 701 | if level == linux.SOL_TCP && name == linux.TCP_INQ { |
| 702 | if len(optVal) < sizeOfInt32 { |
| 703 | return syserr.ErrInvalidArgument |
| 704 | } |
| 705 | s.readMu.Lock() |
| 706 | defer s.readMu.Unlock() |
| 707 | s.sockOptInq = hostarch.ByteOrder.Uint32(optVal) != 0 |
| 708 | return nil |
| 709 | } |
| 710 | |
| 711 | switch level { |
| 712 | case linux.SOL_SOCKET: |
| 713 | return SetSockOptSocket(t, s, s.Endpoint, name, optVal) |
| 714 | |
| 715 | case linux.SOL_TCP: |
| 716 | return s.setSockOptTCP(t, s.Endpoint, name, optVal) |
| 717 | |
| 718 | case linux.SOL_ICMPV6: |
| 719 | return s.setSockOptICMPv6(t, s.Endpoint, name, optVal) |
| 720 | |
| 721 | case linux.SOL_IPV6: |
| 722 | return s.setSockOptIPv6(t, s.Endpoint, name, optVal) |
| 723 | |
| 724 | case linux.SOL_IP: |
| 725 | return s.setSockOptIP(t, s.Endpoint, name, optVal) |
| 726 | |
| 727 | case linux.SOL_PACKET: |
| 728 | return s.setSockOptPacket(t, s.Endpoint, name, optVal) |
| 729 | |
| 730 | case linux.SOL_UDP, linux.SOL_RAW: |
| 731 | // Not supported. |
| 732 | } |
| 733 | |
| 734 | return nil |
| 735 | } |
| 736 | |
| 737 | // minSockAddrLen returns the minimum length in bytes of a socket address for |
| 738 | // the socket's family. |
nothing calls this directly
no test coverage detected