PageRenderTime 51ms CodeModel.GetById 15ms app.highlight 32ms RepoModel.GetById 1ms app.codeStats 0ms

/src/core/sys/posix/arpa/inet.d

http://github.com/AlexeyProkhin/druntime
D | 140 lines | 72 code | 19 blank | 49 comment | 4 complexity | f70b556872096e741b643b72fe35ccd0 MD5 | raw file
  1/**
  2 * D header file for POSIX.
  3 *
  4 * Copyright: Copyright Sean Kelly 2005 - 2009.
  5 * License:   <a href="http://www.boost.org/LICENSE_1_0.txt">Boost License 1.0</a>.
  6 * Authors:   Sean Kelly
  7 * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
  8 */
  9
 10/*          Copyright Sean Kelly 2005 - 2009.
 11 * Distributed under the Boost Software License, Version 1.0.
 12 *    (See accompanying file LICENSE or copy at
 13 *          http://www.boost.org/LICENSE_1_0.txt)
 14 */
 15module core.sys.posix.arpa.inet;
 16
 17private import core.sys.posix.config;
 18public import core.stdc.inttypes; // for uint32_t, uint16_t
 19public import core.sys.posix.sys.socket; // for socklen_t
 20
 21version (Posix):
 22extern (C):
 23
 24//
 25// Required
 26//
 27/*
 28NOTE: The following must must be defined in core.sys.posix.arpa.inet to break
 29      a circular import: in_port_t, in_addr_t, struct in_addr, INET_ADDRSTRLEN.
 30
 31in_port_t // from core.sys.posix.netinet.in_
 32in_addr_t // from core.sys.posix.netinet.in_
 33
 34struct in_addr  // from core.sys.posix.netinet.in_
 35INET_ADDRSTRLEN // from core.sys.posix.netinet.in_
 36
 37uint32_t // from core.stdc.inttypes
 38uint16_t // from core.stdc.inttypes
 39
 40uint32_t htonl(uint32_t);
 41uint16_t htons(uint16_t);
 42uint32_t ntohl(uint32_t);
 43uint16_t ntohs(uint16_t);
 44
 45in_addr_t inet_addr(in char*);
 46char*     inet_ntoa(in_addr);
 47// per spec: const char* inet_ntop(int, const void*, char*, socklen_t);
 48char*     inet_ntop(int, in void*, char*, socklen_t);
 49int       inet_pton(int, in char*, void*);
 50*/
 51
 52version( linux )
 53{
 54    alias uint16_t in_port_t;
 55    alias uint32_t in_addr_t;
 56
 57    struct in_addr
 58    {
 59        in_addr_t s_addr;
 60    }
 61
 62    enum INET_ADDRSTRLEN = 16;
 63
 64    uint32_t htonl(uint32_t);
 65    uint16_t htons(uint16_t);
 66    uint32_t ntohl(uint32_t);
 67    uint16_t ntohs(uint16_t);
 68
 69    in_addr_t       inet_addr(in char*);
 70    char*           inet_ntoa(in_addr);
 71    const(char)*    inet_ntop(int, in void*, char*, socklen_t);
 72    int             inet_pton(int, in char*, void*);
 73}
 74else version( OSX )
 75{
 76    alias uint16_t in_port_t;
 77    alias uint32_t in_addr_t;
 78
 79    struct in_addr
 80    {
 81        in_addr_t s_addr;
 82    }
 83
 84    enum INET_ADDRSTRLEN = 16;
 85
 86    uint32_t htonl(uint32_t);
 87    uint16_t htons(uint16_t);
 88    uint32_t ntohl(uint32_t);
 89    uint16_t ntohs(uint16_t);
 90
 91    in_addr_t       inet_addr(in char*);
 92    char*           inet_ntoa(in_addr);
 93    const(char)*    inet_ntop(int, in void*, char*, socklen_t);
 94    int             inet_pton(int, in char*, void*);
 95}
 96else version( FreeBSD )
 97{
 98    alias uint16_t in_port_t;
 99    alias uint32_t in_addr_t;
100
101    struct in_addr
102    {
103        in_addr_t s_addr;
104    }
105
106    enum INET_ADDRSTRLEN = 16;
107
108    uint32_t htonl(uint32_t);
109    uint16_t htons(uint16_t);
110    uint32_t ntohl(uint32_t);
111    uint16_t ntohs(uint16_t);
112
113    in_addr_t       inet_addr(in char*);
114    char*           inet_ntoa(in_addr);
115    const(char)*    inet_ntop(int, in void*, char*, socklen_t);
116    int             inet_pton(int, in char*, void*);
117}
118
119//
120// IPV6 (IP6)
121//
122/*
123NOTE: The following must must be defined in core.sys.posix.arpa.inet to break
124      a circular import: INET6_ADDRSTRLEN.
125
126INET6_ADDRSTRLEN // from core.sys.posix.netinet.in_
127*/
128
129version( linux )
130{
131    enum INET6_ADDRSTRLEN = 46;
132}
133else version( OSX )
134{
135    enum INET6_ADDRSTRLEN = 46;
136}
137else version( FreeBSD )
138{
139    enum INET6_ADDRSTRLEN = 46;
140}