provider.h 6.05 KB
Newer Older
1 2 3 4 5 6
/*
	belle-sip - SIP (RFC3261) library.
    Copyright (C) 2010  Belledonne Communications SARL

    This program is free software: you can redistribute it and/or modify
    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 9 10 11 12 13 14 15 16 17 18 19 20 21 22
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/


#ifndef belle_sip_provider_h
#define belle_sip_provider_h

23
#define BELLE_SIP_BRANCH_MAGIC_COOKIE "z9hG4bK"
24 25 26

BELLE_SIP_BEGIN_DECLS

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);
Simon Morlat's avatar
Simon Morlat committed
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

/**
jehan's avatar
jehan committed
60
 * Add auth info to the request if found
61 62 63
 * @param p object
 * @param request to be updated
 * @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 66
 * @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.
 * @param realm optional - If an outbound proxy realm is used, nounce can be reused from previous request to avoid re-authentication.
67 68
 * @returns 0 in case of success,
 *
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 76
 * @param recv_error if <=0, will cause channel error to be reported
**/
77
BELLESIP_EXPORT void belle_sip_provider_set_recv_error(belle_sip_provider_t *prov, int recv_error);
78

79 80 81 82 83 84 85 86
/**
 * Can be used to unconditionally answer to incoming sip messages. By  default 480 is answered.
 * Can be enhanced by a new method belle_sip_provider_set_unconditional_answer to allows user to provide answer code
 * @param prov
 * @param enable 0 to disable
**/
BELLESIP_EXPORT void belle_sip_provider_enable_unconditional_answer(belle_sip_provider_t *prov, int enable);

87 88 89 90 91 92 93 94
/**
 * Can be used to choose unconditionally answer to incoming sip messages.
 * use belle_sip_provider_enable_unconditional_answer to enable/disable
 * @param prov
 * @param code 0 to sip response code
 **/
BELLESIP_EXPORT void belle_sip_provider_set_unconditional_answer(belle_sip_provider_t *prov, unsigned short code);

95 96 97 98
/**
 * Provides access to a specific dialog
 * @param prov object
 * @param call_if of the dialog
99 100
 * @param local_tag of the dialog
 * @param remote_tag of the dialog
101 102 103
 * @returns dialog corresponding to this parameter or NULL if not found
 *
 **/
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 108 109 110 111 112 113 114 115 116 117 118 119
/**
 * Enable rport in via header. Enabled by default
 * @param prov
 * @return enable 0 to disable
**/
BELLESIP_EXPORT void belle_sip_provider_enable_rport(belle_sip_provider_t *prov, int enable);
/**
 * get Enable rport in via header. Enabled by default
 * @param prov
 * @param enable 0 to disable
**/
BELLESIP_EXPORT int belle_sip_provider_is_rport_enabled(belle_sip_provider_t *prov);


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 124 125 126 127 128 129 130 131 132 133 134
 * will use discovered public IP address and port (if any) instead of local ones.
 * NAT public address and port are discovered using received and rport parameters in via header of responses.
 * As a result, disabling rport ( see  belle_sip_provider_enable_rport() ) will also break this feature.
**/
BELLESIP_EXPORT void belle_sip_provider_enable_nat_helper(belle_sip_provider_t *prov, int enabled);

/**
 * Returns if nat helper behavior is enabled.
 * @see belle_sip_provider_enable_nat_helper()
**/
BELLESIP_EXPORT int belle_sip_provider_nat_helper_enabled(const belle_sip_provider_t *prov);

135 136
BELLE_SIP_END_DECLS

137 138
#define BELLE_SIP_PROVIDER(obj) BELLE_SIP_CAST(obj,belle_sip_provider_t)

139
#endif