(五)pjsip Message 追加协议头

1、PJSIP流程:

PJLIB-UTIL初始化 ---> 创建 pool factory ---> 创建SIP endpoint ---> 创建SIP transport ---> 发送短信

2、主要代码说明:

2.1初始化发送内容


	status = pjsip_endpt_create_request(sip_endptLocal, &method, &str_target, &str_from, &str_to, &str_from, NULL, -1, &body, &tdata);
	if (status != PJ_SUCCESS) {
		
		return status;
	}	

	

2.2追加协议头

pj_str_t name = pj_str("HeaderName");
	pj_str_t value = pj_str("HeaderValue");
	pjsip_generic_string_hdr* add_hdr = pjsip_generic_string_hdr_create(pool, &name, &value);
	pj_list_push_back(&tdata->msg->hdr, add_hdr);

2.3发送内容



	status = pjsip_endpt_send_request_stateless(sip_endptLocal, tdata, "",	NULL);
	
	if (status != PJ_SUCCESS) {
		
		return status;
	}

3、wireshark抓包: SIP属于OSI的应用层,要求对端能够连接才能看到本条协议数据

你可能感兴趣的:(pjsip)