os/ossrv/genericopenlibs/openenvcore/include/arpa/inet.dosc
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/genericopenlibs/openenvcore/include/arpa/inet.dosc	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,311 @@
     1.4 +/** @file ../include/arpa/inet.h
     1.5 +@internalComponent
     1.6 +*/
     1.7 +
     1.8 +/** @fn  inet_addr(const char *cp)
     1.9 +@param cp
    1.10 +
    1.11 +Note: This description also covers the following functions -
    1.12 + inet_aton()  inet_ntoa()  inet_ntop()  inet_pton() 
    1.13 +
    1.14 +@code
    1.15 +  struct in_addr or some other internal binary representation, in network byte order).
    1.16 + It returns 1 if the address was valid for the specified address family, or
    1.17 + 0 if the address was not parseable in the specified address family, or -1
    1.18 + if some system error occurred.
    1.19 + This function is presently valid for AF_INET and AF_INET6.
    1.20 +@endcode
    1.21 +@code
    1.22 +  struct in_addr or some other binary form, in network byte order) to presentation format
    1.23 + (suitable for external display purposes).
    1.24 + The size argument specifies the size, in bytes, of the buffer *dst It returns NULL if a system error occurs (in which case, errno will have been set), or it returns a pointer to the destination string.
    1.25 + This function is presently valid for AF_INET and AF_INET6.
    1.26 +@endcode
    1.27 +@code
    1.28 +  The routines inet_addr and inet_aton interpret character strings representing
    1.29 +numbers expressed in the Internet standard ‘.’ notation.
    1.30 +@endcode
    1.31 +
    1.32 + The inet_pton function converts a presentation format address (that is, printable form
    1.33 +as held in a character string) to network format (usually a  struct in_addr or some other internal binary representation, in network byte order).
    1.34 +It returns 1 if the address was valid for the specified address family, or
    1.35 +0 if the address was not parseable in the specified address family, or -1
    1.36 +if some system error occurred.
    1.37 +This function is presently valid for AF_INET and AF_INET6.
    1.38 +
    1.39 + The inet_aton routine interprets the specified character string as an Internet address,
    1.40 +placing the address into the structure provided.
    1.41 +It returns 1 if the string was successfully interpreted,
    1.42 +or 0 if the string is invalid.
    1.43 +The inet_addr functions return numbers suitable for use
    1.44 +as Internet addresses.
    1.45 +
    1.46 + The function inet_ntop converts an address *src from network format
    1.47 +(usually a  struct in_addr or some other binary form, in network byte order) to presentation format
    1.48 +(suitable for external display purposes).
    1.49 +The size argument specifies the size, in bytes, of the buffer *dst It returns NULL if a system error occurs (in which case, errno will have been set), or it returns a pointer to the destination string.
    1.50 +This function is presently valid for AF_INET and AF_INET6.
    1.51 +
    1.52 + The routine inet_ntoa takes an Internet address and returns an ASCII string representing the address in ' . '
    1.53 +notation.
    1.54 +
    1.55 + All Internet addresses are returned in network
    1.56 +order (bytes ordered from left to right).
    1.57 +All network numbers and local address parts are
    1.58 +returned as machine byte order integer values.
    1.59 +
    1.60 +Diagnostics:
    1.61 +
    1.62 + The constant INADDR_NONE is returned by inet_addr for malformed requests.
    1.63 +
    1.64 +@see gethostbyname()
    1.65 +
    1.66 +
    1.67 +Examples:
    1.68 +@code
    1.69 +#include <stdio.h>
    1.70 +#include <arpa/inet.h>
    1.71 +#include <netinet/in.h>
    1.72 +#define IPV6ADDRSIZE 48
    1.73 +int main()
    1.74 +    {
    1.75 +     unsigned int nbo_value;
    1.76 +     char *ipaddrstring="1.2.3.4";
    1.77 +     char *ipaddrholdr=NULL;
    1.78 +     char *ipv6addrstring="8000::123:4567:89AB:CDEF";
    1.79 +     struct in_addr ipstruct;
    1.80 +     struct in6_addr ipv6struct;
    1.81 +     char result[IPV6ADDRSIZE];
    1.82 +     int err;
    1.83 +     int size;
    1.84 +     const char* error;
    1.85 +     nbo_value=inet_addr(ipaddrstring);
    1.86 +     if(nbo_value == -1)
    1.87 +      {
    1.88 +       printf("inet_addr failed0);
    1.89 +      }
    1.90 +     else
    1.91 +      {
    1.92 +       printf("inet_addr passed0);
    1.93 +      }
    1.94 +     ipstruct.s_addr=nbo_value;
    1.95 +     ipaddrholdr=inet_ntoa(ipstruct);
    1.96 +     if(ipaddrholdr==NULL)
    1.97 +      {
    1.98 +       printf("inet_ntoa failed0);
    1.99 +      }
   1.100 +     else
   1.101 +      {
   1.102 +      printf("ipaddr is %s0,ipaddrholdr);
   1.103 +      }
   1.104 +     err=inet_pton(AF_INET6,ipv6addrstring ,&ipv6struct;);
   1.105 +     if(err ==0  || err==-1)
   1.106 +     printf("inet_pton Failed0);
   1.107 +     else
   1.108 +     printf("inet_pton passed0);
   1.109 +     size=sizeof(result);
   1.110 +     error=inet_ntop(AF_INET6,&ipv6struct.s6;_addr,result,size);     
   1.111 +     if(error==NULL)
   1.112 +      {
   1.113 +      printf("inet_ntop failed");
   1.114 +      }
   1.115 +     else
   1.116 +      {
   1.117 +      printf("inet_ntop passed");
   1.118 +      }
   1.119 +     err=inet_aton(ipaddrstring,&ipstruct;);
   1.120 +     if(err==0)
   1.121 +     {
   1.122 +      printf("invalid address ");
   1.123 +     }
   1.124 +     else
   1.125 +      {
   1.126 +      printf("inet_aton passed ");
   1.127 +      }
   1.128 +    
   1.129 +     return 0;
   1.130 +}
   1.131 +Output:
   1.132 +inet_addr passed
   1.133 +ipaddr is 1.2.3.4
   1.134 +inet_pton passed
   1.135 +inet_ntop passed
   1.136 +inet_aton passed
   1.137 +
   1.138 +@endcode
   1.139 + The inet_ntop and inet_pton functions conform to -xns5.2. Note that inet_pton does not accept 1-, 2-, or 3-part dotted addresses; all four parts
   1.140 +must be specified and are interpreted only as decimal values.
   1.141 +This is a narrower input set than that accepted by inet_aton. These
   1.142 +functions appeared in BSD 4.2.
   1.143 +
   1.144 +Bugs:
   1.145 +
   1.146 + The value INADDR_NONE (0xffffffff) is a valid broadcast address, but inet_addr cannot return that value without indicating failure.
   1.147 +The newer inet_aton function does not share this problem.
   1.148 +The problem of host byte ordering versus network byte ordering is
   1.149 +confusing.
   1.150 +The string returned by inet_ntoa resides in a static memory area. Inet_addr should return a struct in_addr. 
   1.151 +
   1.152 +   
   1.153 +
   1.154 +@publishedAll
   1.155 +@externallyDefinedApi
   1.156 +*/
   1.157 +
   1.158 +/** @fn  inet_ntoa(struct in_addr in)
   1.159 +@param in
   1.160 +
   1.161 +Refer to  inet_addr() for the documentation
   1.162 +@see gethostbyname()
   1.163 +
   1.164 +
   1.165 + 
   1.166 +
   1.167 +@publishedAll
   1.168 +@externallyDefinedApi
   1.169 +*/
   1.170 +
   1.171 +/** @fn  inet_ntop(  int af ,  const void *  src,   char *  dst,   socklen_t size)  
   1.172 +@param af
   1.173 +@param src
   1.174 +@param dst
   1.175 +@param size
   1.176 +
   1.177 +Refer to  inet_addr() for the documentation
   1.178 +
   1.179 +@see gethostbyname()
   1.180 +
   1.181 +
   1.182 + 
   1.183 +
   1.184 +@publishedAll
   1.185 +@externallyDefinedApi
   1.186 +*/
   1.187 +
   1.188 +/** @fn  inet_pton(int af, const char *  src, void *  dst)
   1.189 +@param af
   1.190 +@param src
   1.191 +@param dst
   1.192 +
   1.193 +Refer to  inet_addr() for the documentation
   1.194 +
   1.195 +@see gethostbyname()
   1.196 +
   1.197 +
   1.198 + 
   1.199 +
   1.200 +@publishedAll
   1.201 +@externallyDefinedApi
   1.202 +*/
   1.203 +
   1.204 +/** @fn  inet_aton(const char *cp, struct in_addr *pin)
   1.205 +@param cp
   1.206 +@param pin
   1.207 +
   1.208 +Refer to  inet_addr() for the documentation
   1.209 +
   1.210 +@see gethostbyname()
   1.211 +
   1.212 +
   1.213 + 
   1.214 +
   1.215 +@publishedAll
   1.216 +@externallyDefinedApi
   1.217 +*/
   1.218 +
   1.219 +/** @fn  htonl(uint32_t hl)
   1.220 +@param hl
   1.221 +
   1.222 +Note: This description also covers the following functions -
   1.223 + htons()  ntohl()  ntohs() 
   1.224 +
   1.225 +  These routines convert 16 and 32 bit quantities between network
   1.226 +byte order and host byte order.
   1.227 +On machines which have a byte order which is the same as the network
   1.228 +order, routines are defined as null macros.
   1.229 +
   1.230 + These routines are most often used in conjunction with Internet
   1.231 +addresses and ports as returned by gethostbyname
   1.232 +and getservent .
   1.233 +
   1.234 +@see gethostbyaddr()
   1.235 +@see getservent()
   1.236 +
   1.237 +
   1.238 +Bugs:
   1.239 +
   1.240 + On the VAX bytes are handled backwards from most everyone else in
   1.241 +the world.
   1.242 +
   1.243 + 
   1.244 +
   1.245 +@publishedAll
   1.246 +@externallyDefinedApi
   1.247 +*/
   1.248 +
   1.249 +/** @fn  htons(uint16_t hs)
   1.250 +@param hs
   1.251 +
   1.252 +Refer to  htonl() for the documentation
   1.253 +@see gethostbyaddr()
   1.254 +@see getservent()
   1.255 +
   1.256 +
   1.257 + 
   1.258 +
   1.259 +@publishedAll
   1.260 +@externallyDefinedApi
   1.261 +*/
   1.262 +
   1.263 +/** @def  ntohl
   1.264 +
   1.265 +These are also declared as functions.
   1.266 +
   1.267 +@publishedAll
   1.268 +@externallyDefinedApi
   1.269 +*/
   1.270 +
   1.271 +/** @def  ntohs
   1.272 +
   1.273 +These are also declared as functions.
   1.274 +
   1.275 +@publishedAll
   1.276 +@externallyDefinedApi
   1.277 +*/
   1.278 +
   1.279 +/** @def  inet_addr
   1.280 +
   1.281 +These are also declared as functions.
   1.282 +
   1.283 +@publishedAll
   1.284 +@externallyDefinedApi
   1.285 +*/
   1.286 +
   1.287 +
   1.288 +/** @def  inet_ntoa
   1.289 +
   1.290 +These are also declared as functions.
   1.291 +
   1.292 +@publishedAll
   1.293 +@externallyDefinedApi
   1.294 +*/
   1.295 +
   1.296 +
   1.297 +/** @def  inet_pton
   1.298 +
   1.299 +These are also declared as functions.
   1.300 +
   1.301 +@publishedAll
   1.302 +@externallyDefinedApi
   1.303 +*/
   1.304 +
   1.305 +
   1.306 +/** @def  inet_ntop
   1.307 +
   1.308 +These are also declared as functions.
   1.309 +
   1.310 +@publishedAll
   1.311 +@externallyDefinedApi
   1.312 +*/
   1.313 +
   1.314 +