Ignore:
Timestamp:
Nov 18, 2007 2:53:47 PM (16 years ago)
Author:
bennylp
Message:

Ticket #415: implement IPv6 support in PJLIB

File:
1 edited

Legend:

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

    r1410 r1585  
    6161 */ 
    6262 
     63/** Address family is unspecified. @see pj_AF_UNSPEC() */ 
     64extern const pj_uint16_t PJ_AF_UNSPEC; 
     65 
    6366/** Unix domain socket. @see pj_AF_UNIX() */ 
    6467extern const pj_uint16_t PJ_AF_UNIX; 
     
    8588 */ 
    8689 
     90/** Get #PJ_AF_UNSPEC value */ 
     91PJ_DECL(pj_uint16_t) pj_AF_UNSPEC(void); 
    8792/** Get #PJ_AF_UNIX value. */ 
    8893PJ_DECL(pj_uint16_t) pj_AF_UNIX(void); 
     
    314319 
    315320/** 
     321 * Maximum length of text representation of an IPv4 address. 
     322 */ 
     323#define PJ_INET_ADDRSTRLEN      16 
     324 
     325/** 
     326 * Maximum length of text representation of an IPv6 address. 
     327 */ 
     328#define PJ_INET6_ADDRSTRLEN     46 
     329 
     330 
     331/** 
    316332 * This structure describes Internet socket address. 
    317333 * If PJ_SOCKADDR_HAS_LEN is not zero, then sin_zero_len member is added 
     
    334350}; 
    335351 
     352 
    336353#undef s6_addr 
    337354 
     
    339356 * This structure describes IPv6 address. 
    340357 */ 
    341 typedef struct pj_in6_addr 
    342 { 
    343     /** Union of address formats. */ 
    344     union { 
    345         pj_uint8_t  u6_addr8[16];   /**< u6_addr8   */ 
    346         pj_uint16_t u6_addr16[8];   /**< u6_addr16  */ 
    347         pj_uint32_t u6_addr32[4];   /**< u6_addr32  */ 
    348     } in6_u; 
    349 /** Shortcut to access in6_u.u6_addr8. */ 
    350 #define s6_addr                 in6_u.u6_addr8 
    351 /** Shortcut to access in6_u.u6_addr16. */ 
    352 #define s6_addr16               in6_u.u6_addr16 
    353 /** Shortcut to access in6_u.u6_addr32. */ 
    354 #define s6_addr32               in6_u.u6_addr32 
     358typedef union pj_in6_addr 
     359{ 
     360    /* This is the main entry */ 
     361    pj_uint8_t  s6_addr[16];   /**< 8-bit array */ 
     362 
     363    /* While these are used for proper alignment */ 
     364    pj_uint32_t u6_addr32[4]; 
     365#if defined(PJ_HAS_INT64) && PJ_HAS_INT64!=0 
     366    pj_int64_t  u6_addr64[2]; 
     367#endif 
     368 
    355369} pj_in6_addr; 
     370 
    356371 
    357372/** Initializer value for pj_in6_addr. */ 
     
    372387{ 
    373388#if defined(PJ_SOCKADDR_HAS_LEN) && PJ_SOCKADDR_HAS_LEN!=0 
    374     pj_uint8_t  sin_zero_len;       /**< Just ignore this.         */ 
    375     pj_uint8_t  sin_family;         /**< Address family.           */ 
     389    pj_uint8_t  sin6_zero_len;      /**< Just ignore this.         */ 
     390    pj_uint8_t  sin6_family;        /**< Address family.           */ 
    376391#else 
    377392    pj_uint16_t sin6_family;        /**< Address family             */ 
     
    380395    pj_uint32_t sin6_flowinfo;      /**< IPv6 flow information      */ 
    381396    pj_in6_addr sin6_addr;          /**< IPv6 address.              */ 
    382     pj_uint32_t sin6_scope_id;      /**< IPv6 scope-id              */ 
     397    pj_uint32_t sin6_scope_id;      /**< Set of interfaces for a scope  */ 
    383398} pj_sockaddr_in6; 
    384399 
     
    473488 */ 
    474489PJ_DECL(int) pj_inet_aton(const pj_str_t *cp, struct pj_in_addr *inp); 
     490 
     491/** 
     492 * This function converts an address in its standard text presentation form 
     493 * into its numeric binary form. It supports both IPv4 and IPv6 address 
     494 * conversion. 
     495 * 
     496 * @param af    Specify the family of the address.  The PJ_AF_INET and  
     497 *              PJ_AF_INET6 address families shall be supported.   
     498 * @param src   Points to the string being passed in.  
     499 * @param dst   Points to a buffer into which the function stores the  
     500 *              numeric address; this shall be large enough to hold the 
     501 *              numeric address (32 bits for PJ_AF_INET, 128 bits for 
     502 *              PJ_AF_INET6).   
     503 * 
     504 * @return      PJ_SUCCESS if conversion was successful. 
     505 */ 
     506PJ_DECL(pj_status_t) pj_inet_pton(int af, const pj_str_t *src, void *dst); 
     507 
     508/** 
     509 * This function converts a numeric address into a text string suitable 
     510 * for presentation. It supports both IPv4 and IPv6 address 
     511 * conversion. 
     512 * 
     513 * @param af    Specify the family of the address. This can be PJ_AF_INET 
     514 *              or PJ_AF_INET6. 
     515 * @param src   Points to a buffer holding an IPv4 address if the af argument 
     516 *              is PJ_AF_INET, or an IPv6 address if the af argument is 
     517 *              PJ_AF_INET6; the address must be in network byte order.   
     518 * @param dst   Points to a buffer where the function stores the resulting 
     519 *              text string; it shall not be NULL.   
     520 * @param size  Specifies the size of this buffer, which shall be large  
     521 *              enough to hold the text string (PJ_INET_ADDRSTRLEN characters 
     522 *              for IPv4, PJ_INET6_ADDRSTRLEN characters for IPv6). 
     523 * 
     524 * @return      PJ_SUCCESS if conversion was successful.. 
     525 */ 
     526PJ_DECL(pj_status_t) pj_inet_ntop(int af, const void *src, 
     527                                  char *dst, int size); 
    475528 
    476529/** 
Note: See TracChangeset for help on using the changeset viewer.