1 /*
2  *  Licensed to the Apache Software Foundation (ASF) under one or more
3  *  contributor license agreements.  See the NOTICE file distributed with
4  *  this work for additional information regarding copyright ownership.
5  *  The ASF licenses this file to You under the Apache License, Version 2.0
6  *  (the "License"); you may not use this file except in compliance with
7  *  the License.  You may obtain a copy of the License at
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
11  *  Unless required by applicable law or agreed to in writing, software
12  *  distributed under the License is distributed on an "AS IS" BASIS,
13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *  See the License for the specific language governing permissions and
15  *  limitations under the License.
16  */
17 
18 /******************************************************\
19 		Portable socket library header.
20 \******************************************************/
21 
22 #if !defined(hysocket_h)
23 #define hysocket_h
24 
25 #include <stddef.h>
26 #include "hyporterror.h"
27 
28 /* Socket types, stream & datagram */
29 #define HYSOCK_STREAM 0
30 #define HYSOCK_DGRAM 1
31 #define HYSOCK_AFINET 2
32 #define HYSOCK_ANY 3
33 #define HYSOCK_DEFPROTOCOL 0
34 #define HYSOCK_INADDR_ANY (U_32)0
35 #define HYSOCK_NOFLAGS (U_32)0       /* The default flag argument value, as in a recv */
36 #define HYSOCK_INADDR_LEN 4          /* The length in bytes of a binary IPv4 internet address */
37 #define HYSOCK_INADDR6_LEN 16        /* The length in bytes of a binary IPv6 internet address */
38 
39 /* For getaddrinfo (IPv6) -- socket types */
40 #define HYSOCKET_ANY 0        /* for getaddrinfo hints */
41 #define HYSOCKET_STREAM 1     /* stream socket */
42 #define HYSOCKET_DGRAM 2      /* datagram socket */
43 #define HYSOCKET_RAW 3        /* raw-protocol interface */
44 #define HYSOCKET_RDM 4        /* reliably-delivered message */
45 #define HYSOCKET_SEQPACKET 5  /* sequenced packet stream */
46 
47 /** address family */
48 #define HYADDR_FAMILY_UNSPEC 0     /* IPv6 */
49 #define HYADDR_FAMILY_AFINET4 2    /* IPv6 */
50 #define HYADDR_FAMILY_AFINET6 23   /* IPv6 */
51 
52 /** protocol family */
53 #define HYPROTOCOL_FAMILY_UNSPEC  HYADDR_FAMILY_UNSPEC     /* IPv6 */
54 #define HYPROTOCOL_FAMILY_INET4   HYADDR_FAMILY_AFINET4    /* IPv6 */
55 #define HYPROTOCOL_FAMILY_INET6   HYADDR_FAMILY_AFINET6    /* IPv6 */
56 
57 /* Portable defines for socket levels */
58 #define HY_SOL_SOCKET 1
59 #define HY_IPPROTO_TCP 2
60 #define HY_IPPROTO_IP 3
61 #define HY_IPPROTO_IPV6 4
62 
63 /* Portable defines for socket options */
64 #define HY_SO_LINGER 1
65 #define HY_SO_KEEPALIVE 2
66 #define HY_TCP_NODELAY 3
67 #define HY_MCAST_TTL 4
68 #define HY_MCAST_ADD_MEMBERSHIP 5
69 #define HY_MCAST_DROP_MEMBERSHIP 6
70 #define HY_MCAST_INTERFACE 7
71 #define HY_SO_REUSEADDR 8
72 #define HY_SO_REUSEPORT 9
73 #define HY_SO_SNDBUF 11
74 #define HY_SO_RCVBUF 12
75 #define HY_SO_BROADCAST 13
76 #define HY_SO_OOBINLINE 14
77 #define HY_IP_MULTICAST_LOOP 15
78 #define HY_IP_TOS 16
79 #define HY_MCAST_INTERFACE_2 17
80 #define HY_IPV6_ADD_MEMBERSHIP 18
81 #define HY_IPV6_DROP_MEMBERSHIP	19
82 
83 /* Portable defines for socket read/write options */
84 #define HYSOCK_MSG_PEEK 1
85 #define HYSOCK_MSG_OOB 2
86 
87 /* Platform Constants */
88 typedef struct hysocket_struct *hysocket_t;
89 typedef struct hysockaddr_struct *hysockaddr_t;
90 typedef struct hyhostent_struct *hyhostent_t;
91 typedef struct hyfdset_struct *hyfdset_t;
92 typedef struct hytimeval_struct *hytimeval_t;
93 typedef struct hylinger_struct *hylinger_t;
94 typedef struct hyipmreq_struct *hyipmreq_t;
95 typedef struct hyaddrinfo_struct *hyaddrinfo_t;    /* IPv6 */
96 typedef struct hyipv6_mreq_struct *hyipv6_mreq_t;  /* IPv6 */
97 
98 /* constants for calling multi-call functions */
99 #define HY_PORT_SOCKET_STEP_START 		10
100 #define HY_PORT_SOCKET_STEP_CHECK	20
101 #define HY_PORT_SOCKET_STEP_DONE		30
102 
103 #endif     /* hysocket_h */
104