Rev 4243 | Rev 4603 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 4243 | Rev 4578 | ||
|---|---|---|---|
| Line 24... | Line 24... | ||
| 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | */ |
27 | */ |
| 28 | 28 | ||
| 29 | /** @addtogroup net |
29 | /** @addtogroup socket |
| 30 | * @{ |
30 | * @{ |
| 31 | */ |
31 | */ |
| 32 | 32 | ||
| 33 | /** @file |
33 | /** @file |
| 34 | * Common socket constants. |
34 | * Socket application program interface (API). |
| - | 35 | * This is a part of the network application library. |
|
| 35 | * Based on the linux src/include/linux/socket.h header file. |
36 | * Based on the linux src/include/linux/socket.h header file and BSD socket interface. |
| 36 | */ |
37 | */ |
| 37 | 38 | ||
| 38 | #ifndef __NET_SOCKET_H__ |
39 | #ifndef __NET_SOCKET_H__ |
| 39 | #define __NET_SOCKET_H__ |
40 | #define __NET_SOCKET_H__ |
| 40 | 41 | ||
| - | 42 | #include <sys/types.h> |
|
| - | 43 | ||
| - | 44 | #include "in.h" |
|
| - | 45 | #include "inet.h" |
|
| - | 46 | ||
| 41 | /* Supported address families. */ |
47 | /* Supported address families. */ |
| 42 | /** Unspecified address family. |
48 | /** Unspecified address family. |
| 43 | */ |
49 | */ |
| 44 | #define AF_UNSPEC 0 |
50 | #define AF_UNSPEC 0 |
| 45 | 51 | ||
| Line 170... | Line 176... | ||
| 170 | /** Maximum address family. |
176 | /** Maximum address family. |
| 171 | */ |
177 | */ |
| 172 | #define AF_MAX 34 |
178 | #define AF_MAX 34 |
| 173 | 179 | ||
| 174 | /* Protocol families, same as address families. */ |
180 | /* Protocol families, same as address families. */ |
| 175 | /* |
181 | |
| 176 | #define PF_UNSPEC AF_UNSPEC |
182 | #define PF_UNSPEC AF_UNSPEC |
| 177 | #define PF_UNIX AF_UNIX |
183 | #define PF_UNIX AF_UNIX |
| 178 | #define PF_LOCAL AF_LOCAL |
184 | #define PF_LOCAL AF_LOCAL |
| 179 | #define PF_INET AF_INET |
185 | #define PF_INET AF_INET |
| 180 | #define PF_AX25 AF_AX25 |
186 | #define PF_AX25 AF_AX25 |
| Line 205... | Line 211... | ||
| 205 | #define PF_TIPC AF_TIPC |
211 | #define PF_TIPC AF_TIPC |
| 206 | #define PF_BLUETOOTH AF_BLUETOOTH |
212 | #define PF_BLUETOOTH AF_BLUETOOTH |
| 207 | #define PF_IUCV AF_IUCV |
213 | #define PF_IUCV AF_IUCV |
| 208 | #define PF_RXRPC AF_RXRPC |
214 | #define PF_RXRPC AF_RXRPC |
| 209 | #define PF_MAX AF_MAX |
215 | #define PF_MAX AF_MAX |
| 210 | */ |
216 | |
| 211 | /* Setsockoptions(2) level. Thanks to BSD these must match IPPROTO_xxx */ |
217 | /* Setsockoptions(2) level. Thanks to BSD these must match IPPROTO_xxx */ |
| 212 | /*#define SOL_IP 0 |
218 | #define SOL_IP 0 |
| 213 | #define SOL_ICMP 1 |
219 | #define SOL_ICMP 1 |
| 214 | #define SOL_TCP 6 |
220 | #define SOL_TCP 6 |
| 215 | #define SOL_UDP 17 |
221 | #define SOL_UDP 17 |
| 216 | #define SOL_IPV6 41 |
222 | #define SOL_IPV6 41 |
| 217 | #define SOL_ICMPV6 58 |
223 | #define SOL_ICMPV6 58 |
| 218 | #define SOL_SCTP 132 |
224 | #define SOL_SCTP 132 |
| 219 | #define SOL_UDPLITE 136 *//* UDP-Lite (RFC 3828) */ |
225 | #define SOL_UDPLITE 136 /* UDP-Lite (RFC 3828) */ |
| 220 | /*#define SOL_RAW 255 |
226 | #define SOL_RAW 255 |
| 221 | #define SOL_IPX 256 |
227 | #define SOL_IPX 256 |
| 222 | #define SOL_AX25 257 |
228 | #define SOL_AX25 257 |
| 223 | #define SOL_ATALK 258 |
229 | #define SOL_ATALK 258 |
| 224 | #define SOL_NETROM 259 |
230 | #define SOL_NETROM 259 |
| 225 | #define SOL_ROSE 260 |
231 | #define SOL_ROSE 260 |
| 226 | #define SOL_DECNET 261 |
232 | #define SOL_DECNET 261 |
| 227 | #define SOL_X25 262 |
233 | #define SOL_X25 262 |
| 228 | #define SOL_PACKET 263 |
234 | #define SOL_PACKET 263 |
| 229 | #define SOL_ATM 264 *//* ATM layer (cell level) */ |
235 | #define SOL_ATM 264 /* ATM layer (cell level) */ |
| 230 | /*#define SOL_AAL 265 *//* ATM Adaption Layer (packet level) */ |
236 | #define SOL_AAL 265 /* ATM Adaption Layer (packet level) */ |
| 231 | /*#define SOL_IRDA 266 |
237 | #define SOL_IRDA 266 |
| 232 | #define SOL_NETBEUI 267 |
238 | #define SOL_NETBEUI 267 |
| 233 | #define SOL_LLC 268 |
239 | #define SOL_LLC 268 |
| 234 | #define SOL_DCCP 269 |
240 | #define SOL_DCCP 269 |
| 235 | #define SOL_NETLINK 270 |
241 | #define SOL_NETLINK 270 |
| 236 | #define SOL_TIPC 271 |
242 | #define SOL_TIPC 271 |
| 237 | #define SOL_RXRPC 272 |
243 | #define SOL_RXRPC 272 |
| 238 | #define SOL_PPPOL2TP 273 |
244 | #define SOL_PPPOL2TP 273 |
| 239 | #define SOL_BLUETOOTH 274 |
245 | #define SOL_BLUETOOTH 274 |
| 240 | */ |
246 | |
| 241 | // |
247 | // |
| 242 | /* * IPX options. |
248 | /* * IPX options. |
| 243 | */ |
249 | */ |
| 244 | //#define IPX_TYPE 1 |
250 | //#define IPX_TYPE 1 |
| 245 | 251 | ||
| - | 252 | /** Socket type type definition. |
|
| - | 253 | */ |
|
| - | 254 | typedef enum sock_type{ |
|
| - | 255 | /** Stream (connection oriented) socket. |
|
| - | 256 | */ |
|
| - | 257 | SOCK_STREAM = 1, |
|
| - | 258 | /** Datagram (connectionless oriented) socket. |
|
| - | 259 | */ |
|
| - | 260 | SOCK_DGRAM = 2, |
|
| - | 261 | /** Raw socket. |
|
| - | 262 | */ |
|
| - | 263 | SOCK_RAW = 3 |
|
| - | 264 | } sock_type_t; |
|
| - | 265 | ||
| - | 266 | typedef int32_t socklen_t; |
|
| - | 267 | ||
| - | 268 | int socket( int domain, int type, int protocol ); |
|
| - | 269 | int bind( int socket_id, const struct sockaddr * my_addr, socklen_t addrlen ); |
|
| - | 270 | int listen( int socket_id, int backlog ); |
|
| - | 271 | int accept( int socket_id, struct sockaddr * cliaddr, socklen_t * addrlen ); |
|
| - | 272 | int connect( int socket_id, const struct sockaddr * serv_addr, socklen_t addrlen ); |
|
| - | 273 | ||
| - | 274 | int closesocket( int socket_id ); |
|
| - | 275 | ||
| - | 276 | int send( int socket_id, void * data, size_t datalength, int flags ); |
|
| - | 277 | int sendto( int socket_id, const void * data, size_t datalength, int flags, const struct sockaddr * toaddr, socklen_t addrlen ); |
|
| - | 278 | ||
| - | 279 | int recv( int socket_id, void * data, size_t datalength, int flags ); |
|
| - | 280 | int recvfrom( int socket_id, void * data, size_t datalength, int flags, struct sockaddr * fromaddr, socklen_t * addrlen ); |
|
| - | 281 | ||
| - | 282 | int getsockopt( int socket_id, int level, int optname, void * value, size_t * optlen ); |
|
| - | 283 | int setsockopt( int socket_id, int level, int optname, const void * value, size_t optlen ); |
|
| - | 284 | ||
| 246 | #endif |
285 | #endif |
| 247 | 286 | ||
| 248 | /** @} |
287 | /** @} |
| 249 | */ |
288 | */ |