Ignore:
Timestamp:
Jun 4, 2009 3:11:25 PM (15 years ago)
Author:
bennylp
Message:

Ticket #878: New PJLIB API to parse socket address string

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjlib/include/pj/sock.h

    r2394 r2743  
    941941                                      pj_uint16_t hostport); 
    942942 
     943/** 
     944 * Parse string containing IP address and optional port into socket address, 
     945 * possibly also with address family detection. This function supports both 
     946 * IPv4 and IPv6 parsing, however IPv6 parsing may only be done if IPv6 is 
     947 * enabled during compilation. 
     948 * 
     949 * This function supports parsing several formats. Sample IPv4 inputs and 
     950 * their default results:: 
     951 *  - "10.0.0.1:80": address 10.0.0.1 and port 80. 
     952 *  - "10.0.0.1": address 10.0.0.1 and port zero. 
     953 *  - "10.0.0.1:": address 10.0.0.1 and port zero. 
     954 *  - "10.0.0.1:0": address 10.0.0.1 and port zero. 
     955 *  - ":80": address 0.0.0.0 and port 80. 
     956 *  - ":": address 0.0.0.0 and port 0. 
     957 *  - "localhost": address 127.0.0.1 and port 0. 
     958 *  - "localhost:": address 127.0.0.1 and port 0. 
     959 *  - "localhost:80": address 127.0.0.1 and port 80. 
     960 * 
     961 * Sample IPv6 inputs and their default results: 
     962 *  - "[fec0::01]:80": address fec0::01 and port 80 
     963 *  - "[fec0::01]": address fec0::01 and port 0 
     964 *  - "[fec0::01]:": address fec0::01 and port 0 
     965 *  - "[fec0::01]:0": address fec0::01 and port 0 
     966 *  - "fec0::01": address fec0::01 and port 0 
     967 *  - "fec0::01:80": address fec0::01:80 and port 0 
     968 *  - "::": address zero (::) and port 0 
     969 *  - "[::]": address zero (::) and port 0 
     970 *  - "[::]:": address zero (::) and port 0 
     971 *  - ":::": address zero (::) and port 0 
     972 *  - "[::]:80": address zero (::) and port 0 
     973 *  - ":::80": address zero (::) and port 80 
     974 * 
     975 * Note: when the IPv6 socket address contains port number, the IP  
     976 * part of the socket address should be enclosed with square brackets,  
     977 * otherwise the port number will be included as part of the IP address 
     978 * (see "fec0::01:80" example above). 
     979 * 
     980 * @param af        Optionally specify the address family to be used. If the 
     981 *                  address family is to be deducted from the input, specify 
     982 *                  pj_AF_UNSPEC() here. 
     983 * @param options   Additional options to assist the parsing, must be zero 
     984 *                  for now. 
     985 * @param str       The input string to be parsed. 
     986 * @param addr      Pointer to store the result. 
     987 * 
     988 * @return          PJ_SUCCESS if the parsing is successful. 
     989 */ 
     990PJ_DECL(pj_status_t) pj_sockaddr_parse(int af, unsigned options, 
     991                                       const pj_str_t *str, 
     992                                       pj_sockaddr *addr); 
     993 
    943994/***************************************************************************** 
    944995 * 
Note: See TracChangeset for help on using the changeset viewer.