1 /* 2 belle-sip - SIP (RFC3261) library. 3 Copyright (C) 2010 Belledonne Communications SARL 4 5 This program is free software: you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published by 7 the Free Software Foundation, either version 2 of the License, or 8 (at your option) any later version. 9 10 This program is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with this program. If not, see <http://www.gnu.org/licenses/>. 17 */ 18 19 20 #ifndef belle_sip_stack_h 21 #define belle_sip_stack_h 22 23 24 struct belle_sip_timer_config{ 25 int T1; 26 int T2; 27 int T3; 28 int T4; 29 }; 30 31 typedef struct belle_sip_timer_config belle_sip_timer_config_t; 32 33 BELLE_SIP_BEGIN_DECLS 34 35 BELLESIP_EXPORT belle_sip_stack_t * belle_sip_stack_new(const char *properties); 36 37 BELLESIP_EXPORT belle_sip_listening_point_t *belle_sip_stack_create_listening_point(belle_sip_stack_t *s, const char *ipaddress, int port, const char *transport); 38 39 BELLESIP_EXPORT void belle_sip_stack_delete_listening_point(belle_sip_stack_t *s, belle_sip_listening_point_t *lp); 40 41 BELLESIP_EXPORT belle_sip_provider_t *belle_sip_stack_create_provider(belle_sip_stack_t *s, belle_sip_listening_point_t *lp); 42 43 BELLESIP_EXPORT belle_http_provider_t * belle_sip_stack_create_http_provider(belle_sip_stack_t *s, const char *bind_ip); 44 45 BELLESIP_EXPORT belle_sip_main_loop_t* belle_sip_stack_get_main_loop(belle_sip_stack_t *stack); 46 47 BELLESIP_EXPORT void belle_sip_stack_main(belle_sip_stack_t *stack); 48 49 BELLESIP_EXPORT void belle_sip_stack_sleep(belle_sip_stack_t *stack, unsigned int milliseconds); 50 51 /*the transport timeout is typically the maximum time given for making a connection*/ 52 BELLESIP_EXPORT void belle_sip_stack_set_transport_timeout(belle_sip_stack_t *stack, int timeout_ms); 53 54 BELLESIP_EXPORT int belle_sip_stack_get_transport_timeout(const belle_sip_stack_t *stack); 55 56 BELLESIP_EXPORT int belle_sip_stack_get_dns_timeout(const belle_sip_stack_t *stack); 57 58 BELLESIP_EXPORT void belle_sip_stack_set_dns_timeout(belle_sip_stack_t *stack, int timeout); 59 60 BELLESIP_EXPORT unsigned char belle_sip_stack_dns_srv_enabled(const belle_sip_stack_t *stack); 61 62 BELLESIP_EXPORT void belle_sip_stack_enable_dns_srv(belle_sip_stack_t *stack, unsigned char enable); 63 64 BELLESIP_EXPORT unsigned char belle_sip_stack_dns_search_enabled(const belle_sip_stack_t *stack); 65 66 BELLESIP_EXPORT void belle_sip_stack_enable_dns_search(belle_sip_stack_t *stack, unsigned char enable); 67 68 /** 69 * Override system's DNS servers used for DNS resolving by app-supplied list of dns servers. 70 * @param stack the stack 71 * @param servers a list of char*. It is copied internally. 72 **/ 73 BELLESIP_EXPORT void belle_sip_stack_set_dns_servers(belle_sip_stack_t *stack, const belle_sip_list_t *servers); 74 75 /** 76 * Can be used to simulate network transmission delays, for tests. 77 **/ 78 BELLESIP_EXPORT void belle_sip_stack_set_tx_delay(belle_sip_stack_t *stack, int delay_ms); 79 /** 80 * Can be used to simulate network sending error, for tests. 81 * @param stack 82 * @param send_error if <0, will cause channel error to be reported 83 **/ 84 85 BELLESIP_EXPORT void belle_sip_stack_set_send_error(belle_sip_stack_t *stack, int send_error); 86 87 /** 88 * Can be used to simulate network transmission delays, for tests. 89 **/ 90 BELLESIP_EXPORT void belle_sip_stack_set_resolver_tx_delay(belle_sip_stack_t *stack, int delay_ms); 91 92 /** 93 * Can be used to simulate network sending error, for tests. 94 * @param stack 95 * @param send_error if <0, will cause the resolver to fail with this error code. 96 **/ 97 BELLESIP_EXPORT void belle_sip_stack_set_resolver_send_error(belle_sip_stack_t *stack, int send_error); 98 99 /** 100 * Get the additional DNS hosts file. 101 * @return The path to the additional DNS hosts file. 102 **/ 103 BELLESIP_EXPORT const char * belle_sip_stack_get_dns_user_hosts_file(const belle_sip_stack_t *stack); 104 105 /** 106 * Can be used to load an additional DNS hosts file for tests. 107 * @param stack 108 * @param hosts_file The path to the additional DNS hosts file to load. 109 **/ 110 BELLESIP_EXPORT void belle_sip_stack_set_dns_user_hosts_file(belle_sip_stack_t *stack, const char *hosts_file); 111 112 113 /** 114 * Get the overriding DNS resolv.conf file. 115 * @return The path to the overriding DNS resolv.conf file. 116 **/ 117 BELLESIP_EXPORT const char * belle_sip_stack_get_dns_resolv_conf_file(const belle_sip_stack_t *stack); 118 119 /** 120 * Can be used to load an overriding DNS resolv.conf file for tests. 121 * @param stack 122 * @param hosts_file The path to the overriding DNS resolv.conf file to load. 123 **/ 124 BELLESIP_EXPORT void belle_sip_stack_set_dns_resolv_conf_file(belle_sip_stack_t *stack, const char *hosts_file); 125 126 /** 127 * Returns the time interval in seconds after which a connection must be closed when inactive. 128 **/ 129 BELLESIP_EXPORT int belle_sip_stack_get_inactive_transport_timeout(const belle_sip_stack_t *stack); 130 131 /** 132 * Sets the time interval in seconds after which a connection must be closed when inactive. 133 **/ 134 BELLESIP_EXPORT void belle_sip_stack_set_inactive_transport_timeout(belle_sip_stack_t *stack, int seconds); 135 136 137 /** 138 * Set the default dscp value to be used for all SIP sockets created and used in the stack. 139 **/ 140 BELLESIP_EXPORT void belle_sip_stack_set_default_dscp(belle_sip_stack_t *stack, int dscp); 141 142 /** 143 * Get the default dscp value to be used for all SIP sockets created and used in the stack. 144 **/ 145 BELLESIP_EXPORT int belle_sip_stack_get_default_dscp(belle_sip_stack_t *stack); 146 147 148 /** 149 * Returns TRUE if TLS support has been compiled into, FALSE otherwise. 150 **/ 151 BELLESIP_EXPORT int belle_sip_stack_tls_available(belle_sip_stack_t *stack); 152 153 /** 154 * Returns TRUE if the content encoding support has been compiled in, FALSE otherwise. 155 **/ 156 BELLESIP_EXPORT int belle_sip_stack_content_encoding_available(belle_sip_stack_t *stack, const char *content_encoding); 157 158 /* 159 * returns timer config for this stack 160 **/ 161 BELLESIP_EXPORT const belle_sip_timer_config_t *belle_sip_stack_get_timer_config(const belle_sip_stack_t *stack); 162 163 /* 164 * 165 * set sip timer config to be used for this stack 166 **/ 167 BELLESIP_EXPORT void belle_sip_stack_set_timer_config(belle_sip_stack_t *stack, const belle_sip_timer_config_t *timer_config); 168 169 BELLESIP_EXPORT void belle_sip_stack_set_http_proxy_host(belle_sip_stack_t *stack, const char* proxy_addr); 170 BELLESIP_EXPORT void belle_sip_stack_set_http_proxy_port(belle_sip_stack_t *stack, int port); 171 BELLESIP_EXPORT const char *belle_sip_stack_get_http_proxy_host(const belle_sip_stack_t *stack); 172 BELLESIP_EXPORT int belle_sip_stack_get_http_proxy_port(const belle_sip_stack_t *stack); 173 174 175 BELLE_SIP_END_DECLS 176 177 #endif 178 179