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/src/pjlib-test/sock.c

    r1405 r1585  
    4141 *  - pj_inet_aton() 
    4242 *  - pj_inet_ntoa() 
     43 *  - pj_inet_pton()  (only if IPv6 is enabled) 
     44 *  - pj_inet_ntop()  (only if IPv6 is enabled) 
    4345 *  - pj_gethostname() 
    4446 *  - pj_sock_socket() 
     
    101103 
    102104    if (pj_strcmp2(&s, (char*)p) != 0) 
    103         return -30; 
     105        return -22; 
     106 
     107#if defined(PJ_HAS_IPV6) && PJ_HAS_IPV6!=0 
     108    /* pj_inet_pton() */ 
     109    /* pj_inet_ntop() */ 
     110    { 
     111        const pj_str_t s_ipv4 = pj_str("127.0.0.1"); 
     112        const pj_str_t s_ipv6 = pj_str("fe80::2ff:83ff:fe7c:8b42"); 
     113        char buf_ipv4[PJ_INET_ADDRSTRLEN]; 
     114        char buf_ipv6[PJ_INET6_ADDRSTRLEN]; 
     115        pj_in_addr ipv4; 
     116        pj_in6_addr ipv6; 
     117 
     118        if (pj_inet_pton(pj_AF_INET(), &s_ipv4, &ipv4) != PJ_SUCCESS) 
     119            return -24; 
     120 
     121        p = (unsigned char*)&ipv4; 
     122        if (p[0]!=A[0] || p[1]!=A[1] || p[2]!=A[2] || p[3]!=A[3]) { 
     123            return -25; 
     124        } 
     125 
     126        if (pj_inet_pton(pj_AF_INET6(), &s_ipv6, &ipv6) != PJ_SUCCESS) 
     127            return -26; 
     128 
     129        p = (unsigned char*)&ipv6; 
     130        if (p[0] != 0xfe || p[1] != 0x80 || p[2] != 0 || p[3] != 0 || 
     131            p[4] != 0 || p[5] != 0 || p[6] != 0 || p[7] != 0 || 
     132            p[8] != 0x02 || p[9] != 0xff || p[10] != 0x83 || p[11] != 0xff || 
     133            p[12]!=0xfe || p[13]!=0x7c || p[14] != 0x8b || p[15]!=0x42) 
     134        { 
     135            return -27; 
     136        } 
     137 
     138        if (pj_inet_ntop(pj_AF_INET(), &ipv4, buf_ipv4, sizeof(buf_ipv4)) != PJ_SUCCESS) 
     139            return -28; 
     140        if (pj_stricmp2(&s_ipv4, buf_ipv4) != 0) 
     141            return -29; 
     142 
     143        if (pj_inet_ntop(pj_AF_INET6(), &ipv6, buf_ipv6, sizeof(buf_ipv6)) != PJ_SUCCESS) 
     144            return -30; 
     145        if (pj_stricmp2(&s_ipv6, buf_ipv6) != 0) 
     146            return -31; 
     147    } 
     148 
     149#endif  /* PJ_HAS_IPV6 */ 
    104150 
    105151    /* Test that pj_sockaddr_in_init() initialize the whole structure,  
Note: See TracChangeset for help on using the changeset viewer.