Commit 13b44982 authored by Simon Morlat's avatar Simon Morlat

expose refresher's local and public address thanks to channel

parent 915ecf8e
......@@ -103,9 +103,14 @@ BELLESIP_EXPORT const belle_sip_list_t* belle_sip_refresher_get_auth_events(cons
BELLESIP_EXPORT void belle_sip_refresher_enable_manual_mode(belle_sip_refresher_t *refresher, int enabled);
/**
* Retrieve last know public ip:port contact used.
* Retrieve current local address used by the underlying refresher's channel.
**/
BELLESIP_EXPORT char* belle_sip_refresher_get_public_uri(belle_sip_refresher_t* refresher);
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);
/**
* Retrieve last know contact header if known. Only available after a successful registration.
**/
......
......@@ -253,13 +253,6 @@ static int get_message_start_pos(char *buff, size_t bufflen) {
return -1;
}
char *belle_sip_channel_get_public_ip_port(belle_sip_channel_t *obj){
if (obj->public_ip){
return belle_sip_strdup_printf("%s:%d", obj->public_ip, obj->public_port);
}
return NULL;
}
void belle_sip_channel_set_public_ip_port(belle_sip_channel_t *obj, const char *public_ip, int port){
if (obj->public_ip){
int ip_changed=0;
......@@ -835,6 +828,12 @@ const char *belle_sip_channel_get_local_address(belle_sip_channel_t *obj, int *p
return obj->local_ip;
}
const char *belle_sip_channel_get_public_address(belle_sip_channel_t *obj, int *port){
const char *ret = obj->public_ip ? obj->public_ip : obj->local_ip;
if (*port) *port= obj->public_port;
return ret;
}
belle_sip_uri_t *belle_sip_channel_create_routable_uri(belle_sip_channel_t *chan) {
const char *transport = belle_sip_channel_get_transport_name_lower_case(chan);
belle_sip_uri_t* uri = belle_sip_uri_new();
......
......@@ -167,11 +167,11 @@ int belle_sip_channel_is_reliable(const belle_sip_channel_t *obj);
const char * belle_sip_channel_get_transport_name(const belle_sip_channel_t *obj);
const char * belle_sip_channel_get_transport_name_lower_case(const belle_sip_channel_t *obj);
char *belle_sip_channel_get_public_ip_port(belle_sip_channel_t *obj);
const struct addrinfo * belle_sip_channel_get_peer(belle_sip_channel_t *obj);
const char *belle_sip_channel_get_local_address(belle_sip_channel_t *obj, int *port);
const char *belle_sip_channel_get_public_address(belle_sip_channel_t *obj, int *port);
/*
* Returns a sip-uri suitable for using in record-route.
......
......@@ -24,6 +24,12 @@
#include "config.h"
#endif
#ifdef HAVE_LIBRT /*configure defines HAVE_LIBRT with AC_CHECK_LIB*/
# ifndef HAVE_CLOCK_GETTIME
# define HAVE_CLOCK_GETTIME 1
#endif
#endif
#ifndef HAVE_CLOCK_GETTIME
#include <sys/time.h>
......
......@@ -820,9 +820,18 @@ void belle_sip_refresher_enable_manual_mode(belle_sip_refresher_t *refresher, in
refresher->manual=enabled;
}
char *belle_sip_refresher_get_public_uri(belle_sip_refresher_t* refresher) {
return belle_sip_channel_get_public_ip_port(refresher->transaction->base.channel);
const char * belle_sip_refresher_get_local_address(belle_sip_refresher_t* refresher, int *port){
belle_sip_channel_t *chan = refresher->transaction->base.channel;
if (chan) return belle_sip_channel_get_local_address(chan, port);
return NULL;
}
const char * belle_sip_refresher_get_public_address(belle_sip_refresher_t* refresher, int *port){
belle_sip_channel_t *chan = refresher->transaction->base.channel;
if (chan) return belle_sip_channel_get_public_address(chan, port);
return NULL;
}
static void set_or_update_dialog(belle_sip_refresher_t* refresher, belle_sip_dialog_t* dialog) {
if (refresher->dialog!=dialog){
belle_sip_message("refresher [%p] : set_or_update_dialog() current=[%p] new=[%p]",refresher,refresher->dialog,dialog);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment