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_provider_h 21 #define belle_sip_provider_h 22 23 #define BELLE_SIP_BRANCH_MAGIC_COOKIE "z9hG4bK" 24 25 BELLE_SIP_BEGIN_DECLS 26 27 BELLESIP_EXPORT belle_sip_uri_t *belle_sip_provider_create_inbound_record_route(belle_sip_provider_t *p, belle_sip_request_t *req); 28 29 BELLESIP_EXPORT int belle_sip_provider_is_us(belle_sip_provider_t *p, belle_sip_uri_t*); 30 31 BELLESIP_EXPORT int belle_sip_provider_add_listening_point(belle_sip_provider_t *p, belle_sip_listening_point_t *lp); 32 33 BELLESIP_EXPORT void belle_sip_provider_remove_listening_point(belle_sip_provider_t *p, belle_sip_listening_point_t *lp); 34 35 BELLESIP_EXPORT belle_sip_listening_point_t *belle_sip_provider_get_listening_point(belle_sip_provider_t *p, const char *transport); 36 37 BELLESIP_EXPORT const belle_sip_list_t *belle_sip_provider_get_listening_points(belle_sip_provider_t *p); 38 39 BELLESIP_EXPORT void belle_sip_provider_add_sip_listener(belle_sip_provider_t *p, belle_sip_listener_t *l); 40 41 BELLESIP_EXPORT void belle_sip_provider_remove_sip_listener(belle_sip_provider_t *p, belle_sip_listener_t *l); 42 43 BELLESIP_EXPORT belle_sip_header_call_id_t * belle_sip_provider_create_call_id(const belle_sip_provider_t *prov); 44 45 BELLESIP_EXPORT belle_sip_dialog_t *belle_sip_provider_create_dialog(belle_sip_provider_t *prov, belle_sip_transaction_t *t); 46 47 BELLESIP_EXPORT belle_sip_client_transaction_t *belle_sip_provider_create_client_transaction(belle_sip_provider_t *p, belle_sip_request_t *req); 48 49 BELLESIP_EXPORT belle_sip_server_transaction_t *belle_sip_provider_create_server_transaction(belle_sip_provider_t *p, belle_sip_request_t *req); 50 51 BELLESIP_EXPORT belle_sip_stack_t *belle_sip_provider_get_sip_stack(belle_sip_provider_t *p); 52 53 BELLESIP_EXPORT void belle_sip_provider_send_request(belle_sip_provider_t *p, belle_sip_request_t *req); 54 55 BELLESIP_EXPORT void belle_sip_provider_send_response(belle_sip_provider_t *p, belle_sip_response_t *resp); 56 57 BELLESIP_EXPORT void belle_sip_provider_clean_channels(belle_sip_provider_t *p); 58 59 /** 60 * Add auth info to the request if found 61 * @param p object 62 * @param request to be updated 63 * @param resp response to take authentication values from, might be NULL 64 * @param from_uri optional - an uri to use instead of the from of the request, which can be anonymous. 65 * @param auth_infos optional - A newly allocated belle_sip_auth_info_t object is added to this list. These object contains useful information like realm and username. 66 * @param realm optional - If an outbound proxy realm is used, nounce can be reused from previous request to avoid re-authentication. 67 * @returns 0 in case of success, 68 * 69 **/ 70 BELLESIP_EXPORT int belle_sip_provider_add_authorization(belle_sip_provider_t *p, belle_sip_request_t* request,belle_sip_response_t *resp, belle_sip_uri_t *from_uri, belle_sip_list_t** auth_infos, const char* realm); 71 72 /** 73 * Can be used to simulate network recv error, for tests. 74 * @param prov 75 * @param recv_error if <=0, will cause channel error to be reported 76 **/ 77 BELLESIP_EXPORT void belle_sip_provider_set_recv_error(belle_sip_provider_t *prov, int recv_error); 78 79 /** 80 * Can be used to unconditionally answer to incoming sip messages. By default 480 is answered. 81 * Can be enhanced by a new method belle_sip_provider_set_unconditional_answer to allows user to provide answer code 82 * @param prov 83 * @param enable 0 to disable 84 **/ 85 BELLESIP_EXPORT void belle_sip_provider_enable_unconditional_answer(belle_sip_provider_t *prov, int enable); 86 87 /** 88 * Can be used to choose unconditionally answer to incoming sip messages. 89 * use belle_sip_provider_enable_unconditional_answer to enable/disable 90 * @param prov 91 * @param code 0 to sip response code 92 **/ 93 BELLESIP_EXPORT void belle_sip_provider_set_unconditional_answer(belle_sip_provider_t *prov, unsigned short code); 94 95 /** 96 * Provides access to a specific dialog 97 * @param prov object 98 * @param call_if of the dialog 99 * @param local_tag of the dialog 100 * @param remote_tag of the dialog 101 * @returns dialog corresponding to this parameter or NULL if not found 102 * 103 **/ 104 BELLESIP_EXPORT belle_sip_dialog_t* belle_sip_provider_find_dialog(const belle_sip_provider_t *prov, const char* call_id,const char* local_tag,const char* remote_tag); 105 106 /** 107 * Enable rport in via header. Enabled by default 108 * @param prov 109 * @return enable 0 to disable 110 **/ 111 BELLESIP_EXPORT void belle_sip_provider_enable_rport(belle_sip_provider_t *prov, int enable); 112 /** 113 * get Enable rport in via header. Enabled by default 114 * @param prov 115 * @param enable 0 to disable 116 **/ 117 BELLESIP_EXPORT int belle_sip_provider_is_rport_enabled(belle_sip_provider_t *prov); 118 119 120 /** 121 * Enable discovery of NAT's public address and port during SIP exchanges. 122 * When activated, automatic contacts ( see belle_sip_header_contact_set_automatic() ) 123 * will use discovered public IP address and port (if any) instead of local ones. 124 * NAT public address and port are discovered using received and rport parameters in via header of responses. 125 * As a result, disabling rport ( see belle_sip_provider_enable_rport() ) will also break this feature. 126 **/ 127 BELLESIP_EXPORT void belle_sip_provider_enable_nat_helper(belle_sip_provider_t *prov, int enabled); 128 129 /** 130 * Returns if nat helper behavior is enabled. 131 * @see belle_sip_provider_enable_nat_helper() 132 **/ 133 BELLESIP_EXPORT int belle_sip_provider_nat_helper_enabled(const belle_sip_provider_t *prov); 134 135 BELLE_SIP_END_DECLS 136 137 #define BELLE_SIP_PROVIDER(obj) BELLE_SIP_CAST(obj,belle_sip_provider_t) 138 139 #endif 140