Ignore:
Timestamp:
Dec 2, 2007 3:40:52 PM (16 years ago)
Author:
bennylp
Message:

More ticket #421: fixed SIP messaging components to support IPv6 format

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip/src/test-pjsip/msg_test.c

    r1451 r1610  
    701701 
    702702 
     703#if INCLUDE_BENCHMARKS 
    703704static int msg_benchmark(unsigned *p_detect, unsigned *p_parse,  
    704705                         unsigned *p_print) 
     
    776777    return status; 
    777778} 
     779#endif  /* INCLUDE_BENCHMARKS */ 
    778780 
    779781/*****************************************************************************/ 
     
    796798static int hdr_test_to(pjsip_hdr *h); 
    797799static int hdr_test_via(pjsip_hdr *h); 
    798  
     800static int hdr_test_via_ipv6_1(pjsip_hdr *h); 
     801static int hdr_test_via_ipv6_2(pjsip_hdr *h); 
     802static int hdr_test_via_ipv6_3(pjsip_hdr *h); 
    799803 
    800804 
    801805#define GENERIC_PARAM        "p0=a;p1=\"ab:;cd\";p2=ab%3acd;p3" 
    802806#define GENERIC_PARAM_PARSED "p0=a;p1=\"ab:;cd\";p2=ab:cd;p3" 
    803 #define PARAM_CHAR           "[]/:&+$" 
     807#define PARAM_CHAR           "][/:&+$" 
    804808#define SIMPLE_ADDR_SPEC     "sip:host" 
    805809#define ADDR_SPEC            SIMPLE_ADDR_SPEC ";"PARAM_CHAR"="PARAM_CHAR ";p1=\";\"" 
     
    948952        "SIP/2.0/XYZ host" ";" GENERIC_PARAM, 
    949953        &hdr_test_via 
     954    }, 
     955 
     956    { 
     957        /* Via with IPv6 */ 
     958        "Via", "v", 
     959        "SIP/2.0/UDP [::1]", 
     960        &hdr_test_via_ipv6_1 
     961    }, 
     962 
     963    { 
     964        /* Via with IPv6 */ 
     965        "Via", "v", 
     966        "SIP/2.0/UDP [::1]:5061", 
     967        &hdr_test_via_ipv6_2 
     968    }, 
     969 
     970    { 
     971        /* Via with IPv6 */ 
     972        "Via", "v", 
     973        "SIP/2.0/UDP [::1];rport=5061;received=::2", 
     974        &hdr_test_via_ipv6_3 
    950975    } 
    951976}; 
     
    11121137 
    11131138/*  
    1114 #define PARAM_CHAR          "[]/:&+$" 
     1139#define PARAM_CHAR          "][/:&+$" 
    11151140#define SIMPLE_ADDR_SPEC    "sip:host" 
    11161141#define ADDR_SPEC            SIMPLE_ADDR_SPEC ";"PARAM_CHAR"="PARAM_CHAR ";p1=\";\"" 
     
    14331458} 
    14341459 
     1460 
     1461/* 
     1462    "SIP/2.0/UDP [::1]" 
     1463 */ 
     1464static int hdr_test_via_ipv6_1(pjsip_hdr *h) 
     1465{ 
     1466    pjsip_via_hdr *hdr = (pjsip_via_hdr*)h; 
     1467 
     1468    if (h->type != PJSIP_H_VIA) 
     1469        return -2610; 
     1470 
     1471    if (pj_strcmp2(&hdr->transport, "UDP")) 
     1472        return -2615; 
     1473 
     1474    if (pj_strcmp2(&hdr->sent_by.host, "::1")) 
     1475        return -2620; 
     1476 
     1477    if (hdr->sent_by.port != 0) 
     1478        return -2630; 
     1479 
     1480    return 0; 
     1481} 
     1482 
     1483/* "SIP/2.0/UDP [::1]:5061" */ 
     1484static int hdr_test_via_ipv6_2(pjsip_hdr *h) 
     1485{ 
     1486    pjsip_via_hdr *hdr = (pjsip_via_hdr*)h; 
     1487 
     1488    if (h->type != PJSIP_H_VIA) 
     1489        return -2710; 
     1490 
     1491    if (pj_strcmp2(&hdr->transport, "UDP")) 
     1492        return -2715; 
     1493 
     1494    if (pj_strcmp2(&hdr->sent_by.host, "::1")) 
     1495        return -2720; 
     1496 
     1497    if (hdr->sent_by.port != 5061) 
     1498        return -2730; 
     1499 
     1500    return 0; 
     1501} 
     1502 
     1503/* "SIP/2.0/UDP [::1];rport=5061;received=::2" */ 
     1504static int hdr_test_via_ipv6_3(pjsip_hdr *h) 
     1505{ 
     1506    pjsip_via_hdr *hdr = (pjsip_via_hdr*)h; 
     1507 
     1508    if (h->type != PJSIP_H_VIA) 
     1509        return -2810; 
     1510 
     1511    if (pj_strcmp2(&hdr->transport, "UDP")) 
     1512        return -2815; 
     1513 
     1514    if (pj_strcmp2(&hdr->sent_by.host, "::1")) 
     1515        return -2820; 
     1516 
     1517    if (hdr->sent_by.port != 0) 
     1518        return -2830; 
     1519 
     1520    if (pj_strcmp2(&hdr->recvd_param, "::2")) 
     1521        return -2840; 
     1522 
     1523    if (hdr->rport_param != 5061) 
     1524        return -2850; 
     1525 
     1526    return 0; 
     1527} 
    14351528 
    14361529static int hdr_test(void) 
     
    15341627    pj_status_t status; 
    15351628 
     1629    status = hdr_test(); 
     1630    if (status != 0) 
     1631        return status; 
     1632 
    15361633    status = simple_test(); 
    15371634    if (status != PJ_SUCCESS) 
    15381635        return status; 
    15391636 
    1540     status = hdr_test(); 
    1541     if (status != 0) 
    1542         return status; 
    1543  
     1637#if INCLUDE_BENCHMARKS 
    15441638    for (i=0; i<COUNT; ++i) { 
    15451639        PJ_LOG(3,(THIS_FILE, "  benchmarking (%d of %d)..", i+1, COUNT)); 
     
    16091703                "The value is derived from msg-print-per-sec above."); 
    16101704 
     1705#endif  /* INCLUDE_BENCHMARKS */ 
    16111706 
    16121707    return PJ_SUCCESS; 
Note: See TracChangeset for help on using the changeset viewer.