概述
业务流程
终端向服务器发送REGISTER请求
sip消息示例:
REGISTER sip:39.108.105.163 SIP/2.0
Max-Forwards: 10
Record-Route: <sip:39.108.105.163:5070;r2=on;lr>
Record-Route: <sip:39.108.105.163:5070;transport=tcp;r2=on;lr>
Via: SIP/2.0/UDP 39.108.105.163:5070;branch=z9hG4bK7433.75da75a1.0;i=3081d387
Via: SIP/2.0/TCP 172.18.41.221:6068;received=120.79.51.88;rport=6068;branch=z9hG4bK-10724-1-0
From: "6500100032"<sip:6500100032@39.108.105.163:5070>;tag=1
To: "6500100032"<sip:6500100032@39.108.105.163:5070>
Call-ID: 1-10724@172.18.41.221
CSeq: 1 REGISTER
Contact: <sip:6500100032@120.79.51.88:6068;transport=TCP>
Content-Length: 0
Expires: 1800
服务器回复401,并给出WWW-Authenticate信息
fs处理过程描述:
sofia协议栈:
tport :
tport_recv_event
=>tport_parse
=> tport_deliver
nta :
agent_recv_request
=> irq = incoming_find(agent, sip, sip->sip_via,..)
=> leg = agent->sa_default_leg
=> leg_recv
=> irq = incoming_create(agent, msg, sip, tport, tag)
=> status = incoming_callback(leg, irq, sip);
=>leg->leg_callback(leg->leg_magic, leg, irq, sip);
nua :
nua_stack_process_request
=>sm = nua_register_server_methods
=>nh = nua_stack_incoming_handle(nua, irq, sip, create_dialog)
=> nh = nh_create(nua, ..);
=> nua_stack_init_handle(nua, nh, NULL)
=>nh->nh_soa = soa_clone(dnh->nh_soa, nua->nua_root, nh)
=> nua_registrar_server_preprocess(sr);
=> nua_server_report(sr)
=> nua_base_server_report
=> nua_stack_event(nua, nh, msg, e, status, phrase, tags)
nua_stack :
nua_stack_event
=> su_msg_send_to(sumsg, nua->nua_client, nua_application_event);
注册消息处理表
nua_server_methods_t const nua_register_server_methods = {
SIP_METHOD_REGISTER,
nua_i_register, /* Event */
{
0, /* Do not create dialog */
0, /* Initial request */
0, /* Not a target refresh request */
0, /* Do not add Contact */
},
nua_base_server_init,
nua_registrar_server_preprocess,
nua_base_server_params,
nua_base_server_respond,
nua_registrar_server_report,
};
nua_stack_event处理流程,比较复杂,单独拎出来说明一下:
nua_stack.c:275 nua_stack_event() nua(0x29acea0): event i_register 100 Trying
/** @internal Send an event to the application. */
int nua_stack_event(nua_t *nua, nua_handle_t *nh, msg_t *msg, nua_event_t event, int status, char const *phrase, tagi_t const *tags)
=>su_msg_send_to(sumsg, nua->nua_client, nua_application_event); 发给sofia主线程
/*# Receive event from protocol machine and hand it over to application */
sofia.c:2320 sofia_event_callback,event_name:nua_i_register,status=100,nua=0x214e600,profile=0x26cc100,nua_handle=0x29acea0,private=(nil)
static
void nua_application_event(nua_t *dummy, su_msg_r sumsg, nua_ee_data_t *ee)
=> nua->nua_callback((enum nua_event_e)e->e_event, ..)
=> sofia_event_callback
=> de = su_alloc(nh->nh_home, sizeof(*de));
=> sofia_queue_message(de); 发给sofia 消息处理线程
sofia.c:1411 entering our_sofia_event_callback,event=54(nua_i_register),phrase=Trying,nua=0x214e600,profile=0x26cc100,nh=0x29acea0,sofia_private=(nil)
our_sofia_event_callback
=> sofia_reg_handle_sip_i_register(nua, profile, nh, &sofia_private, sip, de, tags);
=> sofia_reg_handle_register_token
=> nua_respond
void nua_respond(nua_handle_t *nh,int status, char const *phrase,tag_type_t tag, tag_value_t value, ...)
=>nua_signal(nh->nh_nua, nh, NULL, nua_r_respond,status, phrase, ta_tags(ta));
=>su_msg_send_to(sumsg, nua->nua_server, nua_stack_signal); 发给sofia clone线程
Receiving events from client
nua_stack.c:577 nua_stack_signal() nua(0x29acea0): recv signal r_respond 401 Unauthorized
void nua_stack_signal(nua_t *nua, su_msg_r msg, nua_ee_data_t *ee)
=> nua_stack_respond(nua, nh, e->e_status, e->e_phrase, tags);
=> nua_server_params(sr, tags);
=> nua_server_respond(sr, tags);
=> incoming_reply
=> nua_server_report(sr);
=> nua_server_request_destroy
sip消息示例:
SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP 39.108.105.163:5070;branch=z9hG4bK7433.75da75a1.0;i=3081d387;received=172.18.41.220
Via: SIP/2.0/TCP 172.18.41.221:6068;received=120.79.51.88;rport=6068;branch=z9hG4bK-10724-1-0
From: "6500100032"<sip:6500100032@39.108.105.163:5070>;tag=1
To: "6500100032" <sip:6500100032@39.108.105.163:5070>;tag=3vv5rp607ayvQ
Call-ID: 1-10724@172.18.41.221
CSeq: 1 REGISTER
User-Agent: FreeSWITCH
Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY, PUBLISH, SUBSCRIBE
Supported: path, replaces
WWW-Authenticate: Digest realm="39.108.105.163", nonce="40268d7e-e75a-4a78-b692-49e78cc18a4c", algorithm=MD5, qop="auth"
Content-Length: 0
终端再次向服务器发送REGISTER请求,并携带认证信息
REGISTER sip:6500100032@39.108.105.163:5070 SIP/2.0
Max-Forwards: 10
Record-Route: <sip:39.108.105.163:5070;r2=on;lr>
Record-Route: <sip:39.108.105.163:5070;transport=tcp;r2=on;lr>
Via: SIP/2.0/UDP 39.108.105.163:5070;branch=z9hG4bK4433.03c18c94.0;i=3081d387
Via: SIP/2.0/TCP 172.18.41.221:6068;received=120.79.51.88;rport=6068
From: "6500100032"<sip:6500100032@39.108.105.163:5070>;tag=1
To: "6500100032"<sip:6500100032@39.108.105.163:5070>
Call-ID: 1-10724@172.18.41.221
CSeq: 2 REGISTER
Contact: <sip:6500100032@120.79.51.88:6068;transport=TCP>
Allow: INVITE, ACK, BYE, CANCEL, REGISTER
Authorization: Digest username="6500100032",realm="39.108.105.163",cnonce="6b8b4567",nc=00000001,qop=auth,uri="sip:39.108.105.163:5070",nonce="40268d7e-e75a-4a78-b692-49e78cc18a4c",response="0ed61e004e0d9adf199e15476d5feb2a",algorithm=MD5
Content-Length: 0
Expires: 1800
服务器认证后回复200
fs处理过程描述:
类似上面的流程
SIP/2.0 200 OK
Via: SIP/2.0/UDP 39.108.105.163:5070;branch=z9hG4bK4433.03c18c94.0;i=3081d387;received=172.18.41.220
Via: SIP/2.0/TCP 172.18.41.221:6068;received=120.79.51.88;rport=6068
From: "6500100032"<sip:6500100032@39.108.105.163:5070>;tag=1
To: "6500100032" <sip:6500100032@39.108.105.163:5070>;tag=45NytHQ44KmFK
Call-ID: 1-10724@172.18.41.221
CSeq: 2 REGISTER
Contact: <sip:6500100032@120.79.51.88:6068;transport=TCP>;expires=1800
Date: Tue, 03 Nov 2020 10:41:33 GMT
User-Agent: FreeSWITCH
Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY, PUBLISH, SUBSCRIBE
Supported: path, replaces
Content-Length: 0
最后
以上就是勤恳凉面为你收集整理的FreeSwitch系列之注册流程处理的全部内容,希望文章能够帮你解决FreeSwitch系列之注册流程处理所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复