1 module tango.sys.darwin.consts.socket;
2     import tango.sys.darwin.consts.fcntl: F_GETFL, F_SETFL,O_NONBLOCK;
3     enum {SOCKET_ERROR = -1}
4     enum
5     {
6         SO_DEBUG = 0x0001 , /* turn on debugging info recording */
7         SO_BROADCAST = 0x0020 , /* permit sending of broadcast msgs */
8         SO_REUSEADDR = 0x0004 , /* allow local address reuse */
9         SO_LINGER = 0x0080 , /* linger on close if data present */
10         SO_DONTLINGER = ~(0x0080),
11         SO_OOBINLINE = 0x0100 , /* leave received OOB data in line */
12         SO_ACCEPTCONN = 0x0002, /* socket has had listen() */
13         SO_KEEPALIVE = 0x0008 , /* keep connections alive */
14         SO_DONTROUTE = 0x0010 , /* just use interface addresses */
15         SO_TYPE = 0x1008 , /* get socket type */
16         /*
17          * Additional options, not kept in so_options.
18          */
19         SO_SNDBUF = 0x1001, /* send buffer size */
20         SO_RCVBUF = 0x1002, /* receive buffer size */
21         SO_ERROR = 0x1007 , /* get error status and clear */
22         // OptionLevel.IP settings
23         IP_MULTICAST_TTL = 10 ,
24         IP_MULTICAST_LOOP = 11 ,
25         IP_ADD_MEMBERSHIP = 12 ,
26         IP_DROP_MEMBERSHIP = 13,
27         // OptionLevel.TCP settings
28         TCP_NODELAY = 0x01 ,
29     }
30     enum
31     {
32         SOL_SOCKET = 0xffff ,
33     }
34     enum {
35         SOCK_STREAM = 1 , /++ sequential, reliable +/
36         SOCK_DGRAM = 2 , /++ connectionless unreliable, max length +/
37         SOCK_SEQPACKET = 5, /++ sequential, reliable, max length +/
38         SOCK_RAW = 3 , /++ raw protocol +/
39         SOCK_RDM = 4 , /++ reliable messages +/
40     }
41     enum
42     {
43         IPPROTO_IP = 0 , /// default internet protocol (probably 4 for compatibility)
44         IPPROTO_IPV4 = 4 , /// internet protocol version 4
45         IPPROTO_IPV6 = 41 , /// internet protocol version 6
46         IPPROTO_ICMP = 1 , /// internet control message protocol
47         IPPROTO_IGMP = 2 , /// internet group management protocol
48         //IPPROTO_GGP = 3 , /// gateway to gateway protocol
49         IPPROTO_TCP = 6 , /// transmission control protocol
50         IPPROTO_PUP = 12 , /// PARC universal packet protocol
51         IPPROTO_UDP = 17 , /// user datagram protocol
52         IPPROTO_IDP = 22 , /// Xerox NS protocol
53     }
54     enum
55     {
56         AF_UNSPEC = 0 ,
57         AF_UNIX = 1 ,
58         AF_INET = 2 ,
59         AF_IPX = 23 ,
60         AF_APPLETALK = 16,
61         AF_INET6 = 30 ,
62     }
63     enum : uint
64     {
65         SCM_RIGHTS = 0x01
66     }
67     enum
68     {
69         SOMAXCONN       = 128,
70     }
71     enum : uint
72     {
73         MSG_CTRUNC = 0x20 ,
74         MSG_DONTROUTE = 0x4 ,
75         MSG_EOR = 0x8 ,
76         MSG_OOB = 0x1 ,
77         MSG_PEEK = 0x2 ,
78         MSG_TRUNC = 0x10 ,
79         MSG_WAITALL = 0x40 ,
80     }
81     enum
82     {
83         SHUT_RD = 0,
84         SHUT_WR = 1,
85         SHUT_RDWR = 2
86     }
87 
88  enum: int
89  {
90         AI_PASSIVE = 0x00000001, /// get address to use bind()
91         AI_CANONNAME = 0x00000002, /// fill ai_canonname
92         AI_NUMERICHOST = 0x00000004, /// prevent host name resolution
93         AI_NUMERICSERV = 0x00000008, /// prevent service name resolution valid flags for addrinfo (not a standard def, apps should not use it)
94         AI_ALL = 0x00000100, /// IPv6 and IPv4-mapped (with AI_V4MAPPED) 
95         AI_V4MAPPED_CFG = 0x00000200, /// accept IPv4-mapped if kernel supports
96         AI_ADDRCONFIG = 0x00000400, /// only if any address is assigned
97         AI_V4MAPPED = 0x00000800, /// accept IPv4-mapped IPv6 address special recommended flags for getipnodebyname
98         AI_MASK = (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST | AI_NUMERICSERV | AI_ADDRCONFIG),
99         AI_DEFAULT = (AI_V4MAPPED_CFG | AI_ADDRCONFIG),
100  }
101 
102 enum
103 {
104         EAI_BADFLAGS = 3,       /// Invalid value for `ai_flags' field.
105         EAI_NONAME = 8, /// NAME or SERVICE is unknown.
106         EAI_AGAIN = 2,  /// Temporary failure in name resolution.
107         EAI_FAIL = 4,   /// Non-recoverable failure in name res.
108         EAI_NODATA = 7, /// No address associated with NAME.
109         EAI_FAMILY = 5, /// `ai_family' not supported.
110         EAI_SOCKTYPE = 10,      /// `ai_socktype' not supported.
111         EAI_SERVICE = 9,        /// SERVICE not supported for `ai_socktype'.
112         EAI_MEMORY = 6, /// Memory allocation failure.
113 }       
114 
115 enum
116 {
117         NI_MAXHOST = 1025,
118         NI_MAXSERV = 32,
119         NI_NUMERICHOST = 0x00000002,    /// Don't try to look up hostname.
120         NI_NUMERICSERV = 0x00000008,    /// Don't convert port number to name.
121         NI_NOFQDN = 0x00000001, /// Only return nodename portion.
122         NI_NAMEREQD = 0x00000004,       /// Don't return numeric addresses.
123         NI_DGRAM = 0x00000010,  /// Look up UDP service rather than TCP.
124 }