Changeset 612
- Timestamp:
- Jul 18, 2006 2:39:40 PM (18 years ago)
- Location:
- pjproject/trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip-apps/src/pjsua/pjsua_app.c
r597 r612 138 138 static void default_config(struct app_config *cfg) 139 139 { 140 char tmp[80]; 141 140 142 pjsua_config_default(&cfg->cfg); 143 pj_ansi_sprintf(tmp, "PJSUA v%s/%s", PJ_VERSION, PJ_OS_NAME); 144 pj_strdup2_with_null(app_config.pool, &cfg->cfg.user_agent, tmp); 145 141 146 pjsua_logging_config_default(&cfg->log_cfg); 142 147 pjsua_media_config_default(&cfg->media_cfg); … … 473 478 case OPT_NEXT_ACCOUNT: /* Add more account. */ 474 479 cfg->acc_cnt++; 475 cur_acc = &cfg->acc_cfg[cfg->acc_cnt - 1];480 cur_acc = &cfg->acc_cfg[cfg->acc_cnt]; 476 481 break; 477 482 … … 665 670 } 666 671 667 if (cfg->acc_cfg[ 0].id.slen && cfg->acc_cnt==0)668 cfg->acc_cnt = 1;672 if (cfg->acc_cfg[cfg->acc_cnt].id.slen) 673 cfg->acc_cnt++; 669 674 670 675 for (i=0; i<cfg->acc_cnt; ++i) { … … 1307 1312 puts("| | cc Connect port | dd Dump detailed |"); 1308 1313 puts("| | cd Disconnect port | dc Dump config |"); 1309 puts("| 1314 puts("| S Send arbitrary REQUEST | | f Save config |"); 1310 1315 puts("+------------------------------+--------------------------+-------------------+"); 1311 1316 puts("| q QUIT |"); … … 1460 1465 } 1461 1466 puts(""); 1467 } 1468 1469 1470 /* 1471 * Send arbitrary request to remote host 1472 */ 1473 static void send_request(char *cstr_method, const pj_str_t *dst_uri) 1474 { 1475 pj_str_t str_method; 1476 pjsip_method method; 1477 pjsip_tx_data *tdata; 1478 pjsua_acc_info acc_info; 1479 pjsip_endpoint *endpt; 1480 pj_status_t status; 1481 1482 endpt = pjsua_get_pjsip_endpt(); 1483 1484 str_method = pj_str(cstr_method); 1485 pjsip_method_init_np(&method, &str_method); 1486 1487 pjsua_acc_get_info(current_acc, &acc_info); 1488 1489 status = pjsip_endpt_create_request(endpt, &method, dst_uri, 1490 &acc_info.acc_uri, dst_uri, 1491 NULL, NULL, -1, NULL, &tdata); 1492 if (status != PJ_SUCCESS) { 1493 pjsua_perror(THIS_FILE, "Unable to create request", status); 1494 return; 1495 } 1496 1497 status = pjsip_endpt_send_request(endpt, tdata, -1, NULL, NULL); 1498 if (status != PJ_SUCCESS) { 1499 pjsua_perror(THIS_FILE, "Unable to send request", status); 1500 pjsip_tx_data_dec_ref(tdata); 1501 return; 1502 } 1462 1503 } 1463 1504 … … 1892 1933 } 1893 1934 } 1935 break; 1936 1937 case 'S': 1938 /* 1939 * Send arbitrary request 1940 */ 1941 if (pjsua_acc_get_count() == 0) { 1942 puts("Sorry, need at least one account configured"); 1943 break; 1944 } 1945 1946 puts("Send arbitrary request to remote host"); 1947 1948 /* Input METHOD */ 1949 if (!simple_input("Request method:",text,sizeof(text))) 1950 break; 1951 1952 /* Input destination URI */ 1953 uri = NULL; 1954 ui_input_url("Destination URI", buf, sizeof(buf), &result); 1955 if (result.nb_result != NO_NB) { 1956 1957 if (result.nb_result == -1 || result.nb_result == 0) { 1958 puts("Sorry you can't do that!"); 1959 continue; 1960 } else { 1961 pjsua_buddy_info binfo; 1962 pjsua_buddy_get_info(result.nb_result-1, &binfo); 1963 uri = binfo.uri.ptr; 1964 } 1965 1966 } else if (result.uri_result) { 1967 uri = result.uri_result; 1968 } 1969 1970 tmp = pj_str(uri); 1971 1972 send_request(text, &tmp); 1894 1973 break; 1895 1974 -
pjproject/trunk/pjsip/include/pjsip-simple/evsub.h
r515 r612 253 253 const pj_str_t accept[]); 254 254 255 /** 256 * Get the Allow-Events header. This header is built based on the packages 257 * that are registered to the evsub module. 258 * 259 * @param m Pointer to event subscription module instance, or 260 * NULL to use default instance (equal to 261 * #pjsip_evsub_instance()). 262 * 263 * @return The Allow-Events header. 264 */ 265 PJ_DECL(const pjsip_hdr*) pjsip_evsub_get_allow_events_hdr(pjsip_module *m); 266 255 267 256 268 /** -
pjproject/trunk/pjsip/include/pjsip-ua/sip_inv.h
r515 r612 616 616 617 617 618 /** 619 * This is a utility function to create SIP body for SDP content. 620 * 621 * @param pool Pool to allocate memory. 622 * @param sdp SDP session to be put in the SIP message body. 623 * @param p_body Pointer to receive SIP message body containing 624 * the SDP session. 625 * 626 * @return PJ_SUCCESS on success. 627 */ 628 PJ_DECL(pj_status_t) pjsip_create_sdp_body(pj_pool_t *pool, 629 pjmedia_sdp_session *sdp, 630 pjsip_msg_body **p_body); 631 632 618 633 PJ_END_DECL 619 634 -
pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h
r611 r612 418 418 pjsua_callback cb; 419 419 420 /** 421 * User agent string (default empty) 422 */ 423 pj_str_t user_agent; 424 420 425 } pjsua_config; 421 426 … … 469 474 pjsip_cred_dup(pool, &dst->cred_info[i], &src->cred_info[i]); 470 475 } 476 477 pj_strdup_with_null(pool, &dst->user_agent, &src->user_agent); 471 478 } 472 479 … … 2081 2088 * number. 2082 2089 * 2083 * Default: 3.2090 * Default: 5. 2084 2091 */ 2085 2092 unsigned quality; … … 2100 2107 cfg->has_ioqueue = PJ_TRUE; 2101 2108 cfg->thread_cnt = 1; 2102 cfg->quality = 3;2109 cfg->quality = 5; 2103 2110 } 2104 2111 -
pjproject/trunk/pjsip/src/pjsip-simple/evsub.c
r424 r612 421 421 } 422 422 423 /* Add to endpoint's Accept header */ 424 pjsip_endpt_add_capability(mod_evsub.endpt, &mod_evsub.mod, 425 PJSIP_H_ACCEPT, NULL, 426 pkg->pkg_accept->count, 427 pkg->pkg_accept->values); 428 423 429 424 430 /* Done */ … … 431 437 } 432 438 439 440 /* 441 * Retrieve Allow-Events header 442 */ 443 PJ_DEF(const pjsip_hdr*) pjsip_evsub_get_allow_events_hdr(pjsip_module *m) 444 { 445 struct mod_evsub *mod; 446 447 if (m == NULL) 448 m = pjsip_evsub_instance(); 449 450 mod = (struct mod_evsub*)m; 451 452 return (pjsip_hdr*) mod->allow_events_hdr; 453 } 433 454 434 455 -
pjproject/trunk/pjsip/src/pjsip-ua/sip_inv.c
r576 r612 113 113 { 114 114 pj_str_t allowed[] = {{"INVITE", 6}, {"ACK",3}, {"BYE",3}, {"CANCEL",6}}; 115 pj_str_t accepted = { "application/sdp", 15 }; 115 116 116 117 /* Register supported methods: INVITE, ACK, BYE, CANCEL */ 117 118 pjsip_endpt_add_capability(endpt, &mod_inv.mod, PJSIP_H_ALLOW, NULL, 118 119 PJ_ARRAY_SIZE(allowed), allowed); 120 121 /* Register "application/sdp" in Accept header */ 122 pjsip_endpt_add_capability(endpt, &mod_inv.mod, PJSIP_H_ACCEPT, NULL, 123 1, &accepted); 119 124 120 125 return PJ_SUCCESS; … … 960 965 } 961 966 962 static pjsip_msg_body *create_sdp_body(pj_pool_t *pool, 963 const pjmedia_sdp_session *c_sdp) 964 { 967 968 PJ_DEF(pj_status_t) pjsip_create_sdp_body( pj_pool_t *pool, 969 pjmedia_sdp_session *sdp, 970 pjsip_msg_body **p_body) 971 { 972 const pj_str_t STR_APPLICATION = { "application", 11}; 973 const pj_str_t STR_SDP = { "sdp", 3 }; 965 974 pjsip_msg_body *body; 966 975 967 968 976 body = pj_pool_zalloc(pool, sizeof(pjsip_msg_body)); 969 PJ_ASSERT_RETURN(body != NULL, NULL);970 971 body->content_type.type = pj_str("application");972 body->content_type.subtype = pj_str("sdp");973 body->data = pjmedia_sdp_session_clone(pool, c_sdp);977 PJ_ASSERT_RETURN(body != NULL, PJ_ENOMEM); 978 979 body->content_type.type = STR_APPLICATION; 980 body->content_type.subtype = STR_SDP; 981 body->data = sdp; 974 982 body->len = 0; 975 983 body->clone_data = &clone_sdp; 976 984 body->print_body = &print_sdp; 985 986 *p_body = body; 987 988 return PJ_SUCCESS; 989 } 990 991 static pjsip_msg_body *create_sdp_body(pj_pool_t *pool, 992 const pjmedia_sdp_session *c_sdp) 993 { 994 pjsip_msg_body *body; 995 pj_status_t status; 996 997 status = pjsip_create_sdp_body(pool, 998 pjmedia_sdp_session_clone(pool, c_sdp), 999 &body); 1000 1001 if (status != PJ_SUCCESS) 1002 return NULL; 977 1003 978 1004 return body; -
pjproject/trunk/pjsip/src/pjsip/sip_dialog.c
r576 r612 1345 1345 const pj_str_t reason = { "No session found", 16}; 1346 1346 1347 PJ_LOG(4,(tsx->obj_name, "Incoming request was unhandled by " 1348 "dialog usages, sending 500 response")); 1347 PJ_LOG(4,(tsx->obj_name, "%s was unhandled by " 1348 "dialog usages, sending 500 response", 1349 pjsip_rx_data_get_info(rdata))); 1349 1350 1350 1351 status = pjsip_dlg_create_response(dlg, rdata, 500, &reason, &tdata); … … 1458 1459 } 1459 1460 1461 /* Unhandled response does not necessarily mean error because 1462 dialog usages may choose to process the transaction state instead. 1460 1463 if (i==dlg->usage_cnt) { 1461 PJ_LOG(4,(dlg->obj_name, "%s is unhandled by dialog usages",1464 PJ_LOG(4,(dlg->obj_name, "%s was not claimed by any dialog usages", 1462 1465 pjsip_rx_data_get_info(rdata))); 1463 1466 } 1467 */ 1464 1468 1465 1469 /* Unlock dialog and dec session, may destroy dialog. */ -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_acc.c
r611 r612 539 539 } 540 540 541 if (status == PJ_SUCCESS) 541 if (status == PJ_SUCCESS) { 542 pjsua_process_msg_data(tdata, NULL); 542 543 status = pjsip_regc_send( pjsua_var.acc[acc_id].regc, tdata ); 544 } 543 545 544 546 if (status != PJ_SUCCESS) { -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c
r611 r612 130 130 131 131 /***************************************************************************** 132 * Another simple module to handle incoming OPTIONS request 133 */ 134 135 /* Notification on incoming request */ 136 static pj_bool_t options_on_rx_request(pjsip_rx_data *rdata) 137 { 138 pjsip_tx_data *tdata; 139 pjsip_response_addr res_addr; 140 pjmedia_sdp_session *sdp; 141 const pjsip_hdr *cap_hdr; 142 pj_status_t status; 143 144 /* Only want to handle OPTIONS requests */ 145 if (pjsip_method_cmp(&rdata->msg_info.msg->line.req.method, 146 &pjsip_options_method) != 0) 147 { 148 return PJ_FALSE; 149 } 150 151 /* Create basic response. */ 152 status = pjsip_endpt_create_response(pjsua_var.endpt, rdata, 200, NULL, 153 &tdata); 154 if (status != PJ_SUCCESS) { 155 pjsua_perror(THIS_FILE, "Unable to create OPTIONS response", status); 156 return PJ_TRUE; 157 } 158 159 /* Add Allow header */ 160 cap_hdr = pjsip_endpt_get_capability(pjsua_var.endpt, PJSIP_H_ALLOW, NULL); 161 if (cap_hdr) { 162 pjsip_msg_add_hdr(tdata->msg, pjsip_hdr_clone(tdata->pool, cap_hdr)); 163 } 164 165 /* Add Accept header */ 166 cap_hdr = pjsip_endpt_get_capability(pjsua_var.endpt, PJSIP_H_ACCEPT, NULL); 167 if (cap_hdr) { 168 pjsip_msg_add_hdr(tdata->msg, pjsip_hdr_clone(tdata->pool, cap_hdr)); 169 } 170 171 /* Add Supported header */ 172 cap_hdr = pjsip_endpt_get_capability(pjsua_var.endpt, PJSIP_H_SUPPORTED, NULL); 173 if (cap_hdr) { 174 pjsip_msg_add_hdr(tdata->msg, pjsip_hdr_clone(tdata->pool, cap_hdr)); 175 } 176 177 /* Add Allow-Events header from the evsub module */ 178 cap_hdr = pjsip_evsub_get_allow_events_hdr(NULL); 179 if (cap_hdr) { 180 pjsip_msg_add_hdr(tdata->msg, pjsip_hdr_clone(tdata->pool, cap_hdr)); 181 } 182 183 /* Add User-Agent header */ 184 if (pjsua_var.ua_cfg.user_agent.slen) { 185 const pj_str_t USER_AGENT = { "User-Agent", 10}; 186 pjsip_hdr *h; 187 188 h = (pjsip_hdr*) pjsip_generic_string_hdr_create(tdata->pool, 189 &USER_AGENT, 190 &pjsua_var.ua_cfg.user_agent); 191 pjsip_msg_add_hdr(tdata->msg, h); 192 } 193 194 /* Add SDP body, using call0's RTP address */ 195 status = pjmedia_endpt_create_sdp(pjsua_var.med_endpt, tdata->pool, 1, 196 &pjsua_var.calls[0].skinfo, &sdp); 197 if (status == PJ_SUCCESS) { 198 pjsip_create_sdp_body(tdata->pool, sdp, &tdata->msg->body); 199 } 200 201 /* Send response statelessly */ 202 pjsip_get_response_addr(tdata->pool, rdata, &res_addr); 203 status = pjsip_endpt_send_response(pjsua_var.endpt, &res_addr, tdata, NULL, NULL); 204 if (status != PJ_SUCCESS) 205 pjsip_tx_data_dec_ref(tdata); 206 207 return PJ_TRUE; 208 } 209 210 211 /* The module instance. */ 212 static pjsip_module pjsua_options_handler = 213 { 214 NULL, NULL, /* prev, next. */ 215 { "mod-pjsua-options", 17 }, /* Name. */ 216 -1, /* Id */ 217 PJSIP_MOD_PRIORITY_APPLICATION, /* Priority */ 218 NULL, /* load() */ 219 NULL, /* start() */ 220 NULL, /* stop() */ 221 NULL, /* unload() */ 222 &options_on_rx_request, /* on_rx_request() */ 223 NULL, /* on_rx_response() */ 224 NULL, /* on_tx_request. */ 225 NULL, /* on_tx_response() */ 226 NULL, /* on_tsx_state() */ 227 228 }; 229 230 231 /***************************************************************************** 132 232 * These two functions are the main callbacks registered to PJSIP stack 133 233 * to receive SIP request and response messages that are outside any … … 235 335 } 236 336 337 /* Unregister OPTIONS handler if it's previously registered */ 338 if (pjsua_options_handler.id >= 0) { 339 pjsip_endpt_unregister_module(pjsua_var.endpt, &pjsua_options_handler); 340 pjsua_options_handler.id = -1; 341 } 342 237 343 /* Unregister msg logging if it's previously registered */ 238 344 if (pjsua_msg_logger.id >= 0) { … … 245 351 pjsip_endpt_register_module(pjsua_var.endpt, &pjsua_msg_logger); 246 352 353 /* Register OPTIONS handler */ 354 pjsip_endpt_register_module(pjsua_var.endpt, &pjsua_options_handler); 247 355 248 356 return PJ_SUCCESS; … … 1025 1133 const pjsip_hdr *hdr; 1026 1134 1135 /* Always add User-Agent */ 1136 if (pjsua_var.ua_cfg.user_agent.slen && 1137 tdata->msg->type == PJSIP_REQUEST_MSG) 1138 { 1139 const pj_str_t STR_USER_AGENT = { "User-Agent", 10 }; 1140 pjsip_hdr *h; 1141 h = (pjsip_hdr*)pjsip_generic_string_hdr_create(tdata->pool, 1142 &STR_USER_AGENT, 1143 &pjsua_var.ua_cfg.user_agent); 1144 pjsip_msg_add_hdr(tdata->msg, h); 1145 } 1146 1027 1147 if (!msg_data) 1028 1148 return;
Note: See TracChangeset
for help on using the changeset viewer.