Controlling network parameters (ports, mtu...) 控制网络参数(端口、最大传输单元...)
自定义类型
typedef enum _LinphoneFirewallPolicy LinphoneFirewallPolicy
typedef struct _LinphoneNatPolicy LinphoneNatPolicy
枚举类型
enum _LinphoneFirewallPolicy{
LinphonePolicyNoFirewall,
LinphonePolicyUseNatAddress,
LinphonePolicyUseStun,
LinphonPolicyUseIce,
LinphonPolicyUseUpnp}
函数
详细说明
自定义文档
typedef enum _LinphoneFirewallPolicy LinphoneFirewallPolicy
用来穿透防火墙的策略
已弃用:
用LinphoneNatPolicy代替
typedef struct _LinphoneNatPolicy LinphoneNatPolicy
用来穿透NAT/防火墙的策略
枚举类型文档
enum _LinphoneFirewallPolicy
用于穿透防火墙的策略
已弃用:
用LinphoneNatPolicy代替
枚举成员
LinphonePolicyNoFirewall 不使用任何机制穿透防火墙
LinphonePolicyUseNatAddress 使用指定的公网地址
LinphonePolicyUseStun 使用STUN服务器获取公网地址
LinphonePolicyUseIce 使用ICE协议
LinphonePolicyUpnp 使用uPnP协议
函数文档
LinphoneNatPolicy* linphone_core_create_nat_policy(LinphoneCore* lc)
创建一个新的LinphoneNatPolicy对象,每种策略都被禁用.
参数
[in] lc LinphoneCore对象
返回
一个新的LinphoneNatPolicy对象
LinphoneNatPolicy* linphone_core_create_nat_policy_from_config(LinphoneCore* lc, const char* ref)
创建一个新的LinphoneNatPolicy对象通过读取LinphoneCore的配置,根据传进的ref.
参数
[in] lc LinphoneCore对象
[in] ref 在LinphoneCore的配置中 Nat策略的引用
返回
一个新的LinphoneNatPolicy对象
void linphone_core_enable_ipv6(LinphoneCore* lc, bool_t val)
开启或关闭IPv6
void linphone_core_enable_keep_alive(LinphoneCore* lc, bool_t enable)
启用信号保持心跳.小的udp数据包定期发送来保存udp NAT关联
void linphone_core_enable_sdp_200_ack(LinphoneCore* lc, bool_t enable)
参数
lc LinphoneCore对象
enable 如果INVITE在SDP外已经发送,设置TRUE
int linphone_core_get_audio_dscp(const LinphoneCore* lc)
为传出的音频流获取DSCP
DSCP定义了在IP数据包的服务优先级
int linphone_core_get_audio_port(const LinphoneCore* lc)
返回用于音频流的UDP端口
void linphone_core_get_audio_port_range(const Linphone* lc, int* min_port, int* max_port)
获取音频端口范围,从该范围中随机选择UDP端口用于音频流传输
LinphoneFirewallPolicy linphone_core_get_firewall_policy(const LinphoneCore* lc)
获取用于穿透防火墙的策略
参数
[in] lc LinphoneCore对象
返回
被使用的LinphoneFirewallPolicy
已弃用:
用 linphone_core_get_nat_policy()代替
const char* linphone_core_get_http_proxy_host(const LinphoneCore* lc)
获取http代理地址用于发信号
参数
[in] lc LinphoneCore对象
返回
http代理的IP地址的主机名(如果为NULL表示禁用)
int linphone_core_get_http_proxy_port(const LinphoneCore* lc)
获取http代理端口用来发信号
参数
[in] lc LinphoneCore对象
返回
http代理端口
const char* linphone_core_get_nat_address(const LinphoneCore* lc)
获取NAT的公网IP地址
参数
[in] lc LinphoneCore对象
返回
NAT的公网地址
LinphoneNatPolicy* linphone_core_get_nat_policy(const LinphoneCore* lc)
获取用于穿透NAT/防火墙的策略.它可能被一个指定的代理配置的NAT策略覆盖
参数
[in] lc LinphoneCore对象
返回
正在用的LinphoneNatPolicy对象
另参见
linphone_proxy_config_get_nat_policy()
int linphone_core_get_sip_dscp(const LinphoneCore* lc)
为SIP信号通道获取DSCP
DSCP定义了在IP数据包的服务优先级
int linphone_core_get_sip_port(const LinphoneCore* lc)
返回SIP使用的UDP端口
已弃用:
使用linphone_core_get_sip_transports()代替
int linphone_core_get_sip_transports(LinphoneCore* lc, LCSipTransports* tr)
获取用于每种传输协议(udp, tcp, tls)的端口配置. 端口0值对于一个给定的传输协议代表没有使用该传输协议.
端口值为LC_SIP_TRANSPORT_RANDOM(-1)意味着端口是由系统随机选择的.
void linphone_core_get_sip_transports_used(LinphoneCore* lc, LCSipTransports* tr)
获取分配给每个sip传输协议(udp,tcp,tls)的真正的端口号.0值意味着该类传输没被激活.如果LC_SIP_TRANSPORT_RANDOM被传给linphone_core_set_sip_transports(),返回由系统选择的随机端口
参数
lc LinphoneCore对象
tr LCSipTransports结构体
const char* linphone_core_get_stun_server(const LinphoneCore* lc)
获取在使用的STUN服务器地址
参数
[in] lc LinphoneCore对象
返回
STUN服务器地址
int linphone_core_get_text_port(const LinphonCore* lc)
返回UDP端口用于文本流
void linphone_core_get_text_port_range(const LinphoneCore* lc, int* min_port, int* max_port)
获取视频端口范围,从该端口范围内随机选择UDP端口用于文本流
const char* linphone_core_get_upnp_external_ipaddress(const LinphoneCore* lc)
返回路由器外部的ip地址.在某些情况下uPnP可能有一个外部的IP地址,但是没有可用的uPnP(状态不同于Ok)
参数
lc LinphoneCore对象
返回
一个以NULL结尾的字符串包含了外部的ip地址.如果该外部ip地址不可用返回NULL.
LinphoneUpnpState linphone_core_get_upnp_state(const LinphoneCore* lc)
返回uPnP的内部状态
参数
lc LinphoneCore对象
返回
一个LinphoneUpnpState对象
int linphone_core_get_video_dscp(const LinphoneCore* lc)
为呼出视频流获取DSCP域
int linphone_core_get_video_port_range(const LinphoneCore* lc, int* min_port, int* max_port)
获取视频端口范围 在该范围中随机选择UDP端口用于视频流
bool_t linphone_core_ipv6_enabled(LinphoneCore* lc)
如果IPv6可用返回TRUE
参见 linphone_core_enable_ipv6()来了解更多关于IPv6怎么样被支持在linphone的细节
bool_t linphone_core_is_network_reachable(LinphoneCore* lc)
返回网络状态,由应用程序定位或者由linphone自己定位.
bool_t linphone_core_keep_alive_enabled(LinphoneCore* lc)
是否启用发送信号来保持心跳
bool_t linphone_core_sdp_200_ack_enabled(const LinphoneCore* lc)
媒体为SIP INVITE提供控制参数
返回
如果INVITE必须在SDP外被发送.返回TRUE.
void linphone_core_set_audio_dscp(LinphoneCore* lc, int dscp)
为传出的音频流发送DSCP域
DSCP定义了IP数据包中的服务优先级
void linphone_core_set_audio_port(LinphoneCore* lc, int port)
设置用于音频流的UDP端口.如果为-1将请求系统随机分配本地端口.这是为了避免防火墙警告
void linphone_core_set_firewall_policy(LinphoneCore* lc, LinphoneFirewallPolicy pol)
设置用来穿透防火墙的策略
参数
[in] lc LinphoneCore对象
[in] pol 被设置的LinphoneFirewallPolicy对象
已弃用:
用linphone_core_set_nat_policy()代替
void linphone_core_set_http_proxy_host(LinphoneCore* lc, const char* host)
设置http代理地址用来发送信号在下一个通道连接期间.用linphone_core_set_network_reachable FASLE/TRUE来强制通道重启
参数
[in] lc LinphoneCore对象
[in] host http代理的IP地址的主机名(可以为NULL,表示禁用)
void linphone_core_set_http_proxy_port(LinphoneCore* lc, int port)
设置http代理端口用于发送信号
参数
[in] lc LinphoneCore对象
[in] port http代理端口
void linphone_core_set_media_network_reachable(LinphoneCore* lc, bool_t value)
这个方法被应用程序调用来通知linphone内核库在媒体(RTP)网络可获得时.这是高级用法,当SIP和RTP层被要求用不同的接口.大多数应用程序只需要linphone_core_set_network_reachable().
void linphone_core_set_nat_address(LinphoneCore* lc, const char* addr)
设置NAT的公网IP地址,当使用NAT设置防火墙策略时
参数
[in] lc LinphoneCore对象
[in] addr NAT的公网IP地址
void linphone_core_set_nat_policy(LinphoneCore* lc, LinphoneNatPolicy* policy)
设置用于穿透NAT/防火墙的策略.这可能被一个特定的代理配置的NAT策略覆盖.
参数
[in] lc LinphoneCore对象
[in] policy LinphoneNatPolicy对象
另参见
linphone_proxy_config_set_nat_policy()
void linphone_core_set_network_reachable(LinphoneCore* lc, bool_t value)
这个方法被应用程序调用来通知linphone内涵库当网络可获得时.传入TRUE调用这个方法触发linphone启动所有代理的注册进程.调用该方法禁用自动网络检测模式.这意味着你必须在每次网络状态发生改变之后调用这个函数.
void linphone_core_set_sip_dscp(LinphoneCore* lc, int dscp)
为SIP信号通道设置DSCP域
DSCP定义了IP数据包的服务优先级
void linphone_core_set_sip_network_reachable(LinphoneCore* lc, bool_t value)
这个方法被应用程序调用来通知linphone核心库当SIP网络可获得时.这是高级用法,当SIP和RTP层被要求用不同的接口.大多数应用程序只需要linphone_core_set_network_reachable().
void linphone_core_set_sip_port(LinphoneCore* lc, int port)
设置用于SIP的UDP端口
已弃用:
用linphone_core_set_sip_transports()代替
int linphone_core_set_sip_transports(LinphoneCore* lc, const LCSipTransports* tr_config)
设置用于每个传输协议(UDP或者TCP)的端口
如果指定的传输协议端口值为0意味着该传输协议没被使用.值为LC_SIP_TRANSPORT_RANDOM(-1)意味着端口是由系统随机选择的
void linphone_core_set_stun_server(LinphoneCore* lc, const char* server)
设置STUN服务器地址,当防火墙策略被设置为STUN时
参数
[in] lc LinphoneCore对象
[in] server STUN服务器地址
void linphone_core_set_text_port(LinphoneCore* lc, int port)
设置用于文本流的UDP端口.设置-1将要求系统随机分配本地端口.这是为了避免防火墙警告
void linphone_core_set_video_dscp(LinphoneCore* lc, int dscp)
为传出的视频流设置DSCP域
DSCP域定义IP数据包的服务优先级
void linphone_core_set_video_port(LinphoneCore* lc, int port)
设置用于视频流的UDP端口.设置-1将要求系统随机分配本地端口.这是为了避免防火墙警告
bool_t linphone_core_upnp_available(void )
判断upnp是否可用
返回
如果uPnP可用返回 true,否则返回FALSE
void linphone_nat_policy_clear(LinphoneNatPolicy* policy)
清除一个NAT策略(关闭全部协议并设置STUN服务器)
参数
[in] policy LinphoneNatPolicy对象
void linphone_nat_policy_enable_ice(LinphoneNatPolicy* policy, bool_t enable)
启用ICE.ICE可以在没有STUN/TURN的情况下被启用.在这种情况下只有本地的候选人将被使用
参数
[in] policy LinphoneNatPolicy对象
[in] enable 布尔值 表明是否启用ICE
void linphone_nat_policy_enable_stun(LinphoneNatPolicy* policy, bool_t enable)
启用STUN.如果TURN也被启用,TURN会被用代替STUN
参数
[in] policy LinphoneNatPolicy 对象
[in] enable 布尔值表明是否启用STUN
void linphone_nat_policy_enable_upnp(LinphoneNatPolicy* policy, bool_t enable)
启用uPnP.这对禁用所有其他的策略有影响(ICE、STUN、TURN)
参数
[in] policy LinphoneNatPolicy对象
[in] enable布尔值表明是否启用uPnP
const char* linphone_nat_policy_get_stun_server(const LinphoneNatPolicy* policy)
获取使用这个NAT策略的STUN/TURN服务器地址.当STUN或者TURN已经启用时.
参数
[in] policy LinphoneNatPolicy对象
返回
被这个NAT策略使用的STUN服务器地址
const struct addrinfo* linphone_nat_policy_get_stun_server_addrinfo(LinphoneNatPolicy* policy)
获取STUN服务器地址的addrinfo表示形式.警告:这个函数可能阻塞长达1秒钟
参数
[in] policy LinphoneNatPolicy对象
返回
STUN服务器地址的addrinfo表示形式
const char* linphone_nat_policy_get_stun_server_username(const LinphoneNatPolicy* policy)
获取用于STUN/TURN服务器身份验证的用户名.身份验证会用这个用户名去搜索一个LinphoneAuthInfo对象.如果
参数
[in] policy LinphoneNatPolicy对象
返回
用于STUN/TURN服务器的身份验证的用户名
void* linphone_nat_policy_get_user_data(const LinphoneNatPolicy* policy)
获取以指定的LinphoneNatPolicy对象相关联的用户指针
参数
[in] policy LinphoneNatatPolicy对象
返回
与LinphoneNatPolicy对象相关联的用户指针
bool_t linphone_nat_policy_ice_enabled(const LinphoneNatPolicy* policy)
判断ICE是否可用
参数
[in] policy LinphoneNatPolicy对象
返回
布尔值判断是否ICE可用
LinphoneNatPolicy* linphone_nat_policy_ref(LinphoneNatPolicy* policy)
获得LinphoneNatPolicy对象的引用
参数
[in] policy LinphoneNatPolicy对象
返回
一样的LinphoneNatPolicy对象
void linphone_nat_policy_stun_server(LinphoneNatPolicy* policy)
开始一个STUN服务器地址DNS解析
参数
[in] policy LinphoneNatPolicy对象
void linphone_nat_policy_set_stun_server(LinphoneNatPolicy* policy, const char* stun_server)
设置STUN/TURN服务器和这个NAT策略一起使用.前提是STUN或者TURN已启用
参数
[in] policy LinphoneNatPolicy对象
[in] stun_server 和这个NAT策略一起使用的STUN 服务器
void linphone_nat_policy_set_stun_server_username(LinphoneNatPolicy* policy, const char* username)
设置用于STUN/TURN服务器身份验证的用户名.身份验证会用这个用户名搜索一个LinphoneAuthInfo.如果它没有设置当前使用的LinphoneProxyConfig对象(被用于寻找LinphoneAuthInfo)的用户名
参数
[in] policy LinphoneNatPolicy对象
[in] username 用于STUN/TURN服务器身份验证的用户名
void linphone_nat_policy_set_user_data(LinphoneNatPolicy* policy, void* ud)
设置用户指针给LinphoneNatPolicy对象
参数
[in] LinphoneNatPolicy对象
[in] 与LinphoneNatPolicy对象相关的用户指针
bool_t linphone_nat_policy_stun_enabled(const LinphoneNatPolicy* policy)
判断是否STUN已经启用
参数
[in] policy LinphoneNatPolicy对象
返回
布尔值表明是否STUN已启用
bool_t linphone_nat_policy_turn_enabled(const LinphoneNatPolicy* policy)
判断是否TURN是否已启用
参数
[in] policy LinphoneNatPolicy 对象
返回
布尔值表明是否TURN已启用
void linphone_nat_policy_unref(LinphoneNatPolicy* policy)
释放LinphoneNatPolicy对象的引用
参数
[in] policy LinphoneNatPolicy对象
bool_t linphone_nat_policy_upnp_enabled(const LinphoneNatPolicy* policy)
判断uPnP是否已启用
参数
[in] policy LinphoneNatPolicy对象
返回
布尔值判断uPnP是否已启用