github.com/google/syzkaller@v0.0.0-20240517125934-c0f1611a36d6/sys/darwin/socket_inet.txt (about)

     1  # Copyright 2021 syzkaller project authors. All rights reserved.
     2  # Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
     3  
     4  include <sys/types.h>
     5  include <sys/socket.h>
     6  include <sys/sockio.h>
     7  include <netinet/in.h>
     8  
     9  # IP sockets
    10  
    11  resource sock_in[sock]
    12  resource ifindex[int32]
    13  
    14  sockaddr_in {
    15  	len	len[parent, int8]
    16  	family	const[AF_INET, int8]
    17  	port	sock_port
    18  	addr	ipv4_addr
    19  	pad	array[const[0, int8], 8]
    20  }
    21  
    22  sockaddr_storage_in {
    23  	addr	sockaddr_in
    24  	pad	array[const[0, int64], 15]
    25  }
    26  
    27  socket$inet(domain const[AF_INET], type flags[socket_type], proto int8) sock_in
    28  accept$inet(fd sock_in, peer ptr[out, sockaddr_in, opt], peerlen ptr[inout, len[peer, int32]]) sock_in
    29  bind$inet(fd sock_in, addr ptr[in, sockaddr_in], addrlen len[addr])
    30  connect$inet(fd sock_in, addr ptr[in, sockaddr_in], addrlen len[addr])
    31  sendto$inet(fd sock_in, buf buffer[in], len len[buf], f flags[send_flags], addr ptr[in, sockaddr_in, opt], addrlen len[addr])
    32  recvfrom$inet(fd sock_in, buf buffer[out], len len[buf], f flags[recv_flags], addr ptr[in, sockaddr_in, opt], addrlen len[addr])
    33  getsockname$inet(fd sock_in, addr ptr[out, sockaddr_in], addrlen ptr[inout, len[addr, int32]])
    34  getpeername$inet(fd sock_in, peer ptr[out, sockaddr_in], peerlen ptr[inout, len[peer, int32]])
    35  
    36  # Generic IP options
    37  
    38  inet_option_types_int = IP_TOS, IP_TTL, IP_HDRINCL, IP_RECVOPTS, IP_RETOPTS, IP_RECVTTL, IP_RECVTOS
    39  
    40  inet_option_types_buf = IP_OPTIONS, IP_IPSEC_POLICY, IP_MSFILTER, MCAST_JOIN_GROUP, MCAST_LEAVE_GROUP, sockopt_opt_ip_mreq, sockopt_opt_ip_mreqsrc, sockopt_opt_group_source_req
    41  
    42  getsockopt$inet_int(fd sock_in, level const[IPPROTO_IP], optname flags[inet_option_types_int], optval ptr[out, int32], optlen ptr[inout, len[optval, int32]])
    43  setsockopt$inet_int(fd sock_in, level const[IPPROTO_IP], optname flags[inet_option_types_int], optval ptr[in, int32], optlen len[optval])
    44  getsockopt$inet_buf(fd sock_in, level const[IPPROTO_IP], optname flags[inet_option_types_buf], optval buffer[out], optlen ptr[inout, len[optval, int32]])
    45  setsockopt$inet_buf(fd sock_in, level const[IPPROTO_IP], optname flags[inet_option_types_buf], optval buffer[in], optlen len[optval])
    46  
    47  # Specific IP options
    48  
    49  sockopt_opt_ip_opts = IP_OPTIONS
    50  
    51  getsockopt$inet_opts(fd sock_in, level const[IPPROTO_IP], optname flags[sockopt_opt_ip_opts], optval buffer[out], optlen ptr[inout, len[optval, int32]])
    52  setsockopt$inet_opts(fd sock_in, level const[IPPROTO_IP], optname flags[sockopt_opt_ip_opts], optval buffer[in], optlen len[optval])
    53  
    54  sockopt_opt_ip_mreq = IP_ADD_MEMBERSHIP, IP_DROP_MEMBERSHIP, IP_MULTICAST_IF
    55  
    56  getsockopt$inet_mreq(fd sock_in, level const[IPPROTO_IP], optname flags[sockopt_opt_ip_mreq], optval ptr[out, ip_mreq], optlen ptr[inout, len[optval, int32]])
    57  setsockopt$inet_mreq(fd sock_in, level const[IPPROTO_IP], optname flags[sockopt_opt_ip_mreq], optval ptr[in, ip_mreq], optlen len[optval])
    58  getsockopt$inet_mreqn(fd sock_in, level const[IPPROTO_IP], optname flags[sockopt_opt_ip_mreq], optval ptr[out, ip_mreqn], optlen ptr[inout, len[optval, int32]])
    59  setsockopt$inet_mreqn(fd sock_in, level const[IPPROTO_IP], optname flags[sockopt_opt_ip_mreq], optval ptr[in, ip_mreqn], optlen len[optval])
    60  
    61  sockopt_opt_ip_mreqsrc = IP_ADD_SOURCE_MEMBERSHIP, IP_BLOCK_SOURCE, IP_DROP_SOURCE_MEMBERSHIP, IP_UNBLOCK_SOURCE
    62  
    63  getsockopt$inet_mreqsrc(fd sock_in, level const[IPPROTO_IP], optname flags[sockopt_opt_ip_mreqsrc], optval ptr[out, ip_mreq_source], optlen ptr[inout, len[optval, int32]])
    64  setsockopt$inet_mreqsrc(fd sock_in, level const[IPPROTO_IP], optname flags[sockopt_opt_ip_mreqsrc], optval ptr[in, ip_mreq_source], optlen len[optval])
    65  
    66  setsockopt$inet_msfilter(fd sock_in, level const[IPPROTO_IP], optname const[IP_MSFILTER], optval ptr[in, ip_msfilter], optlen len[optval])
    67  
    68  setsockopt$inet_MCAST_JOIN_GROUP(fd sock_in, level const[IPPROTO_IP], optname const[MCAST_JOIN_GROUP], optval ptr[in, group_req_in], optlen len[optval])
    69  setsockopt$inet_MCAST_LEAVE_GROUP(fd sock_in, level const[IPPROTO_IP], optname const[MCAST_LEAVE_GROUP], optval ptr[in, group_req_in], optlen len[optval])
    70  
    71  sockopt_opt_group_source_req = MCAST_JOIN_SOURCE_GROUP, MCAST_LEAVE_SOURCE_GROUP, MCAST_BLOCK_SOURCE, MCAST_UNBLOCK_SOURCE
    72  
    73  setsockopt$inet_group_source_req(fd sock_in, level const[IPPROTO_IP], optname flags[sockopt_opt_group_source_req], optval ptr[in, group_source_req_in], optlen len[optval])
    74  
    75  ip_mreq {
    76  	imr_multiaddr	ipv4_addr
    77  	imr_interface	ipv4_addr
    78  }
    79  
    80  ip_mreqn {
    81  	imr_multiaddr	ipv4_addr
    82  	imr_address	ipv4_addr
    83  	imr_ifindex	ifindex
    84  }
    85  
    86  ip_mreq_source {
    87  	imr_multiaddr	ipv4_addr
    88  	imr_interface	ipv4_addr
    89  	imr_sourceaddr	ipv4_addr
    90  }
    91  
    92  ip_msfilter {
    93  	imsf_multiaddr	ipv4_addr
    94  	imsf_interface	ipv4_addr
    95  	imsf_fmode	flags[ip_msfilter_mode, int32]
    96  	imsf_numsrc	len[imsf_slist, int32]
    97  	imsf_slist	array[ipv4_addr]
    98  }
    99  
   100  ip_msfilter_mode = MCAST_INCLUDE, MCAST_EXCLUDE
   101  
   102  group_req_in {
   103  	gr_interface	int32
   104  	gr_group	sockaddr_storage_in
   105  }
   106  
   107  group_source_req_in {
   108  	gsr_interface	int32
   109  	gsr_group	sockaddr_storage_in
   110  	gsr_source	sockaddr_storage_in
   111  }