refresher.h 4.6 KB
Newer Older
jehan's avatar
jehan committed
1 2 3 4 5 6
/*
	belle-sip - SIP (RFC3261) library.
    Copyright (C) 2012  Belledonne Communications SARL, Grenoble, France

    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
jehan's avatar
jehan committed
8 9 10 11 12 13 14 15 16 17 18 19 20
    (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 REFRESHER_HELPER_H_
#define REFRESHER_HELPER_H_
21

22
#define BELLE_SIP_REFRESHER_REUSE_EXPIRES -1
jehan's avatar
jehan committed
23

24 25
BELLE_SIP_BEGIN_DECLS

jehan's avatar
jehan committed
26 27 28 29 30 31 32
typedef struct belle_sip_refresher belle_sip_refresher_t;
/**
 * Refresher listener invoked every time a refresh action is performed
 * @param refresher corresponding refresher object.
 * @param user_pointer user pointer
 * @param status_code status code for the last refresh action
 * @param reason_phrase
33
 * @param will_retry a boolean indicating wether the refresher is going to retry the request automatically.
jehan's avatar
jehan committed
34
 * */
35
typedef void (*belle_sip_refresher_listener_t) (belle_sip_refresher_t* refresher
36 37 38
								,void* user_pointer
								,unsigned int status_code
								,const char* reason_phrase, int will_retry);
jehan's avatar
jehan committed
39 40 41 42

/**
 * add a refresher listener
 */
43
BELLESIP_EXPORT void belle_sip_refresher_set_listener(belle_sip_refresher_t* refresher, belle_sip_refresher_listener_t listener,void* user_pointer);
jehan's avatar
jehan committed
44 45 46 47 48 49

/**
 * start the refresher
 */
int belle_sip_refresher_start(belle_sip_refresher_t* refresher);
/**
50 51
 * stop refresher.
 * If a transaction is pending, it will be terminated.
jehan's avatar
jehan committed
52
 */
53
BELLESIP_EXPORT void belle_sip_refresher_stop(belle_sip_refresher_t* refresher);
jehan's avatar
jehan committed
54

55 56 57
/**
 * Manually initiate a new transaction .
 * @param refresher object
58
 * @param expires #BELLE_SIP_REFRESHER_REUSE_EXPIRES means value extracted from the transaction
59 60
 * @return 0 if succeed
 */
61
BELLESIP_EXPORT int belle_sip_refresher_refresh(belle_sip_refresher_t* refresher,int expires);
62 63 64
/**
 * returns current expires value;
 */
Sylvain Berfini's avatar
Sylvain Berfini committed
65
BELLESIP_EXPORT int belle_sip_refresher_get_expires(const belle_sip_refresher_t* refresher);
jehan's avatar
jehan committed
66

67 68 69 70 71 72 73 74 75 76
/**
 * returns  delay in ms after which the refresher will retry in case of recoverable error (I.E 408, 480, 503, 504, io error);
 */
BELLESIP_EXPORT int belle_sip_refresher_get_retry_after(const belle_sip_refresher_t* refresher);

/**
 * Delay in ms after which the refresher will retry in case of recoverable error (I.E 408, 480, 503, 504, io error);
 */
BELLESIP_EXPORT void belle_sip_refresher_set_retry_after(belle_sip_refresher_t* refresher, int delay_ms);

77 78 79 80 81 82 83 84 85 86
/**
 * returns  realm of the outbound proxy used for authentication, if any
 */
BELLESIP_EXPORT const char* belle_sip_refresher_get_realm(const belle_sip_refresher_t* refresher);

/**
 * Realm of the outbound proxy used for authentication, if any
 */
BELLESIP_EXPORT void belle_sip_refresher_set_realm(belle_sip_refresher_t* refresher, const char* realm);

87 88 89 90 91 92 93 94
/**
 * get current client transaction
 * @param refresher object
 * @return transaction
 */
BELLESIP_EXPORT const belle_sip_client_transaction_t* belle_sip_refresher_get_transaction(const belle_sip_refresher_t* refresher);

/**
95
 * Get current list of auth info if any. Contains the list of filled #belle_sip_auth_event_t in case of a 401 or 407 is repported to the #belle_sip_refresher_listener_t  ;
96 97 98 99 100
 * @param refresher object
 * @return list of #belle_sip_auth_info_t
 */
BELLESIP_EXPORT const belle_sip_list_t* belle_sip_refresher_get_auth_events(const belle_sip_refresher_t* refresher);

101 102 103 104
/**
 * Enable manual mode: only belle_sip_refresher_refresh() called by application will cause requests to be resubmitted.
**/
BELLESIP_EXPORT void belle_sip_refresher_enable_manual_mode(belle_sip_refresher_t *refresher, int enabled);
105

106
/**
107
 * Retrieve current local address used by the underlying refresher's channel.
108
**/
109 110 111 112 113 114
BELLESIP_EXPORT const char * belle_sip_refresher_get_local_address(belle_sip_refresher_t* refresher, int *port);

/**
 * Retrieve current public address used by the underlying refresher's channel.
**/
BELLESIP_EXPORT const char * belle_sip_refresher_get_public_address(belle_sip_refresher_t* refresher, int *port);
115 116 117 118
/**
 * Retrieve last know contact header if known. Only available after a successful registration.
**/
BELLESIP_EXPORT belle_sip_header_contact_t* belle_sip_refresher_get_contact(const belle_sip_refresher_t* refresher);
119

120 121
BELLE_SIP_END_DECLS

jehan's avatar
jehan committed
122
#endif /* REFRESHER_HELPER_H_ */