Changeset 1225


Ignore:
Timestamp:
Apr 29, 2007 1:55:56 PM (17 years ago)
Author:
bennylp
Message:

Related to ticket #239: Error parsing quoted parameters

Location:
pjproject/branches/symbian/pjsip
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • pjproject/branches/symbian/pjsip/build/pjsip.dsw

    r238 r1225  
    106106############################################################################### 
    107107 
    108 Project: "pjsua"=.\pjsua.dsp - Package Owner=<4> 
     108Project: "pjsua"="..\..\pjsip-apps\build\pjsua.dsp" - Package Owner=<4> 
    109109 
    110110Package=<5> 
     
    171171    Project_Dep_Name pjsip_core 
    172172    End Project Dependency 
     173    Begin Project Dependency 
     174    Project_Dep_Name pjlib_util 
     175    End Project Dependency 
     176    Begin Project Dependency 
     177    Project_Dep_Name pjmedia 
     178    End Project Dependency 
     179    Begin Project Dependency 
     180    Project_Dep_Name pjmedia_codec 
     181    End Project Dependency 
     182    Begin Project Dependency 
     183    Project_Dep_Name pjsip_simple 
     184    End Project Dependency 
     185    Begin Project Dependency 
     186    Project_Dep_Name pjsip_ua 
     187    End Project Dependency 
    173188}}} 
    174189 
  • pjproject/branches/symbian/pjsip/src/pjsip/sip_parser.c

    r789 r1225  
    134134                                     pj_pool_t *pool, 
    135135                                     pj_str_t *pname,  
    136                                      pj_str_t *pvalue); 
     136                                     pj_str_t *pvalue, 
     137                                     unsigned option); 
    137138static void         int_parse_hparam( pj_scanner *scanner, 
    138139                                      pj_pool_t *pool, 
     
    981982/* Parse parameter (";" pname ["=" pvalue]). */ 
    982983static void int_parse_param( pj_scanner *scanner, pj_pool_t *pool, 
    983                              pj_str_t *pname, pj_str_t *pvalue) 
     984                             pj_str_t *pname, pj_str_t *pvalue, 
     985                             unsigned option) 
    984986{ 
    985987    /* Get ';' character */ 
     
    988990    /* Get pname and optionally pvalue */ 
    989991    pjsip_parse_param_imp(scanner, pool, pname, pvalue,  
    990                           PJSIP_PARSE_REMOVE_QUOTE); 
     992                          option); 
    991993} 
    992994 
     
    11991201        pj_str_t pname, pvalue; 
    12001202 
    1201         int_parse_param( scanner, pool, &pname, &pvalue); 
     1203        int_parse_param( scanner, pool, &pname, &pvalue, 0); 
    12021204 
    12031205        if (!parser_stricmp(pname, pjsip_USER_STR) && pvalue.slen) { 
     
    13551357                     &hdr->values[hdr->count]); 
    13561358        hdr->count++; 
     1359 
     1360        if (hdr->count >= PJSIP_GENERIC_ARRAY_MAX_COUNT) 
     1361            break; 
    13571362    } 
    13581363    parse_hdr_end(scanner); 
     
    14191424        pj_str_t pname, pvalue; 
    14201425 
    1421         int_parse_param( scanner, pool, &pname, &pvalue); 
     1426        int_parse_param( scanner, pool, &pname, &pvalue, 0); 
    14221427        if (!parser_stricmp(pname, pjsip_Q_STR) && pvalue.slen) { 
    14231428            char *dot_pos = (char *) memchr(pvalue.ptr, '.', pvalue.slen); 
     
    15131518    while (*scanner->curptr == ';') { 
    15141519        pj_str_t pname, pvalue; 
    1515         int_parse_param(scanner, ctx->pool, &pname, &pvalue); 
     1520        int_parse_param(scanner, ctx->pool, &pname, &pvalue, 0); 
    15161521        concat_param(&hdr->media.param, ctx->pool, &pname, &pvalue); 
    15171522    } 
     
    15661571        pj_str_t pname, pvalue; 
    15671572 
    1568         int_parse_param( scanner, pool, &pname, &pvalue); 
     1573        int_parse_param( scanner, pool, &pname, &pvalue, 0); 
    15691574 
    15701575        if (!parser_stricmp(pname, pjsip_TAG_STR)) { 
     
    16511656        pj_str_t pname, pvalue; 
    16521657 
    1653         int_parse_param( scanner, pool, &pname, &pvalue); 
     1658        int_parse_param( scanner, pool, &pname, &pvalue, 0); 
    16541659 
    16551660        if (!parser_stricmp(pname, pjsip_BRANCH_STR) && pvalue.slen) { 
     
    17141719        pjsip_param *p = (pjsip_param *)  
    17151720                         pj_pool_alloc(pool, sizeof(pjsip_param)); 
    1716         int_parse_param(scanner, pool, &p->name, &p->value); 
     1721        int_parse_param(scanner, pool, &p->name, &p->value, 0); 
    17171722        pj_list_insert_before(&hdr->other_param, p); 
    17181723    } 
  • pjproject/branches/symbian/pjsip/src/pjsip/sip_uri.c

    r789 r1225  
    111111        if (p->value.slen) { 
    112112            *buf++ = '='; 
    113             copy_advance_escape(buf, p->value, (*pvalue_spec)); 
     113            if (*p->value.ptr == '"') 
     114                copy_advance(buf, p->value); 
     115            else 
     116                copy_advance_escape(buf, p->value, (*pvalue_spec)); 
    114117        } 
    115118        p = p->next; 
  • pjproject/branches/symbian/pjsip/src/test-pjsip/msg_logger.c

    r127 r1225  
    6464    -1,                                 /* Id                   */ 
    6565    PJSIP_MOD_PRIORITY_TRANSPORT_LAYER-1,/* Priority            */ 
    66     NULL,                               /* User data.           */ 
    6766    NULL,                               /* load()               */ 
    6867    NULL,                               /* start()              */ 
  • pjproject/branches/symbian/pjsip/src/test-pjsip/msg_test.c

    r127 r1225  
    674674 
    675675/*****************************************************************************/ 
     676/* Test various header parsing and production */ 
     677static int hdr_test_success(pjsip_hdr *h); 
     678static int hdr_test_accept1(pjsip_hdr *h); 
     679static int hdr_test_accept2(pjsip_hdr *h); 
     680static int hdr_test_authorization(pjsip_hdr *h); 
     681static int hdr_test_cid(pjsip_hdr *h); 
     682static int hdr_test_contact0(pjsip_hdr *h); 
     683static int hdr_test_contact1(pjsip_hdr *h); 
     684static int hdr_test_content_length(pjsip_hdr *h); 
     685static int hdr_test_content_type(pjsip_hdr *h); 
     686static int hdr_test_from(pjsip_hdr *h); 
     687static int hdr_test_proxy_authenticate(pjsip_hdr *h); 
     688static int hdr_test_record_route(pjsip_hdr *h); 
     689static int hdr_test_to(pjsip_hdr *h); 
     690static int hdr_test_via(pjsip_hdr *h); 
     691 
     692 
     693 
     694#define GENERIC_PARAM        "p0=a;p1=\"ab:;cd\";p3" 
     695#define GENERIC_PARAM_PARSED "p0=a;p1=\"ab:;cd\";p3" 
     696#define PARAM_CHAR           "[]/:&+$" 
     697#define SIMPLE_ADDR_SPEC     "sip:host" 
     698#define ADDR_SPEC            SIMPLE_ADDR_SPEC ";" PARAM_CHAR "=" PARAM_CHAR 
     699#define NAME_ADDR            "<" ADDR_SPEC ">" 
     700 
     701#define HDR_FLAG_PARSE_FAIL 1 
     702#define HDR_FLAG_DONT_PRINT 2 
     703 
     704#define TEST_EMPTY_HDR      0 
     705 
     706struct hdr_test_t 
     707{ 
     708    char *hname; 
     709    char *hshort_name; 
     710    char *hcontent; 
     711    int  (*test)(pjsip_hdr*); 
     712    unsigned flags; 
     713} hdr_test_data[] = 
     714{ 
     715    { 
     716        /* Overflowing generic string header */ 
     717        "Accept", NULL, 
     718        "a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, " \ 
     719        "a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, " \ 
     720        "a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, " \ 
     721        "a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, " \ 
     722        "a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, " \ 
     723        "a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, " \ 
     724        "a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, " \ 
     725        "a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a", 
     726        &hdr_test_success, 
     727        HDR_FLAG_PARSE_FAIL 
     728    }, 
     729 
     730    { 
     731        /* Normal Accept */ 
     732        "Accept", NULL, 
     733        "application/*, text/plain", 
     734        &hdr_test_accept1 
     735    }, 
     736 
     737    { 
     738        /* Accept with params */ 
     739        "Accept", NULL, 
     740        "application/*;p1=v1, text/plain", 
     741        &hdr_test_accept2 
     742    }, 
     743 
     744    { 
     745        /* Authorization, testing which params should be quoted */ 
     746        "Authorization", NULL, 
     747        "Digest username=\"username\", realm=\"realm\", nonce=\"nonce\", "  \ 
     748                "uri=\"sip:domain\", response=\"RESPONSE\", algorithm=MD5, "    \ 
     749                "cnonce=\"CNONCE\", opaque=\"OPAQUE\", qop=auth, nc=00000001", 
     750        &hdr_test_authorization 
     751    }, 
     752 
     753    { 
     754        /* Call ID */ 
     755        "Call-ID", "i", 
     756        "-.!%*_+`'~()<>:\\\"/[]?{}", 
     757        &hdr_test_cid, 
     758    }, 
     759 
     760    { 
     761        /* Parameter belong to hparam */ 
     762        "Contact", "m", 
     763        SIMPLE_ADDR_SPEC ";p1=v1", 
     764        &hdr_test_contact0, 
     765        HDR_FLAG_DONT_PRINT 
     766    }, 
     767 
     768    { 
     769        /* generic-param in Contact header */ 
     770        "Contact", "m", 
     771        NAME_ADDR ";" GENERIC_PARAM, 
     772        &hdr_test_contact1 
     773    }, 
     774 
     775    { 
     776        /* Content-Length */ 
     777        "Content-Length", "l", 
     778        "10", 
     779        &hdr_test_content_length 
     780    }, 
     781 
     782    { 
     783        /* Content-Type, with generic-param */ 
     784        "Content-Type", "c", 
     785        "application/sdp" ";" GENERIC_PARAM, 
     786        &hdr_test_content_type, 
     787        HDR_FLAG_DONT_PRINT 
     788    }, 
     789 
     790    { 
     791        /* From, testing parameters and generic-param */ 
     792        "From", "f", 
     793        NAME_ADDR ";" GENERIC_PARAM, 
     794        &hdr_test_from 
     795    }, 
     796 
     797    { 
     798        /* Proxy-Authenticate, testing which params should be quoted */ 
     799        "Proxy-Authenticate", NULL, 
     800        "Digest  realm=\"realm\",domain=\"sip:domain\",nonce=\"nonce\","  \ 
     801                "opaque=\"opaque\",stale=true,algorithm=MD5,qop=\"auth\"", 
     802        &hdr_test_proxy_authenticate 
     803    }, 
     804 
     805    { 
     806        /* Record-Route, param belong to header */ 
     807        "Record-Route", NULL, 
     808        NAME_ADDR ";" GENERIC_PARAM, 
     809        &hdr_test_record_route 
     810    }, 
     811 
     812    { 
     813        /* To */ 
     814        "To", "t", 
     815        NAME_ADDR ";" GENERIC_PARAM, 
     816        &hdr_test_to 
     817    }, 
     818 
     819    { 
     820        /* Via */ 
     821        "Via", "v", 
     822        "SIP/2.0/XYZ host" ";" GENERIC_PARAM, 
     823        &hdr_test_via 
     824    } 
     825}; 
     826 
     827static int hdr_test_success(pjsip_hdr *h) 
     828{ 
     829    PJ_UNUSED_ARG(h); 
     830    return 0; 
     831} 
     832 
     833/* "application/*, text/plain\r\n" */ 
     834static int hdr_test_accept1(pjsip_hdr *h) 
     835{ 
     836    pjsip_accept_hdr *hdr = (pjsip_accept_hdr*)h; 
     837 
     838    if (h->type != PJSIP_H_ACCEPT) 
     839        return -1110; 
     840 
     841    if (hdr->count != 2) 
     842        return -1120; 
     843 
     844    if (pj_strcmp2(&hdr->values[0], "application/*")) 
     845        return -1130; 
     846 
     847    if (pj_strcmp2(&hdr->values[1], "text/plain")) 
     848        return -1140; 
     849 
     850    return 0; 
     851} 
     852 
     853/* "application/*;p1=v1, text/plain\r\n" */ 
     854static int hdr_test_accept2(pjsip_hdr *h) 
     855{ 
     856    pjsip_accept_hdr *hdr = (pjsip_accept_hdr*)h; 
     857 
     858    if (h->type != PJSIP_H_ACCEPT) 
     859        return -1210; 
     860 
     861    if (hdr->count != 2) 
     862        return -1220; 
     863 
     864    if (pj_strcmp2(&hdr->values[0], "application/*;p1=v1")) 
     865        return -1230; 
     866 
     867    if (pj_strcmp2(&hdr->values[1], "text/plain")) 
     868        return -1240; 
     869 
     870    return 0; 
     871} 
     872 
     873/* 
     874        "Digest username=\"username\", realm=\"realm\", nonce=\"nonce\", "  \ 
     875                "uri=\"sip:domain\", response=\"RESPONSE\", algorithm=MD5, "    \ 
     876                "cnonce=\"CNONCE\", opaque=\"OPAQUE\", qop=auth, nc=00000001", 
     877 */ 
     878static int hdr_test_authorization(pjsip_hdr *h) 
     879{ 
     880    pjsip_authorization_hdr *hdr = (pjsip_authorization_hdr*)h; 
     881 
     882    if (h->type != PJSIP_H_AUTHORIZATION) 
     883        return -1410; 
     884 
     885    if (pj_strcmp2(&hdr->scheme, "Digest")) 
     886        return -1420; 
     887 
     888    if (pj_strcmp2(&hdr->credential.digest.username, "username")) 
     889        return -1421; 
     890 
     891    if (pj_strcmp2(&hdr->credential.digest.realm, "realm")) 
     892        return -1422; 
     893 
     894    if (pj_strcmp2(&hdr->credential.digest.nonce, "nonce")) 
     895        return -1423; 
     896 
     897    if (pj_strcmp2(&hdr->credential.digest.uri, "sip:domain")) 
     898        return -1424; 
     899 
     900    if (pj_strcmp2(&hdr->credential.digest.response, "RESPONSE")) 
     901        return -1425; 
     902 
     903    if (pj_strcmp2(&hdr->credential.digest.algorithm, "MD5")) 
     904        return -1426; 
     905 
     906    if (pj_strcmp2(&hdr->credential.digest.cnonce, "CNONCE")) 
     907        return -1427; 
     908 
     909    if (pj_strcmp2(&hdr->credential.digest.opaque, "OPAQUE")) 
     910        return -1428; 
     911 
     912    if (pj_strcmp2(&hdr->credential.digest.qop, "auth")) 
     913        return -1429; 
     914 
     915    if (pj_strcmp2(&hdr->credential.digest.nc, "00000001")) 
     916        return -1430; 
     917 
     918    return 0; 
     919} 
     920 
     921 
     922/* 
     923    "-.!%*_+`'~()<>:\\\"/[]?{}\r\n" 
     924 */ 
     925static int hdr_test_cid(pjsip_hdr *h) 
     926{ 
     927    pjsip_cid_hdr *hdr = (pjsip_cid_hdr*)h; 
     928 
     929    if (h->type != PJSIP_H_CALL_ID) 
     930        return -1510; 
     931 
     932    if (pj_strcmp2(&hdr->id, "-.!%*_+`'~()<>:\\\"/[]?{}\r\n")) 
     933        return -1520; 
     934 
     935    return 0; 
     936} 
     937 
     938/* 
     939 #define SIMPLE_ADDR_SPEC    "sip:host" 
     940 */ 
     941static int test_simple_addr_spec(pjsip_uri *uri) 
     942{ 
     943    pjsip_sip_uri *sip_uri = (pjsip_sip_uri *)pjsip_uri_get_uri(uri); 
     944 
     945    if (!PJSIP_URI_SCHEME_IS_SIP(uri)) 
     946        return -900; 
     947 
     948    if (pj_strcmp2(&sip_uri->host, "host")) 
     949        return -910; 
     950 
     951    if (sip_uri->port != 0) 
     952        return -920; 
     953 
     954    return 0; 
     955} 
     956 
     957/*  
     958#define PARAM_CHAR          "[]/:&+$" 
     959#define SIMPLE_ADDR_SPEC    "sip:host" 
     960#define ADDR_SPEC           SIMPLE_ADDR_SPEC ";" PARAM_CHAR "=" PARAM_CHAR 
     961#define NAME_ADDR           "<" ADDR_SPEC ">" 
     962 */ 
     963static int nameaddr_test(pjsip_uri *uri) 
     964{ 
     965    pjsip_sip_uri *sip_uri = (pjsip_sip_uri *)pjsip_uri_get_uri(uri); 
     966    pjsip_param *param; 
     967    int rc; 
     968 
     969    if (!PJSIP_URI_SCHEME_IS_SIP(uri)) 
     970        return -930; 
     971 
     972    rc = test_simple_addr_spec((pjsip_uri*)sip_uri); 
     973    if (rc != 0) 
     974        return rc; 
     975 
     976    if (pj_list_size(&sip_uri->other_param) != 1) 
     977        return -940; 
     978 
     979    param = sip_uri->other_param.next; 
     980 
     981    if (pj_strcmp2(&param->name, PARAM_CHAR)) 
     982        return -942; 
     983 
     984    if (pj_strcmp2(&param->value, PARAM_CHAR)) 
     985        return -943; 
     986 
     987    return 0; 
     988} 
     989 
     990/* 
     991#define GENERIC_PARAM  "p0=a;p1=\"ab:;cd\";p3" 
     992 */ 
     993static int generic_param_test(pjsip_param *param_head) 
     994{ 
     995    pjsip_param *param; 
     996 
     997    if (pj_list_size(param_head) != 3) 
     998        return -950; 
     999 
     1000    param = param_head->next; 
     1001 
     1002    if (pj_strcmp2(&param->name, "p0")) 
     1003        return -952; 
     1004    if (pj_strcmp2(&param->value, "a")) 
     1005        return -953; 
     1006 
     1007    param = param->next; 
     1008    if (pj_strcmp2(&param->name, "p1")) 
     1009        return -954; 
     1010    if (pj_strcmp2(&param->value, "\"ab:;cd\"")) 
     1011        return -955; 
     1012 
     1013    param = param->next; 
     1014    if (pj_strcmp2(&param->name, "p3")) 
     1015        return -958; 
     1016    if (pj_strcmp2(&param->value, "")) 
     1017        return -959; 
     1018 
     1019    return 0; 
     1020} 
     1021 
     1022 
     1023 
     1024/* 
     1025    SIMPLE_ADDR_SPEC ";p1=v1\r\n" 
     1026 */ 
     1027static int hdr_test_contact0(pjsip_hdr *h) 
     1028{ 
     1029    pjsip_contact_hdr *hdr = (pjsip_contact_hdr*)h; 
     1030    pjsip_param *param; 
     1031    int rc; 
     1032 
     1033    if (h->type != PJSIP_H_CONTACT) 
     1034        return -1610; 
     1035 
     1036    rc = test_simple_addr_spec(hdr->uri); 
     1037    if (rc != 0) 
     1038        return rc; 
     1039 
     1040    if (pj_list_size(&hdr->other_param) != 1) 
     1041        return -1620; 
     1042 
     1043    param = hdr->other_param.next; 
     1044 
     1045    if (pj_strcmp2(&param->name, "p1")) 
     1046        return -1630; 
     1047 
     1048    if (pj_strcmp2(&param->value, "v1")) 
     1049        return -1640; 
     1050 
     1051    return 0; 
     1052} 
     1053 
     1054/* 
     1055    NAME_ADDR GENERIC_PARAM "\r\n",     
     1056 */ 
     1057static int hdr_test_contact1(pjsip_hdr *h) 
     1058{ 
     1059    pjsip_contact_hdr *hdr = (pjsip_contact_hdr*)h; 
     1060    int rc; 
     1061 
     1062    if (h->type != PJSIP_H_CONTACT) 
     1063        return -1710; 
     1064 
     1065    rc = nameaddr_test(hdr->uri); 
     1066    if (rc != 0) 
     1067        return rc; 
     1068 
     1069    rc = generic_param_test(&hdr->other_param); 
     1070    if (rc != 0) 
     1071        return rc; 
     1072 
     1073    return 0; 
     1074} 
     1075 
     1076/* 
     1077    "10" 
     1078 */ 
     1079static int hdr_test_content_length(pjsip_hdr *h) 
     1080{ 
     1081    pjsip_clen_hdr *hdr = (pjsip_clen_hdr*)h; 
     1082 
     1083    if (h->type != PJSIP_H_CONTENT_LENGTH) 
     1084        return -1810; 
     1085 
     1086    if (hdr->len != 10) 
     1087        return -1820; 
     1088 
     1089    return 0; 
     1090} 
     1091 
     1092/* 
     1093    "application/sdp" GENERIC_PARAM, 
     1094 */ 
     1095static int hdr_test_content_type(pjsip_hdr *h) 
     1096{ 
     1097    pjsip_ctype_hdr *hdr = (pjsip_ctype_hdr*)h; 
     1098 
     1099    if (h->type != PJSIP_H_CONTENT_TYPE) 
     1100        return -1910; 
     1101 
     1102    if (pj_strcmp2(&hdr->media.type, "application")) 
     1103        return -1920; 
     1104 
     1105    if (pj_strcmp2(&hdr->media.subtype, "sdp")) 
     1106        return -1930; 
     1107 
     1108    /* Currently, if the media parameter contains escaped characters, 
     1109     * pjsip will print the parameter unescaped. 
     1110     */ 
     1111    PJ_TODO(FIX_PARAMETER_IN_MEDIA_TYPE); 
     1112 
     1113    if (pj_strcmp2(&hdr->media.param, ";" GENERIC_PARAM_PARSED)) 
     1114        return -1940; 
     1115 
     1116    return 0; 
     1117} 
     1118 
     1119/* 
     1120    NAME_ADDR GENERIC_PARAM, 
     1121 */ 
     1122static int hdr_test_from(pjsip_hdr *h) 
     1123{ 
     1124    pjsip_from_hdr *hdr = (pjsip_from_hdr*)h; 
     1125    int rc; 
     1126 
     1127    if (h->type != PJSIP_H_FROM) 
     1128        return -2010; 
     1129 
     1130    rc = nameaddr_test(hdr->uri); 
     1131    if (rc != 0) 
     1132        return rc; 
     1133 
     1134    rc = generic_param_test(&hdr->other_param); 
     1135    if (rc != 0) 
     1136        return rc; 
     1137 
     1138    return 0; 
     1139} 
     1140 
     1141/* 
     1142        "Digest realm=\"realm\", domain=\"sip:domain\", nonce=\"nonce\", "  \ 
     1143                "opaque=\"opaque\", stale=true, algorithm=MD5, qop=\"auth\"", 
     1144 */ 
     1145static int hdr_test_proxy_authenticate(pjsip_hdr *h) 
     1146{ 
     1147    pjsip_proxy_authenticate_hdr *hdr = (pjsip_proxy_authenticate_hdr*)h; 
     1148 
     1149    if (h->type != PJSIP_H_PROXY_AUTHENTICATE) 
     1150        return -2110; 
     1151 
     1152    if (pj_strcmp2(&hdr->scheme, "Digest")) 
     1153        return -2120; 
     1154 
     1155    if (pj_strcmp2(&hdr->challenge.digest.realm, "realm")) 
     1156        return -2130; 
     1157 
     1158    if (pj_strcmp2(&hdr->challenge.digest.domain, "sip:domain")) 
     1159        return -2140; 
     1160 
     1161    if (pj_strcmp2(&hdr->challenge.digest.nonce, "nonce")) 
     1162        return -2150; 
     1163 
     1164    if (pj_strcmp2(&hdr->challenge.digest.opaque, "opaque")) 
     1165        return -2160; 
     1166 
     1167    if (hdr->challenge.digest.stale != 1) 
     1168        return -2170; 
     1169 
     1170    if (pj_strcmp2(&hdr->challenge.digest.algorithm, "MD5")) 
     1171        return -2180; 
     1172 
     1173    if (pj_strcmp2(&hdr->challenge.digest.qop, "auth")) 
     1174        return -2190; 
     1175 
     1176    return 0; 
     1177} 
     1178 
     1179/* 
     1180    NAME_ADDR GENERIC_PARAM, 
     1181 */ 
     1182static int hdr_test_record_route(pjsip_hdr *h) 
     1183{ 
     1184    pjsip_rr_hdr *hdr = (pjsip_rr_hdr*)h; 
     1185    int rc; 
     1186 
     1187    if (h->type != PJSIP_H_RECORD_ROUTE) 
     1188        return -2210; 
     1189 
     1190    rc = nameaddr_test((pjsip_uri*)&hdr->name_addr); 
     1191    if (rc != 0) 
     1192        return rc; 
     1193 
     1194    rc = generic_param_test(&hdr->other_param); 
     1195    if (rc != 0) 
     1196        return rc; 
     1197 
     1198    return 0; 
     1199 
     1200} 
     1201 
     1202/* 
     1203    NAME_ADDR GENERIC_PARAM, 
     1204 */ 
     1205static int hdr_test_to(pjsip_hdr *h) 
     1206{ 
     1207    pjsip_to_hdr *hdr = (pjsip_to_hdr*)h; 
     1208    int rc; 
     1209 
     1210    if (h->type != PJSIP_H_TO) 
     1211        return -2410; 
     1212 
     1213    rc = nameaddr_test(hdr->uri); 
     1214    if (rc != 0) 
     1215        return rc; 
     1216 
     1217    rc = generic_param_test(&hdr->other_param); 
     1218    if (rc != 0) 
     1219        return rc; 
     1220 
     1221    return 0; 
     1222} 
     1223 
     1224/* 
     1225    "SIP/2.0 host" GENERIC_PARAM 
     1226 */ 
     1227static int hdr_test_via(pjsip_hdr *h) 
     1228{ 
     1229    pjsip_via_hdr *hdr = (pjsip_via_hdr*)h; 
     1230    int rc; 
     1231 
     1232    if (h->type != PJSIP_H_VIA) 
     1233        return -2510; 
     1234 
     1235    if (pj_strcmp2(&hdr->transport, "XYZ")) 
     1236        return -2515; 
     1237 
     1238    if (pj_strcmp2(&hdr->sent_by.host, "host")) 
     1239        return -2520; 
     1240 
     1241    if (hdr->sent_by.port != 0) 
     1242        return -2530; 
     1243 
     1244    rc = generic_param_test(&hdr->other_param); 
     1245    if (rc != 0) 
     1246        return rc; 
     1247 
     1248    return 0; 
     1249} 
     1250 
     1251 
     1252static int hdr_test(void) 
     1253{ 
     1254    unsigned i; 
     1255 
     1256    PJ_LOG(3,(THIS_FILE, "  testing header parsing..")); 
     1257 
     1258    for (i=0; i<PJ_ARRAY_SIZE(hdr_test_data); ++i) { 
     1259        struct hdr_test_t  *test = &hdr_test_data[i]; 
     1260        pj_str_t hname; 
     1261        int len, parsed_len; 
     1262        pj_pool_t *pool; 
     1263        pjsip_hdr *parsed_hdr1=NULL, *parsed_hdr2=NULL; 
     1264        char *input, *output; 
     1265        int rc; 
     1266 
     1267        pool = pjsip_endpt_create_pool(endpt, NULL, POOL_SIZE, POOL_SIZE); 
     1268 
     1269        /* Parse the header */ 
     1270        hname = pj_str(test->hname); 
     1271        len = strlen(test->hcontent); 
     1272        parsed_hdr1 = pjsip_parse_hdr(pool, &hname, test->hcontent, len, &parsed_len); 
     1273        if (parsed_hdr1 == NULL) { 
     1274            if (test->flags & HDR_FLAG_PARSE_FAIL) { 
     1275                pj_pool_release(pool); 
     1276                continue; 
     1277            } 
     1278            PJ_LOG(3,(THIS_FILE, "    error parsing header %s: %s", test->hname, test->hcontent)); 
     1279            return -500; 
     1280        } 
     1281 
     1282        /* Test the parsing result */ 
     1283        if (test->test && (rc=test->test(parsed_hdr1)) != 0) { 
     1284            PJ_LOG(3,(THIS_FILE, "    validation failed for header %s: %s", test->hname, test->hcontent)); 
     1285            PJ_LOG(3,(THIS_FILE, "    error code is %d", rc)); 
     1286            return -502; 
     1287        } 
     1288 
     1289#if 1 
     1290        /* Parse with hshortname, if present */ 
     1291        if (test->hshort_name) { 
     1292            hname = pj_str(test->hshort_name); 
     1293            len = strlen(test->hcontent); 
     1294            parsed_hdr2 = pjsip_parse_hdr(pool, &hname, test->hcontent, len, &parsed_len); 
     1295            if (parsed_hdr2 == NULL) { 
     1296                PJ_LOG(3,(THIS_FILE, "    error parsing header %s: %s", test->hshort_name, test->hcontent)); 
     1297                return -510; 
     1298            } 
     1299        } 
     1300#endif 
     1301 
     1302        if (test->flags & HDR_FLAG_DONT_PRINT) { 
     1303            pj_pool_release(pool); 
     1304            continue; 
     1305        } 
     1306 
     1307        /* Print the original header */ 
     1308        input = pj_pool_alloc(pool, 1024); 
     1309        len = pj_ansi_snprintf(input, 1024, "%s: %s", test->hname, test->hcontent); 
     1310        if (len < 1 || len >= 1024) 
     1311            return -520; 
     1312 
     1313        /* Print the parsed header*/ 
     1314        output = pj_pool_alloc(pool, 1024); 
     1315        len = pjsip_hdr_print_on(parsed_hdr1, output, 1024); 
     1316        if (len < 1 || len >= 1024) { 
     1317            PJ_LOG(3,(THIS_FILE, "    header too long: %s: %s", test->hname, test->hcontent)); 
     1318            return -530; 
     1319        } 
     1320        output[len] = 0; 
     1321 
     1322        if (strcmp(input, output) != 0) { 
     1323            PJ_LOG(3,(THIS_FILE, "    header character by character comparison failed.")); 
     1324            PJ_LOG(3,(THIS_FILE, "    original header=|%s|", input)); 
     1325            PJ_LOG(3,(THIS_FILE, "    parsed header  =|%s|", output)); 
     1326            return -540; 
     1327        } 
     1328 
     1329        pj_pool_release(pool); 
     1330    } 
     1331 
     1332    return 0; 
     1333}  
     1334 
     1335/*****************************************************************************/ 
    6761336 
    6771337int msg_test(void) 
     
    6931353            return status; 
    6941354    } 
     1355 
     1356    i = hdr_test(); 
     1357    if (i != 0) 
     1358        return i; 
    6951359 
    6961360    PJ_LOG(3,(THIS_FILE, "  benchmarking..")); 
  • pjproject/branches/symbian/pjsip/src/test-pjsip/test.c

    r127 r1225  
    1919 
    2020 
    21 #include "test.h" 
    2221#include <pjlib.h> 
    2322#include <pjsip.h> 
     23#include "test.h" 
    2424 
    2525#define THIS_FILE   "test.c" 
     
    4545    PJ_CHECK_STACK(); 
    4646 
    47     pjsip_strerror(rc, errbuf, sizeof(errbuf)); 
     47    pj_strerror(rc, errbuf, sizeof(errbuf)); 
    4848    PJ_LOG(3,(THIS_FILE, "%s: [pj_status_t=%d] %s", msg, rc, errbuf)); 
    4949 
     
    9696    pj_dump_config(); 
    9797 
    98     pj_caching_pool_init( &caching_pool, &pj_pool_factory_default_policy, 0 ); 
     98    pj_caching_pool_init( &caching_pool, pj_pool_factory_get_default_policy(), 0 ); 
    9999 
    100100    rc = pjsip_endpt_create(&caching_pool.factory, "endpt", &endpt); 
     
    112112 
    113113    /* Start transaction layer module. */ 
    114     rc = pjsip_tsx_layer_init(endpt); 
     114    rc = pjsip_tsx_layer_init_module(endpt); 
    115115    if (rc != PJ_SUCCESS) { 
    116116        app_perror("   Error initializing transaction module", rc); 
     
    127127 
    128128    //DO_TEST(uri_test()); 
    129     //DO_TEST(msg_test()); 
     129    DO_TEST(msg_test()); 
    130130    //DO_TEST(txdata_test()); 
    131131    //DO_TEST(transport_udp_test()); 
  • pjproject/branches/symbian/pjsip/src/test-pjsip/tsx_uac_test.c

    r127 r1225  
    103103    -1,                                 /* Id                   */ 
    104104    PJSIP_MOD_PRIORITY_APPLICATION-1,   /* Priority             */ 
    105     NULL,                               /* User data.           */ 
    106105    NULL,                               /* load()               */ 
    107106    NULL,                               /* start()              */ 
     
    122121    -1,                                 /* Id                   */ 
    123122    PJSIP_MOD_PRIORITY_APPLICATION-1,   /* Priority             */ 
    124     NULL,                               /* User data.           */ 
    125123    NULL,                               /* load()               */ 
    126124    NULL,                               /* start()              */ 
  • pjproject/branches/symbian/pjsip/src/test-pjsip/tsx_uas_test.c

    r160 r1225  
    142142    -1,                                 /* Id                   */ 
    143143    PJSIP_MOD_PRIORITY_APPLICATION-1,   /* Priority             */ 
    144     NULL,                               /* User data.           */ 
    145144    NULL,                               /* load()               */ 
    146145    NULL,                               /* start()              */ 
     
    161160    -1,                                 /* Id                   */ 
    162161    PJSIP_MOD_PRIORITY_APPLICATION-1,   /* Priority             */ 
    163     NULL,                               /* User data.           */ 
    164162    NULL,                               /* load()               */ 
    165163    NULL,                               /* start()              */ 
Note: See TracChangeset for help on using the changeset viewer.