1 /** 2 * D header file for POSIX. 3 * 4 * Copyright: Public Domain 5 * License: Public Domain 6 * Authors: Sean Kelly 7 * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition 8 */ 9 module tango.stdc.posix.arpa.inet; 10 11 private import tango.stdc.posix.config; 12 public import tango.stdc.inttypes : uint32_t, uint16_t; 13 public import tango.stdc.posix.sys.socket : socklen_t; 14 15 extern (C): 16 17 // 18 // Required 19 // 20 /* 21 in_port_t // from tango.stdc.posix.netinet.in_ 22 in_addr_t // from tango.stdc.posix.netinet.in_ 23 24 struct in_addr // from tango.stdc.posix.netinet.in_ 25 INET_ADDRSTRLEN // from tango.stdc.posix.netinet.in_ 26 27 uint32_t // from tango.stdc.inttypes 28 uint16_t // from tango.stdc.inttypes 29 30 uint32_t htonl(uint32_t); 31 uint16_t htons(uint16_t); 32 uint32_t ntohl(uint32_t); 33 uint16_t ntohs(uint16_t); 34 35 in_addr_t inet_addr(in char*); 36 char* inet_ntoa(in_addr); 37 // per spec: const char* inet_ntop(int, const void*, char*, socklen_t); 38 char* inet_ntop(int, in void*, char*, socklen_t); 39 int inet_pton(int, in char*, void*); 40 */ 41 42 version( linux ) 43 { 44 alias uint16_t in_port_t; 45 alias uint32_t in_addr_t; 46 47 struct in_addr 48 { 49 in_addr_t s_addr; 50 } 51 52 const INET_ADDRSTRLEN = 16; 53 54 uint32_t htonl(uint32_t); 55 uint16_t htons(uint16_t); 56 uint32_t ntohl(uint32_t); 57 uint16_t ntohs(uint16_t); 58 59 in_addr_t inet_addr(in char*); 60 char* inet_ntoa(in_addr); 61 char* inet_ntop(int, in void*, char*, socklen_t); 62 int inet_pton(int, in char*, void*); 63 } 64 else version( darwin ) 65 { 66 alias uint16_t in_port_t; // TODO: verify 67 alias uint32_t in_addr_t; // TODO: verify 68 69 struct in_addr 70 { 71 in_addr_t s_addr; 72 } 73 74 const INET_ADDRSTRLEN = 16; 75 76 uint32_t htonl(uint32_t); 77 uint16_t htons(uint16_t); 78 uint32_t ntohl(uint32_t); 79 uint16_t ntohs(uint16_t); 80 81 in_addr_t inet_addr(in char*); 82 char* inet_ntoa(in_addr); 83 char* inet_ntop(int, in void*, char*, socklen_t); 84 int inet_pton(int, in char*, void*); 85 } 86 else version( FreeBSD ) 87 { 88 alias uint16_t in_port_t; // TODO: verify 89 alias uint32_t in_addr_t; // TODO: verify 90 91 struct in_addr 92 { 93 in_addr_t s_addr; 94 } 95 96 const INET_ADDRSTRLEN = 16; 97 98 uint32_t htonl(uint32_t); 99 uint16_t htons(uint16_t); 100 uint32_t ntohl(uint32_t); 101 uint16_t ntohs(uint16_t); 102 103 in_addr_t inet_addr(in char*); 104 char* inet_ntoa(in_addr); 105 char* inet_ntop(int, in void*, char*, socklen_t); 106 int inet_pton(int, in char*, void*); 107 } 108 else version( solaris ) 109 { 110 alias uint16_t in_port_t; 111 alias uint32_t in_addr_t; 112 113 struct in_addr 114 { 115 in_addr_t s_addr; 116 } 117 118 const INET_ADDRSTRLEN = 16; 119 120 uint32_t htonl(uint32_t); 121 uint16_t htons(uint16_t); 122 uint32_t ntohl(uint32_t); 123 uint16_t ntohs(uint16_t); 124 125 in_addr_t inet_addr(in char*); 126 char* inet_ntoa(in_addr); 127 char* inet_ntop(int, in void*, char*, socklen_t); 128 int inet_pton(int, in char*, void*); 129 } 130 131 // 132 // IPV6 (IP6) 133 // 134 /* 135 INET6_ADDRSTRLEN // from tango.stdc.posix.netinet.in_ 136 */ 137 138 version( linux ) 139 { 140 const INET6_ADDRSTRLEN = 46; 141 } 142 else version( darwin ) 143 { 144 const INET6_ADDRSTRLEN = 46; 145 } 146 else version( FreeBSD ) 147 { 148 const INET6_ADDRSTRLEN = 46; 149 } 150 else version( solaris ) 151 { 152 const INET6_ADDRSTRLEN = 46; 153 }