linphone用户注册与sip交互过程分析
在linphone_core_init
在linphone_configuring_terminated
在linphone_core_start
在 sip_config_read
在linphone_core_set_sip_transports
在_linphone_core_apply_transports
在sal_listen_port
在sal_add_listen_port
在 belle_sip_stack_create_listening_point
在belle_sip_udp_listening_point_new
在belle_sip_udp_listening_point_init
在belle_sip_udp_listening_point_init_socket
在create_udp_socket
实现随机端口原理是 将udp的端口号设为-1,这样处理的时候会随机赋值,具体处理在create_udp_socket函数中 原理是,bind时使用端口号为0,这样会随机绑定一个未占用的端口,然后通过getsockname 获取具体绑定的端口返回
linphone监听端口是在linphone_core_init函数中就已经处理完成的,在这个函数中会先读取文本配置,然后根据配置再进行处理
使用belle_sip_main_loop_add_source 将lp->source(携带了监听的socket)加入到ml->fd_sources链表中,该结构最终在linphonecore.c文件 linphone_core_iterate函数下sal_iterate(lc->sal)中调用,跟代码可以发现前面监听的socket是在lc->sal->prov->lp 下, <