From 389054bc7f7b9979916faafd746c4000ef5d8482 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Wed, 27 Feb 2013 17:28:15 +0100 Subject: [PATCH 01/21] Fix to be C89 compliant --- coreapi/callbacks.c | 4 +-- coreapi/conference.c | 9 +++-- coreapi/ec-calibrator.c | 4 ++- coreapi/friend.c | 10 ++++-- coreapi/linphonecall.c | 61 ++++++++++++++++++++++------------ coreapi/linphonecore.c | 18 ++++++---- coreapi/lpconfig.c | 21 ++++++++---- coreapi/misc.c | 7 +++- coreapi/offeranswer.c | 2 +- coreapi/private.h | 2 +- coreapi/sal.c | 2 +- coreapi/siplogin.c | 5 ++- coreapi/test_ecc.c | 11 ++++-- coreapi/upnp.c | 2 +- coreapi/upnp.h | 2 +- {coreapi => include/sal}/sal.h | 0 16 files changed, 106 insertions(+), 54 deletions(-) rename {coreapi => include/sal}/sal.h (100%) diff --git a/coreapi/callbacks.c b/coreapi/callbacks.c index 1c87f88ce..cf2b5cb4a 100644 --- a/coreapi/callbacks.c +++ b/coreapi/callbacks.c @@ -18,7 +18,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "sal.h" +#include "sal/sal.h" #include "linphonecore.h" #include "private.h" @@ -179,9 +179,9 @@ static bool_t is_duplicate_call(LinphoneCore *lc, const LinphoneAddress *from, c #endif static bool_t already_a_call_with_remote_address(const LinphoneCore *lc, const LinphoneAddress *remote) { + MSList *elem; ms_warning(" searching for already_a_call_with_remote_address."); - MSList *elem; for(elem=lc->calls;elem!=NULL;elem=elem->next){ const LinphoneCall *call=(LinphoneCall*)elem->data; const LinphoneAddress *cRemote=linphone_call_get_remote_address(call); diff --git a/coreapi/conference.c b/coreapi/conference.c index 16be62613..c98392e95 100644 --- a/coreapi/conference.c +++ b/coreapi/conference.c @@ -215,6 +215,7 @@ int linphone_core_add_to_conference(LinphoneCore *lc, LinphoneCall *call){ static int remove_from_conference(LinphoneCore *lc, LinphoneCall *call, bool_t active){ int err=0; + char *str; if (!call->current_params.in_conference){ if (call->params.in_conference){ @@ -227,7 +228,7 @@ static int remove_from_conference(LinphoneCore *lc, LinphoneCall *call, bool_t a } call->params.in_conference=FALSE; - char *str=linphone_call_get_remote_address_as_string(call); + str=linphone_call_get_remote_address_as_string(call); ms_message("%s will be removed from conference", str); ms_free(str); if (active){ @@ -283,10 +284,11 @@ static int convert_conference_to_call(LinphoneCore *lc){ * @returns 0 if successful, -1 otherwise. **/ int linphone_core_remove_from_conference(LinphoneCore *lc, LinphoneCall *call){ + int err; char * str=linphone_call_get_remote_address_as_string(call); ms_message("Removing call %s from the conference", str); ms_free(str); - int err=remove_from_conference(lc,call, FALSE); + err=remove_from_conference(lc,call, FALSE); if (err){ ms_error("Error removing participant from conference."); return err; @@ -335,13 +337,14 @@ int linphone_core_leave_conference(LinphoneCore *lc){ * @returns 0 if successful, -1 otherwise **/ int linphone_core_enter_conference(LinphoneCore *lc){ + LinphoneConference *conf; if (linphone_core_sound_resources_locked(lc)) { return -1; } if (lc->current_call != NULL) { linphone_core_pause_call(lc, lc->current_call); } - LinphoneConference *conf=&lc->conf_ctx; + conf=&lc->conf_ctx; if (conf->local_participant==NULL) add_local_endpoint(conf,lc); return 0; } diff --git a/coreapi/ec-calibrator.c b/coreapi/ec-calibrator.c index 8efbabb1b..f0f009747 100644 --- a/coreapi/ec-calibrator.c +++ b/coreapi/ec-calibrator.c @@ -241,11 +241,13 @@ void ec_calibrator_destroy(EcCalibrator *ecc){ } int linphone_core_start_echo_calibration(LinphoneCore *lc, LinphoneEcCalibrationCallback cb, void *cb_data){ + unsigned int rate; + if (lc->ecc!=NULL){ ms_error("Echo calibration is still on going !"); return -1; } - unsigned int rate = lp_config_get_int(lc->config,"sound","echo_cancellation_rate",8000); + rate = lp_config_get_int(lc->config,"sound","echo_cancellation_rate",8000); lc->ecc=ec_calibrator_new(lc->sound_conf.play_sndcard,lc->sound_conf.capt_sndcard,rate,cb,cb_data); return 0; } diff --git a/coreapi/friend.c b/coreapi/friend.c index c6dee2440..06e55a4c5 100644 --- a/coreapi/friend.c +++ b/coreapi/friend.c @@ -152,11 +152,13 @@ LinphoneFriend * linphone_friend_new(){ LinphoneFriend *linphone_friend_new_with_addr(const char *addr){ LinphoneAddress* linphone_address = linphone_address_new(addr); + LinphoneFriend *fr; + if (linphone_address == NULL) { ms_error("Cannot create friend for address [%s]",addr?addr:"null"); return NULL; } - LinphoneFriend *fr=linphone_friend_new(); + fr=linphone_friend_new(); if (linphone_friend_set_addr(fr,linphone_address)<0){ linphone_friend_destroy(fr); return NULL; @@ -437,6 +439,8 @@ LinphoneFriend *linphone_core_get_friend_by_address(const LinphoneCore *lc, cons const MSList *elem; const char *username; const char *domain; + const char *it_username; + const char *it_host; LinphoneFriend *lf=NULL; if (puri==NULL){ @@ -450,8 +454,8 @@ LinphoneFriend *linphone_core_get_friend_by_address(const LinphoneCore *lc, cons } for(elem=lc->friends;elem!=NULL;elem=ms_list_next(elem)){ lf=(LinphoneFriend*)elem->data; - const char *it_username=linphone_address_get_username(lf->uri); - const char *it_host=linphone_address_get_domain(lf->uri);; + it_username=linphone_address_get_username(lf->uri); + it_host=linphone_address_get_domain(lf->uri);; if (strcasecmp(domain,it_host)==0 && username_match(username,it_username)){ break; } diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index a7cad386c..9872c0f5d 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -120,9 +120,10 @@ static void linphone_call_videostream_encryption_changed(void *data, bool_t encr static void linphone_call_audiostream_encryption_changed(void *data, bool_t encrypted) { char status[255]={0}; + LinphoneCall *call; ms_message("Audio stream is %s ", encrypted ? "encrypted" : "not encrypted"); - LinphoneCall *call = (LinphoneCall *)data; + call = (LinphoneCall *)data; call->audiostream_encrypted=encrypted; if (encrypted && call->core->vtable.display_status != NULL) { @@ -1333,6 +1334,13 @@ void _post_configure_audio_stream(AudioStream *st, LinphoneCore *lc, bool_t mute float ng_thres=lp_config_get_float(lc->config,"sound","ng_thres",0.05); float ng_floorgain=lp_config_get_float(lc->config,"sound","ng_floorgain",0); int dc_removal=lp_config_get_int(lc->config,"sound","dc_removal",0); + float speed; + float force; + int sustain; + float transmit_thres; + MSFilter *f=NULL; + float floorgain; + int spk_agc; if (!muted) linphone_core_set_mic_gain_db (lc, mic_gain); @@ -1346,12 +1354,11 @@ void _post_configure_audio_stream(AudioStream *st, LinphoneCore *lc, bool_t mute if (st->volsend){ ms_filter_call_method(st->volsend,MS_VOLUME_REMOVE_DC,&dc_removal); - float speed=lp_config_get_float(lc->config,"sound","el_speed",-1); + speed=lp_config_get_float(lc->config,"sound","el_speed",-1); thres=lp_config_get_float(lc->config,"sound","el_thres",-1); - float force=lp_config_get_float(lc->config,"sound","el_force",-1); - int sustain=lp_config_get_int(lc->config,"sound","el_sustain",-1); - float transmit_thres=lp_config_get_float(lc->config,"sound","el_transmit_thres",-1); - MSFilter *f=NULL; + force=lp_config_get_float(lc->config,"sound","el_force",-1); + sustain=lp_config_get_int(lc->config,"sound","el_sustain",-1); + transmit_thres=lp_config_get_float(lc->config,"sound","el_transmit_thres",-1); f=st->volsend; if (speed==-1) speed=0.03; if (force==-1) force=25; @@ -1369,8 +1376,8 @@ void _post_configure_audio_stream(AudioStream *st, LinphoneCore *lc, bool_t mute } if (st->volrecv){ /* parameters for a limited noise-gate effect, using echo limiter threshold */ - float floorgain = 1/pow(10,(mic_gain)/10); - int spk_agc=lp_config_get_int(lc->config,"sound","speaker_agc_enabled",0); + floorgain = 1/pow(10,(mic_gain)/10); + spk_agc=lp_config_get_int(lc->config,"sound","speaker_agc_enabled",0); ms_filter_call_method(st->volrecv, MS_VOLUME_ENABLE_AGC, &spk_agc); ms_filter_call_method(st->volrecv,MS_VOLUME_SET_NOISE_GATE_THRESHOLD,&ng_thres); ms_filter_call_method(st->volrecv,MS_VOLUME_SET_NOISE_GATE_FLOORGAIN,&floorgain); @@ -1478,9 +1485,19 @@ static void linphone_call_start_audio_stream(LinphoneCall *call, const char *cna LinphoneCore *lc=call->core; int used_pt=-1; char rtcp_tool[128]={0}; + const SalStreamDescription *stream; + MSSndCard *playcard; + MSSndCard *captcard; + bool_t use_ec; + bool_t mute; + const char *playfile; + const char *recfile; + const SalStreamDescription *local_st_desc; + int crypto_idx; + snprintf(rtcp_tool,sizeof(rtcp_tool)-1,"%s-%s",linphone_core_get_user_agent_name(),linphone_core_get_user_agent_version()); /* look for savp stream first */ - const SalStreamDescription *stream=sal_media_description_find_stream(call->resultdesc, + stream=sal_media_description_find_stream(call->resultdesc, SalProtoRtpSavp,SalAudio); /* no savp audio stream, use avp */ if (!stream) @@ -1488,13 +1505,12 @@ static void linphone_call_start_audio_stream(LinphoneCall *call, const char *cna SalProtoRtpAvp,SalAudio); if (stream && stream->dir!=SalStreamInactive && stream->rtp_port!=0){ - MSSndCard *playcard=lc->sound_conf.lsd_card ? + playcard=lc->sound_conf.lsd_card ? lc->sound_conf.lsd_card : lc->sound_conf.play_sndcard; - MSSndCard *captcard=lc->sound_conf.capt_sndcard; - const char *playfile=lc->play_file; - const char *recfile=lc->rec_file; + captcard=lc->sound_conf.capt_sndcard; + playfile=lc->play_file; + recfile=lc->rec_file; call->audio_profile=make_profile(call,call->resultdesc,stream,&used_pt); - bool_t use_ec; if (used_pt!=-1){ call->current_params.audio_codec = rtp_profile_get_payload(call->audio_profile, used_pt); @@ -1570,9 +1586,9 @@ static void linphone_call_start_audio_stream(LinphoneCall *call, const char *cna /* valid local tags are > 0 */ if (stream->proto == SalProtoRtpSavp) { - const SalStreamDescription *local_st_desc=sal_media_description_find_stream(call->localdesc, + local_st_desc=sal_media_description_find_stream(call->localdesc, SalProtoRtpSavp,SalAudio); - int crypto_idx = find_crypto_index_from_tag(local_st_desc->crypto, stream->crypto_local_tag); + crypto_idx = find_crypto_index_from_tag(local_st_desc->crypto, stream->crypto_local_tag); if (crypto_idx >= 0) { audio_stream_enable_srtp( @@ -1588,7 +1604,7 @@ static void linphone_call_start_audio_stream(LinphoneCall *call, const char *cna }else call->audiostream_encrypted=FALSE; if (call->params.in_conference){ /*transform the graph to connect it to the conference filter */ - bool_t mute=stream->dir==SalStreamRecvOnly; + mute=stream->dir==SalStreamRecvOnly; linphone_call_add_to_conf(call, mute); } call->current_params.in_conference=call->params.in_conference; @@ -1696,13 +1712,15 @@ static void linphone_call_start_video_stream(LinphoneCall *call, const char *cna void linphone_call_start_media_streams(LinphoneCall *call, bool_t all_inputs_muted, bool_t send_ringbacktone){ LinphoneCore *lc=call->core; + LinphoneAddress *me; + char *cname; + bool_t use_arc; call->current_params.audio_codec = NULL; call->current_params.video_codec = NULL; - LinphoneAddress *me=linphone_core_get_primary_contact_parsed(lc); - char *cname; - bool_t use_arc=linphone_core_adaptive_rate_control_enabled(lc); + me=linphone_core_get_primary_contact_parsed(lc); + use_arc=linphone_core_adaptive_rate_control_enabled(lc); #ifdef VIDEO_ENABLED const SalStreamDescription *vstream=sal_media_description_find_stream(call->resultdesc, SalProtoRtpAvp,SalVideo); @@ -2370,10 +2388,11 @@ void linphone_call_zoom_video(LinphoneCall* call, float zoom_factor, float* cx, VideoStream* vstream = call->videostream; if (vstream && vstream->output) { float zoom[3]; + float halfsize; if (zoom_factor < 1) zoom_factor = 1; - float halfsize = 0.5 * 1.0 / zoom_factor; + halfsize = 0.5 * 1.0 / zoom_factor; if ((*cx - halfsize) < 0) *cx = 0 + halfsize; diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index a33328f03..1e1a7a64b 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -2167,7 +2167,7 @@ void linphone_core_iterate(LinphoneCore *lc){ LinphoneAddress * linphone_core_interpret_url(LinphoneCore *lc, const char *url){ enum_lookup_res_t *enumres=NULL; char *enum_domain=NULL; - LinphoneProxyConfig *proxy=lc->default_proxy;; + LinphoneProxyConfig *proxy=lc->default_proxy; char *tmpurl; LinphoneAddress *uri; @@ -5265,9 +5265,10 @@ static void linphone_core_uninit(LinphoneCore *lc) } static void set_network_reachable(LinphoneCore* lc,bool_t isReachable, time_t curtime){ - ms_message("Network state is now [%s]",isReachable?"UP":"DOWN"); // second get the list of available proxies const MSList *elem=linphone_core_get_proxy_config_list(lc); + + ms_message("Network state is now [%s]",isReachable?"UP":"DOWN"); for(;elem!=NULL;elem=elem->next){ LinphoneProxyConfig *cfg=(LinphoneProxyConfig*)elem->data; if (linphone_proxy_config_register_enabled(cfg) ) { @@ -5582,13 +5583,18 @@ const char *linphone_core_get_zrtp_secrets_file(LinphoneCore *lc){ } const LinphoneCall* linphone_core_find_call_from_uri(LinphoneCore *lc, const char *uri) { + MSList *calls; + const LinphoneCall *c; + const LinphoneAddress *address; + char *current_uri; + if (uri == NULL) return NULL; - MSList *calls=lc->calls; + calls=lc->calls; while(calls) { - const LinphoneCall *c=(LinphoneCall*)calls->data; + c=(LinphoneCall*)calls->data; calls=calls->next; - const LinphoneAddress *address = linphone_call_get_remote_address(c); - char *current_uri=linphone_address_as_string_uri_only(address); + address = linphone_call_get_remote_address(c); + current_uri=linphone_address_as_string_uri_only(address); if (strcmp(uri,current_uri)==0) { ms_free(current_uri); return c; diff --git a/coreapi/lpconfig.c b/coreapi/lpconfig.c index 4608beecf..5f90855f5 100644 --- a/coreapi/lpconfig.c +++ b/coreapi/lpconfig.c @@ -34,6 +34,9 @@ #include #include #include +#if _MSC_VER +#include +#endif #endif /*_WIN32_WCE*/ @@ -140,18 +143,20 @@ LpItem *lp_section_find_item(const LpSection *sec, const char *name){ void lp_config_parse(LpConfig *lpconfig, FILE *file){ char tmp[MAX_LEN]= {'\0'}; LpSection *cur=NULL; + char *pos1,*pos2; + int nbs; + char secname[MAX_LEN]; + char key[MAX_LEN]; + LpItem *item; if (file==NULL) return; while(fgets(tmp,MAX_LEN,file)!=NULL){ tmp[sizeof(tmp) -1] = '\0'; - char *pos1,*pos2; pos1=strchr(tmp,'['); if (pos1!=NULL && is_first_char(tmp,pos1) ){ pos2=strchr(pos1,']'); if (pos2!=NULL){ - int nbs; - char secname[MAX_LEN]; secname[0]='\0'; /* found section */ *pos2='\0'; @@ -171,7 +176,6 @@ void lp_config_parse(LpConfig *lpconfig, FILE *file){ }else { pos1=strchr(tmp,'='); if (pos1!=NULL){ - char key[MAX_LEN]; key[0]='\0'; *pos1='\0'; @@ -191,7 +195,7 @@ void lp_config_parse(LpConfig *lpconfig, FILE *file){ if (pos2-pos1>=0){ /* found a pair key,value */ if (cur!=NULL){ - LpItem *item=lp_section_find_item(cur,key); + item=lp_section_find_item(cur,key); if (item==NULL){ lp_section_add_item(cur,lp_item_new(key,pos1)); }else{ @@ -211,17 +215,20 @@ void lp_config_parse(LpConfig *lpconfig, FILE *file){ LpConfig * lp_config_new(const char *filename){ LpConfig *lpconfig=lp_new0(LpConfig,1); + struct stat fileStat; if (filename!=NULL){ lpconfig->filename=ortp_strdup(filename); lpconfig->file=fopen(filename,"rw"); if (lpconfig->file!=NULL){ - struct stat fileStat; lp_config_parse(lpconfig,lpconfig->file); fclose(lpconfig->file); #if !defined(_WIN32_WCE) +#ifndef S_ISREG +#define S_ISREG(mode) ((mode & S_IFMT) == S_IFREG) +#endif if ((stat(filename,&fileStat) == 0) && (S_ISREG(fileStat.st_mode))) { /* make existing configuration files non-group/world-accessible */ - if (chmod(filename, S_IRUSR | S_IWUSR) == -1) { + if (_chmod(filename, _S_IREAD | _S_IWRITE) == -1) { ms_warning("unable to correct permissions on " "configuration file: %s", strerror(errno)); } diff --git a/coreapi/misc.c b/coreapi/misc.c index e84c8cce9..5800d3f06 100644 --- a/coreapi/misc.c +++ b/coreapi/misc.c @@ -32,7 +32,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include #include +#if _MSC_VER +#include +#else #include +#endif #include #endif /*_WIN32_WCE*/ @@ -585,9 +589,10 @@ int linphone_core_get_edge_ptime(LinphoneCore *lc){ } void linphone_core_adapt_to_network(LinphoneCore *lc, int ping_time_ms, LinphoneCallParams *params){ + int threshold; if (ping_time_ms>0 && lp_config_get_int(lc->config,"net","activate_edge_workarounds",0)==1){ ms_message("Stun server ping time is %i ms",ping_time_ms); - int threshold=lp_config_get_int(lc->config,"net","edge_ping_time",500); + threshold=lp_config_get_int(lc->config,"net","edge_ping_time",500); if (ping_time_ms>threshold){ /* we might be in a 2G network*/ diff --git a/coreapi/offeranswer.c b/coreapi/offeranswer.c index 9823c24a6..c07e6e381 100644 --- a/coreapi/offeranswer.c +++ b/coreapi/offeranswer.c @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "sal.h" +#include "sal/sal.h" #include "offeranswer.h" #include "private.h" diff --git a/coreapi/private.h b/coreapi/private.h index 41d453df3..e37e88a2a 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -31,7 +31,7 @@ extern "C" { #include "linphonefriend.h" #include "linphone_tunnel.h" #include "linphonecore_utils.h" -#include "sal.h" +#include "sal/sal.h" #include "sipsetup.h" #ifdef HAVE_CONFIG_H diff --git a/coreapi/sal.c b/coreapi/sal.c index 1411407a8..ba02ef345 100644 --- a/coreapi/sal.c +++ b/coreapi/sal.c @@ -23,7 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. protocols and implementations under linphone, for example SIP, JINGLE... **/ -#include "sal.h" +#include "sal/sal.h" const char* sal_transport_to_string(SalTransport transport) { switch (transport) { case SalTransportUDP:return "udp"; diff --git a/coreapi/siplogin.c b/coreapi/siplogin.c index 6903638d6..f29398c93 100644 --- a/coreapi/siplogin.c +++ b/coreapi/siplogin.c @@ -113,10 +113,9 @@ SipSetup linphone_sip_login={ NULL, NULL, NULL, + sip_login_do_logout, NULL, - NULL, - NULL, - sip_login_do_logout + NULL }; diff --git a/coreapi/test_ecc.c b/coreapi/test_ecc.c index 43ae0dcb2..a0baeea40 100644 --- a/coreapi/test_ecc.c +++ b/coreapi/test_ecc.c @@ -21,6 +21,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "linphonecore.h" #include "linphonecore_utils.h" +#if _MSC_VER +#include +#endif static void calibration_finished(LinphoneCore *lc, LinphoneEcCalibratorStatus status, int delay, void *data){ ms_message("echo calibration finished %s.",status==LinphoneEcCalibratorDone ? "successfully" : "with faillure"); @@ -30,6 +33,9 @@ static void calibration_finished(LinphoneCore *lc, LinphoneEcCalibratorStatus st static char config_file[1024]; void parse_args(int argc, char *argv[]){ +#ifndef F_OK +#define F_OK 4 +#endif if (argc != 3 || strncmp("-c",argv[1], 2) || access(argv[2],F_OK)!=0) { printf("Usage: test_ecc [-c config_file] where config_file will be written with the detected value\n"); exit(-1); @@ -38,10 +44,11 @@ void parse_args(int argc, char *argv[]){ } int main(int argc, char *argv[]){ - if (argc>1) parse_args(argc,argv); int count=0; LinphoneCoreVTable vtable={0}; - LinphoneCore *lc=linphone_core_new(&vtable,config_file,NULL,NULL); + LinphoneCore *lc; + if (argc>1) parse_args(argc,argv); + lc=linphone_core_new(&vtable,config_file,NULL,NULL); linphone_core_enable_logs(NULL); diff --git a/coreapi/upnp.c b/coreapi/upnp.c index 8aead382c..7fe543b4d 100644 --- a/coreapi/upnp.c +++ b/coreapi/upnp.c @@ -488,7 +488,7 @@ int linphone_upnp_context_send_add_port_binding(UpnpContext *lupnp, UpnpPortBind mapping.remote_port = port->external_port; mapping.remote_host = ""; snprintf(description, 128, "%s %s at %s:%d", - PACKAGE_NAME, + LINPHONE_PACKAGE_NAME, (port->protocol == UPNP_IGD_IP_PROTOCOL_TCP)? "TCP": "UDP", port->local_addr, port->local_port); mapping.description = description; diff --git a/coreapi/upnp.h b/coreapi/upnp.h index fe403a772..81edc5986 100644 --- a/coreapi/upnp.h +++ b/coreapi/upnp.h @@ -22,7 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "mediastreamer2/upnp_igd.h" #include "linphonecore.h" -#include "sal.h" +#include "sal/sal.h" typedef struct _UpnpSession UpnpSession; typedef struct _UpnpContext UpnpContext; diff --git a/coreapi/sal.h b/include/sal/sal.h similarity index 100% rename from coreapi/sal.h rename to include/sal/sal.h From e76deb66bd86d2aed2f5d25436e6bf774edbd373 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Thu, 28 Feb 2013 11:08:09 +0100 Subject: [PATCH 02/21] Fix link step of compilation Conflicts: build/vsx/LibLinphone/LibLinphone.vcxproj build/vsx/LibLinphone/LibLinphone.vcxproj.filters coreapi/misc.c --- coreapi/misc.c | 2323 ++++++++++++++++++++++++------------------------ 1 file changed, 1164 insertions(+), 1159 deletions(-) diff --git a/coreapi/misc.c b/coreapi/misc.c index 5800d3f06..c2e1217e0 100644 --- a/coreapi/misc.c +++ b/coreapi/misc.c @@ -1,1159 +1,1164 @@ - -/* -linphone -Copyright (C) 2000 Simon MORLAT (simon.morlat@linphone.org) - -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 the Free Software Foundation; either version 2 -of the License, or (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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "private.h" -#include "lpconfig.h" -#include "mediastreamer2/mediastream.h" -#include -#include -#ifdef HAVE_SIGHANDLER_T -#include -#endif /*HAVE_SIGHANDLER_T*/ - -#include -#if !defined(_WIN32_WCE) -#include -#include -#include -#if _MSC_VER -#include -#else -#include -#endif -#include -#endif /*_WIN32_WCE*/ - -#undef snprintf -#include - -#ifdef HAVE_GETIFADDRS -#include -#include -#endif -#include - -#if !defined(WIN32) - -static char lock_name[80]; -static char lock_set=0; -/* put a lock file in /tmp. this is called when linphone runs as a daemon*/ -int set_lock_file() -{ - FILE *lockfile; - - snprintf(lock_name,80,"/tmp/linphone.%i",getuid()); - lockfile=fopen(lock_name,"w"); - if (lockfile==NULL) - { - printf("Failed to create lock file.\n"); - return(-1); - } - fprintf(lockfile,"%i",getpid()); - fclose(lockfile); - lock_set=1; - return(0); -} - -/* looks if there is a lock file. If presents return its content (the pid of the already running linphone), if not found, returns -1*/ -int get_lock_file() -{ - int pid; - FILE *lockfile; - - snprintf(lock_name,80,"/tmp/linphone.%i",getuid()); - lockfile=fopen(lock_name,"r"); - if (lockfile==NULL) - return(-1); - if (fscanf(lockfile,"%i",&pid)!=1){ - ms_warning("Could not read pid in lock file."); - fclose(lockfile); - return -1; - } - fclose(lockfile); - return pid; -} - -/* remove the lock file if it was set*/ -int remove_lock_file() -{ - int err=0; - if (lock_set) - { - err=unlink(lock_name); - lock_set=0; - } - return(err); -} - -#endif - -char *int2str(int number) -{ - char *numstr=ms_malloc(10); - snprintf(numstr,10,"%i",number); - return numstr; -} - -void check_sound_device(LinphoneCore *lc) -{ -#ifdef _linux - int fd=0; - int len; - int a; - char *file=NULL; - char *i810_audio=NULL; - char *snd_pcm_oss=NULL; - char *snd_mixer_oss=NULL; - char *snd_pcm=NULL; - fd=open("/proc/modules",O_RDONLY); - - if (fd>0){ - /* read the entire /proc/modules file and check if sound conf seems correct */ - /*a=fstat(fd,&statbuf); - if (a<0) ms_warning("Can't stat /proc/modules:%s.",strerror(errno)); - len=statbuf.st_size; - if (len==0) ms_warning("/proc/modules has zero size!"); - */ - /***** fstat does not work on /proc/modules for unknown reason *****/ - len=6000; - file=ms_malloc(len+1); - a=read(fd,file,len); - if (avtable.display_warning(lc,_("You are currently using the i810_audio driver.\nThis driver is buggy and so does not work with Linphone.\nWe suggest that you replace it by its equivalent ALSA driver,\neither with packages from your distribution, or by downloading\nALSA drivers at http://www.alsa-project.org."));*/ - goto end; - } - snd_pcm=strstr(file,"snd-pcm"); - if (snd_pcm!=NULL){ - snd_pcm_oss=strstr(file,"snd-pcm-oss"); - snd_mixer_oss=strstr(file,"snd-mixer-oss"); - if (snd_pcm_oss==NULL){ - lc->vtable.display_warning(lc,_("Your computer appears to be using ALSA sound drivers.\nThis is the best choice. However the pcm oss emulation module\nis missing and linphone needs it. Please execute\n'modprobe snd-pcm-oss' as root to load it.")); - } - if (snd_mixer_oss==NULL){ - lc->vtable.display_warning(lc,_("Your computer appears to be using ALSA sound drivers.\nThis is the best choice. However the mixer oss emulation module\nis missing and linphone needs it. Please execute\n 'modprobe snd-mixer-oss' as root to load it.")); - } - } - }else { - - ms_warning("Could not open /proc/modules."); - } - /* now check general volume. Some user forget to rise it and then complain that linphone is - not working */ - /* but some other users complain that linphone should not change levels... - if (lc->sound_conf.sndcard!=NULL){ - a=snd_card_get_level(lc->sound_conf.sndcard,SND_CARD_LEVEL_GENERAL); - if (a<50){ - ms_warning("General level is quite low (%i). Linphone rises it up for you.",a); - snd_card_set_level(lc->sound_conf.sndcard,SND_CARD_LEVEL_GENERAL,80); - } - } - */ - end: - if (file!=NULL) ms_free(file); - if (fd>0) close(fd); -#endif -} - -#define UDP_HDR_SZ 8 -#define RTP_HDR_SZ 12 -#define IP4_HDR_SZ 20 /*20 is the minimum, but there may be some options*/ - -static void payload_type_set_enable(PayloadType *pt,int value) -{ - if ((value)!=0) payload_type_set_flag(pt,PAYLOAD_TYPE_ENABLED); \ - else payload_type_unset_flag(pt,PAYLOAD_TYPE_ENABLED); -} - -static bool_t payload_type_enabled(const PayloadType *pt) { - return (((pt)->flags & PAYLOAD_TYPE_ENABLED)!=0); -} - -bool_t linphone_core_payload_type_enabled(LinphoneCore *lc, const PayloadType *pt){ - if (ms_list_find(lc->codecs_conf.audio_codecs, (PayloadType*) pt) || ms_list_find(lc->codecs_conf.video_codecs, (PayloadType*)pt)){ - return payload_type_enabled(pt); - } - ms_error("Getting enablement status of codec not in audio or video list of PayloadType !"); - return FALSE; -} - -int linphone_core_enable_payload_type(LinphoneCore *lc, PayloadType *pt, bool_t enabled){ - if (ms_list_find(lc->codecs_conf.audio_codecs,pt) || ms_list_find(lc->codecs_conf.video_codecs,pt)){ - payload_type_set_enable(pt,enabled); - _linphone_core_codec_config_write(lc); - return 0; - } - ms_error("Enabling codec not in audio or video list of PayloadType !"); - return -1; -} - -int linphone_core_get_payload_type_number(LinphoneCore *lc, const PayloadType *pt){ - return payload_type_get_number(pt); -} - -const char *linphone_core_get_payload_type_description(LinphoneCore *lc, PayloadType *pt){ - if (ms_filter_codec_supported(pt->mime_type)){ - MSFilterDesc *desc=ms_filter_get_encoder(pt->mime_type); -#ifdef ENABLE_NLS - return dgettext("mediastreamer",desc->text); -#else - return desc->text; -#endif - } - return NULL; -} - - -/*this function makes a special case for speex/8000. -This codec is variable bitrate. The 8kbit/s mode is interesting when having a low upload bandwidth, but its quality -is not very good. We 'd better use its 15kbt/s mode when we have enough bandwidth*/ -static int get_codec_bitrate(LinphoneCore *lc, const PayloadType *pt){ - int upload_bw=linphone_core_get_upload_bandwidth(lc); - if (bandwidth_is_greater(upload_bw,129) || (bandwidth_is_greater(upload_bw,33) && !linphone_core_video_enabled(lc)) ) { - if (strcmp(pt->mime_type,"speex")==0 && pt->clock_rate==8000){ - return 15000; - } - } - return pt->normal_bitrate; -} - -static double get_audio_payload_bandwidth(LinphoneCore *lc, const PayloadType *pt){ - double npacket=50; - double packet_size; - int bitrate; - bitrate=get_codec_bitrate(lc,pt); - packet_size= (((double)bitrate)/(50*8))+UDP_HDR_SZ+RTP_HDR_SZ+IP4_HDR_SZ; - return packet_size*8.0*npacket; -} - -void linphone_core_update_allocated_audio_bandwidth_in_call(LinphoneCall *call, const PayloadType *pt){ - call->audio_bw=(int)(ceil(get_audio_payload_bandwidth(call->core,pt)/1000.0)); /*rounding codec bandwidth should be avoid, specially for AMR*/ - ms_message("Audio bandwidth for this call is %i",call->audio_bw); -} - -void linphone_core_update_allocated_audio_bandwidth(LinphoneCore *lc){ - const MSList *elem; - PayloadType *max=NULL; - for(elem=linphone_core_get_audio_codecs(lc);elem!=NULL;elem=elem->next){ - PayloadType *pt=(PayloadType*)elem->data; - if (payload_type_enabled(pt)){ - int pt_bitrate=get_codec_bitrate(lc,pt); - if (max==NULL) max=pt; - else if (max->normal_bitrateaudio_bw=(int)(get_audio_payload_bandwidth(lc,max)/1000.0); - } -} - -bool_t linphone_core_is_payload_type_usable_for_bandwidth(LinphoneCore *lc, PayloadType *pt, int bandwidth_limit) -{ - double codec_band; - bool_t ret=FALSE; - - switch (pt->type){ - case PAYLOAD_AUDIO_CONTINUOUS: - case PAYLOAD_AUDIO_PACKETIZED: - codec_band=get_audio_payload_bandwidth(lc,pt); - ret=bandwidth_is_greater(bandwidth_limit*1000,codec_band); - /*hack to avoid using uwb codecs when having low bitrate and video*/ - if (bandwidth_is_greater(199,bandwidth_limit)){ - if (linphone_core_video_enabled(lc) && pt->clock_rate>16000){ - ret=FALSE; - } - } - //ms_message("Payload %s: %g",pt->mime_type,codec_band); - break; - case PAYLOAD_VIDEO: - if (bandwidth_limit!=0) {/* infinite (-1) or strictly positive*/ - ret=TRUE; - } - else ret=FALSE; - break; - } - return ret; -} - -/* return TRUE if codec can be used with bandwidth, FALSE else*/ -bool_t linphone_core_check_payload_type_usability(LinphoneCore *lc, PayloadType *pt) -{ - double codec_band; - int allowed_bw,video_bw; - bool_t ret=FALSE; - - linphone_core_update_allocated_audio_bandwidth(lc); - allowed_bw=get_min_bandwidth(linphone_core_get_download_bandwidth(lc), - linphone_core_get_upload_bandwidth(lc)); - if (allowed_bw==0) { - allowed_bw=-1; - video_bw=1500; /*around 1.5 Mbit/s*/ - }else - video_bw=get_video_bandwidth(allowed_bw,lc->audio_bw); - - switch (pt->type){ - case PAYLOAD_AUDIO_CONTINUOUS: - case PAYLOAD_AUDIO_PACKETIZED: - codec_band=get_audio_payload_bandwidth(lc,pt); - ret=bandwidth_is_greater(allowed_bw*1000,codec_band); - /*hack to avoid using uwb codecs when having low bitrate and video*/ - if (bandwidth_is_greater(199,allowed_bw)){ - if (linphone_core_video_enabled(lc) && pt->clock_rate>16000){ - ret=FALSE; - } - } - //ms_message("Payload %s: %g",pt->mime_type,codec_band); - break; - case PAYLOAD_VIDEO: - if (video_bw>0){ - pt->normal_bitrate=video_bw*1000; - ret=TRUE; - } - else ret=FALSE; - break; - } - return ret; -} - -bool_t lp_spawn_command_line_sync(const char *command, char **result,int *command_ret){ -#if !defined(_WIN32_WCE) - FILE *f=popen(command,"r"); - if (f!=NULL){ - int err; - *result=ms_malloc(4096); - err=fread(*result,1,4096-1,f); - if (err<0){ - ms_warning("Error reading command output:%s",strerror(errno)); - ms_free(result); - return FALSE; - } - (*result)[err]=0; - err=pclose(f); - if (command_ret!=NULL) *command_ret=err; - return TRUE; - } -#endif /*_WIN32_WCE*/ - return FALSE; -} - -static ortp_socket_t create_socket(int local_port){ - struct sockaddr_in laddr; - ortp_socket_t sock; - int optval; - sock=socket(PF_INET,SOCK_DGRAM,IPPROTO_UDP); - if (sock<0) { - ms_error("Fail to create socket"); - return -1; - } - memset (&laddr,0,sizeof(laddr)); - laddr.sin_family=AF_INET; - laddr.sin_addr.s_addr=INADDR_ANY; - laddr.sin_port=htons(local_port); - if (bind(sock,(struct sockaddr*)&laddr,sizeof(laddr))<0){ - ms_error("Bind socket to 0.0.0.0:%i failed: %s",local_port,getSocketError()); - close_socket(sock); - return -1; - } - optval=1; - if (setsockopt (sock, SOL_SOCKET, SO_REUSEADDR, - (SOCKET_OPTION_VALUE)&optval, sizeof (optval))<0){ - ms_warning("Fail to set SO_REUSEADDR"); - } - set_non_blocking_socket(sock); - return sock; -} - -static int sendStunRequest(int sock, const struct sockaddr *server, socklen_t addrlen, int id, bool_t changeAddr){ - char buf[STUN_MAX_MESSAGE_SIZE]; - int len = STUN_MAX_MESSAGE_SIZE; - StunAtrString username; - StunAtrString password; - StunMessage req; - int err; - memset(&req, 0, sizeof(StunMessage)); - memset(&username,0,sizeof(username)); - memset(&password,0,sizeof(password)); - stunBuildReqSimple( &req, &username, changeAddr , changeAddr , id); - len = stunEncodeMessage( &req, buf, len, &password); - if (len<=0){ - ms_error("Fail to encode stun message."); - return -1; - } - err=sendto(sock,buf,len,0,server,addrlen); - if (err<0){ - ms_error("sendto failed: %s",strerror(errno)); - return -1; - } - return 0; -} - -int parse_hostname_to_addr(const char *server, struct sockaddr_storage *ss, socklen_t *socklen){ - struct addrinfo hints,*res=NULL; - int family = PF_INET; - int port_int = 3478; - int ret; - char port[6]; - char host[NI_MAXHOST]; - char *p1, *p2; - if ((sscanf(server, "[%64[^]]]:%d", host, &port_int) == 2) || (sscanf(server, "[%64[^]]]", host) == 1)) { - family = PF_INET6; - } else { - p1 = strchr(server, ':'); - p2 = strrchr(server, ':'); - if (p1 && p2 && (p1 != p2)) { - family = PF_INET6; - host[NI_MAXHOST-1]='\0'; - strncpy(host, server, sizeof(host) - 1); - } else if (sscanf(server, "%[^:]:%d", host, &port_int) != 2) { - host[NI_MAXHOST-1]='\0'; - strncpy(host, server, sizeof(host) - 1); - } - } - snprintf(port, sizeof(port), "%d", port_int); - memset(&hints,0,sizeof(hints)); - hints.ai_family=family; - hints.ai_socktype=SOCK_DGRAM; - hints.ai_protocol=IPPROTO_UDP; - ret=getaddrinfo(host,port,&hints,&res); - if (ret!=0){ - ms_error("getaddrinfo() failed for %s:%s : %s",host,port,gai_strerror(ret)); - return -1; - } - if (!res) return -1; - memcpy(ss,res->ai_addr,res->ai_addrlen); - *socklen=res->ai_addrlen; - freeaddrinfo(res); - return 0; -} - -static int recvStunResponse(ortp_socket_t sock, char *ipaddr, int *port, int *id){ - char buf[STUN_MAX_MESSAGE_SIZE]; - int len = STUN_MAX_MESSAGE_SIZE; - StunMessage resp; - len=recv(sock,buf,len,0); - if (len>0){ - struct in_addr ia; - stunParseMessage(buf,len, &resp ); - *id=resp.msgHdr.tr_id.octet[0]; - if (resp.hasXorMappedAddress){ - *port = resp.xorMappedAddress.ipv4.port; - ia.s_addr=htonl(resp.xorMappedAddress.ipv4.addr); - }else if (resp.hasMappedAddress){ - *port = resp.mappedAddress.ipv4.port; - ia.s_addr=htonl(resp.mappedAddress.ipv4.addr); - }else return -1; - strncpy(ipaddr,inet_ntoa(ia),LINPHONE_IPADDR_SIZE); - } - return len; -} - -/* this functions runs a simple stun test and return the number of milliseconds to complete the tests, or -1 if the test were failed.*/ -int linphone_core_run_stun_tests(LinphoneCore *lc, LinphoneCall *call){ - const char *server=linphone_core_get_stun_server(lc); - StunCandidate *ac=&call->ac; - StunCandidate *vc=&call->vc; - - if (lc->sip_conf.ipv6_enabled){ - ms_warning("stun support is not implemented for ipv6"); - return -1; - } - if (server!=NULL){ - struct sockaddr_storage ss; - socklen_t ss_len; - ortp_socket_t sock1=-1, sock2=-1; - int loops=0; - bool_t video_enabled=linphone_core_video_enabled(lc); - bool_t got_audio,got_video; - bool_t cone_audio=FALSE,cone_video=FALSE; - struct timeval init,cur; - double elapsed; - int ret=0; - - if (parse_hostname_to_addr(server,&ss,&ss_len)<0){ - ms_error("Fail to parser stun server address: %s",server); - return -1; - } - if (lc->vtable.display_status!=NULL) - lc->vtable.display_status(lc,_("Stun lookup in progress...")); - - /*create the two audio and video RTP sockets, and send STUN message to our stun server */ - sock1=create_socket(call->audio_port); - if (sock1==-1) return -1; - if (video_enabled){ - sock2=create_socket(call->video_port); - if (sock2==-1) return -1; - } - got_audio=FALSE; - got_video=FALSE; - gettimeofday(&init,NULL); - do{ - - int id; - if (loops%20==0){ - ms_message("Sending stun requests..."); - sendStunRequest(sock1,(struct sockaddr*)&ss,ss_len,11,TRUE); - sendStunRequest(sock1,(struct sockaddr*)&ss,ss_len,1,FALSE); - if (sock2!=-1){ - sendStunRequest(sock2,(struct sockaddr*)&ss,ss_len,22,TRUE); - sendStunRequest(sock2,(struct sockaddr*)&ss,ss_len,2,FALSE); - } - } -#ifdef WIN32 - Sleep(10); -#else - usleep(10000); -#endif - - if (recvStunResponse(sock1,ac->addr, - &ac->port,&id)>0){ - ms_message("STUN test result: local audio port maps to %s:%i", - ac->addr, - ac->port); - if (id==11) - cone_audio=TRUE; - got_audio=TRUE; - } - if (recvStunResponse(sock2,vc->addr, - &vc->port,&id)>0){ - ms_message("STUN test result: local video port maps to %s:%i", - vc->addr, - vc->port); - if (id==22) - cone_video=TRUE; - got_video=TRUE; - } - gettimeofday(&cur,NULL); - elapsed=((cur.tv_sec-init.tv_sec)*1000.0) + ((cur.tv_usec-init.tv_usec)/1000.0); - if (elapsed>2000) { - ms_message("Stun responses timeout, going ahead."); - ret=-1; - break; - } - loops++; - }while(!(got_audio && (got_video||sock2==-1) ) ); - if (ret==0) ret=(int)elapsed; - if (!got_audio){ - ms_error("No stun server response for audio port."); - }else{ - if (!cone_audio) { - ms_message("NAT is symmetric for audio port"); - } - } - if (sock2!=-1){ - if (!got_video){ - ms_error("No stun server response for video port."); - }else{ - if (!cone_video) { - ms_message("NAT is symmetric for video port."); - } - } - } - close_socket(sock1); - if (sock2!=-1) close_socket(sock2); - return ret; - } - return -1; -} - -int linphone_core_get_edge_bw(LinphoneCore *lc){ - int edge_bw=lp_config_get_int(lc->config,"net","edge_bw",20); - return edge_bw; -} - -int linphone_core_get_edge_ptime(LinphoneCore *lc){ - int edge_ptime=lp_config_get_int(lc->config,"net","edge_ptime",100); - return edge_ptime; -} - -void linphone_core_adapt_to_network(LinphoneCore *lc, int ping_time_ms, LinphoneCallParams *params){ - int threshold; - if (ping_time_ms>0 && lp_config_get_int(lc->config,"net","activate_edge_workarounds",0)==1){ - ms_message("Stun server ping time is %i ms",ping_time_ms); - threshold=lp_config_get_int(lc->config,"net","edge_ping_time",500); - - if (ping_time_ms>threshold){ - /* we might be in a 2G network*/ - params->low_bandwidth=TRUE; - }/*else use default settings */ - } - if (params->low_bandwidth){ - params->up_bw=params->down_bw=linphone_core_get_edge_bw(lc); - params->up_ptime=params->down_ptime=linphone_core_get_edge_ptime(lc); - params->has_video=FALSE; - } -} - - - -int linphone_core_gather_ice_candidates(LinphoneCore *lc, LinphoneCall *call) -{ - char local_addr[64]; - struct sockaddr_storage ss; - socklen_t ss_len; - IceCheckList *audio_check_list; - IceCheckList *video_check_list; - const char *server = linphone_core_get_stun_server(lc); - - if ((server == NULL) || (call->ice_session == NULL)) return -1; - audio_check_list = ice_session_check_list(call->ice_session, 0); - video_check_list = ice_session_check_list(call->ice_session, 1); - if (audio_check_list == NULL) return -1; - - if (lc->sip_conf.ipv6_enabled){ - ms_warning("stun support is not implemented for ipv6"); - return -1; - } - - if (parse_hostname_to_addr(server, &ss, &ss_len) < 0) { - ms_error("Fail to parser stun server address: %s", server); - return -1; - } - if (lc->vtable.display_status != NULL) - lc->vtable.display_status(lc, _("ICE local candidates gathering in progress...")); - - /* Gather local host candidates. */ - if (linphone_core_get_local_ip_for(AF_INET, server, local_addr) < 0) { - ms_error("Fail to get local ip"); - return -1; - } - if ((ice_check_list_state(audio_check_list) != ICL_Completed) && (ice_check_list_candidates_gathered(audio_check_list) == FALSE)) { - ice_add_local_candidate(audio_check_list, "host", local_addr, call->audio_port, 1, NULL); - ice_add_local_candidate(audio_check_list, "host", local_addr, call->audio_port + 1, 2, NULL); - call->stats[LINPHONE_CALL_STATS_AUDIO].ice_state = LinphoneIceStateInProgress; - } - if (call->params.has_video && (video_check_list != NULL) - && (ice_check_list_state(video_check_list) != ICL_Completed) && (ice_check_list_candidates_gathered(video_check_list) == FALSE)) { - ice_add_local_candidate(video_check_list, "host", local_addr, call->video_port, 1, NULL); - ice_add_local_candidate(video_check_list, "host", local_addr, call->video_port + 1, 2, NULL); - call->stats[LINPHONE_CALL_STATS_VIDEO].ice_state = LinphoneIceStateInProgress; - } - - ms_message("ICE: gathering candidate from [%s]",server); - /* Gather local srflx candidates. */ - ice_session_gather_candidates(call->ice_session, ss, ss_len); - return 0; -} - -void linphone_core_update_ice_state_in_call_stats(LinphoneCall *call) -{ - IceCheckList *audio_check_list; - IceCheckList *video_check_list; - IceSessionState session_state; - - if (call->ice_session == NULL) return; - audio_check_list = ice_session_check_list(call->ice_session, 0); - video_check_list = ice_session_check_list(call->ice_session, 1); - if (audio_check_list == NULL) return; - - session_state = ice_session_state(call->ice_session); - if ((session_state == IS_Completed) || ((session_state == IS_Failed) && (ice_session_has_completed_check_list(call->ice_session) == TRUE))) { - if (ice_check_list_state(audio_check_list) == ICL_Completed) { - switch (ice_check_list_selected_valid_candidate_type(audio_check_list)) { - case ICT_HostCandidate: - call->stats[LINPHONE_CALL_STATS_AUDIO].ice_state = LinphoneIceStateHostConnection; - break; - case ICT_ServerReflexiveCandidate: - case ICT_PeerReflexiveCandidate: - call->stats[LINPHONE_CALL_STATS_AUDIO].ice_state = LinphoneIceStateReflexiveConnection; - break; - case ICT_RelayedCandidate: - call->stats[LINPHONE_CALL_STATS_AUDIO].ice_state = LinphoneIceStateRelayConnection; - break; - } - } else { - call->stats[LINPHONE_CALL_STATS_AUDIO].ice_state = LinphoneIceStateFailed; - } - if (call->params.has_video && (video_check_list != NULL)) { - if (ice_check_list_state(video_check_list) == ICL_Completed) { - switch (ice_check_list_selected_valid_candidate_type(video_check_list)) { - case ICT_HostCandidate: - call->stats[LINPHONE_CALL_STATS_VIDEO].ice_state = LinphoneIceStateHostConnection; - break; - case ICT_ServerReflexiveCandidate: - case ICT_PeerReflexiveCandidate: - call->stats[LINPHONE_CALL_STATS_VIDEO].ice_state = LinphoneIceStateReflexiveConnection; - break; - case ICT_RelayedCandidate: - call->stats[LINPHONE_CALL_STATS_VIDEO].ice_state = LinphoneIceStateRelayConnection; - break; - } - } else { - call->stats[LINPHONE_CALL_STATS_VIDEO].ice_state = LinphoneIceStateFailed; - } - } - } else if (session_state == IS_Running) { - call->stats[LINPHONE_CALL_STATS_AUDIO].ice_state = LinphoneIceStateInProgress; - if (call->params.has_video && (video_check_list != NULL)) { - call->stats[LINPHONE_CALL_STATS_VIDEO].ice_state = LinphoneIceStateInProgress; - } - } else { - call->stats[LINPHONE_CALL_STATS_AUDIO].ice_state = LinphoneIceStateFailed; - if (call->params.has_video && (video_check_list != NULL)) { - call->stats[LINPHONE_CALL_STATS_VIDEO].ice_state = LinphoneIceStateFailed; - } - } -} - -void linphone_core_update_local_media_description_from_ice(SalMediaDescription *desc, IceSession *session) -{ - const char *rtp_addr, *rtcp_addr; - IceSessionState session_state = ice_session_state(session); - int nb_candidates; - int i, j; - bool_t result; - - if (session_state == IS_Completed) { - desc->ice_completed = TRUE; - result = ice_check_list_selected_valid_local_candidate(ice_session_check_list(session, 0), &rtp_addr, NULL, NULL, NULL); - if (result == TRUE) { - strncpy(desc->addr, rtp_addr, sizeof(desc->addr)); - } else { - ms_warning("If ICE has completed successfully, rtp_addr should be set!"); - } - } - else { - desc->ice_completed = FALSE; - } - strncpy(desc->ice_pwd, ice_session_local_pwd(session), sizeof(desc->ice_pwd)); - strncpy(desc->ice_ufrag, ice_session_local_ufrag(session), sizeof(desc->ice_ufrag)); - for (i = 0; i < desc->n_active_streams; i++) { - SalStreamDescription *stream = &desc->streams[i]; - IceCheckList *cl = ice_session_check_list(session, i); - nb_candidates = 0; - if (cl == NULL) continue; - if (ice_check_list_state(cl) == ICL_Completed) { - stream->ice_completed = TRUE; - result = ice_check_list_selected_valid_local_candidate(ice_session_check_list(session, i), &rtp_addr, &stream->rtp_port, &rtcp_addr, &stream->rtcp_port); - } else { - stream->ice_completed = FALSE; - result = ice_check_list_default_local_candidate(ice_session_check_list(session, i), &rtp_addr, &stream->rtp_port, &rtcp_addr, &stream->rtcp_port); - } - if (result == TRUE) { - strncpy(stream->rtp_addr, rtp_addr, sizeof(stream->rtp_addr)); - strncpy(stream->rtcp_addr, rtcp_addr, sizeof(stream->rtcp_addr)); - } else { - memset(stream->rtp_addr, 0, sizeof(stream->rtp_addr)); - memset(stream->rtcp_addr, 0, sizeof(stream->rtcp_addr)); - } - if ((strlen(ice_check_list_local_pwd(cl)) != strlen(desc->ice_pwd)) || (strcmp(ice_check_list_local_pwd(cl), desc->ice_pwd))) - strncpy(stream->ice_pwd, ice_check_list_local_pwd(cl), sizeof(stream->ice_pwd)); - else - memset(stream->ice_pwd, 0, sizeof(stream->ice_pwd)); - if ((strlen(ice_check_list_local_ufrag(cl)) != strlen(desc->ice_ufrag)) || (strcmp(ice_check_list_local_ufrag(cl), desc->ice_ufrag))) - strncpy(stream->ice_ufrag, ice_check_list_local_ufrag(cl), sizeof(stream->ice_ufrag)); - else - memset(stream->ice_pwd, 0, sizeof(stream->ice_pwd)); - stream->ice_mismatch = ice_check_list_is_mismatch(cl); - if ((ice_check_list_state(cl) == ICL_Running) || (ice_check_list_state(cl) == ICL_Completed)) { - memset(stream->ice_candidates, 0, sizeof(stream->ice_candidates)); - for (j = 0; j < MIN(ms_list_size(cl->local_candidates), SAL_MEDIA_DESCRIPTION_MAX_ICE_CANDIDATES); j++) { - SalIceCandidate *sal_candidate = &stream->ice_candidates[nb_candidates]; - IceCandidate *ice_candidate = ms_list_nth_data(cl->local_candidates, j); - const char *default_addr = NULL; - int default_port = 0; - if (ice_candidate->componentID == 1) { - default_addr = stream->rtp_addr; - default_port = stream->rtp_port; - } else if (ice_candidate->componentID == 2) { - default_addr = stream->rtcp_addr; - default_port = stream->rtcp_port; - } else continue; - if (default_addr[0] == '\0') default_addr = desc->addr; - /* Only include the candidates matching the default destination for each component of the stream if the state is Completed as specified in RFC5245 section 9.1.2.2. */ - if ((ice_check_list_state(cl) == ICL_Completed) - && !((ice_candidate->taddr.port == default_port) && (strlen(ice_candidate->taddr.ip) == strlen(default_addr)) && (strcmp(ice_candidate->taddr.ip, default_addr) == 0))) - continue; - strncpy(sal_candidate->foundation, ice_candidate->foundation, sizeof(sal_candidate->foundation)); - sal_candidate->componentID = ice_candidate->componentID; - sal_candidate->priority = ice_candidate->priority; - strncpy(sal_candidate->type, ice_candidate_type(ice_candidate), sizeof(sal_candidate->type)); - strncpy(sal_candidate->addr, ice_candidate->taddr.ip, sizeof(sal_candidate->addr)); - sal_candidate->port = ice_candidate->taddr.port; - if ((ice_candidate->base != NULL) && (ice_candidate->base != ice_candidate)) { - strncpy(sal_candidate->raddr, ice_candidate->base->taddr.ip, sizeof(sal_candidate->raddr)); - sal_candidate->rport = ice_candidate->base->taddr.port; - } - nb_candidates++; - } - } - if ((ice_check_list_state(cl) == ICL_Completed) && (ice_session_role(session) == IR_Controlling)) { - int rtp_port, rtcp_port; - memset(stream->ice_remote_candidates, 0, sizeof(stream->ice_remote_candidates)); - if (ice_check_list_selected_valid_remote_candidate(cl, &rtp_addr, &rtp_port, &rtcp_addr, &rtcp_port) == TRUE) { - strncpy(stream->ice_remote_candidates[0].addr, rtp_addr, sizeof(stream->ice_remote_candidates[0].addr)); - stream->ice_remote_candidates[0].port = rtp_port; - strncpy(stream->ice_remote_candidates[1].addr, rtcp_addr, sizeof(stream->ice_remote_candidates[1].addr)); - stream->ice_remote_candidates[1].port = rtcp_port; - } else { - ms_error("ice: Selected valid remote candidates should be present if the check list is in the Completed state"); - } - } else { - for (j = 0; j < SAL_MEDIA_DESCRIPTION_MAX_ICE_REMOTE_CANDIDATES; j++) { - stream->ice_remote_candidates[j].addr[0] = '\0'; - stream->ice_remote_candidates[j].port = 0; - } - } - } -} - -static void get_default_addr_and_port(uint16_t componentID, const SalMediaDescription *md, const SalStreamDescription *stream, const char **addr, int *port) -{ - if (componentID == 1) { - *addr = stream->rtp_addr; - *port = stream->rtp_port; - } else if (componentID == 2) { - *addr = stream->rtcp_addr; - *port = stream->rtcp_port; - } else return; - if ((*addr)[0] == '\0') *addr = md->addr; -} - -void linphone_core_update_ice_from_remote_media_description(LinphoneCall *call, const SalMediaDescription *md) -{ - bool_t ice_restarted = FALSE; - - if ((md->ice_pwd[0] != '\0') && (md->ice_ufrag[0] != '\0')) { - int i, j; - - /* Check for ICE restart and set remote credentials. */ - if ((strcmp(md->addr, "0.0.0.0") == 0) || (strcmp(md->addr, "::0") == 0)) { - ice_session_restart(call->ice_session); - ice_restarted = TRUE; - } else { - for (i = 0; i < md->n_total_streams; i++) { - const SalStreamDescription *stream = &md->streams[i]; - IceCheckList *cl = ice_session_check_list(call->ice_session, i); - if (cl && (strcmp(stream->rtp_addr, "0.0.0.0") == 0)) { - ice_session_restart(call->ice_session); - ice_restarted = TRUE; - break; - } - } - } - if ((ice_session_remote_ufrag(call->ice_session) == NULL) && (ice_session_remote_pwd(call->ice_session) == NULL)) { - ice_session_set_remote_credentials(call->ice_session, md->ice_ufrag, md->ice_pwd); - } else if (ice_session_remote_credentials_changed(call->ice_session, md->ice_ufrag, md->ice_pwd)) { - if (ice_restarted == FALSE) { - ice_session_restart(call->ice_session); - ice_restarted = TRUE; - } - ice_session_set_remote_credentials(call->ice_session, md->ice_ufrag, md->ice_pwd); - } - for (i = 0; i < md->n_total_streams; i++) { - const SalStreamDescription *stream = &md->streams[i]; - IceCheckList *cl = ice_session_check_list(call->ice_session, i); - if (cl && (stream->ice_pwd[0] != '\0') && (stream->ice_ufrag[0] != '\0')) { - if (ice_check_list_remote_credentials_changed(cl, stream->ice_ufrag, stream->ice_pwd)) { - if (ice_restarted == FALSE) { - ice_session_restart(call->ice_session); - ice_restarted = TRUE; - } - ice_session_set_remote_credentials(call->ice_session, md->ice_ufrag, md->ice_pwd); - break; - } - } - } - - /* Create ICE check lists if needed and parse ICE attributes. */ - for (i = 0; i < md->n_total_streams; i++) { - const SalStreamDescription *stream = &md->streams[i]; - IceCheckList *cl = ice_session_check_list(call->ice_session, i); - if (cl == NULL) { - cl = ice_check_list_new(); - ice_session_add_check_list(call->ice_session, cl); - switch (stream->type) { - case SalAudio: - if (call->audiostream != NULL) call->audiostream->ms.ice_check_list = cl; - break; - case SalVideo: - if (call->videostream != NULL) call->videostream->ms.ice_check_list = cl; - break; - default: - break; - } - } - if (stream->ice_mismatch == TRUE) { - ice_check_list_set_state(cl, ICL_Failed); - } else if (stream->rtp_port == 0) { - ice_session_remove_check_list(call->ice_session, cl); - } else { - if ((stream->ice_pwd[0] != '\0') && (stream->ice_ufrag[0] != '\0')) - ice_check_list_set_remote_credentials(cl, stream->ice_ufrag, stream->ice_pwd); - for (j = 0; j < SAL_MEDIA_DESCRIPTION_MAX_ICE_CANDIDATES; j++) { - const SalIceCandidate *candidate = &stream->ice_candidates[j]; - bool_t default_candidate = FALSE; - const char *addr = NULL; - int port = 0; - if (candidate->addr[0] == '\0') break; - if ((candidate->componentID == 0) || (candidate->componentID > 2)) continue; - get_default_addr_and_port(candidate->componentID, md, stream, &addr, &port); - if (addr && (candidate->port == port) && (strlen(candidate->addr) == strlen(addr)) && (strcmp(candidate->addr, addr) == 0)) - default_candidate = TRUE; - ice_add_remote_candidate(cl, candidate->type, candidate->addr, candidate->port, candidate->componentID, - candidate->priority, candidate->foundation, default_candidate); - } - if (ice_restarted == FALSE) { - bool_t losing_pairs_added = FALSE; - for (j = 0; j < SAL_MEDIA_DESCRIPTION_MAX_ICE_REMOTE_CANDIDATES; j++) { - const SalIceRemoteCandidate *candidate = &stream->ice_remote_candidates[j]; - const char *addr = NULL; - int port = 0; - int componentID = j + 1; - if (candidate->addr[0] == '\0') break; - get_default_addr_and_port(componentID, md, stream, &addr, &port); - if (j == 0) { - /* If we receive a re-invite and we finished ICE processing on our side, use the candidates given by the remote. */ - ice_check_list_unselect_valid_pairs(cl); - } - ice_add_losing_pair(cl, j + 1, candidate->addr, candidate->port, addr, port); - losing_pairs_added = TRUE; - } - if (losing_pairs_added == TRUE) ice_check_list_check_completed(cl); - } - } - } - for (i = ice_session_nb_check_lists(call->ice_session); i > md->n_active_streams; i--) { - ice_session_remove_check_list(call->ice_session, ice_session_check_list(call->ice_session, i - 1)); - } - ice_session_check_mismatch(call->ice_session); - } else { - /* Response from remote does not contain mandatory ICE attributes, delete the session. */ - linphone_call_delete_ice_session(call); - return; - } - if (ice_session_nb_check_lists(call->ice_session) == 0) { - linphone_call_delete_ice_session(call); - } -} - -bool_t linphone_core_media_description_contains_video_stream(const SalMediaDescription *md) -{ - int i; - - for (i = 0; i < md->n_active_streams; i++) { - if (md->streams[i].type == SalVideo) - return TRUE; - } - return FALSE; -} - -LinphoneCall * is_a_linphone_call(void *user_pointer){ - LinphoneCall *call=(LinphoneCall*)user_pointer; - if (call==NULL) return NULL; - return call->magic==linphone_call_magic ? call : NULL; -} - -LinphoneProxyConfig * is_a_linphone_proxy_config(void *user_pointer){ - LinphoneProxyConfig *cfg=(LinphoneProxyConfig*)user_pointer; - if (cfg==NULL) return NULL; - return cfg->magic==linphone_proxy_config_magic ? cfg : NULL; -} - -unsigned int linphone_core_get_audio_features(LinphoneCore *lc){ - unsigned int ret=0; - const char *features=lp_config_get_string(lc->config,"sound","features",NULL); - if (features){ - char tmp[256]={0}; - char name[256]; - char *p,*n; - strncpy(tmp,features,sizeof(tmp)-1); - for(p=tmp;*p!='\0';p++){ - if (*p==' ') continue; - n=strchr(p,'|'); - if (n) *n='\0'; - sscanf(p,"%s",name); - ms_message("Found audio feature %s",name); - if (strcasecmp(name,"PLC")==0) ret|=AUDIO_STREAM_FEATURE_PLC; - else if (strcasecmp(name,"EC")==0) ret|=AUDIO_STREAM_FEATURE_EC; - else if (strcasecmp(name,"EQUALIZER")==0) ret|=AUDIO_STREAM_FEATURE_EQUALIZER; - else if (strcasecmp(name,"VOL_SND")==0) ret|=AUDIO_STREAM_FEATURE_VOL_SND; - else if (strcasecmp(name,"VOL_RCV")==0) ret|=AUDIO_STREAM_FEATURE_VOL_RCV; - else if (strcasecmp(name,"DTMF")==0) ret|=AUDIO_STREAM_FEATURE_DTMF; - else if (strcasecmp(name,"DTMF_ECHO")==0) ret|=AUDIO_STREAM_FEATURE_DTMF_ECHO; - else if (strcasecmp(name,"MIXED_RECORDING")==0) ret|=AUDIO_STREAM_FEATURE_MIXED_RECORDING; - else if (strcasecmp(name,"ALL")==0) ret|=AUDIO_STREAM_FEATURE_ALL; - else if (strcasecmp(name,"NONE")==0) ret=0; - else ms_error("Unsupported audio feature %s requested in config file.",name); - if (!n) break; - p=n; - } - }else ret=AUDIO_STREAM_FEATURE_ALL; - - if (ret==AUDIO_STREAM_FEATURE_ALL){ - /*since call recording is specified before creation of the stream in linphonecore, - * it will be requested on demand. It is not necessary to include it all the time*/ - ret&=~AUDIO_STREAM_FEATURE_MIXED_RECORDING; - } - return ret; -} - - -#ifdef HAVE_GETIFADDRS - -#include -static int get_local_ip_with_getifaddrs(int type, char *address, int size) -{ - struct ifaddrs *ifp; - struct ifaddrs *ifpstart; - int ret = 0; - - if (getifaddrs(&ifpstart) < 0) { - return -1; - } -#ifndef __linux - #define UP_FLAG IFF_UP /* interface is up */ -#else - #define UP_FLAG IFF_RUNNING /* resources allocated */ -#endif - - for (ifp = ifpstart; ifp != NULL; ifp = ifp->ifa_next) { - if (ifp->ifa_addr && ifp->ifa_addr->sa_family == type - && (ifp->ifa_flags & UP_FLAG) && !(ifp->ifa_flags & IFF_LOOPBACK)) - { - if(getnameinfo(ifp->ifa_addr, - (type == AF_INET6) ? - sizeof(struct sockaddr_in6) : sizeof(struct sockaddr_in), - address, size, NULL, 0, NI_NUMERICHOST) == 0) { - if (strchr(address, '%') == NULL) { /*avoid ipv6 link-local addresses */ - /*ms_message("getifaddrs() found %s",address);*/ - ret++; - break; - } - } - } - } - freeifaddrs(ifpstart); - return ret; -} -#endif - - -static int get_local_ip_for_with_connect(int type, const char *dest, char *result){ - int err,tmp; - struct addrinfo hints; - struct addrinfo *res=NULL; - struct sockaddr_storage addr; - struct sockaddr *p_addr=(struct sockaddr*)&addr; - ortp_socket_t sock; - socklen_t s; - - memset(&hints,0,sizeof(hints)); - hints.ai_family=(type==AF_INET6) ? PF_INET6 : PF_INET; - hints.ai_socktype=SOCK_DGRAM; - /*hints.ai_flags=AI_NUMERICHOST|AI_CANONNAME;*/ - err=getaddrinfo(dest,"5060",&hints,&res); - if (err!=0){ - ms_error("getaddrinfo() error: %s",gai_strerror(err)); - return -1; - } - if (res==NULL){ - ms_error("bug: getaddrinfo returned nothing."); - return -1; - } - sock=socket(res->ai_family,SOCK_DGRAM,0); - tmp=1; - err=setsockopt(sock,SOL_SOCKET,SO_REUSEADDR,(SOCKET_OPTION_VALUE)&tmp,sizeof(int)); - if (err<0){ - ms_warning("Error in setsockopt: %s",strerror(errno)); - } - err=connect(sock,res->ai_addr,res->ai_addrlen); - if (err<0) { - ms_error("Error in connect: %s",strerror(errno)); - freeaddrinfo(res); - close_socket(sock); - return -1; - } - freeaddrinfo(res); - res=NULL; - s=sizeof(addr); - err=getsockname(sock,(struct sockaddr*)&addr,&s); - if (err!=0) { - ms_error("Error in getsockname: %s",strerror(errno)); - close_socket(sock); - return -1; - } - if (p_addr->sa_family==AF_INET){ - struct sockaddr_in *p_sin=(struct sockaddr_in*)p_addr; - if (p_sin->sin_addr.s_addr==0){ - close_socket(sock); - return -1; - } - } - err=getnameinfo((struct sockaddr *)&addr,s,result,LINPHONE_IPADDR_SIZE,NULL,0,NI_NUMERICHOST); - if (err!=0){ - ms_error("getnameinfo error: %s",strerror(errno)); - } - close_socket(sock); - ms_message("Local interface to reach %s is %s.",dest,result); - return 0; -} - -int linphone_core_get_local_ip_for(int type, const char *dest, char *result){ - strcpy(result,type==AF_INET ? "127.0.0.1" : "::1"); -#ifdef HAVE_GETIFADDRS - if (dest==NULL) { - /*we use getifaddrs for lookup of default interface */ - int found_ifs; - - found_ifs=get_local_ip_with_getifaddrs(type,result,LINPHONE_IPADDR_SIZE); - if (found_ifs==1){ - return 0; - }else if (found_ifs<=0){ - /*absolutely no network on this machine */ - return -1; - } - } -#endif - /*else use connect to find the best local ip address */ - if (type==AF_INET) - dest="87.98.157.38"; /*a public IP address*/ - else dest="2a00:1450:8002::68"; - return get_local_ip_for_with_connect(type,dest,result); -} - -#ifndef WIN32 -#include - - - -void _linphone_core_configure_resolver(){ -/*bionic declares _res but does not define nor export it !!*/ -#ifdef ANDROID - /*timeout and attempts are the same as retrans and retry, but are android specific names.*/ - setenv("RES_OPTIONS","timeout:2 attempts:2 retrans:2 retry:2",1); -#else - res_init(); - _res.retrans=2; /*retransmit every two seconds*/ - _res.retry=2; /*only two times per DNS server*/ -#endif -} - -#else - -void _linphone_core_configure_resolver(){ -} - -#endif + +/* +linphone +Copyright (C) 2000 Simon MORLAT (simon.morlat@linphone.org) + +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 the Free Software Foundation; either version 2 +of the License, or (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, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#include "private.h" +#include "lpconfig.h" +#include "mediastreamer2/mediastream.h" +#include +#include +#ifdef HAVE_SIGHANDLER_T +#include +#endif /*HAVE_SIGHANDLER_T*/ + +#include +#if !defined(_WIN32_WCE) +#include +#include +#include +#if _MSC_VER +#include +#else +#include +#endif +#include +#endif /*_WIN32_WCE*/ + +#undef snprintf +#include + +#ifdef HAVE_GETIFADDRS +#include +#include +#endif +#include +#if _MSC_VER +#define snprintf _snprintf +#define popen _popen +#define pclose _pclose +#endif + +#if !defined(WIN32) + +static char lock_name[80]; +static char lock_set=0; +/* put a lock file in /tmp. this is called when linphone runs as a daemon*/ +int set_lock_file() +{ + FILE *lockfile; + + snprintf(lock_name,80,"/tmp/linphone.%i",getuid()); + lockfile=fopen(lock_name,"w"); + if (lockfile==NULL) + { + printf("Failed to create lock file.\n"); + return(-1); + } + fprintf(lockfile,"%i",getpid()); + fclose(lockfile); + lock_set=1; + return(0); +} + +/* looks if there is a lock file. If presents return its content (the pid of the already running linphone), if not found, returns -1*/ +int get_lock_file() +{ + int pid; + FILE *lockfile; + + snprintf(lock_name,80,"/tmp/linphone.%i",getuid()); + lockfile=fopen(lock_name,"r"); + if (lockfile==NULL) + return(-1); + if (fscanf(lockfile,"%i",&pid)!=1){ + ms_warning("Could not read pid in lock file."); + fclose(lockfile); + return -1; + } + fclose(lockfile); + return pid; +} + +/* remove the lock file if it was set*/ +int remove_lock_file() +{ + int err=0; + if (lock_set) + { + err=unlink(lock_name); + lock_set=0; + } + return(err); +} + +#endif + +char *int2str(int number) +{ + char *numstr=ms_malloc(10); + snprintf(numstr,10,"%i",number); + return numstr; +} + +void check_sound_device(LinphoneCore *lc) +{ +#ifdef _linux + int fd=0; + int len; + int a; + char *file=NULL; + char *i810_audio=NULL; + char *snd_pcm_oss=NULL; + char *snd_mixer_oss=NULL; + char *snd_pcm=NULL; + fd=open("/proc/modules",O_RDONLY); + + if (fd>0){ + /* read the entire /proc/modules file and check if sound conf seems correct */ + /*a=fstat(fd,&statbuf); + if (a<0) ms_warning("Can't stat /proc/modules:%s.",strerror(errno)); + len=statbuf.st_size; + if (len==0) ms_warning("/proc/modules has zero size!"); + */ + /***** fstat does not work on /proc/modules for unknown reason *****/ + len=6000; + file=ms_malloc(len+1); + a=read(fd,file,len); + if (avtable.display_warning(lc,_("You are currently using the i810_audio driver.\nThis driver is buggy and so does not work with Linphone.\nWe suggest that you replace it by its equivalent ALSA driver,\neither with packages from your distribution, or by downloading\nALSA drivers at http://www.alsa-project.org."));*/ + goto end; + } + snd_pcm=strstr(file,"snd-pcm"); + if (snd_pcm!=NULL){ + snd_pcm_oss=strstr(file,"snd-pcm-oss"); + snd_mixer_oss=strstr(file,"snd-mixer-oss"); + if (snd_pcm_oss==NULL){ + lc->vtable.display_warning(lc,_("Your computer appears to be using ALSA sound drivers.\nThis is the best choice. However the pcm oss emulation module\nis missing and linphone needs it. Please execute\n'modprobe snd-pcm-oss' as root to load it.")); + } + if (snd_mixer_oss==NULL){ + lc->vtable.display_warning(lc,_("Your computer appears to be using ALSA sound drivers.\nThis is the best choice. However the mixer oss emulation module\nis missing and linphone needs it. Please execute\n 'modprobe snd-mixer-oss' as root to load it.")); + } + } + }else { + + ms_warning("Could not open /proc/modules."); + } + /* now check general volume. Some user forget to rise it and then complain that linphone is + not working */ + /* but some other users complain that linphone should not change levels... + if (lc->sound_conf.sndcard!=NULL){ + a=snd_card_get_level(lc->sound_conf.sndcard,SND_CARD_LEVEL_GENERAL); + if (a<50){ + ms_warning("General level is quite low (%i). Linphone rises it up for you.",a); + snd_card_set_level(lc->sound_conf.sndcard,SND_CARD_LEVEL_GENERAL,80); + } + } + */ + end: + if (file!=NULL) ms_free(file); + if (fd>0) close(fd); +#endif +} + +#define UDP_HDR_SZ 8 +#define RTP_HDR_SZ 12 +#define IP4_HDR_SZ 20 /*20 is the minimum, but there may be some options*/ + +static void payload_type_set_enable(PayloadType *pt,int value) +{ + if ((value)!=0) payload_type_set_flag(pt,PAYLOAD_TYPE_ENABLED); \ + else payload_type_unset_flag(pt,PAYLOAD_TYPE_ENABLED); +} + +static bool_t payload_type_enabled(const PayloadType *pt) { + return (((pt)->flags & PAYLOAD_TYPE_ENABLED)!=0); +} + +bool_t linphone_core_payload_type_enabled(LinphoneCore *lc, const PayloadType *pt){ + if (ms_list_find(lc->codecs_conf.audio_codecs, (PayloadType*) pt) || ms_list_find(lc->codecs_conf.video_codecs, (PayloadType*)pt)){ + return payload_type_enabled(pt); + } + ms_error("Getting enablement status of codec not in audio or video list of PayloadType !"); + return FALSE; +} + +int linphone_core_enable_payload_type(LinphoneCore *lc, PayloadType *pt, bool_t enabled){ + if (ms_list_find(lc->codecs_conf.audio_codecs,pt) || ms_list_find(lc->codecs_conf.video_codecs,pt)){ + payload_type_set_enable(pt,enabled); + _linphone_core_codec_config_write(lc); + return 0; + } + ms_error("Enabling codec not in audio or video list of PayloadType !"); + return -1; +} + +int linphone_core_get_payload_type_number(LinphoneCore *lc, const PayloadType *pt){ + return payload_type_get_number(pt); +} + +const char *linphone_core_get_payload_type_description(LinphoneCore *lc, PayloadType *pt){ + if (ms_filter_codec_supported(pt->mime_type)){ + MSFilterDesc *desc=ms_filter_get_encoder(pt->mime_type); +#ifdef ENABLE_NLS + return dgettext("mediastreamer",desc->text); +#else + return desc->text; +#endif + } + return NULL; +} + + +/*this function makes a special case for speex/8000. +This codec is variable bitrate. The 8kbit/s mode is interesting when having a low upload bandwidth, but its quality +is not very good. We 'd better use its 15kbt/s mode when we have enough bandwidth*/ +static int get_codec_bitrate(LinphoneCore *lc, const PayloadType *pt){ + int upload_bw=linphone_core_get_upload_bandwidth(lc); + if (bandwidth_is_greater(upload_bw,129) || (bandwidth_is_greater(upload_bw,33) && !linphone_core_video_enabled(lc)) ) { + if (strcmp(pt->mime_type,"speex")==0 && pt->clock_rate==8000){ + return 15000; + } + } + return pt->normal_bitrate; +} + +static double get_audio_payload_bandwidth(LinphoneCore *lc, const PayloadType *pt){ + double npacket=50; + double packet_size; + int bitrate; + bitrate=get_codec_bitrate(lc,pt); + packet_size= (((double)bitrate)/(50*8))+UDP_HDR_SZ+RTP_HDR_SZ+IP4_HDR_SZ; + return packet_size*8.0*npacket; +} + +void linphone_core_update_allocated_audio_bandwidth_in_call(LinphoneCall *call, const PayloadType *pt){ + call->audio_bw=(int)(ceil(get_audio_payload_bandwidth(call->core,pt)/1000.0)); /*rounding codec bandwidth should be avoid, specially for AMR*/ + ms_message("Audio bandwidth for this call is %i",call->audio_bw); +} + +void linphone_core_update_allocated_audio_bandwidth(LinphoneCore *lc){ + const MSList *elem; + PayloadType *max=NULL; + for(elem=linphone_core_get_audio_codecs(lc);elem!=NULL;elem=elem->next){ + PayloadType *pt=(PayloadType*)elem->data; + if (payload_type_enabled(pt)){ + int pt_bitrate=get_codec_bitrate(lc,pt); + if (max==NULL) max=pt; + else if (max->normal_bitrateaudio_bw=(int)(get_audio_payload_bandwidth(lc,max)/1000.0); + } +} + +bool_t linphone_core_is_payload_type_usable_for_bandwidth(LinphoneCore *lc, PayloadType *pt, int bandwidth_limit) +{ + double codec_band; + bool_t ret=FALSE; + + switch (pt->type){ + case PAYLOAD_AUDIO_CONTINUOUS: + case PAYLOAD_AUDIO_PACKETIZED: + codec_band=get_audio_payload_bandwidth(lc,pt); + ret=bandwidth_is_greater(bandwidth_limit*1000,codec_band); + /*hack to avoid using uwb codecs when having low bitrate and video*/ + if (bandwidth_is_greater(199,bandwidth_limit)){ + if (linphone_core_video_enabled(lc) && pt->clock_rate>16000){ + ret=FALSE; + } + } + //ms_message("Payload %s: %g",pt->mime_type,codec_band); + break; + case PAYLOAD_VIDEO: + if (bandwidth_limit!=0) {/* infinite (-1) or strictly positive*/ + ret=TRUE; + } + else ret=FALSE; + break; + } + return ret; +} + +/* return TRUE if codec can be used with bandwidth, FALSE else*/ +bool_t linphone_core_check_payload_type_usability(LinphoneCore *lc, PayloadType *pt) +{ + double codec_band; + int allowed_bw,video_bw; + bool_t ret=FALSE; + + linphone_core_update_allocated_audio_bandwidth(lc); + allowed_bw=get_min_bandwidth(linphone_core_get_download_bandwidth(lc), + linphone_core_get_upload_bandwidth(lc)); + if (allowed_bw==0) { + allowed_bw=-1; + video_bw=1500; /*around 1.5 Mbit/s*/ + }else + video_bw=get_video_bandwidth(allowed_bw,lc->audio_bw); + + switch (pt->type){ + case PAYLOAD_AUDIO_CONTINUOUS: + case PAYLOAD_AUDIO_PACKETIZED: + codec_band=get_audio_payload_bandwidth(lc,pt); + ret=bandwidth_is_greater(allowed_bw*1000,codec_band); + /*hack to avoid using uwb codecs when having low bitrate and video*/ + if (bandwidth_is_greater(199,allowed_bw)){ + if (linphone_core_video_enabled(lc) && pt->clock_rate>16000){ + ret=FALSE; + } + } + //ms_message("Payload %s: %g",pt->mime_type,codec_band); + break; + case PAYLOAD_VIDEO: + if (video_bw>0){ + pt->normal_bitrate=video_bw*1000; + ret=TRUE; + } + else ret=FALSE; + break; + } + return ret; +} + +bool_t lp_spawn_command_line_sync(const char *command, char **result,int *command_ret){ +#if !defined(_WIN32_WCE) + FILE *f=popen(command,"r"); + if (f!=NULL){ + int err; + *result=ms_malloc(4096); + err=fread(*result,1,4096-1,f); + if (err<0){ + ms_warning("Error reading command output:%s",strerror(errno)); + ms_free(result); + return FALSE; + } + (*result)[err]=0; + err=pclose(f); + if (command_ret!=NULL) *command_ret=err; + return TRUE; + } +#endif /*_WIN32_WCE*/ + return FALSE; +} + +static ortp_socket_t create_socket(int local_port){ + struct sockaddr_in laddr; + ortp_socket_t sock; + int optval; + sock=socket(PF_INET,SOCK_DGRAM,IPPROTO_UDP); + if (sock<0) { + ms_error("Fail to create socket"); + return -1; + } + memset (&laddr,0,sizeof(laddr)); + laddr.sin_family=AF_INET; + laddr.sin_addr.s_addr=INADDR_ANY; + laddr.sin_port=htons(local_port); + if (bind(sock,(struct sockaddr*)&laddr,sizeof(laddr))<0){ + ms_error("Bind socket to 0.0.0.0:%i failed: %s",local_port,getSocketError()); + close_socket(sock); + return -1; + } + optval=1; + if (setsockopt (sock, SOL_SOCKET, SO_REUSEADDR, + (SOCKET_OPTION_VALUE)&optval, sizeof (optval))<0){ + ms_warning("Fail to set SO_REUSEADDR"); + } + set_non_blocking_socket(sock); + return sock; +} + +static int sendStunRequest(int sock, const struct sockaddr *server, socklen_t addrlen, int id, bool_t changeAddr){ + char buf[STUN_MAX_MESSAGE_SIZE]; + int len = STUN_MAX_MESSAGE_SIZE; + StunAtrString username; + StunAtrString password; + StunMessage req; + int err; + memset(&req, 0, sizeof(StunMessage)); + memset(&username,0,sizeof(username)); + memset(&password,0,sizeof(password)); + stunBuildReqSimple( &req, &username, changeAddr , changeAddr , id); + len = stunEncodeMessage( &req, buf, len, &password); + if (len<=0){ + ms_error("Fail to encode stun message."); + return -1; + } + err=sendto(sock,buf,len,0,server,addrlen); + if (err<0){ + ms_error("sendto failed: %s",strerror(errno)); + return -1; + } + return 0; +} + +int parse_hostname_to_addr(const char *server, struct sockaddr_storage *ss, socklen_t *socklen){ + struct addrinfo hints,*res=NULL; + int family = PF_INET; + int port_int = 3478; + int ret; + char port[6]; + char host[NI_MAXHOST]; + char *p1, *p2; + if ((sscanf(server, "[%64[^]]]:%d", host, &port_int) == 2) || (sscanf(server, "[%64[^]]]", host) == 1)) { + family = PF_INET6; + } else { + p1 = strchr(server, ':'); + p2 = strrchr(server, ':'); + if (p1 && p2 && (p1 != p2)) { + family = PF_INET6; + host[NI_MAXHOST-1]='\0'; + strncpy(host, server, sizeof(host) - 1); + } else if (sscanf(server, "%[^:]:%d", host, &port_int) != 2) { + host[NI_MAXHOST-1]='\0'; + strncpy(host, server, sizeof(host) - 1); + } + } + snprintf(port, sizeof(port), "%d", port_int); + memset(&hints,0,sizeof(hints)); + hints.ai_family=family; + hints.ai_socktype=SOCK_DGRAM; + hints.ai_protocol=IPPROTO_UDP; + ret=getaddrinfo(host,port,&hints,&res); + if (ret!=0){ + ms_error("getaddrinfo() failed for %s:%s : %s",host,port,gai_strerror(ret)); + return -1; + } + if (!res) return -1; + memcpy(ss,res->ai_addr,res->ai_addrlen); + *socklen=res->ai_addrlen; + freeaddrinfo(res); + return 0; +} + +static int recvStunResponse(ortp_socket_t sock, char *ipaddr, int *port, int *id){ + char buf[STUN_MAX_MESSAGE_SIZE]; + int len = STUN_MAX_MESSAGE_SIZE; + StunMessage resp; + len=recv(sock,buf,len,0); + if (len>0){ + struct in_addr ia; + stunParseMessage(buf,len, &resp ); + *id=resp.msgHdr.tr_id.octet[0]; + if (resp.hasXorMappedAddress){ + *port = resp.xorMappedAddress.ipv4.port; + ia.s_addr=htonl(resp.xorMappedAddress.ipv4.addr); + }else if (resp.hasMappedAddress){ + *port = resp.mappedAddress.ipv4.port; + ia.s_addr=htonl(resp.mappedAddress.ipv4.addr); + }else return -1; + strncpy(ipaddr,inet_ntoa(ia),LINPHONE_IPADDR_SIZE); + } + return len; +} + +/* this functions runs a simple stun test and return the number of milliseconds to complete the tests, or -1 if the test were failed.*/ +int linphone_core_run_stun_tests(LinphoneCore *lc, LinphoneCall *call){ + const char *server=linphone_core_get_stun_server(lc); + StunCandidate *ac=&call->ac; + StunCandidate *vc=&call->vc; + + if (lc->sip_conf.ipv6_enabled){ + ms_warning("stun support is not implemented for ipv6"); + return -1; + } + if (server!=NULL){ + struct sockaddr_storage ss; + socklen_t ss_len; + ortp_socket_t sock1=-1, sock2=-1; + int loops=0; + bool_t video_enabled=linphone_core_video_enabled(lc); + bool_t got_audio,got_video; + bool_t cone_audio=FALSE,cone_video=FALSE; + struct timeval init,cur; + double elapsed; + int ret=0; + + if (parse_hostname_to_addr(server,&ss,&ss_len)<0){ + ms_error("Fail to parser stun server address: %s",server); + return -1; + } + if (lc->vtable.display_status!=NULL) + lc->vtable.display_status(lc,_("Stun lookup in progress...")); + + /*create the two audio and video RTP sockets, and send STUN message to our stun server */ + sock1=create_socket(call->audio_port); + if (sock1==-1) return -1; + if (video_enabled){ + sock2=create_socket(call->video_port); + if (sock2==-1) return -1; + } + got_audio=FALSE; + got_video=FALSE; + gettimeofday(&init,NULL); + do{ + + int id; + if (loops%20==0){ + ms_message("Sending stun requests..."); + sendStunRequest(sock1,(struct sockaddr*)&ss,ss_len,11,TRUE); + sendStunRequest(sock1,(struct sockaddr*)&ss,ss_len,1,FALSE); + if (sock2!=-1){ + sendStunRequest(sock2,(struct sockaddr*)&ss,ss_len,22,TRUE); + sendStunRequest(sock2,(struct sockaddr*)&ss,ss_len,2,FALSE); + } + } +#ifdef WIN32 + Sleep(10); +#else + usleep(10000); +#endif + + if (recvStunResponse(sock1,ac->addr, + &ac->port,&id)>0){ + ms_message("STUN test result: local audio port maps to %s:%i", + ac->addr, + ac->port); + if (id==11) + cone_audio=TRUE; + got_audio=TRUE; + } + if (recvStunResponse(sock2,vc->addr, + &vc->port,&id)>0){ + ms_message("STUN test result: local video port maps to %s:%i", + vc->addr, + vc->port); + if (id==22) + cone_video=TRUE; + got_video=TRUE; + } + gettimeofday(&cur,NULL); + elapsed=((cur.tv_sec-init.tv_sec)*1000.0) + ((cur.tv_usec-init.tv_usec)/1000.0); + if (elapsed>2000) { + ms_message("Stun responses timeout, going ahead."); + ret=-1; + break; + } + loops++; + }while(!(got_audio && (got_video||sock2==-1) ) ); + if (ret==0) ret=(int)elapsed; + if (!got_audio){ + ms_error("No stun server response for audio port."); + }else{ + if (!cone_audio) { + ms_message("NAT is symmetric for audio port"); + } + } + if (sock2!=-1){ + if (!got_video){ + ms_error("No stun server response for video port."); + }else{ + if (!cone_video) { + ms_message("NAT is symmetric for video port."); + } + } + } + close_socket(sock1); + if (sock2!=-1) close_socket(sock2); + return ret; + } + return -1; +} + +int linphone_core_get_edge_bw(LinphoneCore *lc){ + int edge_bw=lp_config_get_int(lc->config,"net","edge_bw",20); + return edge_bw; +} + +int linphone_core_get_edge_ptime(LinphoneCore *lc){ + int edge_ptime=lp_config_get_int(lc->config,"net","edge_ptime",100); + return edge_ptime; +} + +void linphone_core_adapt_to_network(LinphoneCore *lc, int ping_time_ms, LinphoneCallParams *params){ + int threshold; + if (ping_time_ms>0 && lp_config_get_int(lc->config,"net","activate_edge_workarounds",0)==1){ + ms_message("Stun server ping time is %i ms",ping_time_ms); + threshold=lp_config_get_int(lc->config,"net","edge_ping_time",500); + + if (ping_time_ms>threshold){ + /* we might be in a 2G network*/ + params->low_bandwidth=TRUE; + }/*else use default settings */ + } + if (params->low_bandwidth){ + params->up_bw=params->down_bw=linphone_core_get_edge_bw(lc); + params->up_ptime=params->down_ptime=linphone_core_get_edge_ptime(lc); + params->has_video=FALSE; + } +} + + + +int linphone_core_gather_ice_candidates(LinphoneCore *lc, LinphoneCall *call) +{ + char local_addr[64]; + struct sockaddr_storage ss; + socklen_t ss_len; + IceCheckList *audio_check_list; + IceCheckList *video_check_list; + const char *server = linphone_core_get_stun_server(lc); + + if ((server == NULL) || (call->ice_session == NULL)) return -1; + audio_check_list = ice_session_check_list(call->ice_session, 0); + video_check_list = ice_session_check_list(call->ice_session, 1); + if (audio_check_list == NULL) return -1; + + if (lc->sip_conf.ipv6_enabled){ + ms_warning("stun support is not implemented for ipv6"); + return -1; + } + + if (parse_hostname_to_addr(server, &ss, &ss_len) < 0) { + ms_error("Fail to parser stun server address: %s", server); + return -1; + } + if (lc->vtable.display_status != NULL) + lc->vtable.display_status(lc, _("ICE local candidates gathering in progress...")); + + /* Gather local host candidates. */ + if (linphone_core_get_local_ip_for(AF_INET, server, local_addr) < 0) { + ms_error("Fail to get local ip"); + return -1; + } + if ((ice_check_list_state(audio_check_list) != ICL_Completed) && (ice_check_list_candidates_gathered(audio_check_list) == FALSE)) { + ice_add_local_candidate(audio_check_list, "host", local_addr, call->audio_port, 1, NULL); + ice_add_local_candidate(audio_check_list, "host", local_addr, call->audio_port + 1, 2, NULL); + call->stats[LINPHONE_CALL_STATS_AUDIO].ice_state = LinphoneIceStateInProgress; + } + if (call->params.has_video && (video_check_list != NULL) + && (ice_check_list_state(video_check_list) != ICL_Completed) && (ice_check_list_candidates_gathered(video_check_list) == FALSE)) { + ice_add_local_candidate(video_check_list, "host", local_addr, call->video_port, 1, NULL); + ice_add_local_candidate(video_check_list, "host", local_addr, call->video_port + 1, 2, NULL); + call->stats[LINPHONE_CALL_STATS_VIDEO].ice_state = LinphoneIceStateInProgress; + } + + ms_message("ICE: gathering candidate from [%s]",server); + /* Gather local srflx candidates. */ + ice_session_gather_candidates(call->ice_session, ss, ss_len); + return 0; +} + +void linphone_core_update_ice_state_in_call_stats(LinphoneCall *call) +{ + IceCheckList *audio_check_list; + IceCheckList *video_check_list; + IceSessionState session_state; + + if (call->ice_session == NULL) return; + audio_check_list = ice_session_check_list(call->ice_session, 0); + video_check_list = ice_session_check_list(call->ice_session, 1); + if (audio_check_list == NULL) return; + + session_state = ice_session_state(call->ice_session); + if ((session_state == IS_Completed) || ((session_state == IS_Failed) && (ice_session_has_completed_check_list(call->ice_session) == TRUE))) { + if (ice_check_list_state(audio_check_list) == ICL_Completed) { + switch (ice_check_list_selected_valid_candidate_type(audio_check_list)) { + case ICT_HostCandidate: + call->stats[LINPHONE_CALL_STATS_AUDIO].ice_state = LinphoneIceStateHostConnection; + break; + case ICT_ServerReflexiveCandidate: + case ICT_PeerReflexiveCandidate: + call->stats[LINPHONE_CALL_STATS_AUDIO].ice_state = LinphoneIceStateReflexiveConnection; + break; + case ICT_RelayedCandidate: + call->stats[LINPHONE_CALL_STATS_AUDIO].ice_state = LinphoneIceStateRelayConnection; + break; + } + } else { + call->stats[LINPHONE_CALL_STATS_AUDIO].ice_state = LinphoneIceStateFailed; + } + if (call->params.has_video && (video_check_list != NULL)) { + if (ice_check_list_state(video_check_list) == ICL_Completed) { + switch (ice_check_list_selected_valid_candidate_type(video_check_list)) { + case ICT_HostCandidate: + call->stats[LINPHONE_CALL_STATS_VIDEO].ice_state = LinphoneIceStateHostConnection; + break; + case ICT_ServerReflexiveCandidate: + case ICT_PeerReflexiveCandidate: + call->stats[LINPHONE_CALL_STATS_VIDEO].ice_state = LinphoneIceStateReflexiveConnection; + break; + case ICT_RelayedCandidate: + call->stats[LINPHONE_CALL_STATS_VIDEO].ice_state = LinphoneIceStateRelayConnection; + break; + } + } else { + call->stats[LINPHONE_CALL_STATS_VIDEO].ice_state = LinphoneIceStateFailed; + } + } + } else if (session_state == IS_Running) { + call->stats[LINPHONE_CALL_STATS_AUDIO].ice_state = LinphoneIceStateInProgress; + if (call->params.has_video && (video_check_list != NULL)) { + call->stats[LINPHONE_CALL_STATS_VIDEO].ice_state = LinphoneIceStateInProgress; + } + } else { + call->stats[LINPHONE_CALL_STATS_AUDIO].ice_state = LinphoneIceStateFailed; + if (call->params.has_video && (video_check_list != NULL)) { + call->stats[LINPHONE_CALL_STATS_VIDEO].ice_state = LinphoneIceStateFailed; + } + } +} + +void linphone_core_update_local_media_description_from_ice(SalMediaDescription *desc, IceSession *session) +{ + const char *rtp_addr, *rtcp_addr; + IceSessionState session_state = ice_session_state(session); + int nb_candidates; + int i, j; + bool_t result; + + if (session_state == IS_Completed) { + desc->ice_completed = TRUE; + result = ice_check_list_selected_valid_local_candidate(ice_session_check_list(session, 0), &rtp_addr, NULL, NULL, NULL); + if (result == TRUE) { + strncpy(desc->addr, rtp_addr, sizeof(desc->addr)); + } else { + ms_warning("If ICE has completed successfully, rtp_addr should be set!"); + } + } + else { + desc->ice_completed = FALSE; + } + strncpy(desc->ice_pwd, ice_session_local_pwd(session), sizeof(desc->ice_pwd)); + strncpy(desc->ice_ufrag, ice_session_local_ufrag(session), sizeof(desc->ice_ufrag)); + for (i = 0; i < desc->n_active_streams; i++) { + SalStreamDescription *stream = &desc->streams[i]; + IceCheckList *cl = ice_session_check_list(session, i); + nb_candidates = 0; + if (cl == NULL) continue; + if (ice_check_list_state(cl) == ICL_Completed) { + stream->ice_completed = TRUE; + result = ice_check_list_selected_valid_local_candidate(ice_session_check_list(session, i), &rtp_addr, &stream->rtp_port, &rtcp_addr, &stream->rtcp_port); + } else { + stream->ice_completed = FALSE; + result = ice_check_list_default_local_candidate(ice_session_check_list(session, i), &rtp_addr, &stream->rtp_port, &rtcp_addr, &stream->rtcp_port); + } + if (result == TRUE) { + strncpy(stream->rtp_addr, rtp_addr, sizeof(stream->rtp_addr)); + strncpy(stream->rtcp_addr, rtcp_addr, sizeof(stream->rtcp_addr)); + } else { + memset(stream->rtp_addr, 0, sizeof(stream->rtp_addr)); + memset(stream->rtcp_addr, 0, sizeof(stream->rtcp_addr)); + } + if ((strlen(ice_check_list_local_pwd(cl)) != strlen(desc->ice_pwd)) || (strcmp(ice_check_list_local_pwd(cl), desc->ice_pwd))) + strncpy(stream->ice_pwd, ice_check_list_local_pwd(cl), sizeof(stream->ice_pwd)); + else + memset(stream->ice_pwd, 0, sizeof(stream->ice_pwd)); + if ((strlen(ice_check_list_local_ufrag(cl)) != strlen(desc->ice_ufrag)) || (strcmp(ice_check_list_local_ufrag(cl), desc->ice_ufrag))) + strncpy(stream->ice_ufrag, ice_check_list_local_ufrag(cl), sizeof(stream->ice_ufrag)); + else + memset(stream->ice_pwd, 0, sizeof(stream->ice_pwd)); + stream->ice_mismatch = ice_check_list_is_mismatch(cl); + if ((ice_check_list_state(cl) == ICL_Running) || (ice_check_list_state(cl) == ICL_Completed)) { + memset(stream->ice_candidates, 0, sizeof(stream->ice_candidates)); + for (j = 0; j < MIN(ms_list_size(cl->local_candidates), SAL_MEDIA_DESCRIPTION_MAX_ICE_CANDIDATES); j++) { + SalIceCandidate *sal_candidate = &stream->ice_candidates[nb_candidates]; + IceCandidate *ice_candidate = ms_list_nth_data(cl->local_candidates, j); + const char *default_addr = NULL; + int default_port = 0; + if (ice_candidate->componentID == 1) { + default_addr = stream->rtp_addr; + default_port = stream->rtp_port; + } else if (ice_candidate->componentID == 2) { + default_addr = stream->rtcp_addr; + default_port = stream->rtcp_port; + } else continue; + if (default_addr[0] == '\0') default_addr = desc->addr; + /* Only include the candidates matching the default destination for each component of the stream if the state is Completed as specified in RFC5245 section 9.1.2.2. */ + if ((ice_check_list_state(cl) == ICL_Completed) + && !((ice_candidate->taddr.port == default_port) && (strlen(ice_candidate->taddr.ip) == strlen(default_addr)) && (strcmp(ice_candidate->taddr.ip, default_addr) == 0))) + continue; + strncpy(sal_candidate->foundation, ice_candidate->foundation, sizeof(sal_candidate->foundation)); + sal_candidate->componentID = ice_candidate->componentID; + sal_candidate->priority = ice_candidate->priority; + strncpy(sal_candidate->type, ice_candidate_type(ice_candidate), sizeof(sal_candidate->type)); + strncpy(sal_candidate->addr, ice_candidate->taddr.ip, sizeof(sal_candidate->addr)); + sal_candidate->port = ice_candidate->taddr.port; + if ((ice_candidate->base != NULL) && (ice_candidate->base != ice_candidate)) { + strncpy(sal_candidate->raddr, ice_candidate->base->taddr.ip, sizeof(sal_candidate->raddr)); + sal_candidate->rport = ice_candidate->base->taddr.port; + } + nb_candidates++; + } + } + if ((ice_check_list_state(cl) == ICL_Completed) && (ice_session_role(session) == IR_Controlling)) { + int rtp_port, rtcp_port; + memset(stream->ice_remote_candidates, 0, sizeof(stream->ice_remote_candidates)); + if (ice_check_list_selected_valid_remote_candidate(cl, &rtp_addr, &rtp_port, &rtcp_addr, &rtcp_port) == TRUE) { + strncpy(stream->ice_remote_candidates[0].addr, rtp_addr, sizeof(stream->ice_remote_candidates[0].addr)); + stream->ice_remote_candidates[0].port = rtp_port; + strncpy(stream->ice_remote_candidates[1].addr, rtcp_addr, sizeof(stream->ice_remote_candidates[1].addr)); + stream->ice_remote_candidates[1].port = rtcp_port; + } else { + ms_error("ice: Selected valid remote candidates should be present if the check list is in the Completed state"); + } + } else { + for (j = 0; j < SAL_MEDIA_DESCRIPTION_MAX_ICE_REMOTE_CANDIDATES; j++) { + stream->ice_remote_candidates[j].addr[0] = '\0'; + stream->ice_remote_candidates[j].port = 0; + } + } + } +} + +static void get_default_addr_and_port(uint16_t componentID, const SalMediaDescription *md, const SalStreamDescription *stream, const char **addr, int *port) +{ + if (componentID == 1) { + *addr = stream->rtp_addr; + *port = stream->rtp_port; + } else if (componentID == 2) { + *addr = stream->rtcp_addr; + *port = stream->rtcp_port; + } else return; + if ((*addr)[0] == '\0') *addr = md->addr; +} + +void linphone_core_update_ice_from_remote_media_description(LinphoneCall *call, const SalMediaDescription *md) +{ + bool_t ice_restarted = FALSE; + + if ((md->ice_pwd[0] != '\0') && (md->ice_ufrag[0] != '\0')) { + int i, j; + + /* Check for ICE restart and set remote credentials. */ + if ((strcmp(md->addr, "0.0.0.0") == 0) || (strcmp(md->addr, "::0") == 0)) { + ice_session_restart(call->ice_session); + ice_restarted = TRUE; + } else { + for (i = 0; i < md->n_total_streams; i++) { + const SalStreamDescription *stream = &md->streams[i]; + IceCheckList *cl = ice_session_check_list(call->ice_session, i); + if (cl && (strcmp(stream->rtp_addr, "0.0.0.0") == 0)) { + ice_session_restart(call->ice_session); + ice_restarted = TRUE; + break; + } + } + } + if ((ice_session_remote_ufrag(call->ice_session) == NULL) && (ice_session_remote_pwd(call->ice_session) == NULL)) { + ice_session_set_remote_credentials(call->ice_session, md->ice_ufrag, md->ice_pwd); + } else if (ice_session_remote_credentials_changed(call->ice_session, md->ice_ufrag, md->ice_pwd)) { + if (ice_restarted == FALSE) { + ice_session_restart(call->ice_session); + ice_restarted = TRUE; + } + ice_session_set_remote_credentials(call->ice_session, md->ice_ufrag, md->ice_pwd); + } + for (i = 0; i < md->n_total_streams; i++) { + const SalStreamDescription *stream = &md->streams[i]; + IceCheckList *cl = ice_session_check_list(call->ice_session, i); + if (cl && (stream->ice_pwd[0] != '\0') && (stream->ice_ufrag[0] != '\0')) { + if (ice_check_list_remote_credentials_changed(cl, stream->ice_ufrag, stream->ice_pwd)) { + if (ice_restarted == FALSE) { + ice_session_restart(call->ice_session); + ice_restarted = TRUE; + } + ice_session_set_remote_credentials(call->ice_session, md->ice_ufrag, md->ice_pwd); + break; + } + } + } + + /* Create ICE check lists if needed and parse ICE attributes. */ + for (i = 0; i < md->n_total_streams; i++) { + const SalStreamDescription *stream = &md->streams[i]; + IceCheckList *cl = ice_session_check_list(call->ice_session, i); + if (cl == NULL) { + cl = ice_check_list_new(); + ice_session_add_check_list(call->ice_session, cl); + switch (stream->type) { + case SalAudio: + if (call->audiostream != NULL) call->audiostream->ms.ice_check_list = cl; + break; + case SalVideo: + if (call->videostream != NULL) call->videostream->ms.ice_check_list = cl; + break; + default: + break; + } + } + if (stream->ice_mismatch == TRUE) { + ice_check_list_set_state(cl, ICL_Failed); + } else if (stream->rtp_port == 0) { + ice_session_remove_check_list(call->ice_session, cl); + } else { + if ((stream->ice_pwd[0] != '\0') && (stream->ice_ufrag[0] != '\0')) + ice_check_list_set_remote_credentials(cl, stream->ice_ufrag, stream->ice_pwd); + for (j = 0; j < SAL_MEDIA_DESCRIPTION_MAX_ICE_CANDIDATES; j++) { + const SalIceCandidate *candidate = &stream->ice_candidates[j]; + bool_t default_candidate = FALSE; + const char *addr = NULL; + int port = 0; + if (candidate->addr[0] == '\0') break; + if ((candidate->componentID == 0) || (candidate->componentID > 2)) continue; + get_default_addr_and_port(candidate->componentID, md, stream, &addr, &port); + if (addr && (candidate->port == port) && (strlen(candidate->addr) == strlen(addr)) && (strcmp(candidate->addr, addr) == 0)) + default_candidate = TRUE; + ice_add_remote_candidate(cl, candidate->type, candidate->addr, candidate->port, candidate->componentID, + candidate->priority, candidate->foundation, default_candidate); + } + if (ice_restarted == FALSE) { + bool_t losing_pairs_added = FALSE; + for (j = 0; j < SAL_MEDIA_DESCRIPTION_MAX_ICE_REMOTE_CANDIDATES; j++) { + const SalIceRemoteCandidate *candidate = &stream->ice_remote_candidates[j]; + const char *addr = NULL; + int port = 0; + int componentID = j + 1; + if (candidate->addr[0] == '\0') break; + get_default_addr_and_port(componentID, md, stream, &addr, &port); + if (j == 0) { + /* If we receive a re-invite and we finished ICE processing on our side, use the candidates given by the remote. */ + ice_check_list_unselect_valid_pairs(cl); + } + ice_add_losing_pair(cl, j + 1, candidate->addr, candidate->port, addr, port); + losing_pairs_added = TRUE; + } + if (losing_pairs_added == TRUE) ice_check_list_check_completed(cl); + } + } + } + for (i = ice_session_nb_check_lists(call->ice_session); i > md->n_active_streams; i--) { + ice_session_remove_check_list(call->ice_session, ice_session_check_list(call->ice_session, i - 1)); + } + ice_session_check_mismatch(call->ice_session); + } else { + /* Response from remote does not contain mandatory ICE attributes, delete the session. */ + linphone_call_delete_ice_session(call); + return; + } + if (ice_session_nb_check_lists(call->ice_session) == 0) { + linphone_call_delete_ice_session(call); + } +} + +bool_t linphone_core_media_description_contains_video_stream(const SalMediaDescription *md) +{ + int i; + + for (i = 0; i < md->n_active_streams; i++) { + if (md->streams[i].type == SalVideo) + return TRUE; + } + return FALSE; +} + +LinphoneCall * is_a_linphone_call(void *user_pointer){ + LinphoneCall *call=(LinphoneCall*)user_pointer; + if (call==NULL) return NULL; + return call->magic==linphone_call_magic ? call : NULL; +} + +LinphoneProxyConfig * is_a_linphone_proxy_config(void *user_pointer){ + LinphoneProxyConfig *cfg=(LinphoneProxyConfig*)user_pointer; + if (cfg==NULL) return NULL; + return cfg->magic==linphone_proxy_config_magic ? cfg : NULL; +} + +unsigned int linphone_core_get_audio_features(LinphoneCore *lc){ + unsigned int ret=0; + const char *features=lp_config_get_string(lc->config,"sound","features",NULL); + if (features){ + char tmp[256]={0}; + char name[256]; + char *p,*n; + strncpy(tmp,features,sizeof(tmp)-1); + for(p=tmp;*p!='\0';p++){ + if (*p==' ') continue; + n=strchr(p,'|'); + if (n) *n='\0'; + sscanf(p,"%s",name); + ms_message("Found audio feature %s",name); + if (strcasecmp(name,"PLC")==0) ret|=AUDIO_STREAM_FEATURE_PLC; + else if (strcasecmp(name,"EC")==0) ret|=AUDIO_STREAM_FEATURE_EC; + else if (strcasecmp(name,"EQUALIZER")==0) ret|=AUDIO_STREAM_FEATURE_EQUALIZER; + else if (strcasecmp(name,"VOL_SND")==0) ret|=AUDIO_STREAM_FEATURE_VOL_SND; + else if (strcasecmp(name,"VOL_RCV")==0) ret|=AUDIO_STREAM_FEATURE_VOL_RCV; + else if (strcasecmp(name,"DTMF")==0) ret|=AUDIO_STREAM_FEATURE_DTMF; + else if (strcasecmp(name,"DTMF_ECHO")==0) ret|=AUDIO_STREAM_FEATURE_DTMF_ECHO; + else if (strcasecmp(name,"MIXED_RECORDING")==0) ret|=AUDIO_STREAM_FEATURE_MIXED_RECORDING; + else if (strcasecmp(name,"ALL")==0) ret|=AUDIO_STREAM_FEATURE_ALL; + else if (strcasecmp(name,"NONE")==0) ret=0; + else ms_error("Unsupported audio feature %s requested in config file.",name); + if (!n) break; + p=n; + } + }else ret=AUDIO_STREAM_FEATURE_ALL; + + if (ret==AUDIO_STREAM_FEATURE_ALL){ + /*since call recording is specified before creation of the stream in linphonecore, + * it will be requested on demand. It is not necessary to include it all the time*/ + ret&=~AUDIO_STREAM_FEATURE_MIXED_RECORDING; + } + return ret; +} + + +#ifdef HAVE_GETIFADDRS + +#include +static int get_local_ip_with_getifaddrs(int type, char *address, int size) +{ + struct ifaddrs *ifp; + struct ifaddrs *ifpstart; + int ret = 0; + + if (getifaddrs(&ifpstart) < 0) { + return -1; + } +#ifndef __linux + #define UP_FLAG IFF_UP /* interface is up */ +#else + #define UP_FLAG IFF_RUNNING /* resources allocated */ +#endif + + for (ifp = ifpstart; ifp != NULL; ifp = ifp->ifa_next) { + if (ifp->ifa_addr && ifp->ifa_addr->sa_family == type + && (ifp->ifa_flags & UP_FLAG) && !(ifp->ifa_flags & IFF_LOOPBACK)) + { + if(getnameinfo(ifp->ifa_addr, + (type == AF_INET6) ? + sizeof(struct sockaddr_in6) : sizeof(struct sockaddr_in), + address, size, NULL, 0, NI_NUMERICHOST) == 0) { + if (strchr(address, '%') == NULL) { /*avoid ipv6 link-local addresses */ + /*ms_message("getifaddrs() found %s",address);*/ + ret++; + break; + } + } + } + } + freeifaddrs(ifpstart); + return ret; +} +#endif + + +static int get_local_ip_for_with_connect(int type, const char *dest, char *result){ + int err,tmp; + struct addrinfo hints; + struct addrinfo *res=NULL; + struct sockaddr_storage addr; + struct sockaddr *p_addr=(struct sockaddr*)&addr; + ortp_socket_t sock; + socklen_t s; + + memset(&hints,0,sizeof(hints)); + hints.ai_family=(type==AF_INET6) ? PF_INET6 : PF_INET; + hints.ai_socktype=SOCK_DGRAM; + /*hints.ai_flags=AI_NUMERICHOST|AI_CANONNAME;*/ + err=getaddrinfo(dest,"5060",&hints,&res); + if (err!=0){ + ms_error("getaddrinfo() error: %s",gai_strerror(err)); + return -1; + } + if (res==NULL){ + ms_error("bug: getaddrinfo returned nothing."); + return -1; + } + sock=socket(res->ai_family,SOCK_DGRAM,0); + tmp=1; + err=setsockopt(sock,SOL_SOCKET,SO_REUSEADDR,(SOCKET_OPTION_VALUE)&tmp,sizeof(int)); + if (err<0){ + ms_warning("Error in setsockopt: %s",strerror(errno)); + } + err=connect(sock,res->ai_addr,res->ai_addrlen); + if (err<0) { + ms_error("Error in connect: %s",strerror(errno)); + freeaddrinfo(res); + close_socket(sock); + return -1; + } + freeaddrinfo(res); + res=NULL; + s=sizeof(addr); + err=getsockname(sock,(struct sockaddr*)&addr,&s); + if (err!=0) { + ms_error("Error in getsockname: %s",strerror(errno)); + close_socket(sock); + return -1; + } + if (p_addr->sa_family==AF_INET){ + struct sockaddr_in *p_sin=(struct sockaddr_in*)p_addr; + if (p_sin->sin_addr.s_addr==0){ + close_socket(sock); + return -1; + } + } + err=getnameinfo((struct sockaddr *)&addr,s,result,LINPHONE_IPADDR_SIZE,NULL,0,NI_NUMERICHOST); + if (err!=0){ + ms_error("getnameinfo error: %s",strerror(errno)); + } + close_socket(sock); + ms_message("Local interface to reach %s is %s.",dest,result); + return 0; +} + +int linphone_core_get_local_ip_for(int type, const char *dest, char *result){ + strcpy(result,type==AF_INET ? "127.0.0.1" : "::1"); +#ifdef HAVE_GETIFADDRS + if (dest==NULL) { + /*we use getifaddrs for lookup of default interface */ + int found_ifs; + + found_ifs=get_local_ip_with_getifaddrs(type,result,LINPHONE_IPADDR_SIZE); + if (found_ifs==1){ + return 0; + }else if (found_ifs<=0){ + /*absolutely no network on this machine */ + return -1; + } + } +#endif + /*else use connect to find the best local ip address */ + if (type==AF_INET) + dest="87.98.157.38"; /*a public IP address*/ + else dest="2a00:1450:8002::68"; + return get_local_ip_for_with_connect(type,dest,result); +} + +#ifndef WIN32 +#include + + + +void _linphone_core_configure_resolver(){ +/*bionic declares _res but does not define nor export it !!*/ +#ifdef ANDROID + /*timeout and attempts are the same as retrans and retry, but are android specific names.*/ + setenv("RES_OPTIONS","timeout:2 attempts:2 retrans:2 retry:2",1); +#else + res_init(); + _res.retrans=2; /*retransmit every two seconds*/ + _res.retry=2; /*only two times per DNS server*/ +#endif +} + +#else + +void _linphone_core_configure_resolver(){ +} + +#endif From d5f35010c7a37a1e6d0f672990caa69be5b90b6d Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Thu, 28 Feb 2013 13:26:08 +0100 Subject: [PATCH 03/21] Started linphone exports --- coreapi/linphonecore.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/coreapi/linphonecore.h b/coreapi/linphonecore.h index 2c2168646..9a0526f36 100644 --- a/coreapi/linphonecore.h +++ b/coreapi/linphonecore.h @@ -33,6 +33,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define LINPHONE_IPADDR_SIZE 64 #define LINPHONE_HOSTNAME_SIZE 128 +#ifdef LIBLINPHONE_EXPORTS +#define LINPHONE_PUBLIC __declspec(dllexport) +#else +#define LINPHONE_PUBLIC __declspec(dllimport) +#endif + #ifdef __cplusplus extern "C" { #endif @@ -848,7 +854,7 @@ const char *linphone_core_get_version(void); const char *linphone_core_get_user_agent_name(void); const char *linphone_core_get_user_agent_version(void); -LinphoneCore *linphone_core_new(const LinphoneCoreVTable *vtable, +LINPHONE_PUBLIC LinphoneCore *linphone_core_new(const LinphoneCoreVTable *vtable, const char *config_path, const char *factory_config, void* userdata); /* function to be periodically called in a main loop */ @@ -1416,11 +1422,8 @@ int linphone_core_get_audio_dscp(const LinphoneCore *lc); void linphone_core_set_video_dscp(LinphoneCore *lc, int dscp); int linphone_core_get_video_dscp(const LinphoneCore *lc); - - #ifdef __cplusplus } #endif - #endif From e531acae12adcc09e04d7d6d53558a4b0b60f7a2 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Thu, 28 Feb 2013 16:27:20 +0100 Subject: [PATCH 04/21] Added linphonecore exports --- coreapi/linphonecore.h | 176 +++---- coreapi/linphonefriend.h | 14 +- include/sal/sal.h | 972 ++++++++++++++++++++------------------- 3 files changed, 588 insertions(+), 574 deletions(-) diff --git a/coreapi/linphonecore.h b/coreapi/linphonecore.h index 9a0526f36..2012492c4 100644 --- a/coreapi/linphonecore.h +++ b/coreapi/linphonecore.h @@ -83,12 +83,12 @@ typedef struct SalAddress LinphoneAddress; #include "linphone/linphonefriend.h" #endif -LinphoneAddress * linphone_address_new(const char *uri); +LINPHONE_PUBLIC LinphoneAddress * linphone_address_new(const char *uri); LinphoneAddress * linphone_address_clone(const LinphoneAddress *uri); const char *linphone_address_get_scheme(const LinphoneAddress *u); -const char *linphone_address_get_display_name(const LinphoneAddress* u); -const char *linphone_address_get_username(const LinphoneAddress *u); -const char *linphone_address_get_domain(const LinphoneAddress *u); +LINPHONE_PUBLIC const char *linphone_address_get_display_name(const LinphoneAddress* u); +LINPHONE_PUBLIC const char *linphone_address_get_username(const LinphoneAddress *u); +LINPHONE_PUBLIC const char *linphone_address_get_domain(const LinphoneAddress *u); /** * Get port number as an integer value. * @@ -98,17 +98,17 @@ int linphone_address_get_port_int(const LinphoneAddress *u); * Get port number, null if not present. */ const char* linphone_address_get_port(const LinphoneAddress *u); -void linphone_address_set_display_name(LinphoneAddress *u, const char *display_name); -void linphone_address_set_username(LinphoneAddress *uri, const char *username); -void linphone_address_set_domain(LinphoneAddress *uri, const char *host); +LINPHONE_PUBLIC void linphone_address_set_display_name(LinphoneAddress *u, const char *display_name); +LINPHONE_PUBLIC void linphone_address_set_username(LinphoneAddress *uri, const char *username); +LINPHONE_PUBLIC void linphone_address_set_domain(LinphoneAddress *uri, const char *host); void linphone_address_set_port(LinphoneAddress *uri, const char *port); void linphone_address_set_port_int(LinphoneAddress *uri, int port); /*remove tags, params etc... so that it is displayable to the user*/ -void linphone_address_clean(LinphoneAddress *uri); -char *linphone_address_as_string(const LinphoneAddress *u); +LINPHONE_PUBLIC void linphone_address_clean(LinphoneAddress *uri); +LINPHONE_PUBLIC char *linphone_address_as_string(const LinphoneAddress *u); char *linphone_address_as_string_uri_only(const LinphoneAddress *u); -bool_t linphone_address_weak_equal(const LinphoneAddress *a1, const LinphoneAddress *a2); -void linphone_address_destroy(LinphoneAddress *u); +LINPHONE_PUBLIC bool_t linphone_address_weak_equal(const LinphoneAddress *a1, const LinphoneAddress *a2); +LINPHONE_PUBLIC void linphone_address_destroy(LinphoneAddress *u); struct _SipSetupContext; @@ -190,9 +190,9 @@ typedef struct _LinphoneCallParams LinphoneCallParams; const PayloadType* linphone_call_params_get_used_audio_codec(const LinphoneCallParams *cp); const PayloadType* linphone_call_params_get_used_video_codec(const LinphoneCallParams *cp); -LinphoneCallParams * linphone_call_params_copy(const LinphoneCallParams *cp); -void linphone_call_params_enable_video(LinphoneCallParams *cp, bool_t enabled); -bool_t linphone_call_params_video_enabled(const LinphoneCallParams *cp); +LINPHONE_PUBLIC LinphoneCallParams * linphone_call_params_copy(const LinphoneCallParams *cp); +LINPHONE_PUBLIC void linphone_call_params_enable_video(LinphoneCallParams *cp, bool_t enabled); +LINPHONE_PUBLIC bool_t linphone_call_params_video_enabled(const LinphoneCallParams *cp); LinphoneMediaEncryption linphone_call_params_get_media_encryption(const LinphoneCallParams *cp); void linphone_call_params_set_media_encryption(LinphoneCallParams *cp, LinphoneMediaEncryption e); void linphone_call_params_enable_early_media_sending(LinphoneCallParams *cp, bool_t enabled); @@ -372,28 +372,28 @@ typedef enum _LinphoneCallState{ LinphoneCallReleased /**< The call object is no more retained by the core */ } LinphoneCallState; -const char *linphone_call_state_to_string(LinphoneCallState cs); +LINPHONE_PUBLIC const char *linphone_call_state_to_string(LinphoneCallState cs); LinphoneCore *linphone_call_get_core(const LinphoneCall *call); -LinphoneCallState linphone_call_get_state(const LinphoneCall *call); +LINPHONE_PUBLIC LinphoneCallState linphone_call_get_state(const LinphoneCall *call); bool_t linphone_call_asked_to_autoanswer(LinphoneCall *call); -const LinphoneAddress * linphone_core_get_current_call_remote_address(struct _LinphoneCore *lc); +LINPHONE_PUBLIC const LinphoneAddress * linphone_core_get_current_call_remote_address(struct _LinphoneCore *lc); const LinphoneAddress * linphone_call_get_remote_address(const LinphoneCall *call); char *linphone_call_get_remote_address_as_string(const LinphoneCall *call); LinphoneCallDir linphone_call_get_dir(const LinphoneCall *call); -LinphoneCall * linphone_call_ref(LinphoneCall *call); -void linphone_call_unref(LinphoneCall *call); -LinphoneCallLog *linphone_call_get_call_log(const LinphoneCall *call); +LINPHONE_PUBLIC LinphoneCall * linphone_call_ref(LinphoneCall *call); +LINPHONE_PUBLIC void linphone_call_unref(LinphoneCall *call); +LINPHONE_PUBLIC LinphoneCallLog *linphone_call_get_call_log(const LinphoneCall *call); const char *linphone_call_get_refer_to(const LinphoneCall *call); bool_t linphone_call_has_transfer_pending(const LinphoneCall *call); -LinphoneCall *linphone_call_get_replaced_call(LinphoneCall *call); +LINPHONE_PUBLIC LinphoneCall *linphone_call_get_replaced_call(LinphoneCall *call); int linphone_call_get_duration(const LinphoneCall *call); -const LinphoneCallParams * linphone_call_get_current_params(LinphoneCall *call); +LINPHONE_PUBLIC const LinphoneCallParams * linphone_call_get_current_params(LinphoneCall *call); const LinphoneCallParams * linphone_call_get_remote_params(LinphoneCall *call); void linphone_call_enable_camera(LinphoneCall *lc, bool_t enabled); bool_t linphone_call_camera_enabled(const LinphoneCall *lc); int linphone_call_take_video_snapshot(LinphoneCall *call, const char *file); -LinphoneReason linphone_call_get_reason(const LinphoneCall *call); +LINPHONE_PUBLIC LinphoneReason linphone_call_get_reason(const LinphoneCall *call); const char *linphone_call_get_remote_user_agent(LinphoneCall *call); const char *linphone_call_get_remote_contact(LinphoneCall *call); float linphone_call_get_play_volume(LinphoneCall *call); @@ -403,10 +403,10 @@ float linphone_call_get_average_quality(LinphoneCall *call); const char* linphone_call_get_authentication_token(LinphoneCall *call); bool_t linphone_call_get_authentication_token_verified(LinphoneCall *call); void linphone_call_set_authentication_token_verified(LinphoneCall *call, bool_t verified); -void linphone_call_send_vfu_request(LinphoneCall *call); -void *linphone_call_get_user_pointer(LinphoneCall *call); +LINPHONE_PUBLIC void linphone_call_send_vfu_request(LinphoneCall *call); +LINPHONE_PUBLIC void *linphone_call_get_user_pointer(LinphoneCall *call); void linphone_call_set_user_pointer(LinphoneCall *call, void *user_pointer); -void linphone_call_set_next_video_frame_decoded_callback(LinphoneCall *call, LinphoneCallCbFunc cb, void* user_data); +LINPHONE_PUBLIC void linphone_call_set_next_video_frame_decoded_callback(LinphoneCall *call, LinphoneCallCbFunc cb, void* user_data); LinphoneCallState linphone_call_get_transfer_state(LinphoneCall *call); void linphone_call_zoom_video(LinphoneCall* call, float zoom_factor, float* cx, float* cy); void linphone_call_start_recording(LinphoneCall *call); @@ -493,23 +493,23 @@ typedef enum _LinphoneRegistrationState{ * Human readable version of the #LinphoneRegistrationState * @param cs sate */ -const char *linphone_registration_state_to_string(LinphoneRegistrationState cs); +LINPHONE_PUBLIC const char *linphone_registration_state_to_string(LinphoneRegistrationState cs); -LinphoneProxyConfig *linphone_proxy_config_new(void); -int linphone_proxy_config_set_server_addr(LinphoneProxyConfig *obj, const char *server_addr); -int linphone_proxy_config_set_identity(LinphoneProxyConfig *obj, const char *identity); -int linphone_proxy_config_set_route(LinphoneProxyConfig *obj, const char *route); -void linphone_proxy_config_expires(LinphoneProxyConfig *obj, int expires); +LINPHONE_PUBLIC LinphoneProxyConfig *linphone_proxy_config_new(void); +LINPHONE_PUBLIC int linphone_proxy_config_set_server_addr(LinphoneProxyConfig *obj, const char *server_addr); +LINPHONE_PUBLIC int linphone_proxy_config_set_identity(LinphoneProxyConfig *obj, const char *identity); +LINPHONE_PUBLIC int linphone_proxy_config_set_route(LinphoneProxyConfig *obj, const char *route); +LINPHONE_PUBLIC void linphone_proxy_config_expires(LinphoneProxyConfig *obj, int expires); /** * Indicates either or not, REGISTRATION must be issued for this #LinphoneProxyConfig . *
In case this #LinphoneProxyConfig has been added to #LinphoneCore, follows the linphone_proxy_config_edit() rule. * @param obj object pointer * @param val if true, registration will be engaged */ -void linphone_proxy_config_enable_register(LinphoneProxyConfig *obj, bool_t val); +LINPHONE_PUBLIC void linphone_proxy_config_enable_register(LinphoneProxyConfig *obj, bool_t val); #define linphone_proxy_config_enableregister linphone_proxy_config_enable_register -void linphone_proxy_config_edit(LinphoneProxyConfig *obj); -int linphone_proxy_config_done(LinphoneProxyConfig *obj); +LINPHONE_PUBLIC void linphone_proxy_config_edit(LinphoneProxyConfig *obj); +LINPHONE_PUBLIC int linphone_proxy_config_done(LinphoneProxyConfig *obj); /** * Indicates either or not, PUBLISH must be issued for this #LinphoneProxyConfig . *
In case this #LinphoneProxyConfig has been added to #LinphoneCore, follows the linphone_proxy_config_edit() rule. @@ -517,18 +517,18 @@ int linphone_proxy_config_done(LinphoneProxyConfig *obj); * @param val if true, publish will be engaged * */ -void linphone_proxy_config_enable_publish(LinphoneProxyConfig *obj, bool_t val); +LINPHONE_PUBLIC void linphone_proxy_config_enable_publish(LinphoneProxyConfig *obj, bool_t val); void linphone_proxy_config_set_dial_escape_plus(LinphoneProxyConfig *cfg, bool_t val); void linphone_proxy_config_set_dial_prefix(LinphoneProxyConfig *cfg, const char *prefix); LinphoneRegistrationState linphone_proxy_config_get_state(const LinphoneProxyConfig *obj); -bool_t linphone_proxy_config_is_registered(const LinphoneProxyConfig *obj); +LINPHONE_PUBLIC bool_t linphone_proxy_config_is_registered(const LinphoneProxyConfig *obj); const char *linphone_proxy_config_get_domain(const LinphoneProxyConfig *cfg); const char *linphone_proxy_config_get_route(const LinphoneProxyConfig *obj); -const char *linphone_proxy_config_get_identity(const LinphoneProxyConfig *obj); +LINPHONE_PUBLIC const char *linphone_proxy_config_get_identity(const LinphoneProxyConfig *obj); bool_t linphone_proxy_config_publish_enabled(const LinphoneProxyConfig *obj); -const char *linphone_proxy_config_get_addr(const LinphoneProxyConfig *obj); +LINPHONE_PUBLIC const char *linphone_proxy_config_get_addr(const LinphoneProxyConfig *obj); int linphone_proxy_config_get_expires(const LinphoneProxyConfig *obj); bool_t linphone_proxy_config_register_enabled(const LinphoneProxyConfig *obj); void linphone_proxy_config_refresh_register(LinphoneProxyConfig *obj); @@ -617,7 +617,7 @@ struct _LinphoneAuthInfo; **/ typedef struct _LinphoneAuthInfo LinphoneAuthInfo; -LinphoneAuthInfo *linphone_auth_info_new(const char *username, const char *userid, +LINPHONE_PUBLIC LinphoneAuthInfo *linphone_auth_info_new(const char *username, const char *userid, const char *passwd, const char *ha1,const char *realm); void linphone_auth_info_set_passwd(LinphoneAuthInfo *info, const char *passwd); void linphone_auth_info_set_username(LinphoneAuthInfo *info, const char *username); @@ -668,23 +668,23 @@ typedef enum _LinphoneChatMessageStates { */ typedef void (*LinphoneChatMessageStateChangeCb)(LinphoneChatMessage* msg,LinphoneChatMessageState state,void* ud); -LinphoneChatRoom * linphone_core_create_chat_room(LinphoneCore *lc, const char *to); +LINPHONE_PUBLIC LinphoneChatRoom * linphone_core_create_chat_room(LinphoneCore *lc, const char *to); void linphone_chat_room_destroy(LinphoneChatRoom *cr); -LinphoneChatMessage* linphone_chat_room_create_message(LinphoneChatRoom *cr,const char* message); +LINPHONE_PUBLIC LinphoneChatMessage* linphone_chat_room_create_message(LinphoneChatRoom *cr,const char* message); const LinphoneAddress* linphone_chat_room_get_peer_address(LinphoneChatRoom *cr); -void linphone_chat_room_send_message(LinphoneChatRoom *cr, const char *msg); -void linphone_chat_room_send_message2(LinphoneChatRoom *cr, LinphoneChatMessage* msg,LinphoneChatMessageStateChangeCb status_cb,void* ud); +LINPHONE_PUBLIC void linphone_chat_room_send_message(LinphoneChatRoom *cr, const char *msg); +LINPHONE_PUBLIC void linphone_chat_room_send_message2(LinphoneChatRoom *cr, LinphoneChatMessage* msg,LinphoneChatMessageStateChangeCb status_cb,void* ud); LinphoneCore* linphone_chat_room_get_lc(LinphoneChatRoom *cr); void linphone_chat_room_set_user_data(LinphoneChatRoom *cr, void * ud); void * linphone_chat_room_get_user_data(LinphoneChatRoom *cr); -const char* linphone_chat_message_state_to_string(const LinphoneChatMessageState state); +LINPHONE_PUBLIC const char* linphone_chat_message_state_to_string(const LinphoneChatMessageState state); LinphoneChatMessage* linphone_chat_message_clone(const LinphoneChatMessage* message); void linphone_chat_message_set_from(LinphoneChatMessage* message, const LinphoneAddress* from); -LinphoneAddress* linphone_chat_message_get_from(const LinphoneChatMessage* message); -const char* linphone_chat_message_get_external_body_url(const LinphoneChatMessage* message); -void linphone_chat_message_set_external_body_url(LinphoneChatMessage* message,const char* url); -const char * linphone_chat_message_get_text(const LinphoneChatMessage* message); +LINPHONE_PUBLIC LinphoneAddress* linphone_chat_message_get_from(const LinphoneChatMessage* message); +LINPHONE_PUBLIC const char* linphone_chat_message_get_external_body_url(const LinphoneChatMessage* message); +LINPHONE_PUBLIC void linphone_chat_message_set_external_body_url(LinphoneChatMessage* message,const char* url); +LINPHONE_PUBLIC const char * linphone_chat_message_get_text(const LinphoneChatMessage* message); time_t linphone_chat_message_get_time(const LinphoneChatMessage* message); void* linphone_chat_message_get_user_data(const LinphoneChatMessage* message); void linphone_chat_message_set_user_data(LinphoneChatMessage* message,void*); @@ -847,7 +847,7 @@ typedef void * (*LinphoneWaitingCallback)(struct _LinphoneCore *lc, void *contex /* THE main API */ -void linphone_core_enable_logs(FILE *file); +LINPHONE_PUBLIC void linphone_core_enable_logs(FILE *file); void linphone_core_enable_logs_with_cb(OrtpLogFunc logfunc); void linphone_core_disable_logs(void); const char *linphone_core_get_version(void); @@ -859,7 +859,7 @@ LINPHONE_PUBLIC LinphoneCore *linphone_core_new(const LinphoneCoreVTable *vtable /* function to be periodically called in a main loop */ /* For ICE to work properly it should be called every 20ms */ -void linphone_core_iterate(LinphoneCore *lc); +LINPHONE_PUBLIC void linphone_core_iterate(LinphoneCore *lc); #if 0 /*not implemented yet*/ /** * @ingroup initializing @@ -884,43 +884,43 @@ void linphone_core_set_user_agent(LinphoneCore *lc, const char *ua_name, const c LinphoneAddress * linphone_core_interpret_url(LinphoneCore *lc, const char *url); -LinphoneCall * linphone_core_invite(LinphoneCore *lc, const char *url); +LINPHONE_PUBLIC LinphoneCall * linphone_core_invite(LinphoneCore *lc, const char *url); -LinphoneCall * linphone_core_invite_address(LinphoneCore *lc, const LinphoneAddress *addr); +LINPHONE_PUBLIC LinphoneCall * linphone_core_invite_address(LinphoneCore *lc, const LinphoneAddress *addr); LinphoneCall * linphone_core_invite_with_params(LinphoneCore *lc, const char *url, const LinphoneCallParams *params); LinphoneCall * linphone_core_invite_address_with_params(LinphoneCore *lc, const LinphoneAddress *addr, const LinphoneCallParams *params); -int linphone_core_transfer_call(LinphoneCore *lc, LinphoneCall *call, const char *refer_to); +LINPHONE_PUBLIC int linphone_core_transfer_call(LinphoneCore *lc, LinphoneCall *call, const char *refer_to); -int linphone_core_transfer_call_to_another(LinphoneCore *lc, LinphoneCall *call, LinphoneCall *dest); +LINPHONE_PUBLIC int linphone_core_transfer_call_to_another(LinphoneCore *lc, LinphoneCall *call, LinphoneCall *dest); -bool_t linphone_core_inc_invite_pending(LinphoneCore*lc); +LINPHONE_PUBLIC bool_t linphone_core_inc_invite_pending(LinphoneCore*lc); bool_t linphone_core_in_call(const LinphoneCore *lc); -LinphoneCall *linphone_core_get_current_call(const LinphoneCore *lc); +LINPHONE_PUBLIC LinphoneCall *linphone_core_get_current_call(const LinphoneCore *lc); -int linphone_core_accept_call(LinphoneCore *lc, LinphoneCall *call); +LINPHONE_PUBLIC int linphone_core_accept_call(LinphoneCore *lc, LinphoneCall *call); int linphone_core_accept_call_with_params(LinphoneCore *lc, LinphoneCall *call, const LinphoneCallParams *params); -int linphone_core_terminate_call(LinphoneCore *lc, LinphoneCall *call); +LINPHONE_PUBLIC int linphone_core_terminate_call(LinphoneCore *lc, LinphoneCall *call); int linphone_core_redirect_call(LinphoneCore *lc, LinphoneCall *call, const char *redirect_uri); int linphone_core_decline_call(LinphoneCore *lc, LinphoneCall * call, LinphoneReason reason); -int linphone_core_terminate_all_calls(LinphoneCore *lc); +LINPHONE_PUBLIC int linphone_core_terminate_all_calls(LinphoneCore *lc); -int linphone_core_pause_call(LinphoneCore *lc, LinphoneCall *call); +LINPHONE_PUBLIC int linphone_core_pause_call(LinphoneCore *lc, LinphoneCall *call); int linphone_core_pause_all_calls(LinphoneCore *lc); -int linphone_core_resume_call(LinphoneCore *lc, LinphoneCall *call); +LINPHONE_PUBLIC int linphone_core_resume_call(LinphoneCore *lc, LinphoneCall *call); -int linphone_core_update_call(LinphoneCore *lc, LinphoneCall *call, const LinphoneCallParams *params); +LINPHONE_PUBLIC int linphone_core_update_call(LinphoneCore *lc, LinphoneCall *call, const LinphoneCallParams *params); int linphone_core_defer_call_update(LinphoneCore *lc, LinphoneCall *call); @@ -964,7 +964,7 @@ void linphone_core_set_upload_ptime(LinphoneCore *lc, int ptime); int linphone_core_get_upload_ptime(LinphoneCore *lc); /* returns a MSList of PayloadType */ -const MSList *linphone_core_get_audio_codecs(const LinphoneCore *lc); +LINPHONE_PUBLIC const MSList *linphone_core_get_audio_codecs(const LinphoneCore *lc); int linphone_core_set_audio_codecs(LinphoneCore *lc, MSList *codecs); /* returns a MSList of PayloadType */ @@ -974,7 +974,7 @@ int linphone_core_set_video_codecs(LinphoneCore *lc, MSList *codecs); bool_t linphone_core_payload_type_enabled(LinphoneCore *lc, const PayloadType *pt); -int linphone_core_enable_payload_type(LinphoneCore *lc, PayloadType *pt, bool_t enable); +LINPHONE_PUBLIC int linphone_core_enable_payload_type(LinphoneCore *lc, PayloadType *pt, bool_t enable); /** * Wildcard value used by #linphone_core_find_payload_type to ignore rate in search algirithm @@ -996,7 +996,7 @@ int linphone_core_enable_payload_type(LinphoneCore *lc, PayloadType *pt, bool_t * @param channels number of channels, can be #LINPHONE_FIND_PAYLOAD_IGNORE_CHANNELS * @return Returns NULL if not found. */ -PayloadType* linphone_core_find_payload_type(LinphoneCore* lc, const char* type, int rate, int channels) ; +LINPHONE_PUBLIC PayloadType* linphone_core_find_payload_type(LinphoneCore* lc, const char* type, int rate, int channels) ; int linphone_core_get_payload_type_number(LinphoneCore *lc, const PayloadType *pt); @@ -1012,21 +1012,21 @@ bool_t linphone_core_check_payload_type_usability(LinphoneCore *lc, PayloadType */ LinphoneProxyConfig * linphone_core_create_proxy_config(LinphoneCore *lc); -int linphone_core_add_proxy_config(LinphoneCore *lc, LinphoneProxyConfig *config); +LINPHONE_PUBLIC int linphone_core_add_proxy_config(LinphoneCore *lc, LinphoneProxyConfig *config); void linphone_core_clear_proxy_config(LinphoneCore *lc); void linphone_core_remove_proxy_config(LinphoneCore *lc, LinphoneProxyConfig *config); -const MSList *linphone_core_get_proxy_config_list(const LinphoneCore *lc); +LINPHONE_PUBLIC const MSList *linphone_core_get_proxy_config_list(const LinphoneCore *lc); -void linphone_core_set_default_proxy(LinphoneCore *lc, LinphoneProxyConfig *config); +LINPHONE_PUBLIC void linphone_core_set_default_proxy(LinphoneCore *lc, LinphoneProxyConfig *config); void linphone_core_set_default_proxy_index(LinphoneCore *lc, int index); -int linphone_core_get_default_proxy(LinphoneCore *lc, LinphoneProxyConfig **config); +LINPHONE_PUBLIC int linphone_core_get_default_proxy(LinphoneCore *lc, LinphoneProxyConfig **config); -void linphone_core_add_auth_info(LinphoneCore *lc, const LinphoneAuthInfo *info); +LINPHONE_PUBLIC void linphone_core_add_auth_info(LinphoneCore *lc, const LinphoneAuthInfo *info); void linphone_core_remove_auth_info(LinphoneCore *lc, const LinphoneAuthInfo *info); @@ -1086,9 +1086,9 @@ void linphone_core_set_sip_port(LinphoneCore *lc, int port); int linphone_core_get_sip_port(LinphoneCore *lc); -int linphone_core_set_sip_transports(LinphoneCore *lc, const LCSipTransports *transports); +LINPHONE_PUBLIC int linphone_core_set_sip_transports(LinphoneCore *lc, const LCSipTransports *transports); -int linphone_core_get_sip_transports(LinphoneCore *lc, LCSipTransports *transports); +LINPHONE_PUBLIC int linphone_core_get_sip_transports(LinphoneCore *lc, LCSipTransports *transports); /** * * Give access to the UDP sip socket. Can be useful to configure this socket as persistent I.E kCFStreamNetworkServiceType set to kCFStreamNetworkServiceTypeVoIP) @@ -1181,13 +1181,13 @@ int linphone_core_set_playback_device(LinphoneCore *lc, const char * devid); int linphone_core_set_capture_device(LinphoneCore *lc, const char * devid); char linphone_core_get_sound_source(LinphoneCore *lc); void linphone_core_set_sound_source(LinphoneCore *lc, char source); -void linphone_core_set_ring(LinphoneCore *lc, const char *path); +LINPHONE_PUBLIC void linphone_core_set_ring(LinphoneCore *lc, const char *path); const char *linphone_core_get_ring(const LinphoneCore *lc); void linphone_core_verify_server_certificates(LinphoneCore *lc, bool_t yesno); void linphone_core_verify_server_cn(LinphoneCore *lc, bool_t yesno); void linphone_core_set_root_ca(LinphoneCore *lc, const char *path); const char *linphone_core_get_root_ca(LinphoneCore *lc); -void linphone_core_set_ringback(LinphoneCore *lc, const char *path); +LINPHONE_PUBLIC void linphone_core_set_ringback(LinphoneCore *lc, const char *path); const char * linphone_core_get_ringback(const LinphoneCore *lc); void linphone_core_set_remote_ringback_tone(LinphoneCore *lc,const char *); @@ -1226,9 +1226,9 @@ void linphone_core_remove_call_log(LinphoneCore *lc, LinphoneCallLog *call_log); /* video support */ bool_t linphone_core_video_supported(LinphoneCore *lc); -void linphone_core_enable_video(LinphoneCore *lc, bool_t vcap_enabled, bool_t display_enabled); +LINPHONE_PUBLIC void linphone_core_enable_video(LinphoneCore *lc, bool_t vcap_enabled, bool_t display_enabled); bool_t linphone_core_video_enabled(LinphoneCore *lc); -void linphone_core_set_video_policy(LinphoneCore *lc, const LinphoneVideoPolicy *policy); +LINPHONE_PUBLIC void linphone_core_set_video_policy(LinphoneCore *lc, const LinphoneVideoPolicy *policy); const LinphoneVideoPolicy *linphone_core_get_video_policy(LinphoneCore *lc); typedef struct MSVideoSizeDef{ @@ -1296,7 +1296,7 @@ void linphone_core_set_mtu(LinphoneCore *lc, int mtu); * Calling this method with true trigger linphone to initiate a registration process for all proxies. * Calling this method disables the automatic network detection mode. It means you must call this method after each network state changes. */ -void linphone_core_set_network_reachable(LinphoneCore* lc,bool_t value); +LINPHONE_PUBLIC void linphone_core_set_network_reachable(LinphoneCore* lc,bool_t value); /** * @ingroup network_parameters * return network state either as positioned by the application or by linphone itself. @@ -1314,8 +1314,8 @@ void linphone_core_enable_keep_alive(LinphoneCore* lc,bool_t enable); */ bool_t linphone_core_keep_alive_enabled(LinphoneCore* lc); -void *linphone_core_get_user_data(LinphoneCore *lc); -void linphone_core_set_user_data(LinphoneCore *lc, void *userdata); +LINPHONE_PUBLIC void *linphone_core_get_user_data(LinphoneCore *lc); +LINPHONE_PUBLIC void linphone_core_set_user_data(LinphoneCore *lc, void *userdata); /* returns LpConfig object to read/write to the config file: usefull if you wish to extend the config file with your own sections */ @@ -1327,7 +1327,7 @@ void linphone_core_set_waiting_callback(LinphoneCore *lc, LinphoneWaitingCallbac /*returns the list of registered SipSetup (linphonecore plugins) */ const MSList * linphone_core_get_sip_setups(LinphoneCore *lc); -void linphone_core_destroy(LinphoneCore *lc); +LINPHONE_PUBLIC void linphone_core_destroy(LinphoneCore *lc); /*for advanced users:*/ typedef RtpTransport * (*LinphoneRtpTransportFactoryFunc)(void *data, int port); @@ -1349,7 +1349,7 @@ int linphone_core_get_current_call_stats(LinphoneCore *lc, rtp_stats_t *local, r int linphone_core_get_calls_nb(const LinphoneCore *lc); -const MSList *linphone_core_get_calls(LinphoneCore *lc); +LINPHONE_PUBLIC const MSList *linphone_core_get_calls(LinphoneCore *lc); LinphoneGlobalState linphone_core_get_global_state(const LinphoneCore *lc); /** @@ -1364,16 +1364,16 @@ const char *linphone_core_get_zrtp_secrets_file(LinphoneCore *lc); const LinphoneCall* linphone_core_find_call_from_uri(LinphoneCore *lc, const char *uri); -int linphone_core_add_to_conference(LinphoneCore *lc, LinphoneCall *call); +LINPHONE_PUBLIC int linphone_core_add_to_conference(LinphoneCore *lc, LinphoneCall *call); int linphone_core_add_all_to_conference(LinphoneCore *lc); int linphone_core_remove_from_conference(LinphoneCore *lc, LinphoneCall *call); -bool_t linphone_core_is_in_conference(const LinphoneCore *lc); +LINPHONE_PUBLIC bool_t linphone_core_is_in_conference(const LinphoneCore *lc); int linphone_core_enter_conference(LinphoneCore *lc); int linphone_core_leave_conference(LinphoneCore *lc); float linphone_core_get_conference_local_input_volume(LinphoneCore *lc); -int linphone_core_terminate_conference(LinphoneCore *lc); -int linphone_core_get_conference_size(LinphoneCore *lc); +LINPHONE_PUBLIC int linphone_core_terminate_conference(LinphoneCore *lc); +LINPHONE_PUBLIC int linphone_core_get_conference_size(LinphoneCore *lc); int linphone_core_start_conference_recording(LinphoneCore *lc, const char *path); int linphone_core_stop_conference_recording(LinphoneCore *lc); @@ -1387,8 +1387,8 @@ bool_t linphone_core_media_encryption_supported(const LinphoneCore *lc, Linphone /** * Choose media encryption policy to be used for RTP packets */ -int linphone_core_set_media_encryption(LinphoneCore *lc, enum LinphoneMediaEncryption menc); -LinphoneMediaEncryption linphone_core_get_media_encryption(LinphoneCore *lc); +LINPHONE_PUBLIC int linphone_core_set_media_encryption(LinphoneCore *lc, enum LinphoneMediaEncryption menc); +LINPHONE_PUBLIC LinphoneMediaEncryption linphone_core_get_media_encryption(LinphoneCore *lc); bool_t linphone_core_is_media_encryption_mandatory(LinphoneCore *lc); /** diff --git a/coreapi/linphonefriend.h b/coreapi/linphonefriend.h index ab75b7bf7..90491df5b 100644 --- a/coreapi/linphonefriend.h +++ b/coreapi/linphonefriend.h @@ -117,7 +117,7 @@ LinphoneFriend * linphone_friend_new(); * @param addr a buddy address, must be a sip uri like sip:joe@sip.linphone.org * @return a new #LinphoneFriend with \link linphone_friend_get_address() address initialized \endlink */ -LinphoneFriend *linphone_friend_new_with_addr(const char *addr); +LINPHONE_PUBLIC LinphoneFriend *linphone_friend_new_with_addr(const char *addr); /** * Destructor @@ -137,7 +137,7 @@ int linphone_friend_set_addr(LinphoneFriend *fr, const LinphoneAddress* address) * @param lf #LinphoneFriend object * @return #LinphoneAddress */ -const LinphoneAddress *linphone_friend_get_address(const LinphoneFriend *lf); +LINPHONE_PUBLIC const LinphoneAddress *linphone_friend_get_address(const LinphoneFriend *lf); /** * get subscription flag value * @param lf #LinphoneFriend object @@ -153,7 +153,7 @@ bool_t linphone_friend_subscribes_enabled(const LinphoneFriend *lf); * @param val if TRUE this friend will receive subscription message */ -int linphone_friend_enable_subscribes(LinphoneFriend *fr, bool_t val); +LINPHONE_PUBLIC int linphone_friend_enable_subscribes(LinphoneFriend *fr, bool_t val); #define linphone_friend_send_subscribe linphone_friend_enable_subscribes /** @@ -179,12 +179,12 @@ LinphoneSubscribePolicy linphone_friend_get_inc_subscribe_policy(const LinphoneF * Once the modifications are done, then the application must call * linphone_friend_done() to commit the changes. **/ -void linphone_friend_edit(LinphoneFriend *fr); +LINPHONE_PUBLIC void linphone_friend_edit(LinphoneFriend *fr); /** * Commits modification made to the friend configuration. * @param fr #LinphoneFriend object **/ -void linphone_friend_done(LinphoneFriend *fr); +LINPHONE_PUBLIC void linphone_friend_done(LinphoneFriend *fr); @@ -229,7 +229,7 @@ void linphone_core_interpret_friend_uri(LinphoneCore *lc, const char *uri, char * @param lc #LinphoneCore object * @param fr #LinphoneFriend to add */ -void linphone_core_add_friend(LinphoneCore *lc, LinphoneFriend *fr); +LINPHONE_PUBLIC void linphone_core_add_friend(LinphoneCore *lc, LinphoneFriend *fr); /** * remove a friend from the buddy list * @param lc #LinphoneCore object @@ -246,7 +246,7 @@ void linphone_core_reject_subscriber(LinphoneCore *lc, LinphoneFriend *lf); * get Buddy list of LinphoneFriend * @param lc #LinphoneCore object * */ -const MSList * linphone_core_get_friend_list(const LinphoneCore *lc); +LINPHONE_PUBLIC const MSList * linphone_core_get_friend_list(const LinphoneCore *lc); /** * notify all friends that have subscribed * @param lc #LinphoneCore object diff --git a/include/sal/sal.h b/include/sal/sal.h index 25d8d20bc..759e36ad1 100644 --- a/include/sal/sal.h +++ b/include/sal/sal.h @@ -1,479 +1,493 @@ -/* -linphone -Copyright (C) 2010 Simon MORLAT (simon.morlat@free.fr) - -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 the Free Software Foundation; either version 2 -of the License, or (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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -/** - This header files defines the Signaling Abstraction Layer. - The purpose of this layer is too allow experiment different call signaling - protocols and implementations under linphone, for example SIP, JINGLE... -**/ - -#ifndef sal_h -#define sal_h - -#include "mediastreamer2/mscommon.h" -#include "ortp/ortp_srtp.h" - -/*Dirty hack, keep in sync with mediastreamer2/include/mediastream.h */ -#ifndef PAYLOAD_TYPE_FLAG_CAN_RECV -#define PAYLOAD_TYPE_FLAG_CAN_RECV PAYLOAD_TYPE_USER_FLAG_1 -#define PAYLOAD_TYPE_FLAG_CAN_SEND PAYLOAD_TYPE_USER_FLAG_2 -#endif -struct Sal; - -typedef struct Sal Sal; - -struct SalOp; - -typedef struct SalOp SalOp; - -struct SalAddress; - -typedef struct SalAddress SalAddress; - -struct SalCustomHeader; - -typedef struct SalCustomHeader SalCustomHeader; - -typedef enum { - SalTransportUDP, /*UDP*/ - SalTransportTCP, /*TCP*/ - SalTransportTLS, /*TLS*/ - SalTransportDTLS /*DTLS*/ -}SalTransport; - -#define SAL_MEDIA_DESCRIPTION_UNCHANGED 0x00 -#define SAL_MEDIA_DESCRIPTION_NETWORK_CHANGED 0x01 -#define SAL_MEDIA_DESCRIPTION_CODEC_CHANGED 0x02 -#define SAL_MEDIA_DESCRIPTION_CRYPTO_CHANGED 0x04 -#define SAL_MEDIA_DESCRIPTION_CHANGED (SAL_MEDIA_DESCRIPTION_NETWORK_CHANGED | SAL_MEDIA_DESCRIPTION_CODEC_CHANGED | SAL_MEDIA_DESCRIPTION_CRYPTO_CHANGED) - -const char* sal_transport_to_string(SalTransport transport); -SalTransport sal_transport_parse(const char*); -/* Address manipulation API*/ -SalAddress * sal_address_new(const char *uri); -SalAddress * sal_address_clone(const SalAddress *addr); -const char *sal_address_get_scheme(const SalAddress *addr); -const char *sal_address_get_display_name(const SalAddress* addr); -char *sal_address_get_display_name_unquoted(const SalAddress *addr); -const char *sal_address_get_username(const SalAddress *addr); -const char *sal_address_get_domain(const SalAddress *addr); -const char * sal_address_get_port(const SalAddress *addr); -int sal_address_get_port_int(const SalAddress *addr); -SalTransport sal_address_get_transport(const SalAddress* addr); - -void sal_address_set_display_name(SalAddress *addr, const char *display_name); -void sal_address_set_username(SalAddress *addr, const char *username); -void sal_address_set_domain(SalAddress *addr, const char *host); -void sal_address_set_port(SalAddress *addr, const char *port); -void sal_address_set_port_int(SalAddress *uri, int port); -void sal_address_clean(SalAddress *addr); -char *sal_address_as_string(const SalAddress *u); -char *sal_address_as_string_uri_only(const SalAddress *u); -void sal_address_destroy(SalAddress *u); -void sal_address_set_param(SalAddress *u,const char* name,const char* value); -void sal_address_set_transport(SalAddress* addr,SalTransport transport); - - -Sal * sal_init(); -void sal_uninit(Sal* sal); -void sal_set_user_pointer(Sal *sal, void *user_data); -void *sal_get_user_pointer(const Sal *sal); - - -typedef enum { - SalAudio, - SalVideo, - SalOther -} SalStreamType; - -typedef enum{ - SalProtoUnknown, - SalProtoRtpAvp, - SalProtoRtpSavp -}SalMediaProto; - -typedef enum{ - SalStreamSendRecv, - SalStreamSendOnly, - SalStreamRecvOnly, - SalStreamInactive -}SalStreamDir; - -#define SAL_ENDPOINT_CANDIDATE_MAX 2 - -#define SAL_MEDIA_DESCRIPTION_MAX_ICE_ADDR_LEN 64 -#define SAL_MEDIA_DESCRIPTION_MAX_ICE_FOUNDATION_LEN 32 -#define SAL_MEDIA_DESCRIPTION_MAX_ICE_TYPE_LEN 6 - -typedef struct SalIceCandidate { - char addr[SAL_MEDIA_DESCRIPTION_MAX_ICE_ADDR_LEN]; - char raddr[SAL_MEDIA_DESCRIPTION_MAX_ICE_ADDR_LEN]; - char foundation[SAL_MEDIA_DESCRIPTION_MAX_ICE_FOUNDATION_LEN]; - char type[SAL_MEDIA_DESCRIPTION_MAX_ICE_TYPE_LEN]; - unsigned int componentID; - unsigned int priority; - int port; - int rport; -} SalIceCandidate; - -#define SAL_MEDIA_DESCRIPTION_MAX_ICE_CANDIDATES 10 - -typedef struct SalIceRemoteCandidate { - char addr[SAL_MEDIA_DESCRIPTION_MAX_ICE_ADDR_LEN]; - int port; -} SalIceRemoteCandidate; - -#define SAL_MEDIA_DESCRIPTION_MAX_ICE_REMOTE_CANDIDATES 2 - -#define SAL_MEDIA_DESCRIPTION_MAX_ICE_UFRAG_LEN 256 -#define SAL_MEDIA_DESCRIPTION_MAX_ICE_PWD_LEN 256 - -typedef struct SalSrtpCryptoAlgo { - unsigned int tag; - enum ortp_srtp_crypto_suite_t algo; - /* 41= 40 max(key_length for all algo) + '\0' */ - char master_key[41]; -} SalSrtpCryptoAlgo; - -#define SAL_CRYPTO_ALGO_MAX 4 - -typedef struct SalStreamDescription{ - SalMediaProto proto; - SalStreamType type; - char typeother[32]; - char rtp_addr[64]; - char rtcp_addr[64]; - int rtp_port; - int rtcp_port; - MSList *payloads; //user_data=(void*)((long)n); -#define payload_type_get_number(pt) ((int)(long)(pt)->user_data) - -/*misc*/ -void sal_get_default_local_ip(Sal *sal, int address_family, char *ip, size_t iplen); - -struct SalCustomHeader{ - MSList node; - char *header_name; - char *header_value; -}; - -SalCustomHeader *sal_custom_header_append(SalCustomHeader *ch, const char *name, const char *value); -const char *sal_custom_header_find(const SalCustomHeader *ch, const char *name); -void sal_custom_header_free(SalCustomHeader *ch); -SalCustomHeader *sal_custom_header_clone(const SalCustomHeader *ch); -const SalCustomHeader *sal_op_get_custom_header(SalOp *op); -void sal_op_set_custom_header(SalOp *op, SalCustomHeader* ch); - - -/*internal API */ -void __sal_op_init(SalOp *b, Sal *sal); -void __sal_op_set_network_origin(SalOp *op, const char *origin /*a sip uri*/); -void __sal_op_set_remote_contact(SalOp *op, const char *ct); -void __sal_op_free(SalOp *b); - -#endif +/* +linphone +Copyright (C) 2010 Simon MORLAT (simon.morlat@free.fr) + +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 the Free Software Foundation; either version 2 +of the License, or (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, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +/** + This header files defines the Signaling Abstraction Layer. + The purpose of this layer is too allow experiment different call signaling + protocols and implementations under linphone, for example SIP, JINGLE... +**/ + +#ifndef sal_h +#define sal_h + +#include "mediastreamer2/mscommon.h" +#include "ortp/ortp_srtp.h" + +#ifdef LIBLINPHONE_EXPORTS +#define LINPHONE_PUBLIC __declspec(dllexport) +#else +#define LINPHONE_PUBLIC __declspec(dllimport) +#endif + +/*Dirty hack, keep in sync with mediastreamer2/include/mediastream.h */ +#ifndef PAYLOAD_TYPE_FLAG_CAN_RECV +#define PAYLOAD_TYPE_FLAG_CAN_RECV PAYLOAD_TYPE_USER_FLAG_1 +#define PAYLOAD_TYPE_FLAG_CAN_SEND PAYLOAD_TYPE_USER_FLAG_2 +#endif +struct Sal; + +typedef struct Sal Sal; + +struct SalOp; + +typedef struct SalOp SalOp; + +struct SalAddress; + +typedef struct SalAddress SalAddress; + +struct SalCustomHeader; + +typedef struct SalCustomHeader SalCustomHeader; + +typedef enum { + SalTransportUDP, /*UDP*/ + SalTransportTCP, /*TCP*/ + SalTransportTLS, /*TLS*/ + SalTransportDTLS /*DTLS*/ +}SalTransport; + +#define SAL_MEDIA_DESCRIPTION_UNCHANGED 0x00 +#define SAL_MEDIA_DESCRIPTION_NETWORK_CHANGED 0x01 +#define SAL_MEDIA_DESCRIPTION_CODEC_CHANGED 0x02 +#define SAL_MEDIA_DESCRIPTION_CRYPTO_CHANGED 0x04 +#define SAL_MEDIA_DESCRIPTION_CHANGED (SAL_MEDIA_DESCRIPTION_NETWORK_CHANGED | SAL_MEDIA_DESCRIPTION_CODEC_CHANGED | SAL_MEDIA_DESCRIPTION_CRYPTO_CHANGED) + +const char* sal_transport_to_string(SalTransport transport); +SalTransport sal_transport_parse(const char*); +/* Address manipulation API*/ +SalAddress * sal_address_new(const char *uri); +SalAddress * sal_address_clone(const SalAddress *addr); +const char *sal_address_get_scheme(const SalAddress *addr); +const char *sal_address_get_display_name(const SalAddress* addr); +char *sal_address_get_display_name_unquoted(const SalAddress *addr); +const char *sal_address_get_username(const SalAddress *addr); +const char *sal_address_get_domain(const SalAddress *addr); +const char * sal_address_get_port(const SalAddress *addr); +int sal_address_get_port_int(const SalAddress *addr); +SalTransport sal_address_get_transport(const SalAddress* addr); + +void sal_address_set_display_name(SalAddress *addr, const char *display_name); +void sal_address_set_username(SalAddress *addr, const char *username); +void sal_address_set_domain(SalAddress *addr, const char *host); +void sal_address_set_port(SalAddress *addr, const char *port); +void sal_address_set_port_int(SalAddress *uri, int port); +void sal_address_clean(SalAddress *addr); +char *sal_address_as_string(const SalAddress *u); +char *sal_address_as_string_uri_only(const SalAddress *u); +void sal_address_destroy(SalAddress *u); +void sal_address_set_param(SalAddress *u,const char* name,const char* value); +void sal_address_set_transport(SalAddress* addr,SalTransport transport); + + +Sal * sal_init(); +void sal_uninit(Sal* sal); +void sal_set_user_pointer(Sal *sal, void *user_data); +void *sal_get_user_pointer(const Sal *sal); + + +typedef enum { + SalAudio, + SalVideo, + SalOther +} SalStreamType; + +typedef enum{ + SalProtoUnknown, + SalProtoRtpAvp, + SalProtoRtpSavp +}SalMediaProto; + +typedef enum{ + SalStreamSendRecv, + SalStreamSendOnly, + SalStreamRecvOnly, + SalStreamInactive +}SalStreamDir; + +#define SAL_ENDPOINT_CANDIDATE_MAX 2 + +#define SAL_MEDIA_DESCRIPTION_MAX_ICE_ADDR_LEN 64 +#define SAL_MEDIA_DESCRIPTION_MAX_ICE_FOUNDATION_LEN 32 +#define SAL_MEDIA_DESCRIPTION_MAX_ICE_TYPE_LEN 6 + +typedef struct SalIceCandidate { + char addr[SAL_MEDIA_DESCRIPTION_MAX_ICE_ADDR_LEN]; + char raddr[SAL_MEDIA_DESCRIPTION_MAX_ICE_ADDR_LEN]; + char foundation[SAL_MEDIA_DESCRIPTION_MAX_ICE_FOUNDATION_LEN]; + char type[SAL_MEDIA_DESCRIPTION_MAX_ICE_TYPE_LEN]; + unsigned int componentID; + unsigned int priority; + int port; + int rport; +} SalIceCandidate; + +#define SAL_MEDIA_DESCRIPTION_MAX_ICE_CANDIDATES 10 + +typedef struct SalIceRemoteCandidate { + char addr[SAL_MEDIA_DESCRIPTION_MAX_ICE_ADDR_LEN]; + int port; +} SalIceRemoteCandidate; + +#define SAL_MEDIA_DESCRIPTION_MAX_ICE_REMOTE_CANDIDATES 2 + +#define SAL_MEDIA_DESCRIPTION_MAX_ICE_UFRAG_LEN 256 +#define SAL_MEDIA_DESCRIPTION_MAX_ICE_PWD_LEN 256 + +typedef struct SalSrtpCryptoAlgo { + unsigned int tag; + enum ortp_srtp_crypto_suite_t algo; + /* 41= 40 max(key_length for all algo) + '\0' */ + char master_key[41]; +} SalSrtpCryptoAlgo; + +#define SAL_CRYPTO_ALGO_MAX 4 + +typedef struct SalStreamDescription{ + SalMediaProto proto; + SalStreamType type; + char typeother[32]; + char rtp_addr[64]; + char rtcp_addr[64]; + int rtp_port; + int rtcp_port; + MSList *payloads; //user_data=(void*)((long)n); +#define payload_type_get_number(pt) ((int)(long)(pt)->user_data) + +/*misc*/ +void sal_get_default_local_ip(Sal *sal, int address_family, char *ip, size_t iplen); + +struct SalCustomHeader{ + MSList node; + char *header_name; + char *header_value; +}; + +SalCustomHeader *sal_custom_header_append(SalCustomHeader *ch, const char *name, const char *value); +const char *sal_custom_header_find(const SalCustomHeader *ch, const char *name); +void sal_custom_header_free(SalCustomHeader *ch); +SalCustomHeader *sal_custom_header_clone(const SalCustomHeader *ch); +const SalCustomHeader *sal_op_get_custom_header(SalOp *op); +void sal_op_set_custom_header(SalOp *op, SalCustomHeader* ch); + + +/*internal API */ +void __sal_op_init(SalOp *b, Sal *sal); +void __sal_op_set_network_origin(SalOp *op, const char *origin /*a sip uri*/); +void __sal_op_set_remote_contact(SalOp *op, const char *ct); +void __sal_op_free(SalOp *b); + +/*test api*/ +/*0 for no error*/ +LINPHONE_PUBLIC void sal_set_send_error(Sal *sal,int value); +/*1 for no error*/ +LINPHONE_PUBLIC void sal_set_recv_error(Sal *sal,int value); +/*enable contact fixing*/ +void sal_nat_helper_enable(Sal *sal,bool_t enable); +bool_t sal_nat_helper_enabled(Sal *sal); +#endif From 709d6497b4acf06ffe3c4239aeff521f89e86202 Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Wed, 27 Jul 2016 17:05:47 +0200 Subject: [PATCH 05/21] license: update FSF address --- CMakeLists.txt | 2 +- cmake/FindCUnit.cmake | 2 +- cmake/FindIconv.cmake | 2 +- cmake/FindIntl.cmake | 2 +- cmake/FindNotify.cmake | 2 +- cmake/FindSqlite3.cmake | 2 +- cmake/FindXML2.cmake | 2 +- cmake/FindZlib.cmake | 2 +- cmake/LinphoneConfig.cmake.in | 2 +- config.h.cmake | 2 +- console/CMakeLists.txt | 2 +- console/commands.c | 2 +- console/linphonec.c | 2 +- console/shell.c | 2 +- coreapi/CMakeLists.txt | 2 +- coreapi/account_creator.c | 2 +- coreapi/account_creator.h | 2 +- coreapi/address.c | 2 +- coreapi/bellesip_sal/sal_address_impl.c | 2 +- coreapi/bellesip_sal/sal_impl.c | 2 +- coreapi/bellesip_sal/sal_impl.h | 2 +- coreapi/bellesip_sal/sal_op_call.c | 2 +- coreapi/bellesip_sal/sal_op_call_transfer.c | 2 +- coreapi/bellesip_sal/sal_op_events.c | 2 +- coreapi/bellesip_sal/sal_op_impl.c | 2 +- coreapi/bellesip_sal/sal_op_info.c | 2 +- coreapi/bellesip_sal/sal_op_message.c | 2 +- coreapi/bellesip_sal/sal_op_presence.c | 2 +- coreapi/bellesip_sal/sal_op_publish.c | 2 +- coreapi/bellesip_sal/sal_op_registration.c | 2 +- coreapi/bellesip_sal/sal_sdp.c | 2 +- coreapi/buffer.c | 2 +- coreapi/buffer.h | 2 +- coreapi/call_log.c | 2 +- coreapi/call_log.h | 2 +- coreapi/call_params.c | 2 +- coreapi/call_params.h | 2 +- coreapi/callbacks.c | 2 +- coreapi/content.c | 2 +- coreapi/content.h | 2 +- coreapi/dict.c | 2 +- coreapi/ec-calibrator.c | 2 +- coreapi/enum.c | 2 +- coreapi/enum.h | 2 +- coreapi/event.c | 2 +- coreapi/event.h | 2 +- coreapi/fonis.c | 2 +- coreapi/gitversion.cmake | 2 +- coreapi/help/CMakeLists.txt | 2 +- coreapi/help/buddy_status.c | 2 +- coreapi/help/chatroom.c | 2 +- coreapi/help/filetransfer.c | 2 +- coreapi/help/helloworld.c | 2 +- .../java/org/linphone/core/tutorials/TutorialBuddyStatus.java | 2 +- .../help/java/org/linphone/core/tutorials/TutorialChatRoom.java | 2 +- .../java/org/linphone/core/tutorials/TutorialHelloWorld.java | 2 +- .../help/java/org/linphone/core/tutorials/TutorialNotifier.java | 2 +- .../java/org/linphone/core/tutorials/TutorialRegistration.java | 2 +- coreapi/help/notify.c | 2 +- coreapi/help/registration.c | 2 +- coreapi/linphone_proxy_config.h | 2 +- coreapi/linphonecall.c | 2 +- coreapi/linphonecore.c | 2 +- coreapi/linphonecore.h | 2 +- coreapi/linphonecore_jni.cc | 2 +- coreapi/linphonecore_utils.h | 2 +- coreapi/linphonefriend.h | 2 +- coreapi/linphonepresence.h | 2 +- coreapi/localplayer.c | 2 +- coreapi/lpc2xml.c | 2 +- coreapi/lpc2xml.h | 2 +- coreapi/lsd.c | 2 +- coreapi/message_storage.c | 2 +- coreapi/misc.c | 2 +- coreapi/offeranswer.c | 2 +- coreapi/offeranswer.h | 2 +- coreapi/player.c | 2 +- coreapi/presence.c | 2 +- coreapi/quality_reporting.c | 2 +- coreapi/quality_reporting.h | 2 +- coreapi/remote_provisioning.c | 2 +- coreapi/sal.c | 2 +- coreapi/siplogin.c | 2 +- coreapi/sipsetup.c | 2 +- coreapi/sipsetup.h | 2 +- coreapi/test_ecc.c | 2 +- coreapi/test_lsd.c | 2 +- coreapi/test_numbers.c | 2 +- coreapi/upnp.c | 2 +- coreapi/upnp.h | 2 +- coreapi/vtables.c | 2 +- coreapi/xml.c | 2 +- coreapi/xml2lpc.c | 2 +- coreapi/xml2lpc.h | 2 +- coreapi/xmlrpc.c | 2 +- coreapi/xmlrpc.h | 2 +- gtk/CMakeLists.txt | 2 +- gtk/audio_assistant.c | 2 +- gtk/buddylookup.c | 2 +- gtk/calllogs.c | 2 +- gtk/chat.c | 2 +- gtk/config-fetching.c | 2 +- gtk/fonis.c | 2 +- gtk/friendlist.c | 2 +- gtk/incall_view.c | 2 +- gtk/linphone.h | 2 +- gtk/logging.c | 2 +- gtk/loginframe.c | 2 +- gtk/main.c | 2 +- gtk/propertybox.c | 2 +- gtk/setupwizard.c | 2 +- gtk/singleinstance.c | 2 +- gtk/status_icon.c | 2 +- gtk/status_icon.h | 2 +- gtk/status_notifier.c | 2 +- gtk/status_notifier.h | 2 +- gtk/update.c | 2 +- gtk/utils.c | 2 +- gtk/videowindow.c | 2 +- java/common/org/linphone/core/CallDirection.java | 2 +- java/common/org/linphone/core/LinphoneAddress.java | 2 +- java/common/org/linphone/core/LinphoneAuthInfo.java | 2 +- java/common/org/linphone/core/LinphoneCall.java | 2 +- java/common/org/linphone/core/LinphoneCallLog.java | 2 +- java/common/org/linphone/core/LinphoneCallParams.java | 2 +- java/common/org/linphone/core/LinphoneCallStats.java | 2 +- java/common/org/linphone/core/LinphoneChatRoom.java | 2 +- java/common/org/linphone/core/LinphoneCore.java | 2 +- java/common/org/linphone/core/LinphoneCoreFactory.java | 2 +- java/common/org/linphone/core/LinphoneCoreListener.java | 2 +- java/common/org/linphone/core/LinphoneFriend.java | 2 +- java/common/org/linphone/core/LinphoneLogHandler.java | 2 +- java/common/org/linphone/core/LinphoneProxyConfig.java | 2 +- java/common/org/linphone/core/LpConfig.java | 2 +- java/common/org/linphone/core/OnlineStatus.java | 2 +- java/common/org/linphone/core/PayloadType.java | 2 +- java/common/org/linphone/core/PresenceActivity.java | 2 +- java/common/org/linphone/core/PresenceActivityType.java | 2 +- java/common/org/linphone/core/PresenceBasicStatus.java | 2 +- java/common/org/linphone/core/PresenceModel.java | 2 +- java/common/org/linphone/core/PresenceNote.java | 2 +- java/common/org/linphone/core/PresencePerson.java | 2 +- java/common/org/linphone/core/PresenceService.java | 2 +- java/common/org/linphone/core/VideoSize.java | 2 +- java/common/org/linphone/core/package.html | 2 +- java/impl/org/linphone/core/LinphoneAddressImpl.java | 2 +- java/impl/org/linphone/core/LinphoneAuthInfoImpl.java | 2 +- java/impl/org/linphone/core/LinphoneCallImpl.java | 2 +- java/impl/org/linphone/core/LinphoneCallLogImpl.java | 2 +- java/impl/org/linphone/core/LinphoneCallParamsImpl.java | 2 +- java/impl/org/linphone/core/LinphoneCallStatsImpl.java | 2 +- java/impl/org/linphone/core/LinphoneChatRoomImpl.java | 2 +- java/impl/org/linphone/core/LinphoneCoreFactoryImpl.java | 2 +- java/impl/org/linphone/core/LinphoneCoreImpl.java | 2 +- java/impl/org/linphone/core/LinphoneFriendImpl.java | 2 +- java/impl/org/linphone/core/LinphoneProxyConfigImpl.java | 2 +- java/impl/org/linphone/core/LpConfigImpl.java | 2 +- java/impl/org/linphone/core/PayloadTypeImpl.java | 2 +- java/impl/org/linphone/core/PresenceActivityImpl.java | 2 +- java/impl/org/linphone/core/PresenceModelImpl.java | 2 +- java/impl/org/linphone/core/PresenceNoteImpl.java | 2 +- java/impl/org/linphone/core/PresencePersonImpl.java | 2 +- java/impl/org/linphone/core/PresenceServiceImpl.java | 2 +- java/impl/org/linphone/core/video/VideoUtil.java | 2 +- java/j2me/org/linphone/core/LinphoneCoreException.java | 2 +- java/j2se/org/linphone/core/LinphoneCoreException.java | 2 +- pixmaps/CMakeLists.txt | 2 +- po/CMakeLists.txt | 2 +- share/CMakeLists.txt | 2 +- share/rings/CMakeLists.txt | 2 +- share/rootca.cmake | 2 +- tester/CMakeLists.txt | 2 +- tools/CMakeLists.txt | 2 +- tools/auto_answer.c | 2 +- tools/genapixml.py | 2 +- tools/generator.cc | 2 +- tools/generator.hh | 2 +- tools/genwrappers.cc | 2 +- tools/lpc2xml_jni.cc | 2 +- tools/lpc2xml_test.c | 2 +- tools/my_jni.h | 2 +- tools/python/apixml2python.py | 2 +- tools/python/apixml2python/linphone.py | 2 +- tools/python/apixml2python/linphone_module.mustache | 2 +- tools/software-desc.cc | 2 +- tools/software-desc.hh | 2 +- tools/xml2lpc_jni.cc | 2 +- tools/xml2lpc_test.c | 2 +- 188 files changed, 188 insertions(+), 188 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 56329f10b..80f393877 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,7 +16,7 @@ # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # ############################################################################ diff --git a/cmake/FindCUnit.cmake b/cmake/FindCUnit.cmake index 10c1a10b6..91bc67fbd 100644 --- a/cmake/FindCUnit.cmake +++ b/cmake/FindCUnit.cmake @@ -16,7 +16,7 @@ # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # ############################################################################ # diff --git a/cmake/FindIconv.cmake b/cmake/FindIconv.cmake index c65317a56..8497e9f58 100644 --- a/cmake/FindIconv.cmake +++ b/cmake/FindIconv.cmake @@ -16,7 +16,7 @@ # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # ############################################################################ # diff --git a/cmake/FindIntl.cmake b/cmake/FindIntl.cmake index 35ec969cd..97dfea8e0 100644 --- a/cmake/FindIntl.cmake +++ b/cmake/FindIntl.cmake @@ -16,7 +16,7 @@ # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # ############################################################################ # diff --git a/cmake/FindNotify.cmake b/cmake/FindNotify.cmake index a9fb4d978..e13614195 100644 --- a/cmake/FindNotify.cmake +++ b/cmake/FindNotify.cmake @@ -16,7 +16,7 @@ # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # ############################################################################ # diff --git a/cmake/FindSqlite3.cmake b/cmake/FindSqlite3.cmake index 7cab06bd1..e634b0813 100644 --- a/cmake/FindSqlite3.cmake +++ b/cmake/FindSqlite3.cmake @@ -16,7 +16,7 @@ # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # ############################################################################ # diff --git a/cmake/FindXML2.cmake b/cmake/FindXML2.cmake index 9d0eebe14..3f35ab497 100644 --- a/cmake/FindXML2.cmake +++ b/cmake/FindXML2.cmake @@ -16,7 +16,7 @@ # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # ############################################################################ # diff --git a/cmake/FindZlib.cmake b/cmake/FindZlib.cmake index 3a0935f76..1f42aaf81 100644 --- a/cmake/FindZlib.cmake +++ b/cmake/FindZlib.cmake @@ -16,7 +16,7 @@ # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # ############################################################################ # diff --git a/cmake/LinphoneConfig.cmake.in b/cmake/LinphoneConfig.cmake.in index d7aa6cc22..62d0fa74e 100644 --- a/cmake/LinphoneConfig.cmake.in +++ b/cmake/LinphoneConfig.cmake.in @@ -16,7 +16,7 @@ # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # ############################################################################ # diff --git a/config.h.cmake b/config.h.cmake index 35d7e2ac9..6e8fd92dd 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ****************************************************************************/ diff --git a/console/CMakeLists.txt b/console/CMakeLists.txt index 328fdbcf2..696d33a43 100644 --- a/console/CMakeLists.txt +++ b/console/CMakeLists.txt @@ -16,7 +16,7 @@ # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # ############################################################################ diff --git a/console/commands.c b/console/commands.c index f50ed4886..75dbbb688 100644 --- a/console/commands.c +++ b/console/commands.c @@ -19,7 +19,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ****************************************************************************/ diff --git a/console/linphonec.c b/console/linphonec.c index cdf06f474..1ad119ed5 100644 --- a/console/linphonec.c +++ b/console/linphonec.c @@ -20,7 +20,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ****************************************************************************/ #include diff --git a/console/shell.c b/console/shell.c index 7fbccb4c3..49b1b5d45 100644 --- a/console/shell.c +++ b/console/shell.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ****************************************************************************/ diff --git a/coreapi/CMakeLists.txt b/coreapi/CMakeLists.txt index 117d7b6c0..3920d619a 100644 --- a/coreapi/CMakeLists.txt +++ b/coreapi/CMakeLists.txt @@ -16,7 +16,7 @@ # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # ############################################################################ diff --git a/coreapi/account_creator.c b/coreapi/account_creator.c index 23cdffb28..b7c809df6 100644 --- a/coreapi/account_creator.c +++ b/coreapi/account_creator.c @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "linphonecore.h" diff --git a/coreapi/account_creator.h b/coreapi/account_creator.h index f2231984a..fbc5d5114 100644 --- a/coreapi/account_creator.h +++ b/coreapi/account_creator.h @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef LINPHONE_ACCOUNT_CREATOR_H_ diff --git a/coreapi/address.c b/coreapi/address.c index 1299a5351..cb2f3cdf2 100644 --- a/coreapi/address.c +++ b/coreapi/address.c @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "linphonecore.h" diff --git a/coreapi/bellesip_sal/sal_address_impl.c b/coreapi/bellesip_sal/sal_address_impl.c index 2546e7850..54df93fd4 100644 --- a/coreapi/bellesip_sal/sal_address_impl.c +++ b/coreapi/bellesip_sal/sal_address_impl.c @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "sal_impl.h" /**/ diff --git a/coreapi/bellesip_sal/sal_impl.c b/coreapi/bellesip_sal/sal_impl.c index 6e3a6cba9..8bf38740c 100644 --- a/coreapi/bellesip_sal/sal_impl.c +++ b/coreapi/bellesip_sal/sal_impl.c @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "sal_impl.h" diff --git a/coreapi/bellesip_sal/sal_impl.h b/coreapi/bellesip_sal/sal_impl.h index b75be9156..1ca8e058f 100644 --- a/coreapi/bellesip_sal/sal_impl.h +++ b/coreapi/bellesip_sal/sal_impl.h @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef SAL_IMPL_H_ diff --git a/coreapi/bellesip_sal/sal_op_call.c b/coreapi/bellesip_sal/sal_op_call.c index 5474540ea..85b2a125f 100644 --- a/coreapi/bellesip_sal/sal_op_call.c +++ b/coreapi/bellesip_sal/sal_op_call.c @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "sal_impl.h" #include "offeranswer.h" diff --git a/coreapi/bellesip_sal/sal_op_call_transfer.c b/coreapi/bellesip_sal/sal_op_call_transfer.c index 84e529091..ad9da3d5d 100644 --- a/coreapi/bellesip_sal/sal_op_call_transfer.c +++ b/coreapi/bellesip_sal/sal_op_call_transfer.c @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "sal_impl.h" #include "offeranswer.h" diff --git a/coreapi/bellesip_sal/sal_op_events.c b/coreapi/bellesip_sal/sal_op_events.c index d4a24bd9b..e6b456042 100644 --- a/coreapi/bellesip_sal/sal_op_events.c +++ b/coreapi/bellesip_sal/sal_op_events.c @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "sal_impl.h" diff --git a/coreapi/bellesip_sal/sal_op_impl.c b/coreapi/bellesip_sal/sal_op_impl.c index d19091c96..41413637c 100644 --- a/coreapi/bellesip_sal/sal_op_impl.c +++ b/coreapi/bellesip_sal/sal_op_impl.c @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "sal_impl.h" diff --git a/coreapi/bellesip_sal/sal_op_info.c b/coreapi/bellesip_sal/sal_op_info.c index 3cffb8e55..7892dd6ec 100644 --- a/coreapi/bellesip_sal/sal_op_info.c +++ b/coreapi/bellesip_sal/sal_op_info.c @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "sal_impl.h" diff --git a/coreapi/bellesip_sal/sal_op_message.c b/coreapi/bellesip_sal/sal_op_message.c index 921f8c0a6..a60febf7a 100644 --- a/coreapi/bellesip_sal/sal_op_message.c +++ b/coreapi/bellesip_sal/sal_op_message.c @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "sal_impl.h" diff --git a/coreapi/bellesip_sal/sal_op_presence.c b/coreapi/bellesip_sal/sal_op_presence.c index 6de0a0fbf..e60ac3423 100644 --- a/coreapi/bellesip_sal/sal_op_presence.c +++ b/coreapi/bellesip_sal/sal_op_presence.c @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "sal_impl.h" diff --git a/coreapi/bellesip_sal/sal_op_publish.c b/coreapi/bellesip_sal/sal_op_publish.c index 17ef8e8db..b2f17c27e 100644 --- a/coreapi/bellesip_sal/sal_op_publish.c +++ b/coreapi/bellesip_sal/sal_op_publish.c @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "sal_impl.h" diff --git a/coreapi/bellesip_sal/sal_op_registration.c b/coreapi/bellesip_sal/sal_op_registration.c index 961ba4a34..480ee08ad 100644 --- a/coreapi/bellesip_sal/sal_op_registration.c +++ b/coreapi/bellesip_sal/sal_op_registration.c @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "sal_impl.h" diff --git a/coreapi/bellesip_sal/sal_sdp.c b/coreapi/bellesip_sal/sal_sdp.c index 9313a3d43..69a28a8e9 100644 --- a/coreapi/bellesip_sal/sal_sdp.c +++ b/coreapi/bellesip_sal/sal_sdp.c @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "sal_impl.h" #define keywordcmp(key,b) strncmp(key,b,sizeof(key)) diff --git a/coreapi/buffer.c b/coreapi/buffer.c index 9db65798e..fc1aa47bd 100644 --- a/coreapi/buffer.c +++ b/coreapi/buffer.c @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "linphonecore.h" diff --git a/coreapi/buffer.h b/coreapi/buffer.h index 0d22e9ad2..718b577a1 100644 --- a/coreapi/buffer.h +++ b/coreapi/buffer.h @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef LINPHONE_BUFFER_H_ diff --git a/coreapi/call_log.c b/coreapi/call_log.c index 9d16e8511..7109e2557 100644 --- a/coreapi/call_log.c +++ b/coreapi/call_log.c @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #define _XOPEN_SOURCE 700 /*required for strptime of GNU libc*/ diff --git a/coreapi/call_log.h b/coreapi/call_log.h index 6a3ec8dab..da9cdfb6b 100644 --- a/coreapi/call_log.h +++ b/coreapi/call_log.h @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ diff --git a/coreapi/call_params.c b/coreapi/call_params.c index f9a1a1a4d..5bd95550e 100644 --- a/coreapi/call_params.c +++ b/coreapi/call_params.c @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "private.h" diff --git a/coreapi/call_params.h b/coreapi/call_params.h index a45eb8999..08f0c9d5f 100644 --- a/coreapi/call_params.h +++ b/coreapi/call_params.h @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ diff --git a/coreapi/callbacks.c b/coreapi/callbacks.c index 5ce07dd3c..339c0a905 100644 --- a/coreapi/callbacks.c +++ b/coreapi/callbacks.c @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ diff --git a/coreapi/content.c b/coreapi/content.c index 9f5cd4fee..23eb6c26c 100644 --- a/coreapi/content.c +++ b/coreapi/content.c @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "linphonecore.h" diff --git a/coreapi/content.h b/coreapi/content.h index 1e21138eb..02ccc3833 100644 --- a/coreapi/content.h +++ b/coreapi/content.h @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef LINPHONE_CONTENT_H_ diff --git a/coreapi/dict.c b/coreapi/dict.c index 417bb33f0..1dae02c5a 100644 --- a/coreapi/dict.c +++ b/coreapi/dict.c @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "linphonecore.h" diff --git a/coreapi/ec-calibrator.c b/coreapi/ec-calibrator.c index bff0a00f1..3ac8b55ef 100644 --- a/coreapi/ec-calibrator.c +++ b/coreapi/ec-calibrator.c @@ -15,7 +15,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "private.h" diff --git a/coreapi/enum.c b/coreapi/enum.c index 8818ae6ee..e917e0383 100644 --- a/coreapi/enum.c +++ b/coreapi/enum.c @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /* enum lookup code */ diff --git a/coreapi/enum.h b/coreapi/enum.h index 05b285fb7..19ee86baa 100644 --- a/coreapi/enum.h +++ b/coreapi/enum.h @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef ENUM_LOOKUP_H diff --git a/coreapi/event.c b/coreapi/event.c index 836b929a7..6d3beefaf 100644 --- a/coreapi/event.c +++ b/coreapi/event.c @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "private.h" diff --git a/coreapi/event.h b/coreapi/event.h index fe3f984de..07332ca2e 100644 --- a/coreapi/event.h +++ b/coreapi/event.h @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef LINPHONEEVENT_H #define LINPHONEEVENT_H diff --git a/coreapi/fonis.c b/coreapi/fonis.c index 040f68cbb..17357c11d 100644 --- a/coreapi/fonis.c +++ b/coreapi/fonis.c @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ diff --git a/coreapi/gitversion.cmake b/coreapi/gitversion.cmake index 23fecb10c..e626873a4 100644 --- a/coreapi/gitversion.cmake +++ b/coreapi/gitversion.cmake @@ -16,7 +16,7 @@ # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # ############################################################################ diff --git a/coreapi/help/CMakeLists.txt b/coreapi/help/CMakeLists.txt index fa6915d8f..0ee3b6561 100644 --- a/coreapi/help/CMakeLists.txt +++ b/coreapi/help/CMakeLists.txt @@ -16,7 +16,7 @@ # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # ############################################################################ diff --git a/coreapi/help/buddy_status.c b/coreapi/help/buddy_status.c index cd7f13d52..f4ad385f9 100644 --- a/coreapi/help/buddy_status.c +++ b/coreapi/help/buddy_status.c @@ -15,7 +15,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** diff --git a/coreapi/help/chatroom.c b/coreapi/help/chatroom.c index 62d75bab9..df1794664 100644 --- a/coreapi/help/chatroom.c +++ b/coreapi/help/chatroom.c @@ -15,7 +15,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** diff --git a/coreapi/help/filetransfer.c b/coreapi/help/filetransfer.c index 21cb19115..bc321d54f 100644 --- a/coreapi/help/filetransfer.c +++ b/coreapi/help/filetransfer.c @@ -15,7 +15,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** diff --git a/coreapi/help/helloworld.c b/coreapi/help/helloworld.c index f3b3c9752..bb11176dc 100644 --- a/coreapi/help/helloworld.c +++ b/coreapi/help/helloworld.c @@ -16,7 +16,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** diff --git a/coreapi/help/java/org/linphone/core/tutorials/TutorialBuddyStatus.java b/coreapi/help/java/org/linphone/core/tutorials/TutorialBuddyStatus.java index 82a094183..9ac59e6d4 100644 --- a/coreapi/help/java/org/linphone/core/tutorials/TutorialBuddyStatus.java +++ b/coreapi/help/java/org/linphone/core/tutorials/TutorialBuddyStatus.java @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ package org.linphone.core.tutorials; diff --git a/coreapi/help/java/org/linphone/core/tutorials/TutorialChatRoom.java b/coreapi/help/java/org/linphone/core/tutorials/TutorialChatRoom.java index 11e436213..1d4505c71 100644 --- a/coreapi/help/java/org/linphone/core/tutorials/TutorialChatRoom.java +++ b/coreapi/help/java/org/linphone/core/tutorials/TutorialChatRoom.java @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ package org.linphone.core.tutorials; diff --git a/coreapi/help/java/org/linphone/core/tutorials/TutorialHelloWorld.java b/coreapi/help/java/org/linphone/core/tutorials/TutorialHelloWorld.java index 3fc9b78c5..19fcf860c 100644 --- a/coreapi/help/java/org/linphone/core/tutorials/TutorialHelloWorld.java +++ b/coreapi/help/java/org/linphone/core/tutorials/TutorialHelloWorld.java @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ package org.linphone.core.tutorials; diff --git a/coreapi/help/java/org/linphone/core/tutorials/TutorialNotifier.java b/coreapi/help/java/org/linphone/core/tutorials/TutorialNotifier.java index 62a540267..19cbd588f 100644 --- a/coreapi/help/java/org/linphone/core/tutorials/TutorialNotifier.java +++ b/coreapi/help/java/org/linphone/core/tutorials/TutorialNotifier.java @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ package org.linphone.core.tutorials; diff --git a/coreapi/help/java/org/linphone/core/tutorials/TutorialRegistration.java b/coreapi/help/java/org/linphone/core/tutorials/TutorialRegistration.java index 5a2db2568..85cce1e60 100644 --- a/coreapi/help/java/org/linphone/core/tutorials/TutorialRegistration.java +++ b/coreapi/help/java/org/linphone/core/tutorials/TutorialRegistration.java @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ package org.linphone.core.tutorials; diff --git a/coreapi/help/notify.c b/coreapi/help/notify.c index bdfae0835..df26bfe96 100644 --- a/coreapi/help/notify.c +++ b/coreapi/help/notify.c @@ -15,7 +15,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** diff --git a/coreapi/help/registration.c b/coreapi/help/registration.c index 8dbab6440..9459f2081 100644 --- a/coreapi/help/registration.c +++ b/coreapi/help/registration.c @@ -15,7 +15,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** diff --git a/coreapi/linphone_proxy_config.h b/coreapi/linphone_proxy_config.h index 127564504..08557feaa 100644 --- a/coreapi/linphone_proxy_config.h +++ b/coreapi/linphone_proxy_config.h @@ -13,7 +13,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef LINPHONE_PROXY_CONFIG_H diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index 45a78f47f..26525d3ca 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -16,7 +16,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifdef _WIN32 #include diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 3d124d147..2af387dd6 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -15,7 +15,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "linphonecore.h" diff --git a/coreapi/linphonecore.h b/coreapi/linphonecore.h index cdc275bb1..656fb32f5 100644 --- a/coreapi/linphonecore.h +++ b/coreapi/linphonecore.h @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef LINPHONECORE_H #define LINPHONECORE_H diff --git a/coreapi/linphonecore_jni.cc b/coreapi/linphonecore_jni.cc index ab34a3604..469215283 100644 --- a/coreapi/linphonecore_jni.cc +++ b/coreapi/linphonecore_jni.cc @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include #ifdef USE_JAVAH diff --git a/coreapi/linphonecore_utils.h b/coreapi/linphonecore_utils.h index 04069e504..eaf7c1218 100644 --- a/coreapi/linphonecore_utils.h +++ b/coreapi/linphonecore_utils.h @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef LINPHONECORE_UTILS_H diff --git a/coreapi/linphonefriend.h b/coreapi/linphonefriend.h index 1a6535fed..9ca04137c 100644 --- a/coreapi/linphonefriend.h +++ b/coreapi/linphonefriend.h @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef LINPHONEFRIEND_H_ diff --git a/coreapi/linphonepresence.h b/coreapi/linphonepresence.h index c0168cb8b..3f5ea2423 100644 --- a/coreapi/linphonepresence.h +++ b/coreapi/linphonepresence.h @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef LINPHONEPRESENCE_H_ diff --git a/coreapi/localplayer.c b/coreapi/localplayer.c index eb53eb640..374d67a0f 100644 --- a/coreapi/localplayer.c +++ b/coreapi/localplayer.c @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "private.h" diff --git a/coreapi/lpc2xml.c b/coreapi/lpc2xml.c index 1446a94cc..a946f1e70 100644 --- a/coreapi/lpc2xml.c +++ b/coreapi/lpc2xml.c @@ -15,7 +15,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "lpc2xml.h" diff --git a/coreapi/lpc2xml.h b/coreapi/lpc2xml.h index 025400907..067833160 100644 --- a/coreapi/lpc2xml.h +++ b/coreapi/lpc2xml.h @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef LPC2XML_H_ diff --git a/coreapi/lsd.c b/coreapi/lsd.c index 6aa803a06..4ca1ede63 100644 --- a/coreapi/lsd.c +++ b/coreapi/lsd.c @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /* Linphone Sound Daemon: is a lightweight utility to play sounds to speaker during a conversation. diff --git a/coreapi/message_storage.c b/coreapi/message_storage.c index 25d37a1b8..ff5462c76 100644 --- a/coreapi/message_storage.c +++ b/coreapi/message_storage.c @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "private.h" diff --git a/coreapi/misc.c b/coreapi/misc.c index 60465887d..e20f021f3 100644 --- a/coreapi/misc.c +++ b/coreapi/misc.c @@ -15,7 +15,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "private.h" diff --git a/coreapi/offeranswer.c b/coreapi/offeranswer.c index 0b0edb931..c5c02b12c 100644 --- a/coreapi/offeranswer.c +++ b/coreapi/offeranswer.c @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "sal/sal.h" diff --git a/coreapi/offeranswer.h b/coreapi/offeranswer.h index 0c8ebd7b1..74527529c 100644 --- a/coreapi/offeranswer.h +++ b/coreapi/offeranswer.h @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef offeranswer_h diff --git a/coreapi/player.c b/coreapi/player.c index 1b2a01022..c49e07a37 100644 --- a/coreapi/player.c +++ b/coreapi/player.c @@ -15,7 +15,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "private.h" diff --git a/coreapi/presence.c b/coreapi/presence.c index f70f78ae0..ed22ffa05 100644 --- a/coreapi/presence.c +++ b/coreapi/presence.c @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "linphonecore.h" diff --git a/coreapi/quality_reporting.c b/coreapi/quality_reporting.c index 4df8a2e0e..88269a0d9 100644 --- a/coreapi/quality_reporting.c +++ b/coreapi/quality_reporting.c @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifdef HAVE_CONFIG_H diff --git a/coreapi/quality_reporting.h b/coreapi/quality_reporting.h index 07ad65055..921840cb8 100644 --- a/coreapi/quality_reporting.h +++ b/coreapi/quality_reporting.h @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef quality_reporting_h diff --git a/coreapi/remote_provisioning.c b/coreapi/remote_provisioning.c index 40355fa89..4a3045ee0 100644 --- a/coreapi/remote_provisioning.c +++ b/coreapi/remote_provisioning.c @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "private.h" #include "xml2lpc.h" diff --git a/coreapi/sal.c b/coreapi/sal.c index efbc2ea0d..942f6d62a 100644 --- a/coreapi/sal.c +++ b/coreapi/sal.c @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** diff --git a/coreapi/siplogin.c b/coreapi/siplogin.c index f10c98a60..57c97e7f3 100644 --- a/coreapi/siplogin.c +++ b/coreapi/siplogin.c @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "linphonecore.h" diff --git a/coreapi/sipsetup.c b/coreapi/sipsetup.c index 7c9f074d9..5319ca887 100644 --- a/coreapi/sipsetup.c +++ b/coreapi/sipsetup.c @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifdef HAVE_CONFIG_H diff --git a/coreapi/sipsetup.h b/coreapi/sipsetup.h index 63d71d5f1..40e6369a1 100644 --- a/coreapi/sipsetup.h +++ b/coreapi/sipsetup.h @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ diff --git a/coreapi/test_ecc.c b/coreapi/test_ecc.c index 8d383b625..e3600a8d8 100644 --- a/coreapi/test_ecc.c +++ b/coreapi/test_ecc.c @@ -15,7 +15,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ diff --git a/coreapi/test_lsd.c b/coreapi/test_lsd.c index a4e78ea11..373b31b48 100644 --- a/coreapi/test_lsd.c +++ b/coreapi/test_lsd.c @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /* Linphone Sound Daemon: is a lightweight utility to play sounds to speaker during a conversation. diff --git a/coreapi/test_numbers.c b/coreapi/test_numbers.c index da1f22b6f..0124d8c57 100644 --- a/coreapi/test_numbers.c +++ b/coreapi/test_numbers.c @@ -15,7 +15,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ diff --git a/coreapi/upnp.c b/coreapi/upnp.c index 68b82e2ed..e1e4db3e2 100644 --- a/coreapi/upnp.c +++ b/coreapi/upnp.c @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "upnp.h" diff --git a/coreapi/upnp.h b/coreapi/upnp.h index 2239c896c..9df96f1b2 100644 --- a/coreapi/upnp.h +++ b/coreapi/upnp.h @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef LINPHONE_UPNP_H diff --git a/coreapi/vtables.c b/coreapi/vtables.c index 3a5672509..9d44160c1 100644 --- a/coreapi/vtables.c +++ b/coreapi/vtables.c @@ -15,7 +15,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "private.h" diff --git a/coreapi/xml.c b/coreapi/xml.c index b4b994174..db002f5d5 100644 --- a/coreapi/xml.c +++ b/coreapi/xml.c @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ diff --git a/coreapi/xml2lpc.c b/coreapi/xml2lpc.c index 57380bcd2..845ce496b 100644 --- a/coreapi/xml2lpc.c +++ b/coreapi/xml2lpc.c @@ -15,7 +15,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "xml2lpc.h" diff --git a/coreapi/xml2lpc.h b/coreapi/xml2lpc.h index 746fb0200..3a2406671 100644 --- a/coreapi/xml2lpc.h +++ b/coreapi/xml2lpc.h @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef XML2LPC_H_ diff --git a/coreapi/xmlrpc.c b/coreapi/xmlrpc.c index c91ebfa4c..2a55cccaa 100644 --- a/coreapi/xmlrpc.c +++ b/coreapi/xmlrpc.c @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "linphonecore.h" diff --git a/coreapi/xmlrpc.h b/coreapi/xmlrpc.h index b985359c5..cfa9bff8d 100644 --- a/coreapi/xmlrpc.h +++ b/coreapi/xmlrpc.h @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef LINPHONE_XMLRPC_H_ diff --git a/gtk/CMakeLists.txt b/gtk/CMakeLists.txt index 5bd36140d..98116bf5d 100644 --- a/gtk/CMakeLists.txt +++ b/gtk/CMakeLists.txt @@ -16,7 +16,7 @@ # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # ############################################################################ diff --git a/gtk/audio_assistant.c b/gtk/audio_assistant.c index d12327304..a8a71676f 100644 --- a/gtk/audio_assistant.c +++ b/gtk/audio_assistant.c @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include diff --git a/gtk/buddylookup.c b/gtk/buddylookup.c index 3251611d2..1d41dc82a 100644 --- a/gtk/buddylookup.c +++ b/gtk/buddylookup.c @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "linphone.h" diff --git a/gtk/calllogs.c b/gtk/calllogs.c index 4d91c38bd..aa83db99b 100644 --- a/gtk/calllogs.c +++ b/gtk/calllogs.c @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "linphone.h" diff --git a/gtk/chat.c b/gtk/chat.c index ac4fac23c..cfc987af9 100644 --- a/gtk/chat.c +++ b/gtk/chat.c @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "linphone.h" diff --git a/gtk/config-fetching.c b/gtk/config-fetching.c index b1794eea9..44cc8bc21 100644 --- a/gtk/config-fetching.c +++ b/gtk/config-fetching.c @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "linphone.h" diff --git a/gtk/fonis.c b/gtk/fonis.c index dbcbf6853..ebd3e4d94 100644 --- a/gtk/fonis.c +++ b/gtk/fonis.c @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ diff --git a/gtk/friendlist.c b/gtk/friendlist.c index 6cd6c8581..8564728b1 100644 --- a/gtk/friendlist.c +++ b/gtk/friendlist.c @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include diff --git a/gtk/incall_view.c b/gtk/incall_view.c index 9aaefff91..bc37896fd 100644 --- a/gtk/incall_view.c +++ b/gtk/incall_view.c @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /* * C Implementation: incall_frame diff --git a/gtk/linphone.h b/gtk/linphone.h index 618f1590e..2eb3f0026 100644 --- a/gtk/linphone.h +++ b/gtk/linphone.h @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifdef HAVE_CONFIG_H diff --git a/gtk/logging.c b/gtk/logging.c index 00d40227a..68d3d6cac 100644 --- a/gtk/logging.c +++ b/gtk/logging.c @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "linphone.h" diff --git a/gtk/loginframe.c b/gtk/loginframe.c index 40748494b..87bed11ae 100644 --- a/gtk/loginframe.c +++ b/gtk/loginframe.c @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "linphone.h" diff --git a/gtk/main.c b/gtk/main.c index 5e967242b..e4c17cfee 100644 --- a/gtk/main.c +++ b/gtk/main.c @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ diff --git a/gtk/propertybox.c b/gtk/propertybox.c index 59bdb2b06..571bb375a 100644 --- a/gtk/propertybox.c +++ b/gtk/propertybox.c @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "linphone.h" diff --git a/gtk/setupwizard.c b/gtk/setupwizard.c index c7cd6a195..dad50d983 100644 --- a/gtk/setupwizard.c +++ b/gtk/setupwizard.c @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "linphone.h" diff --git a/gtk/singleinstance.c b/gtk/singleinstance.c index 591d5d7cd..d41b22bec 100644 --- a/gtk/singleinstance.c +++ b/gtk/singleinstance.c @@ -15,7 +15,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "linphone.h" diff --git a/gtk/status_icon.c b/gtk/status_icon.c index cbee89f54..805ef4a45 100644 --- a/gtk/status_icon.c +++ b/gtk/status_icon.c @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "status_icon.h" diff --git a/gtk/status_icon.h b/gtk/status_icon.h index 233733724..e09137279 100644 --- a/gtk/status_icon.h +++ b/gtk/status_icon.h @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /* diff --git a/gtk/status_notifier.c b/gtk/status_notifier.c index da9357720..ea9a9b67d 100644 --- a/gtk/status_notifier.c +++ b/gtk/status_notifier.c @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "status_notifier.h" diff --git a/gtk/status_notifier.h b/gtk/status_notifier.h index b8067fdeb..22d95ebae 100644 --- a/gtk/status_notifier.h +++ b/gtk/status_notifier.h @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** diff --git a/gtk/update.c b/gtk/update.c index 34cff9995..a38a9d818 100644 --- a/gtk/update.c +++ b/gtk/update.c @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "linphone.h" diff --git a/gtk/utils.c b/gtk/utils.c index fc3ebde92..c7dc2d672 100644 --- a/gtk/utils.c +++ b/gtk/utils.c @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "linphone.h" diff --git a/gtk/videowindow.c b/gtk/videowindow.c index ebc5f69a5..14b2292af 100644 --- a/gtk/videowindow.c +++ b/gtk/videowindow.c @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "linphone.h" diff --git a/java/common/org/linphone/core/CallDirection.java b/java/common/org/linphone/core/CallDirection.java index 40a5e32d9..083528508 100644 --- a/java/common/org/linphone/core/CallDirection.java +++ b/java/common/org/linphone/core/CallDirection.java @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ package org.linphone.core; diff --git a/java/common/org/linphone/core/LinphoneAddress.java b/java/common/org/linphone/core/LinphoneAddress.java index fefb0edc0..26c0e53af 100644 --- a/java/common/org/linphone/core/LinphoneAddress.java +++ b/java/common/org/linphone/core/LinphoneAddress.java @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ package org.linphone.core; diff --git a/java/common/org/linphone/core/LinphoneAuthInfo.java b/java/common/org/linphone/core/LinphoneAuthInfo.java index 5e2744a1e..6b71d006b 100644 --- a/java/common/org/linphone/core/LinphoneAuthInfo.java +++ b/java/common/org/linphone/core/LinphoneAuthInfo.java @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ package org.linphone.core; /** diff --git a/java/common/org/linphone/core/LinphoneCall.java b/java/common/org/linphone/core/LinphoneCall.java index cd74b6d07..03301470f 100644 --- a/java/common/org/linphone/core/LinphoneCall.java +++ b/java/common/org/linphone/core/LinphoneCall.java @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ package org.linphone.core; diff --git a/java/common/org/linphone/core/LinphoneCallLog.java b/java/common/org/linphone/core/LinphoneCallLog.java index f1dd742b3..0967957a8 100644 --- a/java/common/org/linphone/core/LinphoneCallLog.java +++ b/java/common/org/linphone/core/LinphoneCallLog.java @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ package org.linphone.core; /** diff --git a/java/common/org/linphone/core/LinphoneCallParams.java b/java/common/org/linphone/core/LinphoneCallParams.java index fa827faa2..739e749bb 100644 --- a/java/common/org/linphone/core/LinphoneCallParams.java +++ b/java/common/org/linphone/core/LinphoneCallParams.java @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ package org.linphone.core; import org.linphone.core.LinphoneCore.MediaEncryption; diff --git a/java/common/org/linphone/core/LinphoneCallStats.java b/java/common/org/linphone/core/LinphoneCallStats.java index 295c99484..beea3b043 100644 --- a/java/common/org/linphone/core/LinphoneCallStats.java +++ b/java/common/org/linphone/core/LinphoneCallStats.java @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ package org.linphone.core; diff --git a/java/common/org/linphone/core/LinphoneChatRoom.java b/java/common/org/linphone/core/LinphoneChatRoom.java index f281b4bb6..978e06080 100644 --- a/java/common/org/linphone/core/LinphoneChatRoom.java +++ b/java/common/org/linphone/core/LinphoneChatRoom.java @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ package org.linphone.core; diff --git a/java/common/org/linphone/core/LinphoneCore.java b/java/common/org/linphone/core/LinphoneCore.java index e668520f9..11b2302c3 100644 --- a/java/common/org/linphone/core/LinphoneCore.java +++ b/java/common/org/linphone/core/LinphoneCore.java @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ package org.linphone.core; diff --git a/java/common/org/linphone/core/LinphoneCoreFactory.java b/java/common/org/linphone/core/LinphoneCoreFactory.java index 8019ec7bd..52ec82339 100644 --- a/java/common/org/linphone/core/LinphoneCoreFactory.java +++ b/java/common/org/linphone/core/LinphoneCoreFactory.java @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ package org.linphone.core; diff --git a/java/common/org/linphone/core/LinphoneCoreListener.java b/java/common/org/linphone/core/LinphoneCoreListener.java index b7457a777..55490e6ce 100644 --- a/java/common/org/linphone/core/LinphoneCoreListener.java +++ b/java/common/org/linphone/core/LinphoneCoreListener.java @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ package org.linphone.core; diff --git a/java/common/org/linphone/core/LinphoneFriend.java b/java/common/org/linphone/core/LinphoneFriend.java index b9080bd94..62ad3e1f6 100644 --- a/java/common/org/linphone/core/LinphoneFriend.java +++ b/java/common/org/linphone/core/LinphoneFriend.java @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ package org.linphone.core; diff --git a/java/common/org/linphone/core/LinphoneLogHandler.java b/java/common/org/linphone/core/LinphoneLogHandler.java index ee88ee5f8..9594e1036 100644 --- a/java/common/org/linphone/core/LinphoneLogHandler.java +++ b/java/common/org/linphone/core/LinphoneLogHandler.java @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ package org.linphone.core; /** diff --git a/java/common/org/linphone/core/LinphoneProxyConfig.java b/java/common/org/linphone/core/LinphoneProxyConfig.java index e5381701e..0359c717a 100644 --- a/java/common/org/linphone/core/LinphoneProxyConfig.java +++ b/java/common/org/linphone/core/LinphoneProxyConfig.java @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ package org.linphone.core; /** diff --git a/java/common/org/linphone/core/LpConfig.java b/java/common/org/linphone/core/LpConfig.java index f2503c06b..660f6899c 100644 --- a/java/common/org/linphone/core/LpConfig.java +++ b/java/common/org/linphone/core/LpConfig.java @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ package org.linphone.core; diff --git a/java/common/org/linphone/core/OnlineStatus.java b/java/common/org/linphone/core/OnlineStatus.java index 9a101d223..d58fc9dd5 100644 --- a/java/common/org/linphone/core/OnlineStatus.java +++ b/java/common/org/linphone/core/OnlineStatus.java @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ package org.linphone.core; diff --git a/java/common/org/linphone/core/PayloadType.java b/java/common/org/linphone/core/PayloadType.java index 3952024c5..3c0e406bb 100644 --- a/java/common/org/linphone/core/PayloadType.java +++ b/java/common/org/linphone/core/PayloadType.java @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ package org.linphone.core; diff --git a/java/common/org/linphone/core/PresenceActivity.java b/java/common/org/linphone/core/PresenceActivity.java index b965b526b..17d28bbd9 100644 --- a/java/common/org/linphone/core/PresenceActivity.java +++ b/java/common/org/linphone/core/PresenceActivity.java @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ package org.linphone.core; diff --git a/java/common/org/linphone/core/PresenceActivityType.java b/java/common/org/linphone/core/PresenceActivityType.java index c20398661..ab897925c 100644 --- a/java/common/org/linphone/core/PresenceActivityType.java +++ b/java/common/org/linphone/core/PresenceActivityType.java @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ package org.linphone.core; diff --git a/java/common/org/linphone/core/PresenceBasicStatus.java b/java/common/org/linphone/core/PresenceBasicStatus.java index cfdbadb5c..b5075bb2c 100644 --- a/java/common/org/linphone/core/PresenceBasicStatus.java +++ b/java/common/org/linphone/core/PresenceBasicStatus.java @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ package org.linphone.core; diff --git a/java/common/org/linphone/core/PresenceModel.java b/java/common/org/linphone/core/PresenceModel.java index 78bc264c2..03c372b9c 100644 --- a/java/common/org/linphone/core/PresenceModel.java +++ b/java/common/org/linphone/core/PresenceModel.java @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ package org.linphone.core; diff --git a/java/common/org/linphone/core/PresenceNote.java b/java/common/org/linphone/core/PresenceNote.java index 9353d9de4..8d9bd55fe 100644 --- a/java/common/org/linphone/core/PresenceNote.java +++ b/java/common/org/linphone/core/PresenceNote.java @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ package org.linphone.core; diff --git a/java/common/org/linphone/core/PresencePerson.java b/java/common/org/linphone/core/PresencePerson.java index 730aafe77..3db93e26c 100644 --- a/java/common/org/linphone/core/PresencePerson.java +++ b/java/common/org/linphone/core/PresencePerson.java @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ package org.linphone.core; diff --git a/java/common/org/linphone/core/PresenceService.java b/java/common/org/linphone/core/PresenceService.java index 3e06b6774..6ffcdcd4e 100644 --- a/java/common/org/linphone/core/PresenceService.java +++ b/java/common/org/linphone/core/PresenceService.java @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ package org.linphone.core; diff --git a/java/common/org/linphone/core/VideoSize.java b/java/common/org/linphone/core/VideoSize.java index 7685e20a0..bdf60c100 100644 --- a/java/common/org/linphone/core/VideoSize.java +++ b/java/common/org/linphone/core/VideoSize.java @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ package org.linphone.core; diff --git a/java/common/org/linphone/core/package.html b/java/common/org/linphone/core/package.html index f4ba3711b..a194dbe22 100644 --- a/java/common/org/linphone/core/package.html +++ b/java/common/org/linphone/core/package.html @@ -19,7 +19,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. --> diff --git a/java/impl/org/linphone/core/LinphoneAddressImpl.java b/java/impl/org/linphone/core/LinphoneAddressImpl.java index e5c2b53d8..dd6ee5b12 100644 --- a/java/impl/org/linphone/core/LinphoneAddressImpl.java +++ b/java/impl/org/linphone/core/LinphoneAddressImpl.java @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ package org.linphone.core; diff --git a/java/impl/org/linphone/core/LinphoneAuthInfoImpl.java b/java/impl/org/linphone/core/LinphoneAuthInfoImpl.java index 8efdcc144..f67aa4c94 100644 --- a/java/impl/org/linphone/core/LinphoneAuthInfoImpl.java +++ b/java/impl/org/linphone/core/LinphoneAuthInfoImpl.java @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ package org.linphone.core; diff --git a/java/impl/org/linphone/core/LinphoneCallImpl.java b/java/impl/org/linphone/core/LinphoneCallImpl.java index de9e25364..131ec6c47 100644 --- a/java/impl/org/linphone/core/LinphoneCallImpl.java +++ b/java/impl/org/linphone/core/LinphoneCallImpl.java @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ package org.linphone.core; diff --git a/java/impl/org/linphone/core/LinphoneCallLogImpl.java b/java/impl/org/linphone/core/LinphoneCallLogImpl.java index 7078a2a9f..0a78e9147 100644 --- a/java/impl/org/linphone/core/LinphoneCallLogImpl.java +++ b/java/impl/org/linphone/core/LinphoneCallLogImpl.java @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ package org.linphone.core; diff --git a/java/impl/org/linphone/core/LinphoneCallParamsImpl.java b/java/impl/org/linphone/core/LinphoneCallParamsImpl.java index c4b356fa7..b70d43aaa 100644 --- a/java/impl/org/linphone/core/LinphoneCallParamsImpl.java +++ b/java/impl/org/linphone/core/LinphoneCallParamsImpl.java @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ package org.linphone.core; diff --git a/java/impl/org/linphone/core/LinphoneCallStatsImpl.java b/java/impl/org/linphone/core/LinphoneCallStatsImpl.java index 4657ba01a..3897c03f6 100644 --- a/java/impl/org/linphone/core/LinphoneCallStatsImpl.java +++ b/java/impl/org/linphone/core/LinphoneCallStatsImpl.java @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ package org.linphone.core; diff --git a/java/impl/org/linphone/core/LinphoneChatRoomImpl.java b/java/impl/org/linphone/core/LinphoneChatRoomImpl.java index 7cf1fdbf7..c19a9ae8b 100644 --- a/java/impl/org/linphone/core/LinphoneChatRoomImpl.java +++ b/java/impl/org/linphone/core/LinphoneChatRoomImpl.java @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ package org.linphone.core; diff --git a/java/impl/org/linphone/core/LinphoneCoreFactoryImpl.java b/java/impl/org/linphone/core/LinphoneCoreFactoryImpl.java index 0d6fc777b..2e36ba62e 100644 --- a/java/impl/org/linphone/core/LinphoneCoreFactoryImpl.java +++ b/java/impl/org/linphone/core/LinphoneCoreFactoryImpl.java @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ package org.linphone.core; diff --git a/java/impl/org/linphone/core/LinphoneCoreImpl.java b/java/impl/org/linphone/core/LinphoneCoreImpl.java index 3178e8d66..f7d727506 100644 --- a/java/impl/org/linphone/core/LinphoneCoreImpl.java +++ b/java/impl/org/linphone/core/LinphoneCoreImpl.java @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ package org.linphone.core; diff --git a/java/impl/org/linphone/core/LinphoneFriendImpl.java b/java/impl/org/linphone/core/LinphoneFriendImpl.java index ba47eccb4..2495f72a4 100644 --- a/java/impl/org/linphone/core/LinphoneFriendImpl.java +++ b/java/impl/org/linphone/core/LinphoneFriendImpl.java @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ package org.linphone.core; diff --git a/java/impl/org/linphone/core/LinphoneProxyConfigImpl.java b/java/impl/org/linphone/core/LinphoneProxyConfigImpl.java index 33ac36f8f..918d55989 100644 --- a/java/impl/org/linphone/core/LinphoneProxyConfigImpl.java +++ b/java/impl/org/linphone/core/LinphoneProxyConfigImpl.java @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ package org.linphone.core; diff --git a/java/impl/org/linphone/core/LpConfigImpl.java b/java/impl/org/linphone/core/LpConfigImpl.java index d2c24e93b..29b44ec22 100644 --- a/java/impl/org/linphone/core/LpConfigImpl.java +++ b/java/impl/org/linphone/core/LpConfigImpl.java @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ package org.linphone.core; diff --git a/java/impl/org/linphone/core/PayloadTypeImpl.java b/java/impl/org/linphone/core/PayloadTypeImpl.java index b882f1ecb..0d47d6eec 100644 --- a/java/impl/org/linphone/core/PayloadTypeImpl.java +++ b/java/impl/org/linphone/core/PayloadTypeImpl.java @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ package org.linphone.core; diff --git a/java/impl/org/linphone/core/PresenceActivityImpl.java b/java/impl/org/linphone/core/PresenceActivityImpl.java index 281ecc9f2..a0cdda6d9 100644 --- a/java/impl/org/linphone/core/PresenceActivityImpl.java +++ b/java/impl/org/linphone/core/PresenceActivityImpl.java @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ package org.linphone.core; diff --git a/java/impl/org/linphone/core/PresenceModelImpl.java b/java/impl/org/linphone/core/PresenceModelImpl.java index b70ab6bd5..859e64a2b 100644 --- a/java/impl/org/linphone/core/PresenceModelImpl.java +++ b/java/impl/org/linphone/core/PresenceModelImpl.java @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ package org.linphone.core; diff --git a/java/impl/org/linphone/core/PresenceNoteImpl.java b/java/impl/org/linphone/core/PresenceNoteImpl.java index 113519c7f..66439f55e 100644 --- a/java/impl/org/linphone/core/PresenceNoteImpl.java +++ b/java/impl/org/linphone/core/PresenceNoteImpl.java @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ package org.linphone.core; diff --git a/java/impl/org/linphone/core/PresencePersonImpl.java b/java/impl/org/linphone/core/PresencePersonImpl.java index 7b7a336ac..988caaba0 100644 --- a/java/impl/org/linphone/core/PresencePersonImpl.java +++ b/java/impl/org/linphone/core/PresencePersonImpl.java @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ package org.linphone.core; diff --git a/java/impl/org/linphone/core/PresenceServiceImpl.java b/java/impl/org/linphone/core/PresenceServiceImpl.java index 29cd930e4..cf5bdf122 100644 --- a/java/impl/org/linphone/core/PresenceServiceImpl.java +++ b/java/impl/org/linphone/core/PresenceServiceImpl.java @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ package org.linphone.core; diff --git a/java/impl/org/linphone/core/video/VideoUtil.java b/java/impl/org/linphone/core/video/VideoUtil.java index 065557b77..c23441571 100644 --- a/java/impl/org/linphone/core/video/VideoUtil.java +++ b/java/impl/org/linphone/core/video/VideoUtil.java @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ package org.linphone.core.video; diff --git a/java/j2me/org/linphone/core/LinphoneCoreException.java b/java/j2me/org/linphone/core/LinphoneCoreException.java index 9ebb98fad..353b80186 100644 --- a/java/j2me/org/linphone/core/LinphoneCoreException.java +++ b/java/j2me/org/linphone/core/LinphoneCoreException.java @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ package org.linphone.core; diff --git a/java/j2se/org/linphone/core/LinphoneCoreException.java b/java/j2se/org/linphone/core/LinphoneCoreException.java index 05cc82a64..ae4989a4b 100644 --- a/java/j2se/org/linphone/core/LinphoneCoreException.java +++ b/java/j2se/org/linphone/core/LinphoneCoreException.java @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ package org.linphone.core; diff --git a/pixmaps/CMakeLists.txt b/pixmaps/CMakeLists.txt index c90f789eb..d5238f389 100644 --- a/pixmaps/CMakeLists.txt +++ b/pixmaps/CMakeLists.txt @@ -16,7 +16,7 @@ # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # ############################################################################ diff --git a/po/CMakeLists.txt b/po/CMakeLists.txt index 52f36bb40..b51481639 100644 --- a/po/CMakeLists.txt +++ b/po/CMakeLists.txt @@ -16,7 +16,7 @@ # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # ############################################################################ diff --git a/share/CMakeLists.txt b/share/CMakeLists.txt index b12eb85ef..3eac18e76 100644 --- a/share/CMakeLists.txt +++ b/share/CMakeLists.txt @@ -16,7 +16,7 @@ # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # ############################################################################ diff --git a/share/rings/CMakeLists.txt b/share/rings/CMakeLists.txt index 6ec2182e2..5a7efc8c9 100644 --- a/share/rings/CMakeLists.txt +++ b/share/rings/CMakeLists.txt @@ -16,7 +16,7 @@ # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # ############################################################################ diff --git a/share/rootca.cmake b/share/rootca.cmake index d988b778e..4f6a92dad 100644 --- a/share/rootca.cmake +++ b/share/rootca.cmake @@ -16,7 +16,7 @@ # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # ############################################################################ diff --git a/tester/CMakeLists.txt b/tester/CMakeLists.txt index 2b02ff6c0..b8108ad27 100644 --- a/tester/CMakeLists.txt +++ b/tester/CMakeLists.txt @@ -16,7 +16,7 @@ # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # ############################################################################ diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 6d383a4a7..39e49ee7f 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -16,7 +16,7 @@ # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # ############################################################################ diff --git a/tools/auto_answer.c b/tools/auto_answer.c index b76968ec4..470c3ac8f 100644 --- a/tools/auto_answer.c +++ b/tools/auto_answer.c @@ -15,7 +15,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ diff --git a/tools/genapixml.py b/tools/genapixml.py index 656428b9e..350f111ff 100755 --- a/tools/genapixml.py +++ b/tools/genapixml.py @@ -14,7 +14,7 @@ # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. import argparse import os diff --git a/tools/generator.cc b/tools/generator.cc index c8763f1ef..8eb35c909 100644 --- a/tools/generator.cc +++ b/tools/generator.cc @@ -15,7 +15,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ diff --git a/tools/generator.hh b/tools/generator.hh index 2b09d0eee..f3c1543e0 100644 --- a/tools/generator.hh +++ b/tools/generator.hh @@ -15,7 +15,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef generator_hh diff --git a/tools/genwrappers.cc b/tools/genwrappers.cc index 86a54d9b1..d55f3dc6f 100644 --- a/tools/genwrappers.cc +++ b/tools/genwrappers.cc @@ -15,7 +15,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "software-desc.hh" diff --git a/tools/lpc2xml_jni.cc b/tools/lpc2xml_jni.cc index c21ba7312..fb0fa78ca 100644 --- a/tools/lpc2xml_jni.cc +++ b/tools/lpc2xml_jni.cc @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "my_jni.h" diff --git a/tools/lpc2xml_test.c b/tools/lpc2xml_test.c index 03ac571cf..59807d407 100644 --- a/tools/lpc2xml_test.c +++ b/tools/lpc2xml_test.c @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include diff --git a/tools/my_jni.h b/tools/my_jni.h index b02882ba3..329d26738 100644 --- a/tools/my_jni.h +++ b/tools/my_jni.h @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef __MY_JNI__H diff --git a/tools/python/apixml2python.py b/tools/python/apixml2python.py index 04de40a9e..c80c6698d 100755 --- a/tools/python/apixml2python.py +++ b/tools/python/apixml2python.py @@ -14,7 +14,7 @@ # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. import argparse import os diff --git a/tools/python/apixml2python/linphone.py b/tools/python/apixml2python/linphone.py index 16d726850..0ebf476b6 100644 --- a/tools/python/apixml2python/linphone.py +++ b/tools/python/apixml2python/linphone.py @@ -12,7 +12,7 @@ # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. import re diff --git a/tools/python/apixml2python/linphone_module.mustache b/tools/python/apixml2python/linphone_module.mustache index 403a2491a..ab5534bae 100644 --- a/tools/python/apixml2python/linphone_module.mustache +++ b/tools/python/apixml2python/linphone_module.mustache @@ -13,7 +13,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include diff --git a/tools/software-desc.cc b/tools/software-desc.cc index 7930cb289..7cf96ac48 100644 --- a/tools/software-desc.cc +++ b/tools/software-desc.cc @@ -15,7 +15,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "software-desc.hh" diff --git a/tools/software-desc.hh b/tools/software-desc.hh index 51b526d71..4063b8097 100644 --- a/tools/software-desc.hh +++ b/tools/software-desc.hh @@ -15,7 +15,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef software_desc_hh diff --git a/tools/xml2lpc_jni.cc b/tools/xml2lpc_jni.cc index a242e7ce8..9150dd661 100644 --- a/tools/xml2lpc_jni.cc +++ b/tools/xml2lpc_jni.cc @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "my_jni.h" diff --git a/tools/xml2lpc_test.c b/tools/xml2lpc_test.c index 3bb5dbc31..335faac16 100644 --- a/tools/xml2lpc_test.c +++ b/tools/xml2lpc_test.c @@ -14,7 +14,7 @@ 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include From 2c905e4cdece80c4887066ff0289405d76f6f86c Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Fri, 4 Nov 2016 12:02:23 +0100 Subject: [PATCH 06/21] Started im encryption engine, process incoming message with lime seems to work --- coreapi/CMakeLists.txt | 2 + coreapi/Makefile.am | 2 + coreapi/bellesip_sal/sal_op_message.c | 73 ++++++--------------------- coreapi/im_encryption_engine.c | 71 ++++++++++++++++++++++++++ coreapi/im_encryption_engine.h | 53 +++++++++++++++++++ coreapi/lime.c | 68 ++++++++++++++++++++++++- coreapi/lime.h | 4 ++ coreapi/linphonecore.c | 20 ++++++++ coreapi/linphonecore.h | 6 +++ coreapi/private.h | 2 + tester/message_tester.c | 4 ++ 11 files changed, 247 insertions(+), 58 deletions(-) create mode 100644 coreapi/im_encryption_engine.c create mode 100644 coreapi/im_encryption_engine.h diff --git a/coreapi/CMakeLists.txt b/coreapi/CMakeLists.txt index c3279b34b..12e41c9d4 100644 --- a/coreapi/CMakeLists.txt +++ b/coreapi/CMakeLists.txt @@ -46,6 +46,7 @@ set(LINPHONE_HEADER_FILES linphonepresence.h linphone_proxy_config.h linphone_tunnel.h + im_encryption_engine.h lpc2xml.h lpconfig.h nat_policy.h @@ -95,6 +96,7 @@ set(LINPHONE_SOURCE_FILES_C info.c ldap/ldapprovider.c lime.c + im_encryption_engine.c linphonecall.c linphonecore.c linphone_tunnel_config.c diff --git a/coreapi/Makefile.am b/coreapi/Makefile.am index a35031e3c..ce008a496 100644 --- a/coreapi/Makefile.am +++ b/coreapi/Makefile.am @@ -40,6 +40,7 @@ linphone_include_HEADERS=\ linphonepresence.h \ linphone_proxy_config.h \ linphone_tunnel.h \ + im_encryption_engine.h \ lpc2xml.h \ lpconfig.h \ nat_policy.h \ @@ -80,6 +81,7 @@ liblinphone_la_SOURCES=\ localplayer.c \ lpc2xml.c \ lime.c lime.h\ + im_encryption_engine.c \ lpconfig.c \ lsd.c \ message_storage.c \ diff --git a/coreapi/bellesip_sal/sal_op_message.c b/coreapi/bellesip_sal/sal_op_message.c index 533453da4..ccead1c76 100644 --- a/coreapi/bellesip_sal/sal_op_message.c +++ b/coreapi/bellesip_sal/sal_op_message.c @@ -70,13 +70,6 @@ static bool_t is_plain_text(belle_sip_header_content_type_t* content_type) { && strcmp("plain",belle_sip_header_content_type_get_subtype(content_type))==0; } -static bool_t is_cipher_xml(belle_sip_header_content_type_t* content_type) { - return (strcmp("xml",belle_sip_header_content_type_get_type(content_type))==0 - && strcmp("cipher",belle_sip_header_content_type_get_subtype(content_type))==0) - - || (strcmp("application",belle_sip_header_content_type_get_type(content_type))==0 - && strcmp("cipher.vnd.gsma.rcs-ft-http+xml",belle_sip_header_content_type_get_subtype(content_type))==0); -} static bool_t is_external_body(belle_sip_header_content_type_t* content_type) { return strcmp("message",belle_sip_header_content_type_get_type(content_type))==0 && strcmp("external-body",belle_sip_header_content_type_get_subtype(content_type))==0; @@ -107,62 +100,28 @@ void sal_process_incoming_message(SalOp *op,const belle_sip_request_event_t *eve bool_t cipher_xml=FALSE; bool_t rcs_filetransfer=FALSE; uint8_t *decryptedMessage = NULL; + LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(op)); + int retval = -1; from_header=belle_sip_message_get_header_by_type(BELLE_SIP_MESSAGE(req),belle_sip_header_from_t); content_type=belle_sip_message_get_header_by_type(BELLE_SIP_MESSAGE(req),belle_sip_header_content_type_t); - if (content_type){ - - /* check if we have a xml/cipher message to be decrypted */ - if ((cipher_xml=is_cipher_xml(content_type))) { - /* access the zrtp cache to get keys needed to decipher the message */ - LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(op)); - FILE *CACHEFD = NULL; - if (lc->zrtp_secrets_cache != NULL) CACHEFD = fopen(lc->zrtp_secrets_cache, "rb+"); - if (CACHEFD == NULL) { - ms_warning("Unable to access ZRTP ZID cache to decrypt message"); - goto error; - } else { - size_t cacheSize; - char *cacheString; - int retval; - xmlDocPtr cacheXml; - - cacheString=ms_load_file_content(CACHEFD, &cacheSize); - if (!cacheString){ - ms_warning("Unable to load content of ZRTP ZID cache to decrypt message"); - goto error; - } - cacheString[cacheSize] = '\0'; - cacheSize += 1; - fclose(CACHEFD); - cacheXml = xmlParseDoc((xmlChar*)cacheString); - ms_free(cacheString); - retval = lime_decryptMultipartMessage(cacheXml, (uint8_t *)belle_sip_message_get_body(BELLE_SIP_MESSAGE(req)), &decryptedMessage); - if (retval != 0) { - ms_warning("Unable to decrypt message, reason : %s - op [%p]", lime_error_code_to_string(retval), op); - free(decryptedMessage); - xmlFreeDoc(cacheXml); - errcode = 488; - goto error; - } else { - /* dump updated cache to a string */ - xmlChar *xmlStringOutput; - int xmlStringLength; - xmlDocDumpFormatMemoryEnc(cacheXml, &xmlStringOutput, &xmlStringLength, "UTF-8", 0); - /* write it to the cache file */ - CACHEFD = fopen(lc->zrtp_secrets_cache, "wb+"); - if (fwrite(xmlStringOutput, 1, xmlStringLength, CACHEFD)<=0){ - ms_warning("Fail to write cache"); - } - xmlFree(xmlStringOutput); - fclose(CACHEFD); - } - - xmlFreeDoc(cacheXml); + if (content_type) { + LinphoneImEncryptionEngine *imee = linphone_core_get_im_encryption_engine(lc); + if (imee) { + LinphoneImEncryptionEngineCbs *imee_cbs = linphone_im_encryption_engine_get_callbacks(imee); + LinphoneImEncryptionEngineIncomingMessageCb cb_process_incoming_message = linphone_im_encryption_engine_cbs_get_process_incoming_message(imee_cbs); + if (cb_process_incoming_message) { + retval = cb_process_incoming_message(lc, belle_sip_header_content_type_get_type(content_type), belle_sip_header_content_type_get_subtype(content_type), + belle_sip_message_get_body(BELLE_SIP_MESSAGE(req)), (char **)&decryptedMessage); } - } + cipher_xml = retval >= 0; + if (retval > 0) { + errcode = retval; + goto error; + } + external_body=is_external_body(content_type); plain_text=is_plain_text(content_type); rcs_filetransfer = is_rcs_filetransfer(content_type); diff --git a/coreapi/im_encryption_engine.c b/coreapi/im_encryption_engine.c new file mode 100644 index 000000000..cf6a34530 --- /dev/null +++ b/coreapi/im_encryption_engine.c @@ -0,0 +1,71 @@ +/* +ImEncryptionEgine.c +Copyright (C) 2016 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 the Free Software Foundation; either version 2 +of the License, or (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, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "linphonecore.h" +#include "im_encryption_engine.h" + +struct _LinphoneImEncryptionEngineCbs { + void *user_data; + LinphoneImEncryptionEngineIncomingMessageCb process_incoming_message; +}; + +struct _LinphoneImEncryptionEngine { + void *user_data; + LinphoneImEncryptionEngineCbs *callbacks; +}; + +LinphoneImEncryptionEngineCbs *linphone_im_encryption_engine_cbs_new(void) { + LinphoneImEncryptionEngineCbs *cbs = ms_new0(LinphoneImEncryptionEngineCbs, 1); + return cbs; +} + +void linphone_im_encryption_engine_cbs_destory(LinphoneImEncryptionEngineCbs *cbs) { + ms_free(cbs); +} + +void *linphone_im_encryption_engine_cbs_get_user_data(const LinphoneImEncryptionEngineCbs *cbs) { + return cbs->user_data; +} + +void linphone_im_encryption_engine_cbs_set_user_data(LinphoneImEncryptionEngineCbs *cbs, void *data) { + cbs->user_data = data; +} + +LinphoneImEncryptionEngine *linphone_im_encryption_engine_new(void) { + LinphoneImEncryptionEngine *imee = ms_new0(LinphoneImEncryptionEngine, 1); + imee->callbacks = linphone_im_encryption_engine_cbs_new(); + return imee; +} + +void linphone_im_encryption_engine_destory(LinphoneImEncryptionEngine *imee) { + if (imee->callbacks) linphone_im_encryption_engine_cbs_destory(imee->callbacks); + ms_free(imee); +} + +LinphoneImEncryptionEngineCbs* linphone_im_encryption_engine_get_callbacks(const LinphoneImEncryptionEngine *imee) { + return imee->callbacks; +} + +LinphoneImEncryptionEngineIncomingMessageCb linphone_im_encryption_engine_cbs_get_process_incoming_message(LinphoneImEncryptionEngineCbs *cbs) { + return cbs->process_incoming_message; +} + +void linphone_im_encryption_engine_cbs_set_process_incoming_message(LinphoneImEncryptionEngineCbs *cbs, LinphoneImEncryptionEngineIncomingMessageCb cb) { + cbs->process_incoming_message = cb; +} \ No newline at end of file diff --git a/coreapi/im_encryption_engine.h b/coreapi/im_encryption_engine.h new file mode 100644 index 000000000..7ab571dbe --- /dev/null +++ b/coreapi/im_encryption_engine.h @@ -0,0 +1,53 @@ +/* +ImEncryptionEgine.h +Copyright (C) 2016 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 the Free Software Foundation; either version 2 +of the License, or (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, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef IM_ENCRYPTION_ENGINE_H +#define IM_ENCRYPTION_ENGINE_H + +#include + +#ifndef LINPHONE_PUBLIC +#define LINPHONE_PUBLIC MS2_PUBLIC +#endif + +typedef int (*LinphoneImEncryptionEngineIncomingMessageCb)(LinphoneCore* lc, const char* content_type, const char* content_subtype, const char* body, char** decrypted_body); + +typedef struct _LinphoneImEncryptionEngineCbs LinphoneImEncryptionEngineCbs; + +typedef struct _LinphoneImEncryptionEngine LinphoneImEncryptionEngine; + +LINPHONE_PUBLIC LinphoneImEncryptionEngineCbs *linphone_im_encryption_engine_cbs_new(void); + +LINPHONE_PUBLIC void linphone_im_encryption_engine_cbs_destory(LinphoneImEncryptionEngineCbs *cbs); + +LINPHONE_PUBLIC void *linphone_im_encryption_engine_cbs_get_user_data(const LinphoneImEncryptionEngineCbs *cbs); + +LINPHONE_PUBLIC void linphone_im_encryption_engine_cbs_set_user_data(LinphoneImEncryptionEngineCbs *cbs, void *data); + +LINPHONE_PUBLIC LinphoneImEncryptionEngine *linphone_im_encryption_engine_new(void); + +LINPHONE_PUBLIC void linphone_im_encryption_engine_destory(LinphoneImEncryptionEngine *imee); + +LINPHONE_PUBLIC LinphoneImEncryptionEngineCbs* linphone_im_encryption_engine_get_callbacks(const LinphoneImEncryptionEngine *imee); + +LINPHONE_PUBLIC LinphoneImEncryptionEngineIncomingMessageCb linphone_im_encryption_engine_cbs_get_process_incoming_message(LinphoneImEncryptionEngineCbs *cbs); + +LINPHONE_PUBLIC void linphone_im_encryption_engine_cbs_set_process_incoming_message(LinphoneImEncryptionEngineCbs *cbs, LinphoneImEncryptionEngineIncomingMessageCb cb); + +#endif /* IM_ENCRYPTION_ENGINE_H */ \ No newline at end of file diff --git a/coreapi/lime.c b/coreapi/lime.c index 063331bd3..833161818 100644 --- a/coreapi/lime.c +++ b/coreapi/lime.c @@ -23,7 +23,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #endif #ifdef HAVE_LIME -#include "linphonecore.h" #include "bctoolbox/crypto.h" /** @@ -812,6 +811,70 @@ int lime_decryptMultipartMessage(xmlDocPtr cacheBuffer, uint8_t *message, uint8_ return 0; } +static bool_t is_cipher_xml(const char* content_type, const char *content_subtype) { + return (strcmp("xml",content_type)==0 + && strcmp("cipher",content_subtype)==0) + || (strcmp("application",content_type)==0 + && strcmp("cipher.vnd.gsma.rcs-ft-http+xml",content_subtype)==0); +} + +int lime_im_encryption_engine_process_incoming_message_cb(LinphoneCore* lc, const char* content_type, const char* content_subtype, const char* body, char** decrypted_body) { + int errcode = -1; + /* check if we have a xml/cipher message to be decrypted */ + if (is_cipher_xml(content_type, content_subtype)) { + /* access the zrtp cache to get keys needed to decipher the message */ + FILE *CACHEFD = NULL; + const char *zrtp_secrets_cache = linphone_core_get_zrtp_secrets_file(lc); + errcode = 0; + if (zrtp_secrets_cache != NULL) CACHEFD = fopen(zrtp_secrets_cache, "rb+"); + if (CACHEFD == NULL) { + ms_warning("Unable to access ZRTP ZID cache to decrypt message"); + errcode = 500; + return errcode; + } else { + size_t cacheSize; + char *cacheString; + int retval; + xmlDocPtr cacheXml; + + cacheString=ms_load_file_content(CACHEFD, &cacheSize); + if (!cacheString){ + ms_warning("Unable to load content of ZRTP ZID cache to decrypt message"); + errcode = 500; + return errcode; + } + cacheString[cacheSize] = '\0'; + cacheSize += 1; + fclose(CACHEFD); + cacheXml = xmlParseDoc((xmlChar*)cacheString); + ms_free(cacheString); + retval = lime_decryptMultipartMessage(cacheXml, (uint8_t *)body, (uint8_t **)decrypted_body); + if (retval != 0) { + ms_warning("Unable to decrypt message, reason : %s", lime_error_code_to_string(retval)); + free(decrypted_body); + xmlFreeDoc(cacheXml); + errcode = 488; + return errcode; + } else { + /* dump updated cache to a string */ + xmlChar *xmlStringOutput; + int xmlStringLength; + xmlDocDumpFormatMemoryEnc(cacheXml, &xmlStringOutput, &xmlStringLength, "UTF-8", 0); + /* write it to the cache file */ + CACHEFD = fopen(zrtp_secrets_cache, "wb+"); + if (fwrite(xmlStringOutput, 1, xmlStringLength, CACHEFD)<=0){ + ms_warning("Fail to write cache"); + } + xmlFree(xmlStringOutput); + fclose(CACHEFD); + } + + xmlFreeDoc(cacheXml); + } + } + return errcode; +} + #else /* HAVE_LIME */ @@ -837,6 +900,9 @@ int lime_getCachedRcvKeyByZid(xmlDocPtr cacheBuffer, limeKey_t *associatedKey) { int lime_decryptMessage(limeKey_t *key, uint8_t *encryptedMessage, uint32_t messageLength, uint8_t selfZID[12], uint8_t *plainMessage) { return LIME_NOT_ENABLED; } +int lime_im_encryption_engine_process_incoming_message_cb(LinphoneCore* lc, const char* content_type, const char* content_subtype, const char* body, char** decrypted_body) { + return 500; +} #endif /* HAVE_LIME */ char *lime_error_code_to_string(int errorCode) { diff --git a/coreapi/lime.h b/coreapi/lime.h index 277f57cbe..f33622812 100644 --- a/coreapi/lime.h +++ b/coreapi/lime.h @@ -38,6 +38,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include #include +#include "linphonecore.h" #include #ifndef LINPHONE_PUBLIC @@ -203,4 +204,7 @@ LINPHONE_PUBLIC char *lime_error_code_to_string(int errorCode); * @return TRUE if Lime is available, FALSE if not */ LINPHONE_PUBLIC bool_t lime_is_available(void); + +int lime_im_encryption_engine_process_incoming_message_cb(LinphoneCore* lc, const char* content_type, const char* content_subtype, const char* body, char** decrypted_body); + #endif /* LIME_H */ diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index e98633ca7..6bd808c56 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -1950,6 +1950,18 @@ void linphone_core_enable_lime(LinphoneCore *lc, LinphoneLimeState val){ if (linphone_core_ready(lc)){ lp_config_set_int(lc->config,"sip","lime",val); } + + if (val != LinphoneLimeDisabled) { + LinphoneImEncryptionEngine *imee = linphone_im_encryption_engine_new(); + LinphoneImEncryptionEngineCbs *cbs = linphone_im_encryption_engine_get_callbacks(imee); + linphone_im_encryption_engine_cbs_set_process_incoming_message(cbs, lime_im_encryption_engine_process_incoming_message_cb); + lc->im_encryption_engine = imee; + } else { + if (lc->im_encryption_engine) { + linphone_im_encryption_engine_destory(lc->im_encryption_engine); + lc->im_encryption_engine = NULL; + } + } } bool_t linphone_core_lime_available(const LinphoneCore *lc){ @@ -7996,3 +8008,11 @@ const char *linphone_core_get_tls_key_path(const LinphoneCore *lc) { const char *tls_key_path = lp_config_get_string(lc->config, "sip", "client_cert_key", NULL); return tls_key_path; } + +void linphone_core_set_im_encryption_engine(LinphoneCore *lc, LinphoneImEncryptionEngine *imee) { + lc->im_encryption_engine = imee; +} + +LinphoneImEncryptionEngine *linphone_core_get_im_encryption_engine(const LinphoneCore *lc) { + return lc->im_encryption_engine; +} diff --git a/coreapi/linphonecore.h b/coreapi/linphonecore.h index 4eb5335f6..fbdff8de4 100644 --- a/coreapi/linphonecore.h +++ b/coreapi/linphonecore.h @@ -432,6 +432,7 @@ LINPHONE_PUBLIC const char* linphone_privacy_to_string(LinphonePrivacy privacy); #include "nat_policy.h" #include "xmlrpc.h" #include "conference.h" +#include "im_encryption_engine.h" #else #include "linphone/buffer.h" #include "linphone/call_log.h" @@ -442,6 +443,7 @@ LINPHONE_PUBLIC const char* linphone_privacy_to_string(LinphonePrivacy privacy); #include "linphone/nat_policy.h" #include "linphone/xmlrpc.h" #include "linphone/conference.h" +#include "linphone/im_encryption_engine.h" #endif LINPHONE_PUBLIC LinphoneAddress * linphone_address_new(const char *addr); @@ -4728,6 +4730,10 @@ LINPHONE_PUBLIC const char *linphone_core_get_tls_cert_path(const LinphoneCore * */ LINPHONE_PUBLIC const char *linphone_core_get_tls_key_path(const LinphoneCore *lc); +LINPHONE_PUBLIC void linphone_core_set_im_encryption_engine(LinphoneCore *lc, LinphoneImEncryptionEngine *imee); + +LINPHONE_PUBLIC LinphoneImEncryptionEngine * linphone_core_get_im_encryption_engine(const LinphoneCore *lc); + #include "ringtoneplayer.h" #ifdef __cplusplus diff --git a/coreapi/private.h b/coreapi/private.h index f8fe6cda6..c1339826c 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -1071,6 +1071,8 @@ struct _LinphoneCore /*default resource list server*/ LinphoneAddress *default_rls_addr; + + LinphoneImEncryptionEngine *im_encryption_engine; }; diff --git a/tester/message_tester.c b/tester/message_tester.c index 3c49bd180..f326bc893 100644 --- a/tester/message_tester.c +++ b/tester/message_tester.c @@ -809,6 +809,10 @@ static void lime_text_message(void) { linphone_chat_room_send_message(chat_room,"Bla bla bla bla"); BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneMessageReceived,1)); BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneMessageReceivedLegacy,1)); + BC_ASSERT_PTR_NOT_NULL(marie->stat.last_received_chat_message); + if (marie->stat.last_received_chat_message) { + BC_ASSERT_STRING_EQUAL(linphone_chat_message_get_text(marie->stat.last_received_chat_message), "Bla bla bla bla"); + } BC_ASSERT_PTR_NOT_NULL(linphone_core_get_chat_room(marie->lc,pauline->identity)); /* TODO : check the msg arrived correctly deciphered */ From 47c08783afcbdfc97fa91a612b8935ae376ec4d5 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Fri, 4 Nov 2016 15:35:59 +0100 Subject: [PATCH 07/21] Added process outgoing message for im encryption engine --- coreapi/bellesip_sal/sal_op_message.c | 68 ++++++--------------------- coreapi/im_encryption_engine.c | 9 ++++ coreapi/im_encryption_engine.h | 6 +++ coreapi/lime.c | 57 +++++++++++++++++++++- coreapi/lime.h | 2 + coreapi/linphonecore.c | 1 + 6 files changed, 89 insertions(+), 54 deletions(-) diff --git a/coreapi/bellesip_sal/sal_op_message.c b/coreapi/bellesip_sal/sal_op_message.c index ccead1c76..48243a548 100644 --- a/coreapi/bellesip_sal/sal_op_message.c +++ b/coreapi/bellesip_sal/sal_op_message.c @@ -100,7 +100,7 @@ void sal_process_incoming_message(SalOp *op,const belle_sip_request_event_t *eve bool_t cipher_xml=FALSE; bool_t rcs_filetransfer=FALSE; uint8_t *decryptedMessage = NULL; - LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(op)); + LinphoneCore *lc = (LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(op)); int retval = -1; from_header=belle_sip_message_get_header_by_type(BELLE_SIP_MESSAGE(req),belle_sip_header_from_t); @@ -206,7 +206,9 @@ int sal_message_send(SalOp *op, const char *from, const char *to, const char* co time_t curtime = ms_time(NULL); uint8_t *multipartEncryptedMessage = NULL; const char *body; - int retval; + int retval = -1; + LinphoneCore *lc = (LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(op)); + LinphoneImEncryptionEngine *imee = linphone_core_get_im_encryption_engine(lc); if (op->dialog){ /*for SIP MESSAGE that are sent in call's dialog*/ @@ -228,59 +230,19 @@ int sal_message_send(SalOp *op, const char *from, const char *to, const char* co } } - /* shall we try to encrypt the message?*/ - if ((strcmp(content_type, "xml/cipher") == 0) || ((strcmp(content_type, "application/cipher.vnd.gsma.rcs-ft-http+xml") == 0))) { - /* access the zrtp cache to get keys needed to cipher the message */ - LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(op)); - FILE *CACHEFD = fopen(lc->zrtp_secrets_cache, "rb+"); - if (CACHEFD == NULL) { - ms_warning("Unable to access ZRTP ZID cache to encrypt message"); - /*probably not a good idea to do this:*/ - sal_error_info_set(&op->error_info, SalReasonNotAcceptable, 488, "Unable to encrypt IM", NULL); - op->base.root->callbacks.text_delivery_update(op,SalTextDeliveryFailed); - return -1; - } else { - size_t cacheSize; - char *cacheString; - xmlDocPtr cacheXml; - int retval; - - cacheString=ms_load_file_content(CACHEFD, &cacheSize); - if (!cacheString){ - ms_warning("Unable to load content of ZRTP ZID cache to encrypt message"); - return -1; - } - cacheString[cacheSize] = '\0'; - cacheSize += 1; - fclose(CACHEFD); - cacheXml = xmlParseDoc((xmlChar*)cacheString); - ms_free(cacheString); - retval = lime_createMultipartMessage(cacheXml, (uint8_t *)msg, (uint8_t *)peer_uri, &multipartEncryptedMessage); - if (retval != 0) { - ms_warning("Unable to encrypt message for %s : %s - op [%p]", peer_uri, lime_error_code_to_string(retval), op); - xmlFreeDoc(cacheXml); - free(multipartEncryptedMessage); - /*probably not a good idea to do this:*/ - sal_error_info_set(&op->error_info, SalReasonNotAcceptable, 488, "Unable to encrypt IM", NULL); - op->base.root->callbacks.text_delivery_update(op,SalTextDeliveryFailed); - return -1; - } else { - /* dump updated cache to a string */ - xmlChar *xmlStringOutput; - int xmlStringLength; - xmlDocDumpFormatMemoryEnc(cacheXml, &xmlStringOutput, &xmlStringLength, "UTF-8", 0); - /* write it to the cache file */ - CACHEFD = fopen(lc->zrtp_secrets_cache, "wb+"); - if (fwrite(xmlStringOutput, 1, xmlStringLength, CACHEFD)<=0){ - ms_warning("Unable to write zid cache"); - } - xmlFree(xmlStringOutput); - fclose(CACHEFD); - content_length = strlen((const char *)multipartEncryptedMessage); - } - xmlFreeDoc(cacheXml); + if (imee) { + LinphoneImEncryptionEngineCbs *imee_cbs = linphone_im_encryption_engine_get_callbacks(imee); + LinphoneImEncryptionEngineOutgoingMessageCb cb_process_outgoing_message = linphone_im_encryption_engine_cbs_get_process_outgoing_message(imee_cbs); + if (cb_process_outgoing_message) { + retval = cb_process_outgoing_message(lc, peer_uri, content_type, msg, (char **)&multipartEncryptedMessage, &content_length); } } + if (retval > 0) { + /*probably not a good idea to do this:*/ + sal_error_info_set(&op->error_info, SalReasonNotAcceptable, retval, "Unable to encrypt IM", NULL); + op->base.root->callbacks.text_delivery_update(op, SalTextDeliveryFailed); + return -1; + } snprintf(content_type_raw,sizeof(content_type_raw),BELLE_SIP_CONTENT_TYPE ": %s",content_type); belle_sip_message_add_header(BELLE_SIP_MESSAGE(req),BELLE_SIP_HEADER(belle_sip_header_content_type_parse(content_type_raw))); diff --git a/coreapi/im_encryption_engine.c b/coreapi/im_encryption_engine.c index cf6a34530..95b019eac 100644 --- a/coreapi/im_encryption_engine.c +++ b/coreapi/im_encryption_engine.c @@ -23,6 +23,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. struct _LinphoneImEncryptionEngineCbs { void *user_data; LinphoneImEncryptionEngineIncomingMessageCb process_incoming_message; + LinphoneImEncryptionEngineOutgoingMessageCb process_outgoing_message; }; struct _LinphoneImEncryptionEngine { @@ -68,4 +69,12 @@ LinphoneImEncryptionEngineIncomingMessageCb linphone_im_encryption_engine_cbs_ge void linphone_im_encryption_engine_cbs_set_process_incoming_message(LinphoneImEncryptionEngineCbs *cbs, LinphoneImEncryptionEngineIncomingMessageCb cb) { cbs->process_incoming_message = cb; +} + +LinphoneImEncryptionEngineOutgoingMessageCb linphone_im_encryption_engine_cbs_get_process_outgoing_message(LinphoneImEncryptionEngineCbs *cbs) { + return cbs->process_outgoing_message; +} + +void linphone_im_encryption_engine_cbs_set_process_outgoing_message(LinphoneImEncryptionEngineCbs *cbs, LinphoneImEncryptionEngineOutgoingMessageCb cb) { + cbs->process_outgoing_message = cb; } \ No newline at end of file diff --git a/coreapi/im_encryption_engine.h b/coreapi/im_encryption_engine.h index 7ab571dbe..17ac20ea3 100644 --- a/coreapi/im_encryption_engine.h +++ b/coreapi/im_encryption_engine.h @@ -28,6 +28,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. typedef int (*LinphoneImEncryptionEngineIncomingMessageCb)(LinphoneCore* lc, const char* content_type, const char* content_subtype, const char* body, char** decrypted_body); +typedef int (*LinphoneImEncryptionEngineOutgoingMessageCb)(LinphoneCore* lc, const char *peer_uri, const char* content_type, const char* body, char** crypted_body, size_t* content_length); + typedef struct _LinphoneImEncryptionEngineCbs LinphoneImEncryptionEngineCbs; typedef struct _LinphoneImEncryptionEngine LinphoneImEncryptionEngine; @@ -50,4 +52,8 @@ LINPHONE_PUBLIC LinphoneImEncryptionEngineIncomingMessageCb linphone_im_encrypti LINPHONE_PUBLIC void linphone_im_encryption_engine_cbs_set_process_incoming_message(LinphoneImEncryptionEngineCbs *cbs, LinphoneImEncryptionEngineIncomingMessageCb cb); +LINPHONE_PUBLIC LinphoneImEncryptionEngineOutgoingMessageCb linphone_im_encryption_engine_cbs_get_process_outgoing_message(LinphoneImEncryptionEngineCbs *cbs); + +LINPHONE_PUBLIC void linphone_im_encryption_engine_cbs_set_process_outgoing_message(LinphoneImEncryptionEngineCbs *cbs, LinphoneImEncryptionEngineOutgoingMessageCb cb); + #endif /* IM_ENCRYPTION_ENGINE_H */ \ No newline at end of file diff --git a/coreapi/lime.c b/coreapi/lime.c index 833161818..845f2de98 100644 --- a/coreapi/lime.c +++ b/coreapi/lime.c @@ -851,7 +851,7 @@ int lime_im_encryption_engine_process_incoming_message_cb(LinphoneCore* lc, cons retval = lime_decryptMultipartMessage(cacheXml, (uint8_t *)body, (uint8_t **)decrypted_body); if (retval != 0) { ms_warning("Unable to decrypt message, reason : %s", lime_error_code_to_string(retval)); - free(decrypted_body); + if (*decrypted_body) free(*decrypted_body); xmlFreeDoc(cacheXml); errcode = 488; return errcode; @@ -875,6 +875,58 @@ int lime_im_encryption_engine_process_incoming_message_cb(LinphoneCore* lc, cons return errcode; } +int lime_im_encryption_engine_process_outgoing_message_cb(LinphoneCore* lc, const char *peer_uri, const char* content_type, const char* body, char** crypted_body, size_t* content_length) { + int errcode = -1; + /* shall we try to encrypt the message?*/ + if ((strcmp(content_type, "xml/cipher") == 0) || ((strcmp(content_type, "application/cipher.vnd.gsma.rcs-ft-http+xml") == 0))) { + /* access the zrtp cache to get keys needed to cipher the message */ + const char *zrtp_secrets_cache = linphone_core_get_zrtp_secrets_file(lc); + FILE *CACHEFD = fopen(zrtp_secrets_cache, "rb+"); + errcode = 0; + if (CACHEFD == NULL) { + ms_warning("Unable to access ZRTP ZID cache to encrypt message"); + errcode = 488; + } else { + size_t cacheSize; + char *cacheString; + xmlDocPtr cacheXml; + int retval; + + cacheString=ms_load_file_content(CACHEFD, &cacheSize); + if (!cacheString){ + ms_warning("Unable to load content of ZRTP ZID cache to encrypt message"); + errcode = 500; + return errcode; + } + cacheString[cacheSize] = '\0'; + cacheSize += 1; + fclose(CACHEFD); + cacheXml = xmlParseDoc((xmlChar*)cacheString); + ms_free(cacheString); + retval = lime_createMultipartMessage(cacheXml, (uint8_t *)body, (uint8_t *)peer_uri, (uint8_t **)crypted_body); + if (retval != 0) { + ms_warning("Unable to encrypt message for %s : %s", peer_uri, lime_error_code_to_string(retval)); + if (*crypted_body) free(*crypted_body); + errcode = 488; + } else { + /* dump updated cache to a string */ + xmlChar *xmlStringOutput; + int xmlStringLength; + xmlDocDumpFormatMemoryEnc(cacheXml, &xmlStringOutput, &xmlStringLength, "UTF-8", 0); + /* write it to the cache file */ + CACHEFD = fopen(zrtp_secrets_cache, "wb+"); + if (fwrite(xmlStringOutput, 1, xmlStringLength, CACHEFD)<=0){ + ms_warning("Unable to write zid cache"); + } + xmlFree(xmlStringOutput); + fclose(CACHEFD); + *content_length = strlen((const char *)*crypted_body); + } + xmlFreeDoc(cacheXml); + } + } + return errcode; +} #else /* HAVE_LIME */ @@ -903,6 +955,9 @@ int lime_decryptMessage(limeKey_t *key, uint8_t *encryptedMessage, uint32_t mess int lime_im_encryption_engine_process_incoming_message_cb(LinphoneCore* lc, const char* content_type, const char* content_subtype, const char* body, char** decrypted_body) { return 500; } +int lime_im_encryption_engine_process_outgoing_message_cb(LinphoneCore* lc, const char *peer_uri, const char* content_type, const char* body, char** crypted_body, size_t* content_length) { + return 500; +} #endif /* HAVE_LIME */ char *lime_error_code_to_string(int errorCode) { diff --git a/coreapi/lime.h b/coreapi/lime.h index f33622812..db2ef6994 100644 --- a/coreapi/lime.h +++ b/coreapi/lime.h @@ -207,4 +207,6 @@ LINPHONE_PUBLIC bool_t lime_is_available(void); int lime_im_encryption_engine_process_incoming_message_cb(LinphoneCore* lc, const char* content_type, const char* content_subtype, const char* body, char** decrypted_body); +int lime_im_encryption_engine_process_outgoing_message_cb(LinphoneCore* lc, const char *peer_uri, const char* content_type, const char* body, char** crypted_body, size_t* content_length); + #endif /* LIME_H */ diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 6bd808c56..3b43bea09 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -1955,6 +1955,7 @@ void linphone_core_enable_lime(LinphoneCore *lc, LinphoneLimeState val){ LinphoneImEncryptionEngine *imee = linphone_im_encryption_engine_new(); LinphoneImEncryptionEngineCbs *cbs = linphone_im_encryption_engine_get_callbacks(imee); linphone_im_encryption_engine_cbs_set_process_incoming_message(cbs, lime_im_encryption_engine_process_incoming_message_cb); + linphone_im_encryption_engine_cbs_set_process_outgoing_message(cbs, lime_im_encryption_engine_process_outgoing_message_cb); lc->im_encryption_engine = imee; } else { if (lc->im_encryption_engine) { From 28d5816c0686a798406144c740a3f2e8b15322f2 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Fri, 4 Nov 2016 16:26:36 +0100 Subject: [PATCH 08/21] Added belle_sip_request_t parameter to im encryption engine callbacks to authorize read/write of SIP headers --- coreapi/bellesip_sal/sal_op_message.c | 7 +++---- coreapi/im_encryption_engine.c | 8 ++++++++ coreapi/im_encryption_engine.h | 12 ++++++++---- coreapi/lime.c | 8 ++++---- coreapi/lime.h | 4 ++-- coreapi/linphonecore.h | 1 + 6 files changed, 26 insertions(+), 14 deletions(-) diff --git a/coreapi/bellesip_sal/sal_op_message.c b/coreapi/bellesip_sal/sal_op_message.c index 48243a548..c1858b4b4 100644 --- a/coreapi/bellesip_sal/sal_op_message.c +++ b/coreapi/bellesip_sal/sal_op_message.c @@ -20,7 +20,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "linphonecore.h" #include "private.h" -#include "lime.h" #include static void process_error( SalOp* op) { @@ -90,7 +89,7 @@ void sal_process_incoming_message(SalOp *op,const belle_sip_request_event_t *eve belle_sip_header_from_t* from_header; belle_sip_header_content_type_t* content_type; belle_sip_response_t* resp; - int errcode=500; + int errcode = 500; belle_sip_header_call_id_t* call_id = belle_sip_message_get_header_by_type(req,belle_sip_header_call_id_t); belle_sip_header_cseq_t* cseq = belle_sip_message_get_header_by_type(req,belle_sip_header_cseq_t); belle_sip_header_date_t *date=belle_sip_message_get_header_by_type(req,belle_sip_header_date_t); @@ -112,7 +111,7 @@ void sal_process_incoming_message(SalOp *op,const belle_sip_request_event_t *eve LinphoneImEncryptionEngineCbs *imee_cbs = linphone_im_encryption_engine_get_callbacks(imee); LinphoneImEncryptionEngineIncomingMessageCb cb_process_incoming_message = linphone_im_encryption_engine_cbs_get_process_incoming_message(imee_cbs); if (cb_process_incoming_message) { - retval = cb_process_incoming_message(lc, belle_sip_header_content_type_get_type(content_type), belle_sip_header_content_type_get_subtype(content_type), + retval = cb_process_incoming_message(lc, req, belle_sip_header_content_type_get_type(content_type), belle_sip_header_content_type_get_subtype(content_type), belle_sip_message_get_body(BELLE_SIP_MESSAGE(req)), (char **)&decryptedMessage); } } @@ -234,7 +233,7 @@ int sal_message_send(SalOp *op, const char *from, const char *to, const char* co LinphoneImEncryptionEngineCbs *imee_cbs = linphone_im_encryption_engine_get_callbacks(imee); LinphoneImEncryptionEngineOutgoingMessageCb cb_process_outgoing_message = linphone_im_encryption_engine_cbs_get_process_outgoing_message(imee_cbs); if (cb_process_outgoing_message) { - retval = cb_process_outgoing_message(lc, peer_uri, content_type, msg, (char **)&multipartEncryptedMessage, &content_length); + retval = cb_process_outgoing_message(lc, req, peer_uri, content_type, msg, (char **)&multipartEncryptedMessage, &content_length); } } if (retval > 0) { diff --git a/coreapi/im_encryption_engine.c b/coreapi/im_encryption_engine.c index 95b019eac..b7b43b676 100644 --- a/coreapi/im_encryption_engine.c +++ b/coreapi/im_encryption_engine.c @@ -59,6 +59,14 @@ void linphone_im_encryption_engine_destory(LinphoneImEncryptionEngine *imee) { ms_free(imee); } +void *linphone_im_encryption_engine_get_user_data(const LinphoneImEncryptionEngine *imee) { + return imee->user_data; +} + +void linphone_im_encryption_engine_set_user_data(LinphoneImEncryptionEngine *imee, void *data) { + imee->user_data = data; +} + LinphoneImEncryptionEngineCbs* linphone_im_encryption_engine_get_callbacks(const LinphoneImEncryptionEngine *imee) { return imee->callbacks; } diff --git a/coreapi/im_encryption_engine.h b/coreapi/im_encryption_engine.h index 17ac20ea3..a5742d721 100644 --- a/coreapi/im_encryption_engine.h +++ b/coreapi/im_encryption_engine.h @@ -26,17 +26,17 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #define LINPHONE_PUBLIC MS2_PUBLIC #endif -typedef int (*LinphoneImEncryptionEngineIncomingMessageCb)(LinphoneCore* lc, const char* content_type, const char* content_subtype, const char* body, char** decrypted_body); +typedef int (*LinphoneImEncryptionEngineIncomingMessageCb)(LinphoneCore* lc, belle_sip_request_t* req, const char* content_type, const char* content_subtype, const char* body, char** decrypted_body); -typedef int (*LinphoneImEncryptionEngineOutgoingMessageCb)(LinphoneCore* lc, const char *peer_uri, const char* content_type, const char* body, char** crypted_body, size_t* content_length); +typedef int (*LinphoneImEncryptionEngineOutgoingMessageCb)(LinphoneCore* lc, belle_sip_request_t* req, const char *peer_uri, const char* content_type, const char* body, char** crypted_body, size_t* content_length); typedef struct _LinphoneImEncryptionEngineCbs LinphoneImEncryptionEngineCbs; typedef struct _LinphoneImEncryptionEngine LinphoneImEncryptionEngine; -LINPHONE_PUBLIC LinphoneImEncryptionEngineCbs *linphone_im_encryption_engine_cbs_new(void); +LinphoneImEncryptionEngineCbs *linphone_im_encryption_engine_cbs_new(void); -LINPHONE_PUBLIC void linphone_im_encryption_engine_cbs_destory(LinphoneImEncryptionEngineCbs *cbs); +void linphone_im_encryption_engine_cbs_destory(LinphoneImEncryptionEngineCbs *cbs); LINPHONE_PUBLIC void *linphone_im_encryption_engine_cbs_get_user_data(const LinphoneImEncryptionEngineCbs *cbs); @@ -46,6 +46,10 @@ LINPHONE_PUBLIC LinphoneImEncryptionEngine *linphone_im_encryption_engine_new(vo LINPHONE_PUBLIC void linphone_im_encryption_engine_destory(LinphoneImEncryptionEngine *imee); +LINPHONE_PUBLIC void *linphone_im_encryption_engine_get_user_data(const LinphoneImEncryptionEngine *imee); + +LINPHONE_PUBLIC void linphone_im_encryption_engine_set_user_data(LinphoneImEncryptionEngine *imee, void *data); + LINPHONE_PUBLIC LinphoneImEncryptionEngineCbs* linphone_im_encryption_engine_get_callbacks(const LinphoneImEncryptionEngine *imee); LINPHONE_PUBLIC LinphoneImEncryptionEngineIncomingMessageCb linphone_im_encryption_engine_cbs_get_process_incoming_message(LinphoneImEncryptionEngineCbs *cbs); diff --git a/coreapi/lime.c b/coreapi/lime.c index 845f2de98..fd246198e 100644 --- a/coreapi/lime.c +++ b/coreapi/lime.c @@ -818,7 +818,7 @@ static bool_t is_cipher_xml(const char* content_type, const char *content_subtyp && strcmp("cipher.vnd.gsma.rcs-ft-http+xml",content_subtype)==0); } -int lime_im_encryption_engine_process_incoming_message_cb(LinphoneCore* lc, const char* content_type, const char* content_subtype, const char* body, char** decrypted_body) { +int lime_im_encryption_engine_process_incoming_message_cb(LinphoneCore* lc, belle_sip_request_t* req, const char* content_type, const char* content_subtype, const char* body, char** decrypted_body) { int errcode = -1; /* check if we have a xml/cipher message to be decrypted */ if (is_cipher_xml(content_type, content_subtype)) { @@ -875,7 +875,7 @@ int lime_im_encryption_engine_process_incoming_message_cb(LinphoneCore* lc, cons return errcode; } -int lime_im_encryption_engine_process_outgoing_message_cb(LinphoneCore* lc, const char *peer_uri, const char* content_type, const char* body, char** crypted_body, size_t* content_length) { +int lime_im_encryption_engine_process_outgoing_message_cb(LinphoneCore* lc, belle_sip_request_t* req, const char *peer_uri, const char* content_type, const char* body, char** crypted_body, size_t* content_length) { int errcode = -1; /* shall we try to encrypt the message?*/ if ((strcmp(content_type, "xml/cipher") == 0) || ((strcmp(content_type, "application/cipher.vnd.gsma.rcs-ft-http+xml") == 0))) { @@ -952,10 +952,10 @@ int lime_getCachedRcvKeyByZid(xmlDocPtr cacheBuffer, limeKey_t *associatedKey) { int lime_decryptMessage(limeKey_t *key, uint8_t *encryptedMessage, uint32_t messageLength, uint8_t selfZID[12], uint8_t *plainMessage) { return LIME_NOT_ENABLED; } -int lime_im_encryption_engine_process_incoming_message_cb(LinphoneCore* lc, const char* content_type, const char* content_subtype, const char* body, char** decrypted_body) { +int lime_im_encryption_engine_process_incoming_message_cb(LinphoneCore* lc, belle_sip_request_t* req, const char* content_type, const char* content_subtype, const char* body, char** decrypted_body) { return 500; } -int lime_im_encryption_engine_process_outgoing_message_cb(LinphoneCore* lc, const char *peer_uri, const char* content_type, const char* body, char** crypted_body, size_t* content_length) { +int lime_im_encryption_engine_process_outgoing_message_cb(LinphoneCore* lc, belle_sip_request_t* req, const char *peer_uri, const char* content_type, const char* body, char** crypted_body, size_t* content_length) { return 500; } #endif /* HAVE_LIME */ diff --git a/coreapi/lime.h b/coreapi/lime.h index db2ef6994..717f57064 100644 --- a/coreapi/lime.h +++ b/coreapi/lime.h @@ -205,8 +205,8 @@ LINPHONE_PUBLIC char *lime_error_code_to_string(int errorCode); */ LINPHONE_PUBLIC bool_t lime_is_available(void); -int lime_im_encryption_engine_process_incoming_message_cb(LinphoneCore* lc, const char* content_type, const char* content_subtype, const char* body, char** decrypted_body); +int lime_im_encryption_engine_process_incoming_message_cb(LinphoneCore* lc, belle_sip_request_t* req, const char* content_type, const char* content_subtype, const char* body, char** decrypted_body); -int lime_im_encryption_engine_process_outgoing_message_cb(LinphoneCore* lc, const char *peer_uri, const char* content_type, const char* body, char** crypted_body, size_t* content_length); +int lime_im_encryption_engine_process_outgoing_message_cb(LinphoneCore* lc, belle_sip_request_t* req, const char *peer_uri, const char* content_type, const char* body, char** crypted_body, size_t* content_length); #endif /* LIME_H */ diff --git a/coreapi/linphonecore.h b/coreapi/linphonecore.h index fbdff8de4..d51d25cf8 100644 --- a/coreapi/linphonecore.h +++ b/coreapi/linphonecore.h @@ -19,6 +19,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #ifndef LINPHONECORE_H #define LINPHONECORE_H +#include "belle-sip/belle-sip.h" #include "ortp/ortp.h" #include "ortp/payloadtype.h" #include "mediastreamer2/mscommon.h" From c284239d54bc526e363c04248b86323fb576a44e Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Mon, 7 Nov 2016 16:32:09 +0100 Subject: [PATCH 09/21] Added callbacks in im encryption engine for decrypting incoming files in chat messages + improved lime test to check decrypted file is equal to sent one --- coreapi/chat_file_transfer.c | 92 ++++++++++++++++++---------------- coreapi/im_encryption_engine.c | 18 +++++++ coreapi/im_encryption_engine.h | 12 +++++ coreapi/lime.c | 44 ++++++++++++++++ coreapi/lime.h | 4 ++ coreapi/linphonecore.c | 2 + coreapi/linphonecore.h | 8 ++- tester/message_tester.c | 5 ++ 8 files changed, 139 insertions(+), 46 deletions(-) diff --git a/coreapi/chat_file_transfer.c b/coreapi/chat_file_transfer.c index 6669257d4..340d6e9d9 100644 --- a/coreapi/chat_file_transfer.c +++ b/coreapi/chat_file_transfer.c @@ -323,7 +323,10 @@ const LinphoneContent *linphone_chat_message_get_file_transfer_information(const static void on_recv_body(belle_sip_user_body_handler_t *bh, belle_sip_message_t *m, void *data, size_t offset, const uint8_t *buffer, size_t size) { LinphoneChatMessage *msg = (LinphoneChatMessage *)data; - LinphoneCore *lc; + LinphoneCore *lc = NULL; + LinphoneImEncryptionEngine *imee = NULL; + int retval = -1; + char *decrypted_buffer = NULL; if (!msg->chat_room) { linphone_chat_message_cancel_file_transfer(msg); @@ -344,33 +347,33 @@ static void on_recv_body(belle_sip_user_body_handler_t *bh, belle_sip_message_t if (size == 0) { return; } - - if (linphone_content_get_key(msg->file_transfer_information) != - NULL) { /* we have a key, we must decrypt the file */ - /* get data from callback to a plainBuffer */ - char *plainBuffer = (char *)ms_malloc0(size); - lime_decryptFile(linphone_content_get_cryptoContext_address(msg->file_transfer_information), - (unsigned char *)linphone_content_get_key(msg->file_transfer_information), size, plainBuffer, - (char *)buffer); - if (linphone_chat_message_cbs_get_file_transfer_recv(msg->callbacks)) { - LinphoneBuffer *lb = linphone_buffer_new_from_data((unsigned char *)plainBuffer, size); - linphone_chat_message_cbs_get_file_transfer_recv(msg->callbacks)(msg, msg->file_transfer_information, lb); - linphone_buffer_unref(lb); - } else { - /* legacy: call back given by application level */ - linphone_core_notify_file_transfer_recv(lc, msg, msg->file_transfer_information, plainBuffer, size); + + decrypted_buffer = (char *)ms_malloc0(size); + imee = linphone_core_get_im_encryption_engine(lc); + if (imee) { + LinphoneImEncryptionEngineCbs *imee_cbs = linphone_im_encryption_engine_get_callbacks(imee); + LinphoneImEncryptionEngineDownloadingFileBufferCb cb_process_downloading_file_buffer = linphone_im_encryption_engine_cbs_get_process_downloading_file_buffer(imee_cbs); + if (cb_process_downloading_file_buffer) { + retval = cb_process_downloading_file_buffer(lc, msg, (const char *)buffer, size, &decrypted_buffer); } - ms_free(plainBuffer); - } else { /* regular file, no deciphering */ + } + + if (retval <= 0) { + const uint8_t *buffer_to_use = buffer; + if (retval == 0) { + buffer_to_use = (const uint8_t *)decrypted_buffer; + } + if (linphone_chat_message_cbs_get_file_transfer_recv(msg->callbacks)) { - LinphoneBuffer *lb = linphone_buffer_new_from_data(buffer, size); + LinphoneBuffer *lb = linphone_buffer_new_from_data(buffer_to_use, size); linphone_chat_message_cbs_get_file_transfer_recv(msg->callbacks)(msg, msg->file_transfer_information, lb); linphone_buffer_unref(lb); } else { /* Legacy: call back given by application level */ - linphone_core_notify_file_transfer_recv(lc, msg, msg->file_transfer_information, (char *)buffer, size); + linphone_core_notify_file_transfer_recv(lc, msg, msg->file_transfer_information, (const char *)buffer_to_use, size); } } + ms_free(decrypted_buffer); return; } @@ -446,11 +449,25 @@ static void linphone_chat_process_response_from_get_file(void *data, const belle int code = belle_http_response_get_status_code(event->response); if (code == 200) { LinphoneCore *lc = msg->chat_room->lc; - if (msg->file_transfer_filepath == NULL) { - /* if the file was encrypted, finish the decryption and free context */ - if (linphone_content_get_key(msg->file_transfer_information) != NULL) { - lime_decryptFile(linphone_content_get_cryptoContext_address(msg->file_transfer_information), NULL, 0, NULL, NULL); + int retval = -1; + LinphoneImEncryptionEngine *imee = linphone_core_get_im_encryption_engine(lc); + if (imee) { + LinphoneImEncryptionEngineCbs *imee_cbs = linphone_im_encryption_engine_get_callbacks(imee); + + if (msg->file_transfer_filepath == NULL) { + LinphoneImEncryptionEngineDownloadingFileBufferCb cb_process_downloading_file_buffer = linphone_im_encryption_engine_cbs_get_process_downloading_file_buffer(imee_cbs); + if (cb_process_downloading_file_buffer) { + retval = cb_process_downloading_file_buffer(lc, msg, NULL, 0, NULL); + } + } else { + LinphoneImEncryptionEngineDownloadingFileCb cb_process_downloading_file = linphone_im_encryption_engine_cbs_get_process_downloading_file(imee_cbs); + if (cb_process_downloading_file) { + retval = cb_process_downloading_file(lc, msg, msg->file_transfer_filepath); + } } + } + + if (msg->file_transfer_filepath == NULL) { if (linphone_chat_message_cbs_get_file_transfer_recv(msg->callbacks)) { LinphoneBuffer *lb = linphone_buffer_new(); linphone_chat_message_cbs_get_file_transfer_recv(msg->callbacks)(msg, msg->file_transfer_information, lb); @@ -459,28 +476,15 @@ static void linphone_chat_process_response_from_get_file(void *data, const belle linphone_core_notify_file_transfer_recv(lc, msg, msg->file_transfer_information, NULL, 0); } } else { - if (linphone_content_get_key(msg->file_transfer_information) != NULL) { - bctbx_vfs_t *vfs = bctbx_vfs_get_default(); - bctbx_vfs_file_t *decrypted_file; - bctbx_vfs_file_t *encrypted_file = bctbx_file_open(vfs, msg->file_transfer_filepath, "r"); - size_t encrypted_file_size = (size_t)bctbx_file_size(encrypted_file); - char *encrypted_content = bctbx_malloc(encrypted_file_size); - char *decrypted_content = bctbx_malloc(encrypted_file_size); - bctbx_file_read(encrypted_file, encrypted_content, encrypted_file_size, 0); - bctbx_file_close(encrypted_file); - lime_decryptFile(linphone_content_get_cryptoContext_address(msg->file_transfer_information), - (unsigned char *)linphone_content_get_key(msg->file_transfer_information), - encrypted_file_size, decrypted_content, encrypted_content); - lime_decryptFile(linphone_content_get_cryptoContext_address(msg->file_transfer_information), NULL, 0, NULL, NULL); - decrypted_file = bctbx_file_open(vfs, msg->file_transfer_filepath, "w"); - bctbx_file_write(decrypted_file, decrypted_content, encrypted_file_size, 0); - bctbx_file_close(decrypted_file); - bctbx_free(encrypted_content); - bctbx_free(decrypted_content); - } linphone_core_notify_file_transfer_recv(lc, msg, msg->file_transfer_information, NULL, 0); } - linphone_chat_message_set_state(msg, LinphoneChatMessageStateFileTransferDone); + + if (retval <= 0) { + linphone_chat_message_set_state(msg, LinphoneChatMessageStateFileTransferDone); + } else { + ms_warning("File transfer decrypt failed with code %d", code); + linphone_chat_message_set_state(msg, LinphoneChatMessageStateFileTransferError); + } } else if (code >= 400 && code < 500) { ms_warning("File transfer failed with code %d", code); linphone_chat_message_set_state(msg, LinphoneChatMessageStateFileTransferError); diff --git a/coreapi/im_encryption_engine.c b/coreapi/im_encryption_engine.c index b7b43b676..f7cdbbf79 100644 --- a/coreapi/im_encryption_engine.c +++ b/coreapi/im_encryption_engine.c @@ -23,6 +23,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. struct _LinphoneImEncryptionEngineCbs { void *user_data; LinphoneImEncryptionEngineIncomingMessageCb process_incoming_message; + LinphoneImEncryptionEngineDownloadingFileBufferCb process_downlading_file_buffer; + LinphoneImEncryptionEngineDownloadingFileCb process_downloading_file; LinphoneImEncryptionEngineOutgoingMessageCb process_outgoing_message; }; @@ -85,4 +87,20 @@ LinphoneImEncryptionEngineOutgoingMessageCb linphone_im_encryption_engine_cbs_ge void linphone_im_encryption_engine_cbs_set_process_outgoing_message(LinphoneImEncryptionEngineCbs *cbs, LinphoneImEncryptionEngineOutgoingMessageCb cb) { cbs->process_outgoing_message = cb; +} + +LinphoneImEncryptionEngineDownloadingFileBufferCb linphone_im_encryption_engine_cbs_get_process_downloading_file_buffer(LinphoneImEncryptionEngineCbs *cbs) { + return cbs->process_downlading_file_buffer; +} + +void linphone_im_encryption_engine_cbs_set_process_downloading_file_buffer(LinphoneImEncryptionEngineCbs *cbs, LinphoneImEncryptionEngineDownloadingFileBufferCb cb) { + cbs->process_downlading_file_buffer = cb; +} + +LinphoneImEncryptionEngineDownloadingFileCb linphone_im_encryption_engine_cbs_get_process_downloading_file(LinphoneImEncryptionEngineCbs *cbs) { + return cbs->process_downloading_file; +} + +void linphone_im_encryption_engine_cbs_set_process_downloading_file(LinphoneImEncryptionEngineCbs *cbs, LinphoneImEncryptionEngineDownloadingFileCb cb) { + cbs->process_downloading_file = cb; } \ No newline at end of file diff --git a/coreapi/im_encryption_engine.h b/coreapi/im_encryption_engine.h index a5742d721..095be933c 100644 --- a/coreapi/im_encryption_engine.h +++ b/coreapi/im_encryption_engine.h @@ -30,6 +30,10 @@ typedef int (*LinphoneImEncryptionEngineIncomingMessageCb)(LinphoneCore* lc, bel typedef int (*LinphoneImEncryptionEngineOutgoingMessageCb)(LinphoneCore* lc, belle_sip_request_t* req, const char *peer_uri, const char* content_type, const char* body, char** crypted_body, size_t* content_length); +typedef int (*LinphoneImEncryptionEngineDownloadingFileBufferCb)(LinphoneCore *lc, LinphoneChatMessage *msg, const char *buffer, size_t size, char **decrypted_buffer); + +typedef int (*LinphoneImEncryptionEngineDownloadingFileCb)(LinphoneCore *lc, LinphoneChatMessage *msg, const char *path); + typedef struct _LinphoneImEncryptionEngineCbs LinphoneImEncryptionEngineCbs; typedef struct _LinphoneImEncryptionEngine LinphoneImEncryptionEngine; @@ -60,4 +64,12 @@ LINPHONE_PUBLIC LinphoneImEncryptionEngineOutgoingMessageCb linphone_im_encrypti LINPHONE_PUBLIC void linphone_im_encryption_engine_cbs_set_process_outgoing_message(LinphoneImEncryptionEngineCbs *cbs, LinphoneImEncryptionEngineOutgoingMessageCb cb); +LINPHONE_PUBLIC LinphoneImEncryptionEngineDownloadingFileBufferCb linphone_im_encryption_engine_cbs_get_process_downloading_file_buffer(LinphoneImEncryptionEngineCbs *cbs); + +LINPHONE_PUBLIC void linphone_im_encryption_engine_cbs_set_process_downloading_file_buffer(LinphoneImEncryptionEngineCbs *cbs, LinphoneImEncryptionEngineDownloadingFileBufferCb cb); + +LINPHONE_PUBLIC LinphoneImEncryptionEngineDownloadingFileCb linphone_im_encryption_engine_cbs_get_process_downloading_file(LinphoneImEncryptionEngineCbs *cbs); + +LINPHONE_PUBLIC void linphone_im_encryption_engine_cbs_set_process_downloading_file(LinphoneImEncryptionEngineCbs *cbs, LinphoneImEncryptionEngineDownloadingFileCb cb); + #endif /* IM_ENCRYPTION_ENGINE_H */ \ No newline at end of file diff --git a/coreapi/lime.c b/coreapi/lime.c index fd246198e..78c6a1793 100644 --- a/coreapi/lime.c +++ b/coreapi/lime.c @@ -23,6 +23,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #endif #ifdef HAVE_LIME +#include "private.h" #include "bctoolbox/crypto.h" /** @@ -928,6 +929,43 @@ int lime_im_encryption_engine_process_outgoing_message_cb(LinphoneCore* lc, bell return errcode; } +int lime_im_encryption_engine_process_downloading_file_buffer_cb(LinphoneCore *lc, LinphoneChatMessage *msg, const char *buffer, size_t size, char **decrypted_buffer) { + if (linphone_content_get_key(msg->file_transfer_information) == NULL) return -1; + + if (buffer == NULL || size == 0) { + return lime_decryptFile(linphone_content_get_cryptoContext_address(msg->file_transfer_information), NULL, 0, NULL, NULL); + } + + return lime_decryptFile(linphone_content_get_cryptoContext_address(msg->file_transfer_information), + (unsigned char *)linphone_content_get_key(msg->file_transfer_information), size, *decrypted_buffer, + (char *)buffer); +} + +int lime_im_encryption_engine_process_downloading_file_cb(LinphoneCore *lc, LinphoneChatMessage *msg, const char *path) { + if (linphone_content_get_key(msg->file_transfer_information) == NULL) { + return -1; + } else { + bctbx_vfs_t *vfs = bctbx_vfs_get_default(); + bctbx_vfs_file_t *decrypted_file; + bctbx_vfs_file_t *encrypted_file = bctbx_file_open(vfs, msg->file_transfer_filepath, "r"); + size_t encrypted_file_size = (size_t)bctbx_file_size(encrypted_file); + char *encrypted_content = bctbx_malloc(encrypted_file_size); + char *decrypted_content = bctbx_malloc(encrypted_file_size); + bctbx_file_read(encrypted_file, encrypted_content, encrypted_file_size, 0); + bctbx_file_close(encrypted_file); + lime_decryptFile(linphone_content_get_cryptoContext_address(msg->file_transfer_information), + (unsigned char *)linphone_content_get_key(msg->file_transfer_information), + encrypted_file_size, decrypted_content, encrypted_content); + lime_decryptFile(linphone_content_get_cryptoContext_address(msg->file_transfer_information), NULL, 0, NULL, NULL); + decrypted_file = bctbx_file_open(vfs, msg->file_transfer_filepath, "w"); + bctbx_file_write(decrypted_file, decrypted_content, encrypted_file_size, 0); + bctbx_file_close(decrypted_file); + bctbx_free(encrypted_content); + bctbx_free(decrypted_content); + return 0; + } +} + #else /* HAVE_LIME */ bool_t lime_is_available() { return FALSE; } @@ -958,6 +996,12 @@ int lime_im_encryption_engine_process_incoming_message_cb(LinphoneCore* lc, bell int lime_im_encryption_engine_process_outgoing_message_cb(LinphoneCore* lc, belle_sip_request_t* req, const char *peer_uri, const char* content_type, const char* body, char** crypted_body, size_t* content_length) { return 500; } +int lime_im_encryption_engine_process_downloading_file_buffer_cb(LinphoneCore *lc, LinphoneChatMessage *msg, const char *buffer, size_t size, char **decrypted_buffer) { + return 500; +} +int lime_im_encryption_engine_process_downloading_file_cb(LinphoneCore *lc, LinphoneChatMessage *msg, const char *path) { + return 500; +} #endif /* HAVE_LIME */ char *lime_error_code_to_string(int errorCode) { diff --git a/coreapi/lime.h b/coreapi/lime.h index 717f57064..46d6d96bc 100644 --- a/coreapi/lime.h +++ b/coreapi/lime.h @@ -209,4 +209,8 @@ int lime_im_encryption_engine_process_incoming_message_cb(LinphoneCore* lc, bell int lime_im_encryption_engine_process_outgoing_message_cb(LinphoneCore* lc, belle_sip_request_t* req, const char *peer_uri, const char* content_type, const char* body, char** crypted_body, size_t* content_length); +int lime_im_encryption_engine_process_downloading_file_buffer_cb(LinphoneCore *lc, LinphoneChatMessage *msg, const char *buffer, size_t size, char **decrypted_buffer); + +int lime_im_encryption_engine_process_downloading_file_cb(LinphoneCore *lc, LinphoneChatMessage *msg, const char *path); + #endif /* LIME_H */ diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 3b43bea09..e3fee2bda 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -1956,6 +1956,8 @@ void linphone_core_enable_lime(LinphoneCore *lc, LinphoneLimeState val){ LinphoneImEncryptionEngineCbs *cbs = linphone_im_encryption_engine_get_callbacks(imee); linphone_im_encryption_engine_cbs_set_process_incoming_message(cbs, lime_im_encryption_engine_process_incoming_message_cb); linphone_im_encryption_engine_cbs_set_process_outgoing_message(cbs, lime_im_encryption_engine_process_outgoing_message_cb); + linphone_im_encryption_engine_cbs_set_process_downloading_file_buffer(cbs, lime_im_encryption_engine_process_downloading_file_buffer_cb); + linphone_im_encryption_engine_cbs_set_process_downloading_file(cbs, lime_im_encryption_engine_process_downloading_file_cb); lc->im_encryption_engine = imee; } else { if (lc->im_encryption_engine) { diff --git a/coreapi/linphonecore.h b/coreapi/linphonecore.h index d51d25cf8..64f2ada6f 100644 --- a/coreapi/linphonecore.h +++ b/coreapi/linphonecore.h @@ -433,7 +433,6 @@ LINPHONE_PUBLIC const char* linphone_privacy_to_string(LinphonePrivacy privacy); #include "nat_policy.h" #include "xmlrpc.h" #include "conference.h" -#include "im_encryption_engine.h" #else #include "linphone/buffer.h" #include "linphone/call_log.h" @@ -444,7 +443,6 @@ LINPHONE_PUBLIC const char* linphone_privacy_to_string(LinphonePrivacy privacy); #include "linphone/nat_policy.h" #include "linphone/xmlrpc.h" #include "linphone/conference.h" -#include "linphone/im_encryption_engine.h" #endif LINPHONE_PUBLIC LinphoneAddress * linphone_address_new(const char *addr); @@ -4731,6 +4729,12 @@ LINPHONE_PUBLIC const char *linphone_core_get_tls_cert_path(const LinphoneCore * */ LINPHONE_PUBLIC const char *linphone_core_get_tls_key_path(const LinphoneCore *lc); +#ifdef IN_LINPHONE +#include "im_encryption_engine.h" +#else +#include "linphone/im_encryption_engine.h" +#endif + LINPHONE_PUBLIC void linphone_core_set_im_encryption_engine(LinphoneCore *lc, LinphoneImEncryptionEngine *imee); LINPHONE_PUBLIC LinphoneImEncryptionEngine * linphone_core_get_im_encryption_engine(const LinphoneCore *lc); diff --git a/tester/message_tester.c b/tester/message_tester.c index f326bc893..70604d337 100644 --- a/tester/message_tester.c +++ b/tester/message_tester.c @@ -864,6 +864,8 @@ void lime_transfer_message_base(bool_t encrypt_file,bool_t download_file_from_st LinphoneChatMessageCbs *cbs; char *pauline_id, *marie_id; char *filepath; + char *send_filepath = bc_tester_res("images/nowebcamCIF.jpg"); + char *receive_filepath = bc_tester_file("receive_file.dump"); marie = linphone_core_manager_new( "marie_rc"); pauline = linphone_core_manager_new( "pauline_tcp_rc"); @@ -932,12 +934,15 @@ void lime_transfer_message_base(bool_t encrypt_file,bool_t download_file_from_st BC_ASSERT_PTR_NULL(linphone_content_get_key(content)); linphone_chat_message_download_file(recv_msg); BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneFileTransferDownloadSuccessful,1)); + compare_files(send_filepath, receive_filepath); } BC_ASSERT_EQUAL(pauline->stat.number_of_LinphoneMessageInProgress,2, int, "%d"); // file transfer BC_ASSERT_EQUAL(pauline->stat.number_of_LinphoneMessageDelivered,1, int, "%d"); BC_ASSERT_EQUAL(marie->stat.number_of_LinphoneFileTransferDownloadSuccessful,1, int, "%d"); end: + ms_free(send_filepath); + bc_free(receive_filepath); linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); } From 127d52d72da14f0219746f10b6e18c8a9729beeb Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Wed, 9 Nov 2016 17:26:55 +0100 Subject: [PATCH 10/21] Reworked API for im encryption engine for file download + added test for file body handler --- coreapi/chat_file_transfer.c | 46 ++++++++++++++++++++++------------ coreapi/im_encryption_engine.c | 15 +++-------- coreapi/im_encryption_engine.h | 8 +----- coreapi/lime.c | 32 ++--------------------- coreapi/lime.h | 4 +-- coreapi/linphonecore.c | 1 - 6 files changed, 37 insertions(+), 69 deletions(-) diff --git a/coreapi/chat_file_transfer.c b/coreapi/chat_file_transfer.c index 340d6e9d9..584496bca 100644 --- a/coreapi/chat_file_transfer.c +++ b/coreapi/chat_file_transfer.c @@ -352,9 +352,9 @@ static void on_recv_body(belle_sip_user_body_handler_t *bh, belle_sip_message_t imee = linphone_core_get_im_encryption_engine(lc); if (imee) { LinphoneImEncryptionEngineCbs *imee_cbs = linphone_im_encryption_engine_get_callbacks(imee); - LinphoneImEncryptionEngineDownloadingFileBufferCb cb_process_downloading_file_buffer = linphone_im_encryption_engine_cbs_get_process_downloading_file_buffer(imee_cbs); - if (cb_process_downloading_file_buffer) { - retval = cb_process_downloading_file_buffer(lc, msg, (const char *)buffer, size, &decrypted_buffer); + LinphoneImEncryptionEngineDownloadingFileCb cb_process_downloading_file = linphone_im_encryption_engine_cbs_get_process_downloading_file(imee_cbs); + if (cb_process_downloading_file) { + retval = cb_process_downloading_file(lc, msg, (const char *)buffer, size, &decrypted_buffer); } } @@ -453,30 +453,44 @@ static void linphone_chat_process_response_from_get_file(void *data, const belle LinphoneImEncryptionEngine *imee = linphone_core_get_im_encryption_engine(lc); if (imee) { LinphoneImEncryptionEngineCbs *imee_cbs = linphone_im_encryption_engine_get_callbacks(imee); - - if (msg->file_transfer_filepath == NULL) { - LinphoneImEncryptionEngineDownloadingFileBufferCb cb_process_downloading_file_buffer = linphone_im_encryption_engine_cbs_get_process_downloading_file_buffer(imee_cbs); - if (cb_process_downloading_file_buffer) { - retval = cb_process_downloading_file_buffer(lc, msg, NULL, 0, NULL); - } - } else { - LinphoneImEncryptionEngineDownloadingFileCb cb_process_downloading_file = linphone_im_encryption_engine_cbs_get_process_downloading_file(imee_cbs); - if (cb_process_downloading_file) { - retval = cb_process_downloading_file(lc, msg, msg->file_transfer_filepath); + LinphoneImEncryptionEngineDownloadingFileCb cb_process_downloading_file = linphone_im_encryption_engine_cbs_get_process_downloading_file(imee_cbs); + if (cb_process_downloading_file) { + if (msg->file_transfer_filepath == NULL) { + retval = cb_process_downloading_file(lc, msg, NULL, 0, NULL); + } else { + bctbx_vfs_t *vfs = bctbx_vfs_get_default(); + bctbx_vfs_file_t *decrypted_file; + bctbx_vfs_file_t *encrypted_file = bctbx_file_open(vfs, msg->file_transfer_filepath, "r"); + size_t encrypted_file_size = (size_t)bctbx_file_size(encrypted_file); + char *encrypted_content = bctbx_malloc(encrypted_file_size); + char *decrypted_content = bctbx_malloc(encrypted_file_size); + retval = (int)bctbx_file_read(encrypted_file, encrypted_content, encrypted_file_size, 0); + bctbx_file_close(encrypted_file); + if (retval != BCTBX_VFS_ERROR && retval == (int)encrypted_file_size) { + retval = cb_process_downloading_file(lc, msg, encrypted_content, encrypted_file_size, &decrypted_content); + cb_process_downloading_file(lc, msg, NULL, 0, NULL); + decrypted_file = bctbx_file_open(vfs, msg->file_transfer_filepath, "w"); + bctbx_file_write(decrypted_file, decrypted_content, encrypted_file_size, 0); + bctbx_file_close(decrypted_file); + } else { + ms_error("file %s read failed: expected %d, got %d", msg->file_transfer_filepath, (int)encrypted_file_size, retval); + retval = 500; + } + bctbx_free(encrypted_content); + bctbx_free(decrypted_content); } } } - if (msg->file_transfer_filepath == NULL) { + if (retval <= 0) { if (linphone_chat_message_cbs_get_file_transfer_recv(msg->callbacks)) { LinphoneBuffer *lb = linphone_buffer_new(); linphone_chat_message_cbs_get_file_transfer_recv(msg->callbacks)(msg, msg->file_transfer_information, lb); linphone_buffer_unref(lb); } else { + /* Legacy: call back given by application level */ linphone_core_notify_file_transfer_recv(lc, msg, msg->file_transfer_information, NULL, 0); } - } else { - linphone_core_notify_file_transfer_recv(lc, msg, msg->file_transfer_information, NULL, 0); } if (retval <= 0) { diff --git a/coreapi/im_encryption_engine.c b/coreapi/im_encryption_engine.c index f7cdbbf79..792ff1634 100644 --- a/coreapi/im_encryption_engine.c +++ b/coreapi/im_encryption_engine.c @@ -23,8 +23,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. struct _LinphoneImEncryptionEngineCbs { void *user_data; LinphoneImEncryptionEngineIncomingMessageCb process_incoming_message; - LinphoneImEncryptionEngineDownloadingFileBufferCb process_downlading_file_buffer; - LinphoneImEncryptionEngineDownloadingFileCb process_downloading_file; + LinphoneImEncryptionEngineDownloadingFileCb process_downlading_file; LinphoneImEncryptionEngineOutgoingMessageCb process_outgoing_message; }; @@ -89,18 +88,10 @@ void linphone_im_encryption_engine_cbs_set_process_outgoing_message(LinphoneImEn cbs->process_outgoing_message = cb; } -LinphoneImEncryptionEngineDownloadingFileBufferCb linphone_im_encryption_engine_cbs_get_process_downloading_file_buffer(LinphoneImEncryptionEngineCbs *cbs) { - return cbs->process_downlading_file_buffer; -} - -void linphone_im_encryption_engine_cbs_set_process_downloading_file_buffer(LinphoneImEncryptionEngineCbs *cbs, LinphoneImEncryptionEngineDownloadingFileBufferCb cb) { - cbs->process_downlading_file_buffer = cb; -} - LinphoneImEncryptionEngineDownloadingFileCb linphone_im_encryption_engine_cbs_get_process_downloading_file(LinphoneImEncryptionEngineCbs *cbs) { - return cbs->process_downloading_file; + return cbs->process_downlading_file; } void linphone_im_encryption_engine_cbs_set_process_downloading_file(LinphoneImEncryptionEngineCbs *cbs, LinphoneImEncryptionEngineDownloadingFileCb cb) { - cbs->process_downloading_file = cb; + cbs->process_downlading_file = cb; } \ No newline at end of file diff --git a/coreapi/im_encryption_engine.h b/coreapi/im_encryption_engine.h index 095be933c..2ec8b701b 100644 --- a/coreapi/im_encryption_engine.h +++ b/coreapi/im_encryption_engine.h @@ -30,9 +30,7 @@ typedef int (*LinphoneImEncryptionEngineIncomingMessageCb)(LinphoneCore* lc, bel typedef int (*LinphoneImEncryptionEngineOutgoingMessageCb)(LinphoneCore* lc, belle_sip_request_t* req, const char *peer_uri, const char* content_type, const char* body, char** crypted_body, size_t* content_length); -typedef int (*LinphoneImEncryptionEngineDownloadingFileBufferCb)(LinphoneCore *lc, LinphoneChatMessage *msg, const char *buffer, size_t size, char **decrypted_buffer); - -typedef int (*LinphoneImEncryptionEngineDownloadingFileCb)(LinphoneCore *lc, LinphoneChatMessage *msg, const char *path); +typedef int (*LinphoneImEncryptionEngineDownloadingFileCb)(LinphoneCore *lc, LinphoneChatMessage *msg, const char *buffer, size_t size, char **decrypted_buffer); typedef struct _LinphoneImEncryptionEngineCbs LinphoneImEncryptionEngineCbs; @@ -64,10 +62,6 @@ LINPHONE_PUBLIC LinphoneImEncryptionEngineOutgoingMessageCb linphone_im_encrypti LINPHONE_PUBLIC void linphone_im_encryption_engine_cbs_set_process_outgoing_message(LinphoneImEncryptionEngineCbs *cbs, LinphoneImEncryptionEngineOutgoingMessageCb cb); -LINPHONE_PUBLIC LinphoneImEncryptionEngineDownloadingFileBufferCb linphone_im_encryption_engine_cbs_get_process_downloading_file_buffer(LinphoneImEncryptionEngineCbs *cbs); - -LINPHONE_PUBLIC void linphone_im_encryption_engine_cbs_set_process_downloading_file_buffer(LinphoneImEncryptionEngineCbs *cbs, LinphoneImEncryptionEngineDownloadingFileBufferCb cb); - LINPHONE_PUBLIC LinphoneImEncryptionEngineDownloadingFileCb linphone_im_encryption_engine_cbs_get_process_downloading_file(LinphoneImEncryptionEngineCbs *cbs); LINPHONE_PUBLIC void linphone_im_encryption_engine_cbs_set_process_downloading_file(LinphoneImEncryptionEngineCbs *cbs, LinphoneImEncryptionEngineDownloadingFileCb cb); diff --git a/coreapi/lime.c b/coreapi/lime.c index 78c6a1793..23109a662 100644 --- a/coreapi/lime.c +++ b/coreapi/lime.c @@ -929,7 +929,7 @@ int lime_im_encryption_engine_process_outgoing_message_cb(LinphoneCore* lc, bell return errcode; } -int lime_im_encryption_engine_process_downloading_file_buffer_cb(LinphoneCore *lc, LinphoneChatMessage *msg, const char *buffer, size_t size, char **decrypted_buffer) { +int lime_im_encryption_engine_process_downloading_file_cb(LinphoneCore *lc, LinphoneChatMessage *msg, const char *buffer, size_t size, char **decrypted_buffer) { if (linphone_content_get_key(msg->file_transfer_information) == NULL) return -1; if (buffer == NULL || size == 0) { @@ -941,31 +941,6 @@ int lime_im_encryption_engine_process_downloading_file_buffer_cb(LinphoneCore *l (char *)buffer); } -int lime_im_encryption_engine_process_downloading_file_cb(LinphoneCore *lc, LinphoneChatMessage *msg, const char *path) { - if (linphone_content_get_key(msg->file_transfer_information) == NULL) { - return -1; - } else { - bctbx_vfs_t *vfs = bctbx_vfs_get_default(); - bctbx_vfs_file_t *decrypted_file; - bctbx_vfs_file_t *encrypted_file = bctbx_file_open(vfs, msg->file_transfer_filepath, "r"); - size_t encrypted_file_size = (size_t)bctbx_file_size(encrypted_file); - char *encrypted_content = bctbx_malloc(encrypted_file_size); - char *decrypted_content = bctbx_malloc(encrypted_file_size); - bctbx_file_read(encrypted_file, encrypted_content, encrypted_file_size, 0); - bctbx_file_close(encrypted_file); - lime_decryptFile(linphone_content_get_cryptoContext_address(msg->file_transfer_information), - (unsigned char *)linphone_content_get_key(msg->file_transfer_information), - encrypted_file_size, decrypted_content, encrypted_content); - lime_decryptFile(linphone_content_get_cryptoContext_address(msg->file_transfer_information), NULL, 0, NULL, NULL); - decrypted_file = bctbx_file_open(vfs, msg->file_transfer_filepath, "w"); - bctbx_file_write(decrypted_file, decrypted_content, encrypted_file_size, 0); - bctbx_file_close(decrypted_file); - bctbx_free(encrypted_content); - bctbx_free(decrypted_content); - return 0; - } -} - #else /* HAVE_LIME */ bool_t lime_is_available() { return FALSE; } @@ -996,10 +971,7 @@ int lime_im_encryption_engine_process_incoming_message_cb(LinphoneCore* lc, bell int lime_im_encryption_engine_process_outgoing_message_cb(LinphoneCore* lc, belle_sip_request_t* req, const char *peer_uri, const char* content_type, const char* body, char** crypted_body, size_t* content_length) { return 500; } -int lime_im_encryption_engine_process_downloading_file_buffer_cb(LinphoneCore *lc, LinphoneChatMessage *msg, const char *buffer, size_t size, char **decrypted_buffer) { - return 500; -} -int lime_im_encryption_engine_process_downloading_file_cb(LinphoneCore *lc, LinphoneChatMessage *msg, const char *path) { +int lime_im_encryption_engine_process_downloading_file_cb(LinphoneCore *lc, LinphoneChatMessage *msg, const char *buffer, size_t size, char **decrypted_buffer) { return 500; } #endif /* HAVE_LIME */ diff --git a/coreapi/lime.h b/coreapi/lime.h index 46d6d96bc..8c6c2d00f 100644 --- a/coreapi/lime.h +++ b/coreapi/lime.h @@ -209,8 +209,6 @@ int lime_im_encryption_engine_process_incoming_message_cb(LinphoneCore* lc, bell int lime_im_encryption_engine_process_outgoing_message_cb(LinphoneCore* lc, belle_sip_request_t* req, const char *peer_uri, const char* content_type, const char* body, char** crypted_body, size_t* content_length); -int lime_im_encryption_engine_process_downloading_file_buffer_cb(LinphoneCore *lc, LinphoneChatMessage *msg, const char *buffer, size_t size, char **decrypted_buffer); - -int lime_im_encryption_engine_process_downloading_file_cb(LinphoneCore *lc, LinphoneChatMessage *msg, const char *path); +int lime_im_encryption_engine_process_downloading_file_cb(LinphoneCore *lc, LinphoneChatMessage *msg, const char *buffer, size_t size, char **decrypted_buffer); #endif /* LIME_H */ diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index e3fee2bda..882ac4045 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -1956,7 +1956,6 @@ void linphone_core_enable_lime(LinphoneCore *lc, LinphoneLimeState val){ LinphoneImEncryptionEngineCbs *cbs = linphone_im_encryption_engine_get_callbacks(imee); linphone_im_encryption_engine_cbs_set_process_incoming_message(cbs, lime_im_encryption_engine_process_incoming_message_cb); linphone_im_encryption_engine_cbs_set_process_outgoing_message(cbs, lime_im_encryption_engine_process_outgoing_message_cb); - linphone_im_encryption_engine_cbs_set_process_downloading_file_buffer(cbs, lime_im_encryption_engine_process_downloading_file_buffer_cb); linphone_im_encryption_engine_cbs_set_process_downloading_file(cbs, lime_im_encryption_engine_process_downloading_file_cb); lc->im_encryption_engine = imee; } else { From 4cb2ddcfad938991517eb1b946bdd0bf32893392 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Wed, 9 Nov 2016 17:27:53 +0100 Subject: [PATCH 11/21] Forgot to commit changes to message_tester --- tester/message_tester.c | 59 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 52 insertions(+), 7 deletions(-) diff --git a/tester/message_tester.c b/tester/message_tester.c index 70604d337..babf00259 100644 --- a/tester/message_tester.c +++ b/tester/message_tester.c @@ -74,9 +74,17 @@ void message_received(LinphoneCore *lc, LinphoneChatRoom *room, LinphoneChatMess * */ void file_transfer_received(LinphoneChatMessage *msg, const LinphoneContent* content, const LinphoneBuffer *buffer){ FILE* file=NULL; - char *receive_file = bc_tester_file("receive_file.dump"); + char *receive_file = NULL; LinphoneChatRoom *cr = linphone_chat_message_get_chat_room(msg); LinphoneCore *lc = linphone_chat_room_get_core(cr); + + if (linphone_chat_message_get_file_transfer_filepath(msg) != NULL) { + stats* counters = get_stats(lc); + counters->number_of_LinphoneFileTransferDownloadSuccessful++; + return; + } + + receive_file = bc_tester_file("receive_file.dump"); if (!linphone_chat_message_get_user_data(msg)) { /*first chunk, creating file*/ file = fopen(receive_file,"wb"); @@ -196,7 +204,7 @@ void compare_files(const char *path1, const char *path2) { buf2 = (uint8_t*)ms_load_path_content(path2, &size2); BC_ASSERT_PTR_NOT_NULL(buf1); BC_ASSERT_PTR_NOT_NULL(buf2); - BC_ASSERT_EQUAL((uint8_t)size1, (uint8_t)size2, uint8_t, "%u"); + BC_ASSERT_EQUAL((uint8_t)size2, (uint8_t)size1, uint8_t, "%u"); BC_ASSERT_EQUAL(memcmp(buf1, buf2, size1), 0, int, "%d"); ms_free(buf1); ms_free(buf2); @@ -234,6 +242,30 @@ LinphoneChatMessage* create_message_from_nowebcam(LinphoneChatRoom *chat_room) { return msg; } +LinphoneChatMessage* create_file_transfer_message_from_nowebcam(LinphoneChatRoom *chat_room) { + LinphoneChatMessageCbs *cbs; + LinphoneContent* content; + LinphoneChatMessage* msg; + char *send_filepath = bc_tester_res("images/nowebcamCIF.jpg"); + + content = linphone_core_create_content(chat_room->lc); + belle_sip_object_set_name(&content->base, "nowebcam content"); + linphone_content_set_type(content,"image"); + linphone_content_set_subtype(content,"jpeg"); + linphone_content_set_name(content,"nowebcamCIF.jpg"); + + + msg = linphone_chat_room_create_file_transfer_message(chat_room, content); + linphone_chat_message_set_file_transfer_filepath(msg, send_filepath); + cbs = linphone_chat_message_get_callbacks(msg); + linphone_chat_message_cbs_set_msg_state_changed(cbs,liblinphone_tester_chat_message_msg_state_changed); + linphone_chat_message_cbs_set_file_transfer_progress_indication(cbs, file_transfer_progress_indication); + + linphone_content_unref(content); + ms_free(send_filepath); + return msg; +} + void text_message_base(LinphoneCoreManager* marie, LinphoneCoreManager* pauline) { LinphoneChatMessage* msg = linphone_chat_room_create_message(linphone_core_get_chat_room(pauline->lc,marie->identity),"Bli bli bli \n blu"); LinphoneChatMessageCbs *cbs = linphone_chat_message_get_callbacks(msg); @@ -857,7 +889,7 @@ end: linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); } -void lime_transfer_message_base(bool_t encrypt_file,bool_t download_file_from_stored_msg) { +void lime_transfer_message_base(bool_t encrypt_file,bool_t download_file_from_stored_msg, bool_t use_file_body_handler) { FILE *ZIDCacheMarieFD, *ZIDCachePaulineFD; LinphoneCoreManager *marie, *pauline; LinphoneChatMessage *msg; @@ -906,7 +938,11 @@ void lime_transfer_message_base(bool_t encrypt_file,bool_t download_file_from_st linphone_core_set_file_transfer_server(pauline->lc,"https://www.linphone.org:444/lft.php"); /* create a file transfer msg */ - msg = create_message_from_nowebcam(linphone_core_get_chat_room(pauline->lc, marie->identity)); + if (use_file_body_handler) { + msg = create_file_transfer_message_from_nowebcam(linphone_core_get_chat_room(pauline->lc, marie->identity)); + } else { + msg = create_message_from_nowebcam(linphone_core_get_chat_room(pauline->lc, marie->identity)); + } linphone_chat_room_send_chat_message(msg->chat_room, msg); BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneMessageReceivedWithFile,1)); @@ -932,6 +968,10 @@ void lime_transfer_message_base(bool_t encrypt_file,bool_t download_file_from_st BC_ASSERT_PTR_NOT_NULL(linphone_content_get_key(content)); else BC_ASSERT_PTR_NULL(linphone_content_get_key(content)); + + if (use_file_body_handler) { + linphone_chat_message_set_file_transfer_filepath(recv_msg, receive_filepath); + } linphone_chat_message_download_file(recv_msg); BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneFileTransferDownloadSuccessful,1)); compare_files(send_filepath, receive_filepath); @@ -948,15 +988,19 @@ end: } static void lime_transfer_message(void) { - lime_transfer_message_base(TRUE,FALSE); + lime_transfer_message_base(TRUE,FALSE,FALSE); +} + +static void lime_transfer_message_2(void) { + lime_transfer_message_base(TRUE,FALSE,TRUE); } static void lime_transfer_message_from_history(void) { - lime_transfer_message_base(TRUE,TRUE); + lime_transfer_message_base(TRUE,TRUE,FALSE); } static void lime_transfer_message_without_encryption(void) { - lime_transfer_message_base(FALSE,FALSE); + lime_transfer_message_base(FALSE,FALSE,FALSE); } static void printHex(char *title, uint8_t *data, size_t length) { @@ -1856,6 +1900,7 @@ test_t message_tests[] = { TEST_NO_TAG("Lime text message", lime_text_message), TEST_NO_TAG("Lime text message to non lime", lime_text_message_to_non_lime), TEST_NO_TAG("Lime transfer message", lime_transfer_message), + TEST_NO_TAG("Lime transfer message 2", lime_transfer_message_2), TEST_NO_TAG("Lime transfer message from history", lime_transfer_message_from_history), TEST_NO_TAG("Lime transfer message without encryption", lime_transfer_message_without_encryption), TEST_NO_TAG("Lime unitary", lime_unit), From 7f9c7dcbf9a6b3a7b871e31850342dff1fe29058 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Wed, 9 Nov 2016 17:45:17 +0100 Subject: [PATCH 12/21] Added file body handler message tests for non-lime messages as well --- tester/message_tester.c | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/tester/message_tester.c b/tester/message_tester.c index babf00259..77ba69b18 100644 --- a/tester/message_tester.c +++ b/tester/message_tester.c @@ -443,7 +443,7 @@ static void text_message_with_external_body(void) { linphone_core_manager_destroy(pauline); } -void transfer_message_base2(LinphoneCoreManager* marie, LinphoneCoreManager* pauline, bool_t upload_error, bool_t download_error) { +void transfer_message_base2(LinphoneCoreManager* marie, LinphoneCoreManager* pauline, bool_t upload_error, bool_t download_error, bool_t use_file_body_handler) { char *send_filepath = bc_tester_res("images/nowebcamCIF.jpg"); char *receive_filepath = bc_tester_file("receive_file.dump"); LinphoneChatRoom* chat_room; @@ -456,7 +456,12 @@ void transfer_message_base2(LinphoneCoreManager* marie, LinphoneCoreManager* pau /* create a chatroom on pauline's side */ chat_room = linphone_core_get_chat_room(pauline->lc, marie->identity); /* create a file transfer msg */ - msg = create_message_from_nowebcam(chat_room); + if (use_file_body_handler) { + msg = create_file_transfer_message_from_nowebcam(chat_room); + } else { + msg = create_message_from_nowebcam(chat_room); + } + linphone_chat_room_send_chat_message(chat_room,msg); if (upload_error) { @@ -480,6 +485,9 @@ void transfer_message_base2(LinphoneCoreManager* marie, LinphoneCoreManager* pau linphone_chat_message_cbs_set_msg_state_changed(cbs, liblinphone_tester_chat_message_msg_state_changed); linphone_chat_message_cbs_set_file_transfer_recv(cbs, file_transfer_received); linphone_chat_message_cbs_set_file_transfer_progress_indication(cbs, file_transfer_progress_indication); + if (use_file_body_handler) { + linphone_chat_message_set_file_transfer_filepath(marie->stat.last_received_chat_message, receive_filepath); + } linphone_chat_message_download_file(marie->stat.last_received_chat_message); if (download_error) { @@ -503,25 +511,29 @@ void transfer_message_base2(LinphoneCoreManager* marie, LinphoneCoreManager* pau bc_free(receive_filepath); } -void transfer_message_base(bool_t upload_error, bool_t download_error) { +void transfer_message_base(bool_t upload_error, bool_t download_error, bool_t use_file_body_handler) { if (transport_supported(LinphoneTransportTls)) { LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_tcp_rc"); - transfer_message_base2(marie,pauline,upload_error,download_error); + transfer_message_base2(marie,pauline,upload_error,download_error, use_file_body_handler); linphone_core_manager_destroy(pauline); linphone_core_manager_destroy(marie); } } static void transfer_message(void) { - transfer_message_base(FALSE, FALSE); + transfer_message_base(FALSE, FALSE, FALSE); +} + +static void transfer_message_2(void) { + transfer_message_base(FALSE, FALSE, TRUE); } static void transfer_message_with_upload_io_error(void) { - transfer_message_base(TRUE, FALSE); + transfer_message_base(TRUE, FALSE, FALSE); } static void transfer_message_with_download_io_error(void) { - transfer_message_base(FALSE, TRUE); + transfer_message_base(FALSE, TRUE, FALSE); } static void transfer_message_upload_cancelled(void) { @@ -1003,6 +1015,10 @@ static void lime_transfer_message_without_encryption(void) { lime_transfer_message_base(FALSE,FALSE,FALSE); } +static void lime_transfer_message_without_encryption_2(void) { + lime_transfer_message_base(FALSE,FALSE,TRUE); +} + static void printHex(char *title, uint8_t *data, size_t length) { size_t i; char debug_string_buffer[2048]; @@ -1870,7 +1886,7 @@ void file_transfer_with_http_proxy(void) { LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_tcp_rc"); linphone_core_set_http_proxy_host(marie->lc, "sip.linphone.org"); - transfer_message_base2(marie,pauline,FALSE,FALSE); + transfer_message_base2(marie,pauline,FALSE,FALSE,FALSE); linphone_core_manager_destroy(pauline); linphone_core_manager_destroy(marie); } @@ -1886,6 +1902,7 @@ test_t message_tests[] = { TEST_NO_TAG("Text message with send error", text_message_with_send_error), TEST_NO_TAG("Text message with external body", text_message_with_external_body), TEST_NO_TAG("Transfer message", transfer_message), + TEST_NO_TAG("Transfer message 2", transfer_message_2), TEST_NO_TAG("Transfer message with http proxy", file_transfer_with_http_proxy), TEST_NO_TAG("Transfer message with upload io error", transfer_message_with_upload_io_error), TEST_NO_TAG("Transfer message with download io error", transfer_message_with_download_io_error), @@ -1903,6 +1920,7 @@ test_t message_tests[] = { TEST_NO_TAG("Lime transfer message 2", lime_transfer_message_2), TEST_NO_TAG("Lime transfer message from history", lime_transfer_message_from_history), TEST_NO_TAG("Lime transfer message without encryption", lime_transfer_message_without_encryption), + TEST_NO_TAG("Lime transfer message without encryption 2", lime_transfer_message_without_encryption_2), TEST_NO_TAG("Lime unitary", lime_unit), #ifdef SQLITE_STORAGE_ENABLED TEST_NO_TAG("Database migration", database_migration), From 3214b4371ad109269a008aa9471a91e8e0b49cd5 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Thu, 10 Nov 2016 12:02:56 +0100 Subject: [PATCH 13/21] Reworked im encryption engine to be at linphone level instead of sal level --- coreapi/bellesip_sal/sal_op_message.c | 103 +++------------- coreapi/callbacks.c | 7 +- coreapi/chat.c | 168 ++++++++++++-------------- coreapi/im_encryption_engine.h | 4 +- coreapi/lime.c | 106 +++++++++++++--- coreapi/lime.h | 4 +- coreapi/linphonecore.c | 43 +++++++ coreapi/linphonecore.h | 8 +- coreapi/private.h | 2 +- 9 files changed, 241 insertions(+), 204 deletions(-) diff --git a/coreapi/bellesip_sal/sal_op_message.c b/coreapi/bellesip_sal/sal_op_message.c index c1858b4b4..07a59ae75 100644 --- a/coreapi/bellesip_sal/sal_op_message.c +++ b/coreapi/bellesip_sal/sal_op_message.c @@ -59,16 +59,6 @@ static void process_response_event(void *op_base, const belle_sip_response_event op->base.root->callbacks.text_delivery_update(op,status); } -static bool_t is_rcs_filetransfer(belle_sip_header_content_type_t* content_type) { - return (strcmp("application",belle_sip_header_content_type_get_type(content_type))==0) - && ((strcmp("vnd.gsma.rcs-ft-http+xml",belle_sip_header_content_type_get_subtype(content_type))==0) || (strcmp("cipher.vnd.gsma.rcs-ft-http+xml",belle_sip_header_content_type_get_subtype(content_type))==0)); -} - -static bool_t is_plain_text(belle_sip_header_content_type_t* content_type) { - return strcmp("text",belle_sip_header_content_type_get_type(content_type))==0 - && strcmp("plain",belle_sip_header_content_type_get_subtype(content_type))==0; -} - static bool_t is_external_body(belle_sip_header_content_type_t* content_type) { return strcmp("message",belle_sip_header_content_type_get_type(content_type))==0 && strcmp("external-body",belle_sip_header_content_type_get_subtype(content_type))==0; @@ -94,40 +84,29 @@ void sal_process_incoming_message(SalOp *op,const belle_sip_request_event_t *eve belle_sip_header_cseq_t* cseq = belle_sip_message_get_header_by_type(req,belle_sip_header_cseq_t); belle_sip_header_date_t *date=belle_sip_message_get_header_by_type(req,belle_sip_header_date_t); char* from; - bool_t plain_text=FALSE; bool_t external_body=FALSE; - bool_t cipher_xml=FALSE; - bool_t rcs_filetransfer=FALSE; - uint8_t *decryptedMessage = NULL; - LinphoneCore *lc = (LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(op)); - int retval = -1; from_header=belle_sip_message_get_header_by_type(BELLE_SIP_MESSAGE(req),belle_sip_header_from_t); content_type=belle_sip_message_get_header_by_type(BELLE_SIP_MESSAGE(req),belle_sip_header_content_type_t); if (content_type) { - LinphoneImEncryptionEngine *imee = linphone_core_get_im_encryption_engine(lc); - if (imee) { - LinphoneImEncryptionEngineCbs *imee_cbs = linphone_im_encryption_engine_get_callbacks(imee); - LinphoneImEncryptionEngineIncomingMessageCb cb_process_incoming_message = linphone_im_encryption_engine_cbs_get_process_incoming_message(imee_cbs); - if (cb_process_incoming_message) { - retval = cb_process_incoming_message(lc, req, belle_sip_header_content_type_get_type(content_type), belle_sip_header_content_type_get_subtype(content_type), - belle_sip_message_get_body(BELLE_SIP_MESSAGE(req)), (char **)&decryptedMessage); - } - } - cipher_xml = retval >= 0; - if (retval > 0) { - errcode = retval; - goto error; - } - - external_body=is_external_body(content_type); - plain_text=is_plain_text(content_type); - rcs_filetransfer = is_rcs_filetransfer(content_type); - - if (external_body || plain_text || rcs_filetransfer || decryptedMessage!=NULL) { + if (is_im_iscomposing(content_type)) { + SalIsComposing saliscomposing; + address=belle_sip_header_address_create(belle_sip_header_address_get_displayname(BELLE_SIP_HEADER_ADDRESS(from_header)) + ,belle_sip_header_address_get_uri(BELLE_SIP_HEADER_ADDRESS(from_header))); + from=belle_sip_object_to_string(BELLE_SIP_OBJECT(address)); + saliscomposing.from=from; + saliscomposing.text=belle_sip_message_get_body(BELLE_SIP_MESSAGE(req)); + op->base.root->callbacks.is_composing_received(op,&saliscomposing); + resp = belle_sip_response_create_from_request(req,200); + belle_sip_server_transaction_send_response(server_transaction,resp); + belle_sip_object_unref(address); + belle_sip_free(from); + } else { SalMessage salmsg; char message_id[256]={0}; + + external_body=is_external_body(content_type); if (op->pending_server_trans) belle_sip_object_unref(op->pending_server_trans); op->pending_server_trans=server_transaction; @@ -141,16 +120,9 @@ void sal_process_incoming_message(SalOp *op,const belle_sip_request_event_t *eve ,belle_sip_header_cseq_get_seq_number(cseq)); salmsg.from=from; /* if we just deciphered a message, use the deciphered part(which can be a rcs xml body pointing to the file to retreive from server)*/ - if (cipher_xml) { - salmsg.text = (char *)decryptedMessage; - } else { /* message body wasn't ciphered */ - salmsg.text=(plain_text||rcs_filetransfer)?belle_sip_message_get_body(BELLE_SIP_MESSAGE(req)):NULL; - } + salmsg.text=(!external_body)?belle_sip_message_get_body(BELLE_SIP_MESSAGE(req)):NULL; salmsg.url=NULL; - salmsg.content_type = NULL; - if (rcs_filetransfer) { /* if we have a rcs file transfer, set the type, message body (stored in salmsg.text) contains all needed information to retrieve the file */ - salmsg.content_type = "application/vnd.gsma.rcs-ft-http+xml"; - } + salmsg.content_type = ms_strdup_printf("%s/%s", belle_sip_header_content_type_get_type(content_type), belle_sip_header_content_type_get_subtype(content_type)); if (external_body && belle_sip_parameters_get_parameter(BELLE_SIP_PARAMETERS(content_type),"URL")) { size_t url_length=strlen(belle_sip_parameters_get_parameter(BELLE_SIP_PARAMETERS(content_type),"URL")); salmsg.url = ms_strdup(belle_sip_parameters_get_parameter(BELLE_SIP_PARAMETERS(content_type),"URL")+1); /* skip first "*/ @@ -160,28 +132,11 @@ void sal_process_incoming_message(SalOp *op,const belle_sip_request_event_t *eve salmsg.time=date ? belle_sip_header_date_get_time(date) : time(NULL); op->base.root->callbacks.text_received(op,&salmsg); - free(decryptedMessage); belle_sip_object_unref(address); belle_sip_free(from); if (salmsg.url) ms_free((char*)salmsg.url); - } else if (is_im_iscomposing(content_type)) { - SalIsComposing saliscomposing; - address=belle_sip_header_address_create(belle_sip_header_address_get_displayname(BELLE_SIP_HEADER_ADDRESS(from_header)) - ,belle_sip_header_address_get_uri(BELLE_SIP_HEADER_ADDRESS(from_header))); - from=belle_sip_object_to_string(BELLE_SIP_OBJECT(address)); - saliscomposing.from=from; - saliscomposing.text=belle_sip_message_get_body(BELLE_SIP_MESSAGE(req)); - op->base.root->callbacks.is_composing_received(op,&saliscomposing); - resp = belle_sip_response_create_from_request(req,200); - belle_sip_server_transaction_send_response(server_transaction,resp); - belle_sip_object_unref(address); - belle_sip_free(from); - }else{ - ms_error("Unsupported MESSAGE (content-type not recognized)"); - errcode = 415; - goto error; } - }else { + } else { ms_error("Unsupported MESSAGE (no Content-Type)"); goto error; } @@ -203,11 +158,8 @@ int sal_message_send(SalOp *op, const char *from, const char *to, const char* co char content_type_raw[256]; size_t content_length = msg?strlen(msg):0; time_t curtime = ms_time(NULL); - uint8_t *multipartEncryptedMessage = NULL; const char *body; - int retval = -1; - LinphoneCore *lc = (LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(op)); - LinphoneImEncryptionEngine *imee = linphone_core_get_im_encryption_engine(lc); + int retval; if (op->dialog){ /*for SIP MESSAGE that are sent in call's dialog*/ @@ -229,31 +181,16 @@ int sal_message_send(SalOp *op, const char *from, const char *to, const char* co } } - if (imee) { - LinphoneImEncryptionEngineCbs *imee_cbs = linphone_im_encryption_engine_get_callbacks(imee); - LinphoneImEncryptionEngineOutgoingMessageCb cb_process_outgoing_message = linphone_im_encryption_engine_cbs_get_process_outgoing_message(imee_cbs); - if (cb_process_outgoing_message) { - retval = cb_process_outgoing_message(lc, req, peer_uri, content_type, msg, (char **)&multipartEncryptedMessage, &content_length); - } - } - if (retval > 0) { - /*probably not a good idea to do this:*/ - sal_error_info_set(&op->error_info, SalReasonNotAcceptable, retval, "Unable to encrypt IM", NULL); - op->base.root->callbacks.text_delivery_update(op, SalTextDeliveryFailed); - return -1; - } - snprintf(content_type_raw,sizeof(content_type_raw),BELLE_SIP_CONTENT_TYPE ": %s",content_type); belle_sip_message_add_header(BELLE_SIP_MESSAGE(req),BELLE_SIP_HEADER(belle_sip_header_content_type_parse(content_type_raw))); belle_sip_message_add_header(BELLE_SIP_MESSAGE(req),BELLE_SIP_HEADER(belle_sip_header_content_length_create(content_length))); belle_sip_message_add_header(BELLE_SIP_MESSAGE(req),BELLE_SIP_HEADER(belle_sip_header_date_create_from_time(&curtime))); - body = (multipartEncryptedMessage==NULL) ? msg : (char*) multipartEncryptedMessage; + body = msg; if (body){ /*don't call set_body() with null argument because it resets content type and content length*/ belle_sip_message_set_body(BELLE_SIP_MESSAGE(req), body, content_length); } retval = sal_op_send_request(op,req); - free(multipartEncryptedMessage); return retval; } diff --git a/coreapi/callbacks.c b/coreapi/callbacks.c index 9e6e359fb..b9275a57d 100644 --- a/coreapi/callbacks.c +++ b/coreapi/callbacks.c @@ -1159,10 +1159,11 @@ static bool_t is_duplicate_msg(LinphoneCore *lc, const char *msg_id){ static void text_received(SalOp *op, const SalMessage *msg){ LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(op)); LinphoneCall *call=(LinphoneCall*)sal_op_get_user_pointer(op); - if (lc->chat_deny_code==LinphoneReasonNone && is_duplicate_msg(lc,msg->message_id)==FALSE){ - linphone_core_message_received(lc,op,msg); + LinphoneReason reason = lc->chat_deny_code; + if (reason == LinphoneReasonNone && is_duplicate_msg(lc, msg->message_id) == FALSE) { + reason = linphone_core_message_received(lc, op, msg); } - sal_message_reply(op,linphone_reason_to_sal(lc->chat_deny_code)); + sal_message_reply(op,linphone_reason_to_sal(reason)); if (!call) sal_op_release(op); } diff --git a/coreapi/chat.c b/coreapi/chat.c index 933909121..98f3ed0cd 100644 --- a/coreapi/chat.c +++ b/coreapi/chat.c @@ -27,7 +27,6 @@ #include "lpconfig.h" #include "belle-sip/belle-sip.h" #include "ortp/b64.h" -#include "lime.h" #include #include @@ -265,50 +264,6 @@ LinphoneChatRoom *linphone_core_get_chat_room_from_uri(LinphoneCore *lc, const c return _linphone_core_get_or_create_chat_room(lc, to); } -bool_t linphone_chat_room_lime_available(LinphoneChatRoom *cr) { - if (cr) { - switch (linphone_core_lime_enabled(cr->lc)) { - case LinphoneLimeDisabled: return FALSE; - case LinphoneLimeMandatory: return TRUE; - case LinphoneLimePreferred: { - FILE *CACHEFD = NULL; - if (cr->lc->zrtp_secrets_cache != NULL) { - CACHEFD = fopen(cr->lc->zrtp_secrets_cache, "rb+"); - if (CACHEFD) { - size_t cacheSize; - xmlDocPtr cacheXml; - char *cacheString=ms_load_file_content(CACHEFD, &cacheSize); - if (!cacheString){ - ms_warning("Unable to load content of ZRTP ZID cache to decrypt message"); - return FALSE; - } - cacheString[cacheSize] = '\0'; - cacheSize += 1; - fclose(CACHEFD); - cacheXml = xmlParseDoc((xmlChar*)cacheString); - ms_free(cacheString); - if (cacheXml) { - bool_t res; - limeURIKeys_t associatedKeys; - /* retrieve keys associated to the peer URI */ - associatedKeys.peerURI = (uint8_t *)malloc(strlen(cr->peer)+1); - strcpy((char *)(associatedKeys.peerURI), cr->peer); - associatedKeys.associatedZIDNumber = 0; - associatedKeys.peerKeys = NULL; - - res = (lime_getCachedSndKeysByURI(cacheXml, &associatedKeys) == 0 && associatedKeys.associatedZIDNumber != 0); - lime_freeKeys(&associatedKeys); - xmlFreeDoc(cacheXml); - return res; - } - } - } - } - } - } - return FALSE; -} - static void linphone_chat_room_delete_composing_idle_timer(LinphoneChatRoom *cr) { if (cr->composing_idle_timer) { if (cr->lc && cr->lc->sal) @@ -366,6 +321,10 @@ void linphone_chat_room_set_user_data(LinphoneChatRoom *cr, void *ud) { } void _linphone_chat_room_send_message(LinphoneChatRoom *cr, LinphoneChatMessage *msg) { + int retval = -1; + LinphoneCore *lc = cr->lc; + LinphoneImEncryptionEngine *imee = lc->im_encryption_engine; + /*stubed rtt text*/ if (cr->call && linphone_call_params_realtime_text_enabled(linphone_call_get_current_params(cr->call))) { uint32_t new_line = 0x2028; @@ -406,6 +365,15 @@ void _linphone_chat_room_send_message(LinphoneChatRoom *cr, LinphoneChatMessage } } } + + if (imee) { + LinphoneImEncryptionEngineCbs *imee_cbs = linphone_im_encryption_engine_get_callbacks(imee); + LinphoneImEncryptionEngineOutgoingMessageCb cb_process_outgoing_message = linphone_im_encryption_engine_cbs_get_process_outgoing_message(imee_cbs); + if (cb_process_outgoing_message) { + retval = cb_process_outgoing_message(lc, cr, msg); + } + } + if (op == NULL) { LinphoneProxyConfig *proxy = linphone_core_lookup_known_proxy(cr->lc, cr->peer_url); if (proxy) { @@ -418,6 +386,13 @@ void _linphone_chat_room_send_message(LinphoneChatRoom *cr, LinphoneChatMessage lp_config_get_int(cr->lc->config, "sip", "chat_msg_with_contact", 0)); sal_op_set_user_pointer(op, msg); /*if out of call, directly store msg*/ } + + if (retval > 0) { + sal_error_info_set((SalErrorInfo *)sal_op_get_error_info(op), SalReasonNotAcceptable, retval, "Unable to encrypt IM", NULL); + linphone_chat_message_update_state(msg, LinphoneChatMessageStateNotDelivered); + linphone_chat_message_unref(msg); + return; + } if (msg->external_body_url) { content_type = ms_strdup_printf("message/external-body; access-type=URL; URL=\"%s\"", msg->external_body_url); @@ -425,21 +400,7 @@ void _linphone_chat_room_send_message(LinphoneChatRoom *cr, LinphoneChatMessage ms_free(content_type); } else { char *peer_uri = linphone_address_as_string_uri_only(linphone_chat_room_get_peer_address(cr)); - const char *content_type; - - if (linphone_chat_room_lime_available(cr)) { - /* ref the msg or it may be destroyed by callback if the encryption failed */ - if (msg->content_type && strcmp(msg->content_type, "application/vnd.gsma.rcs-ft-http+xml") == 0) { - /* it's a file transfer, content type shall be set to - application/cipher.vnd.gsma.rcs-ft-http+xml*/ - content_type = "application/cipher.vnd.gsma.rcs-ft-http+xml"; - } else { - content_type = "xml/cipher"; - } - } else { - content_type = msg->content_type; - } - + const char *content_type = msg->content_type; if (content_type == NULL) { sal_text_send(op, identity, cr->peer, msg->message); } else { @@ -509,30 +470,68 @@ void linphone_chat_room_message_received(LinphoneChatRoom *cr, LinphoneCore *lc, linphone_core_notify_is_composing_received(cr->lc, cr); } -void linphone_core_message_received(LinphoneCore *lc, SalOp *op, const SalMessage *sal_msg) { +LinphoneReason linphone_core_message_received(LinphoneCore *lc, SalOp *op, const SalMessage *sal_msg) { LinphoneChatRoom *cr = NULL; LinphoneAddress *addr; + LinphoneAddress *to; LinphoneChatMessage *msg; + LinphoneImEncryptionEngine *imee = lc->im_encryption_engine; const SalCustomHeader *ch; + LinphoneReason reason = LinphoneReasonNone; + int retval = -1; addr = linphone_address_new(sal_msg->from); linphone_address_clean(addr); cr = linphone_core_get_chat_room(lc, addr); - if (sal_msg->content_type != - NULL) { /* content_type field is, for now, used only for rcs file transfer but we shall strcmp it with - "application/vnd.gsma.rcs-ft-http+xml" */ + msg = linphone_chat_room_create_message(cr, sal_msg->text); /* create a msg with empty body */ + msg->content_type = ms_strdup(sal_msg->content_type); /* add the content_type "application/vnd.gsma.rcs-ft-http+xml" */ + linphone_chat_message_set_from(msg, cr->peer_url); + + to = sal_op_get_to(op) ? linphone_address_new(sal_op_get_to(op)) : linphone_address_new(linphone_core_get_identity(lc)); + msg->to = to; + + msg->time = sal_msg->time; + msg->state = LinphoneChatMessageStateDelivered; + msg->is_read = FALSE; + msg->dir = LinphoneChatMessageIncoming; + + ch = sal_op_get_recv_custom_header(op); + if (ch) { + msg->custom_headers = sal_custom_header_clone(ch); + } + + if (sal_msg->url) { + linphone_chat_message_set_external_body_url(msg, sal_msg->url); + } + + if (imee) { + LinphoneImEncryptionEngineCbs *imee_cbs = linphone_im_encryption_engine_get_callbacks(imee); + LinphoneImEncryptionEngineIncomingMessageCb cb_process_incoming_message = linphone_im_encryption_engine_cbs_get_process_incoming_message(imee_cbs); + if (cb_process_incoming_message) { + retval = cb_process_incoming_message(lc, cr, msg); + } + } + + if (retval < 0 && strcmp("text/plain", msg->content_type) != 0 && strcmp("message/external-body", msg->content_type) != 0 + && strcmp("application/vnd.gsma.rcs-ft-http+xml", msg->content_type) != 0) { + retval = 415; + ms_error("Unsupported MESSAGE (content-type %s not recognized)", msg->content_type); + } + + if (retval > 0) { + reason = linphone_error_code_to_reason(retval); + goto end; + } + + if (strcmp("application/vnd.gsma.rcs-ft-http+xml", msg->content_type) == 0) { xmlChar *file_url = NULL; xmlDocPtr xmlMessageBody; xmlNodePtr cur; - - msg = linphone_chat_room_create_message(cr, NULL); /* create a msg with empty body */ - msg->content_type = - ms_strdup(sal_msg->content_type); /* add the content_type "application/vnd.gsma.rcs-ft-http+xml" */ - msg->file_transfer_information = linphone_content_new(); - + /* content_type field is, for now, used only for rcs file transfer but we shall strcmp it with "application/vnd.gsma.rcs-ft-http+xml" */ /* parse the msg body to get all informations from it */ - xmlMessageBody = xmlParseDoc((const xmlChar *)sal_msg->text); + xmlMessageBody = xmlParseDoc((const xmlChar *)msg->message); + msg->file_transfer_information = linphone_content_new(); cur = xmlDocGetRootElement(xmlMessageBody); if (cur != NULL) { @@ -609,31 +608,8 @@ void linphone_core_message_received(LinphoneCore *lc, SalOp *op, const SalMessag linphone_chat_message_set_external_body_url(msg, (const char *)file_url); xmlFree(file_url); - } else { /* msg is not rcs file transfer, create it with provided sal_msg->text as ->msg */ - msg = linphone_chat_room_create_message(cr, sal_msg->text); - } - linphone_chat_message_set_from(msg, cr->peer_url); - - { - LinphoneAddress *to; - to = sal_op_get_to(op) ? linphone_address_new(sal_op_get_to(op)) - : linphone_address_new(linphone_core_get_identity(lc)); - msg->to = to; } - msg->time = sal_msg->time; - msg->state = LinphoneChatMessageStateDelivered; - msg->is_read = FALSE; - msg->dir = LinphoneChatMessageIncoming; - ch = sal_op_get_recv_custom_header(op); - if (ch) - msg->custom_headers = sal_custom_header_clone(ch); - - if (sal_msg->url) { - linphone_chat_message_set_external_body_url(msg, sal_msg->url); - } - - linphone_address_destroy(addr); msg->storage_id = linphone_chat_message_store(msg); if (cr->unread_count < 0) @@ -642,7 +618,11 @@ void linphone_core_message_received(LinphoneCore *lc, SalOp *op, const SalMessag cr->unread_count++; linphone_chat_room_message_received(cr, lc, msg); + +end: + linphone_address_destroy(addr); linphone_chat_message_unref(msg); + return reason; } static int linphone_chat_room_remote_refresh_composing_expired(void *data, unsigned int revents) { diff --git a/coreapi/im_encryption_engine.h b/coreapi/im_encryption_engine.h index 2ec8b701b..d9b2c63b3 100644 --- a/coreapi/im_encryption_engine.h +++ b/coreapi/im_encryption_engine.h @@ -26,9 +26,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #define LINPHONE_PUBLIC MS2_PUBLIC #endif -typedef int (*LinphoneImEncryptionEngineIncomingMessageCb)(LinphoneCore* lc, belle_sip_request_t* req, const char* content_type, const char* content_subtype, const char* body, char** decrypted_body); +typedef int (*LinphoneImEncryptionEngineIncomingMessageCb)(LinphoneCore* lc, LinphoneChatRoom *room, LinphoneChatMessage *msg); -typedef int (*LinphoneImEncryptionEngineOutgoingMessageCb)(LinphoneCore* lc, belle_sip_request_t* req, const char *peer_uri, const char* content_type, const char* body, char** crypted_body, size_t* content_length); +typedef int (*LinphoneImEncryptionEngineOutgoingMessageCb)(LinphoneCore* lc, LinphoneChatRoom *room, LinphoneChatMessage *msg); typedef int (*LinphoneImEncryptionEngineDownloadingFileCb)(LinphoneCore *lc, LinphoneChatMessage *msg, const char *buffer, size_t size, char **decrypted_buffer); diff --git a/coreapi/lime.c b/coreapi/lime.c index 23109a662..575c8588a 100644 --- a/coreapi/lime.c +++ b/coreapi/lime.c @@ -812,17 +812,54 @@ int lime_decryptMultipartMessage(xmlDocPtr cacheBuffer, uint8_t *message, uint8_ return 0; } -static bool_t is_cipher_xml(const char* content_type, const char *content_subtype) { - return (strcmp("xml",content_type)==0 - && strcmp("cipher",content_subtype)==0) - || (strcmp("application",content_type)==0 - && strcmp("cipher.vnd.gsma.rcs-ft-http+xml",content_subtype)==0); +bool_t linphone_chat_room_lime_available(LinphoneChatRoom *cr) { + if (cr) { + switch (linphone_core_lime_enabled(cr->lc)) { + case LinphoneLimeDisabled: return FALSE; + case LinphoneLimeMandatory: return TRUE; + case LinphoneLimePreferred: { + FILE *CACHEFD = NULL; + if (cr->lc->zrtp_secrets_cache != NULL) { + CACHEFD = fopen(cr->lc->zrtp_secrets_cache, "rb+"); + if (CACHEFD) { + size_t cacheSize; + xmlDocPtr cacheXml; + char *cacheString=ms_load_file_content(CACHEFD, &cacheSize); + if (!cacheString){ + ms_warning("Unable to load content of ZRTP ZID cache to decrypt message"); + return FALSE; + } + cacheString[cacheSize] = '\0'; + cacheSize += 1; + fclose(CACHEFD); + cacheXml = xmlParseDoc((xmlChar*)cacheString); + ms_free(cacheString); + if (cacheXml) { + bool_t res; + limeURIKeys_t associatedKeys; + /* retrieve keys associated to the peer URI */ + associatedKeys.peerURI = (uint8_t *)malloc(strlen(cr->peer)+1); + strcpy((char *)(associatedKeys.peerURI), cr->peer); + associatedKeys.associatedZIDNumber = 0; + associatedKeys.peerKeys = NULL; + + res = (lime_getCachedSndKeysByURI(cacheXml, &associatedKeys) == 0 && associatedKeys.associatedZIDNumber != 0); + lime_freeKeys(&associatedKeys); + xmlFreeDoc(cacheXml); + return res; + } + } + } + } + } + } + return FALSE; } -int lime_im_encryption_engine_process_incoming_message_cb(LinphoneCore* lc, belle_sip_request_t* req, const char* content_type, const char* content_subtype, const char* body, char** decrypted_body) { +int lime_im_encryption_engine_process_incoming_message_cb(LinphoneCore* lc, LinphoneChatRoom *room, LinphoneChatMessage *msg) { int errcode = -1; /* check if we have a xml/cipher message to be decrypted */ - if (is_cipher_xml(content_type, content_subtype)) { + if (msg->content_type && (strcmp("xml/cipher", msg->content_type) == 0 || strcmp("application/cipher.vnd.gsma.rcs-ft-http+xml", msg->content_type) == 0)) { /* access the zrtp cache to get keys needed to decipher the message */ FILE *CACHEFD = NULL; const char *zrtp_secrets_cache = linphone_core_get_zrtp_secrets_file(lc); @@ -837,6 +874,7 @@ int lime_im_encryption_engine_process_incoming_message_cb(LinphoneCore* lc, bell char *cacheString; int retval; xmlDocPtr cacheXml; + uint8_t *decrypted_body = NULL; cacheString=ms_load_file_content(CACHEFD, &cacheSize); if (!cacheString){ @@ -849,10 +887,10 @@ int lime_im_encryption_engine_process_incoming_message_cb(LinphoneCore* lc, bell fclose(CACHEFD); cacheXml = xmlParseDoc((xmlChar*)cacheString); ms_free(cacheString); - retval = lime_decryptMultipartMessage(cacheXml, (uint8_t *)body, (uint8_t **)decrypted_body); + retval = lime_decryptMultipartMessage(cacheXml, (uint8_t *)msg->message, &decrypted_body); if (retval != 0) { ms_warning("Unable to decrypt message, reason : %s", lime_error_code_to_string(retval)); - if (*decrypted_body) free(*decrypted_body); + if (decrypted_body) free(decrypted_body); xmlFreeDoc(cacheXml); errcode = 488; return errcode; @@ -868,6 +906,18 @@ int lime_im_encryption_engine_process_incoming_message_cb(LinphoneCore* lc, bell } xmlFree(xmlStringOutput); fclose(CACHEFD); + if (msg->message) { + ms_free(msg->message); + } + msg->message = (char *)decrypted_body; + + if (strcmp("application/cipher.vnd.gsma.rcs-ft-http+xml", msg->content_type) == 0) { + ms_free(msg->content_type); + msg->content_type = ms_strdup("application/vnd.gsma.rcs-ft-http+xml"); + } else { + ms_free(msg->content_type); + msg->content_type = ms_strdup("text/plain"); + } } xmlFreeDoc(cacheXml); @@ -876,10 +926,21 @@ int lime_im_encryption_engine_process_incoming_message_cb(LinphoneCore* lc, bell return errcode; } -int lime_im_encryption_engine_process_outgoing_message_cb(LinphoneCore* lc, belle_sip_request_t* req, const char *peer_uri, const char* content_type, const char* body, char** crypted_body, size_t* content_length) { +int lime_im_encryption_engine_process_outgoing_message_cb(LinphoneCore* lc, LinphoneChatRoom *room, LinphoneChatMessage *msg) { int errcode = -1; - /* shall we try to encrypt the message?*/ - if ((strcmp(content_type, "xml/cipher") == 0) || ((strcmp(content_type, "application/cipher.vnd.gsma.rcs-ft-http+xml") == 0))) { + char *content_type = NULL; + + if (linphone_chat_room_lime_available(room)) { + if (msg->content_type && strcmp(msg->content_type, "application/vnd.gsma.rcs-ft-http+xml") == 0) { + /* it's a file transfer, content type shall be set to + application/cipher.vnd.gsma.rcs-ft-http+xml*/ + content_type = "application/cipher.vnd.gsma.rcs-ft-http+xml"; + } else { + content_type = "xml/cipher"; + } + msg->content_type = ms_strdup(content_type); + + /* access the zrtp cache to get keys needed to cipher the message */ const char *zrtp_secrets_cache = linphone_core_get_zrtp_secrets_file(lc); FILE *CACHEFD = fopen(zrtp_secrets_cache, "rb+"); @@ -892,6 +953,8 @@ int lime_im_encryption_engine_process_outgoing_message_cb(LinphoneCore* lc, bell char *cacheString; xmlDocPtr cacheXml; int retval; + uint8_t *crypted_body = NULL; + char *peer = linphone_address_as_string_uri_only(linphone_chat_room_get_peer_address(room)); cacheString=ms_load_file_content(CACHEFD, &cacheSize); if (!cacheString){ @@ -904,10 +967,10 @@ int lime_im_encryption_engine_process_outgoing_message_cb(LinphoneCore* lc, bell fclose(CACHEFD); cacheXml = xmlParseDoc((xmlChar*)cacheString); ms_free(cacheString); - retval = lime_createMultipartMessage(cacheXml, (uint8_t *)body, (uint8_t *)peer_uri, (uint8_t **)crypted_body); + retval = lime_createMultipartMessage(cacheXml, (uint8_t *)msg->message, (uint8_t *)peer, &crypted_body); if (retval != 0) { - ms_warning("Unable to encrypt message for %s : %s", peer_uri, lime_error_code_to_string(retval)); - if (*crypted_body) free(*crypted_body); + ms_warning("Unable to encrypt message for %s : %s", peer, lime_error_code_to_string(retval)); + if (crypted_body) free(crypted_body); errcode = 488; } else { /* dump updated cache to a string */ @@ -921,8 +984,12 @@ int lime_im_encryption_engine_process_outgoing_message_cb(LinphoneCore* lc, bell } xmlFree(xmlStringOutput); fclose(CACHEFD); - *content_length = strlen((const char *)*crypted_body); + if (msg->message) { + ms_free(msg->message); + } + msg->message = (char *)crypted_body; } + ms_free(peer); xmlFreeDoc(cacheXml); } } @@ -965,10 +1032,13 @@ int lime_getCachedRcvKeyByZid(xmlDocPtr cacheBuffer, limeKey_t *associatedKey) { int lime_decryptMessage(limeKey_t *key, uint8_t *encryptedMessage, uint32_t messageLength, uint8_t selfZID[12], uint8_t *plainMessage) { return LIME_NOT_ENABLED; } -int lime_im_encryption_engine_process_incoming_message_cb(LinphoneCore* lc, belle_sip_request_t* req, const char* content_type, const char* content_subtype, const char* body, char** decrypted_body) { +bool_t linphone_chat_room_lime_available(LinphoneChatRoom *cr) { + return FALSE; +} +int lime_im_encryption_engine_process_incoming_message_cb(LinphoneCore* lc, LinphoneChatRoom *room, LinphoneChatMessage *msg) { return 500; } -int lime_im_encryption_engine_process_outgoing_message_cb(LinphoneCore* lc, belle_sip_request_t* req, const char *peer_uri, const char* content_type, const char* body, char** crypted_body, size_t* content_length) { +int lime_im_encryption_engine_process_outgoing_message_cb(LinphoneCore* lc, LinphoneChatRoom *room, LinphoneChatMessage *msg) { return 500; } int lime_im_encryption_engine_process_downloading_file_cb(LinphoneCore *lc, LinphoneChatMessage *msg, const char *buffer, size_t size, char **decrypted_buffer) { diff --git a/coreapi/lime.h b/coreapi/lime.h index 8c6c2d00f..932ff9bd3 100644 --- a/coreapi/lime.h +++ b/coreapi/lime.h @@ -205,9 +205,9 @@ LINPHONE_PUBLIC char *lime_error_code_to_string(int errorCode); */ LINPHONE_PUBLIC bool_t lime_is_available(void); -int lime_im_encryption_engine_process_incoming_message_cb(LinphoneCore* lc, belle_sip_request_t* req, const char* content_type, const char* content_subtype, const char* body, char** decrypted_body); +int lime_im_encryption_engine_process_incoming_message_cb(LinphoneCore* lc, LinphoneChatRoom *room, LinphoneChatMessage *msg); -int lime_im_encryption_engine_process_outgoing_message_cb(LinphoneCore* lc, belle_sip_request_t* req, const char *peer_uri, const char* content_type, const char* body, char** crypted_body, size_t* content_length); +int lime_im_encryption_engine_process_outgoing_message_cb(LinphoneCore* lc, LinphoneChatRoom *room, LinphoneChatMessage *msg); int lime_im_encryption_engine_process_downloading_file_cb(LinphoneCore *lc, LinphoneChatMessage *msg, const char *buffer, size_t size, char **decrypted_buffer); diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index c03dde5b4..b760a1c80 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -7184,6 +7184,49 @@ const char *linphone_reason_to_string(LinphoneReason err){ return "unknown error"; } +LinphoneReason linphone_error_code_to_reason(int err) { + if (err == 200) { + return LinphoneReasonNone; + } else if (err == 503) { + return LinphoneReasonIOError; + } else if (err == 400) { + return LinphoneReasonUnknown; + } else if (err == 486) { + return LinphoneReasonBusy; + } else if (err == 603) { + return LinphoneReasonDeclined; + } else if (err == 600) { + return LinphoneReasonDoNotDisturb; + } else if (err == 403) { + return LinphoneReasonForbidden; + } else if (err == 415) { + return LinphoneReasonUnsupportedContent; + } else if (err == 404) { + return LinphoneReasonNotFound; + } else if (err == 480) { + return LinphoneReasonTemporarilyUnavailable; + } else if (err == 401) { + return LinphoneReasonUnauthorized; + } else if (err == 488) { + return LinphoneReasonNotAcceptable; + } else if (err == 481) { + return LinphoneReasonNoMatch; + } else if (err == 301) { + return LinphoneReasonMovedPermanently; + } else if (err == 410) { + return LinphoneReasonGone; + } else if (err == 484) { + return LinphoneReasonAddressIncomplete; + } else if (err == 501) { + return LinphoneReasonNotImplemented; + } else if (err == 504) { + return LinphoneReasonServerTimeout; + } else if (err == 502) { + return LinphoneReasonBadGateway; + } + return LinphoneReasonUnknown; +} + const char *linphone_error_to_string(LinphoneReason err){ return linphone_reason_to_string(err); } diff --git a/coreapi/linphonecore.h b/coreapi/linphonecore.h index 598209da5..26cfa6817 100644 --- a/coreapi/linphonecore.h +++ b/coreapi/linphonecore.h @@ -227,6 +227,12 @@ typedef enum _LinphoneReason LinphoneReason; **/ LINPHONE_PUBLIC const char *linphone_reason_to_string(LinphoneReason err); +/** + * Converts a error code to a LinphoneReason. + * @ingroup misc +**/ +LINPHONE_PUBLIC LinphoneReason linphone_error_code_to_reason(int err); + /** * Object representing full details about a signaling error or status. * All LinphoneErrorInfo object returned by the liblinphone API are readonly and transcients. For safety they must be used immediately @@ -1639,7 +1645,7 @@ LINPHONE_PUBLIC uint32_t linphone_chat_room_get_char(const LinphoneChatRoom *cr) * * @return true if zrtp secrets have already been shared and ready to use */ - LINPHONE_PUBLIC bool_t linphone_chat_room_lime_available(LinphoneChatRoom *cr); +LINPHONE_PUBLIC bool_t linphone_chat_room_lime_available(LinphoneChatRoom *cr); /** * Returns an list of chat rooms diff --git a/coreapi/private.h b/coreapi/private.h index e72a5618f..ce8386b7a 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -549,7 +549,7 @@ LINPHONE_PUBLIC void linphone_core_get_local_ip(LinphoneCore *lc, int af, const LinphoneProxyConfig *linphone_proxy_config_new_from_config_file(LinphoneCore *lc, int index); void linphone_proxy_config_write_to_config_file(struct _LpConfig* config,LinphoneProxyConfig *obj, int index); -void linphone_core_message_received(LinphoneCore *lc, SalOp *op, const SalMessage *msg); +LinphoneReason linphone_core_message_received(LinphoneCore *lc, SalOp *op, const SalMessage *msg); void linphone_core_is_composing_received(LinphoneCore *lc, SalOp *op, const SalIsComposing *is_composing); void linphone_core_real_time_text_received(LinphoneCore *lc, LinphoneChatRoom *cr, uint32_t character, LinphoneCall *call); From 395c81f69a16fc661d72a84ed283b2b8a136be2f Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Thu, 10 Nov 2016 15:44:32 +0100 Subject: [PATCH 14/21] Added encryption callbacks for file upload in im encryption engine --- coreapi/chat.c | 10 ++-- coreapi/chat_file_transfer.c | 103 ++++++++++++++++----------------- coreapi/im_encryption_engine.c | 29 +++++++++- coreapi/im_encryption_engine.h | 20 ++++++- coreapi/lime.c | 45 +++++++++++++- coreapi/lime.h | 8 ++- coreapi/linphonecore.c | 3 + 7 files changed, 153 insertions(+), 65 deletions(-) diff --git a/coreapi/chat.c b/coreapi/chat.c index 98f3ed0cd..174555ded 100644 --- a/coreapi/chat.c +++ b/coreapi/chat.c @@ -578,18 +578,16 @@ LinphoneReason linphone_core_message_received(LinphoneCore *lc, SalOp *op, const file_url = xmlGetProp(cur, (const xmlChar *)"url"); } - if (!xmlStrcmp(cur->name, - (const xmlChar *)"file-key")) { /* there is a key in the msg: file has - been encrypted */ + if (!xmlStrcmp(cur->name, (const xmlChar *)"file-key")) { + /* there is a key in the msg: file has been encrypted */ /* convert the key from base 64 */ xmlChar *keyb64 = xmlNodeListGetString(xmlMessageBody, cur->xmlChildrenNode, 1); size_t keyLength = b64_decode((char *)keyb64, strlen((char *)keyb64), NULL, 0); uint8_t *keyBuffer = (uint8_t *)malloc(keyLength); /* decode the key into local key buffer */ b64_decode((char *)keyb64, strlen((char *)keyb64), keyBuffer, keyLength); - linphone_content_set_key( - msg->file_transfer_information, (char *)keyBuffer, - strlen((char *)keyBuffer)); /* duplicate key value into the linphone content private structure */ + linphone_content_set_key(msg->file_transfer_information, (char *)keyBuffer, strlen((char *)keyBuffer)); + /* duplicate key value into the linphone content private structure */ xmlFree(keyb64); free(keyBuffer); } diff --git a/coreapi/chat_file_transfer.c b/coreapi/chat_file_transfer.c index 584496bca..7078191e4 100644 --- a/coreapi/chat_file_transfer.c +++ b/coreapi/chat_file_transfer.c @@ -27,8 +27,6 @@ #include "lime.h" #include "ortp/b64.h" -#define FILE_TRANSFER_KEY_SIZE 32 - static bool_t file_transfer_in_progress_and_valid(LinphoneChatMessage* msg) { return (msg->chat_room && msg->chat_room->lc && msg->http_request && !belle_http_request_is_cancelled(msg->http_request)); } @@ -98,7 +96,8 @@ static int linphone_chat_message_file_transfer_on_send_body(belle_sip_user_body_ void *data, size_t offset, uint8_t *buffer, size_t *size) { LinphoneChatMessage *msg = (LinphoneChatMessage *)data; LinphoneCore *lc = NULL; - char *buf = (char *)buffer; + LinphoneImEncryptionEngine *imee = NULL; + int retval = -1; if (!file_transfer_in_progress_and_valid(msg)) { if (msg->http_request) { @@ -111,50 +110,43 @@ static int linphone_chat_message_file_transfer_on_send_body(belle_sip_user_body_ lc = msg->chat_room->lc; /* if we've not reach the end of file yet, ask for more data*/ if (offset < linphone_content_get_size(msg->file_transfer_information)) { - char *plainBuffer = NULL; - - if (linphone_content_get_key(msg->file_transfer_information) != - NULL) { /* if we have a key to cipher the msg, use it! */ - /* if this chunk is not the last one, the lenght must be a multiple of block cipher size(16 bytes)*/ - if (offset + *size < linphone_content_get_size(msg->file_transfer_information)) { - *size -= (*size % 16); - } - plainBuffer = (char *)ms_malloc0(*size); - } + char *plainBuffer = (char *)ms_malloc0(*size); /* get data from call back */ - if (linphone_chat_message_cbs_get_file_transfer_send(msg->callbacks)) { - LinphoneBuffer *lb = linphone_chat_message_cbs_get_file_transfer_send(msg->callbacks)( - msg, msg->file_transfer_information, offset, *size); + LinphoneChatMessageCbsFileTransferSendCb file_transfer_send_cb = linphone_chat_message_cbs_get_file_transfer_send(msg->callbacks); + if (file_transfer_send_cb) { + LinphoneBuffer *lb = file_transfer_send_cb(msg, msg->file_transfer_information, offset, *size); if (lb == NULL) { *size = 0; } else { *size = linphone_buffer_get_size(lb); - memcpy(plainBuffer ? plainBuffer : buf, linphone_buffer_get_content(lb), *size); + memcpy(plainBuffer, linphone_buffer_get_content(lb), *size); linphone_buffer_unref(lb); } } else { /* Legacy */ - linphone_core_notify_file_transfer_send(lc, msg, msg->file_transfer_information, - plainBuffer ? plainBuffer : buf, size); + linphone_core_notify_file_transfer_send(lc, msg, msg->file_transfer_information, plainBuffer, size); } - - if (linphone_content_get_key(msg->file_transfer_information) != - NULL) { /* if we have a key to cipher the msg, use it! */ - lime_encryptFile(linphone_content_get_cryptoContext_address(msg->file_transfer_information), - (unsigned char *)linphone_content_get_key(msg->file_transfer_information), *size, - plainBuffer, (char *)buffer); - ms_free(plainBuffer); - /* check if we reach the end of file */ - if (offset + *size >= linphone_content_get_size(msg->file_transfer_information)) { - /* conclude file ciphering by calling it context with a zero size */ - lime_encryptFile(linphone_content_get_cryptoContext_address(msg->file_transfer_information), NULL, 0, - NULL, NULL); + + imee = linphone_core_get_im_encryption_engine(lc); + if (imee) { + LinphoneImEncryptionEngineCbs *imee_cbs = linphone_im_encryption_engine_get_callbacks(imee); + LinphoneImEncryptionEngineUploadingFileCb cb_process_uploading_file = linphone_im_encryption_engine_cbs_get_process_uploading_file(imee_cbs); + if (cb_process_uploading_file) { + retval = cb_process_uploading_file(lc, msg, offset, plainBuffer, size, (char *)buffer); + if (offset + *size >= linphone_content_get_size(msg->file_transfer_information)) { + /* conclude file ciphering by calling it context with a zero size */ + cb_process_uploading_file(lc, msg, 0, NULL, NULL, NULL); + } } } + if (retval < 0) { + memcpy(buffer, plainBuffer, *size); + } + ms_free(plainBuffer); } - return BELLE_SIP_CONTINUE; + return retval <= 0 ? BELLE_SIP_CONTINUE : BELLE_SIP_STOP; } static void linphone_chat_message_process_response_from_post_file(void *data, @@ -176,21 +168,27 @@ static void linphone_chat_message_process_response_from_post_file(void *data, char *first_part_header; belle_sip_body_handler_t *first_part_bh; + bool_t is_file_encryption_enabled = FALSE; + LinphoneImEncryptionEngine *imee = linphone_core_get_im_encryption_engine(msg->chat_room->lc); + if (imee) { + LinphoneImEncryptionEngineCbs *imee_cbs = linphone_im_encryption_engine_get_callbacks(imee); + LinphoneImEncryptionEngineIsEncryptionEnabledForFileTransferCb is_encryption_enabled_for_file_transfer_cb = + linphone_im_encryption_engine_cbs_get_is_encryption_enabled_for_file_transfer(imee_cbs); + if (is_encryption_enabled_for_file_transfer_cb) { + is_file_encryption_enabled = is_encryption_enabled_for_file_transfer_cb(msg->chat_room->lc, msg->chat_room); + } + } /* shall we encrypt the file */ - if (linphone_chat_room_lime_available(msg->chat_room) && - linphone_core_lime_for_file_sharing_enabled(msg->chat_room->lc)) { - char keyBuffer - [FILE_TRANSFER_KEY_SIZE]; /* temporary storage of generated key: 192 bits of key + 64 bits of - initial vector */ - /* generate a random 192 bits key + 64 bits of initial vector and store it into the - * file_transfer_information->key field of the msg */ - sal_get_random_bytes((unsigned char *)keyBuffer, FILE_TRANSFER_KEY_SIZE); - linphone_content_set_key( - msg->file_transfer_information, keyBuffer, - FILE_TRANSFER_KEY_SIZE); /* key is duplicated in the content private structure */ + if (is_file_encryption_enabled) { + LinphoneImEncryptionEngineCbs *imee_cbs = linphone_im_encryption_engine_get_callbacks(imee); + LinphoneImEncryptionEngineGenerateFileTransferKeyCb generate_file_transfer_key_cb = + linphone_im_encryption_engine_cbs_get_generate_file_transfer_key(imee_cbs); + if (generate_file_transfer_key_cb) { + generate_file_transfer_key_cb(msg->chat_room->lc, msg->chat_room, msg); + } /* temporary storage for the Content-disposition header value : use a generic filename to not leak it - * Actual filename stored in msg->file_transfer_information->name will be set in encrypted msg - * sended to the */ + * Actual filename stored in msg->file_transfer_information->name will be set in encrypted msg + * sended to the */ first_part_header = belle_sip_strdup_printf("form-data; name=\"File\"; filename=\"filename.txt\""); } else { /* temporary storage for the Content-disposition header value */ @@ -201,8 +199,7 @@ static void linphone_chat_message_process_response_from_post_file(void *data, /* create a user body handler to take care of the file and add the content disposition and content-type * headers */ if (msg->file_transfer_filepath != NULL) { - first_part_bh = - (belle_sip_body_handler_t *)belle_sip_file_body_handler_new(msg->file_transfer_filepath, NULL, msg); + first_part_bh = (belle_sip_body_handler_t *)belle_sip_file_body_handler_new(msg->file_transfer_filepath, NULL, msg); } else if (linphone_content_get_buffer(msg->file_transfer_information) != NULL) { first_part_bh = (belle_sip_body_handler_t *)belle_sip_memory_body_handler_new_from_buffer( linphone_content_get_buffer(msg->file_transfer_information), @@ -233,7 +230,8 @@ static void linphone_chat_message_process_response_from_post_file(void *data, if (body && strlen(body) > 0) { /* if we have an encryption key for the file, we must insert it into the msg and restore the correct * filename */ - if (linphone_content_get_key(msg->file_transfer_information) != NULL) { + const char *content_key = linphone_content_get_key(msg->file_transfer_information); + if (content_key != NULL) { /* parse the msg body */ xmlDocPtr xmlMessageBody = xmlParseDoc((const xmlChar *)body); @@ -252,12 +250,11 @@ static void linphone_chat_message_process_response_from_post_file(void *data, ->xmlChildrenNode; /* need to parse the children node to update the file-name one */ /* convert key to base64 */ - size_t b64Size = b64_encode(NULL, FILE_TRANSFER_KEY_SIZE, NULL, 0); + size_t b64Size = b64_encode(NULL, strlen(content_key), NULL, 0); char *keyb64 = (char *)ms_malloc0(b64Size + 1); int xmlStringLength; - b64Size = b64_encode(linphone_content_get_key(msg->file_transfer_information), - FILE_TRANSFER_KEY_SIZE, keyb64, b64Size); + b64Size = b64_encode(content_key, strlen(content_key), keyb64, b64Size); keyb64[b64Size] = '\0'; /* libxml need a null terminated string */ /* add the node containing the key to the file-info node */ @@ -354,7 +351,7 @@ static void on_recv_body(belle_sip_user_body_handler_t *bh, belle_sip_message_t LinphoneImEncryptionEngineCbs *imee_cbs = linphone_im_encryption_engine_get_callbacks(imee); LinphoneImEncryptionEngineDownloadingFileCb cb_process_downloading_file = linphone_im_encryption_engine_cbs_get_process_downloading_file(imee_cbs); if (cb_process_downloading_file) { - retval = cb_process_downloading_file(lc, msg, (const char *)buffer, size, &decrypted_buffer); + retval = cb_process_downloading_file(lc, msg, (const char *)buffer, size, decrypted_buffer); } } @@ -467,7 +464,7 @@ static void linphone_chat_process_response_from_get_file(void *data, const belle retval = (int)bctbx_file_read(encrypted_file, encrypted_content, encrypted_file_size, 0); bctbx_file_close(encrypted_file); if (retval != BCTBX_VFS_ERROR && retval == (int)encrypted_file_size) { - retval = cb_process_downloading_file(lc, msg, encrypted_content, encrypted_file_size, &decrypted_content); + retval = cb_process_downloading_file(lc, msg, encrypted_content, encrypted_file_size, decrypted_content); cb_process_downloading_file(lc, msg, NULL, 0, NULL); decrypted_file = bctbx_file_open(vfs, msg->file_transfer_filepath, "w"); bctbx_file_write(decrypted_file, decrypted_content, encrypted_file_size, 0); diff --git a/coreapi/im_encryption_engine.c b/coreapi/im_encryption_engine.c index 792ff1634..e30d4e97c 100644 --- a/coreapi/im_encryption_engine.c +++ b/coreapi/im_encryption_engine.c @@ -23,8 +23,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. struct _LinphoneImEncryptionEngineCbs { void *user_data; LinphoneImEncryptionEngineIncomingMessageCb process_incoming_message; - LinphoneImEncryptionEngineDownloadingFileCb process_downlading_file; LinphoneImEncryptionEngineOutgoingMessageCb process_outgoing_message; + LinphoneImEncryptionEngineIsEncryptionEnabledForFileTransferCb is_encryption_enabled_for_file_transfer; + LinphoneImEncryptionEngineGenerateFileTransferKeyCb generate_file_transfer_key; + LinphoneImEncryptionEngineDownloadingFileCb process_downlading_file; + LinphoneImEncryptionEngineUploadingFileCb process_uploading_file; }; struct _LinphoneImEncryptionEngine { @@ -94,4 +97,28 @@ LinphoneImEncryptionEngineDownloadingFileCb linphone_im_encryption_engine_cbs_ge void linphone_im_encryption_engine_cbs_set_process_downloading_file(LinphoneImEncryptionEngineCbs *cbs, LinphoneImEncryptionEngineDownloadingFileCb cb) { cbs->process_downlading_file = cb; +} + +LinphoneImEncryptionEngineUploadingFileCb linphone_im_encryption_engine_cbs_get_process_uploading_file(LinphoneImEncryptionEngineCbs *cbs) { + return cbs->process_uploading_file; +} + +void linphone_im_encryption_engine_cbs_set_process_uploading_file(LinphoneImEncryptionEngineCbs *cbs, LinphoneImEncryptionEngineUploadingFileCb cb) { + cbs->process_uploading_file = cb; +} + +LinphoneImEncryptionEngineIsEncryptionEnabledForFileTransferCb linphone_im_encryption_engine_cbs_get_is_encryption_enabled_for_file_transfer(LinphoneImEncryptionEngineCbs *cbs) { + return cbs->is_encryption_enabled_for_file_transfer; +} + +void linphone_im_encryption_engine_cbs_set_is_encryption_enabled_for_file_transfer(LinphoneImEncryptionEngineCbs *cbs, LinphoneImEncryptionEngineIsEncryptionEnabledForFileTransferCb cb) { + cbs->is_encryption_enabled_for_file_transfer = cb; +} + +LinphoneImEncryptionEngineGenerateFileTransferKeyCb linphone_im_encryption_engine_cbs_get_generate_file_transfer_key(LinphoneImEncryptionEngineCbs *cbs) { + return cbs->generate_file_transfer_key; +} + +void linphone_im_encryption_engine_cbs_set_generate_file_transfer_key(LinphoneImEncryptionEngineCbs *cbs, LinphoneImEncryptionEngineGenerateFileTransferKeyCb cb) { + cbs->generate_file_transfer_key = cb; } \ No newline at end of file diff --git a/coreapi/im_encryption_engine.h b/coreapi/im_encryption_engine.h index d9b2c63b3..ad6f4373d 100644 --- a/coreapi/im_encryption_engine.h +++ b/coreapi/im_encryption_engine.h @@ -30,7 +30,13 @@ typedef int (*LinphoneImEncryptionEngineIncomingMessageCb)(LinphoneCore* lc, Lin typedef int (*LinphoneImEncryptionEngineOutgoingMessageCb)(LinphoneCore* lc, LinphoneChatRoom *room, LinphoneChatMessage *msg); -typedef int (*LinphoneImEncryptionEngineDownloadingFileCb)(LinphoneCore *lc, LinphoneChatMessage *msg, const char *buffer, size_t size, char **decrypted_buffer); +typedef bool_t (*LinphoneImEncryptionEngineIsEncryptionEnabledForFileTransferCb)(LinphoneCore *lc, LinphoneChatRoom *room); + +typedef void (*LinphoneImEncryptionEngineGenerateFileTransferKeyCb)(LinphoneCore *lc, LinphoneChatRoom *room, LinphoneChatMessage *msg); + +typedef int (*LinphoneImEncryptionEngineDownloadingFileCb)(LinphoneCore *lc, LinphoneChatMessage *msg, const char *buffer, size_t size, char *decrypted_buffer); + +typedef int (*LinphoneImEncryptionEngineUploadingFileCb)(LinphoneCore *lc, LinphoneChatMessage *msg, size_t offset, const char *buffer, size_t *size, char *encrypted_buffer); typedef struct _LinphoneImEncryptionEngineCbs LinphoneImEncryptionEngineCbs; @@ -66,4 +72,16 @@ LINPHONE_PUBLIC LinphoneImEncryptionEngineDownloadingFileCb linphone_im_encrypti LINPHONE_PUBLIC void linphone_im_encryption_engine_cbs_set_process_downloading_file(LinphoneImEncryptionEngineCbs *cbs, LinphoneImEncryptionEngineDownloadingFileCb cb); +LINPHONE_PUBLIC LinphoneImEncryptionEngineUploadingFileCb linphone_im_encryption_engine_cbs_get_process_uploading_file(LinphoneImEncryptionEngineCbs *cbs); + +LINPHONE_PUBLIC void linphone_im_encryption_engine_cbs_set_process_uploading_file(LinphoneImEncryptionEngineCbs *cbs, LinphoneImEncryptionEngineUploadingFileCb cb); + +LINPHONE_PUBLIC LinphoneImEncryptionEngineIsEncryptionEnabledForFileTransferCb linphone_im_encryption_engine_cbs_get_is_encryption_enabled_for_file_transfer(LinphoneImEncryptionEngineCbs *cbs); + +LINPHONE_PUBLIC void linphone_im_encryption_engine_cbs_set_is_encryption_enabled_for_file_transfer(LinphoneImEncryptionEngineCbs *cbs, LinphoneImEncryptionEngineIsEncryptionEnabledForFileTransferCb cb); + +LINPHONE_PUBLIC LinphoneImEncryptionEngineGenerateFileTransferKeyCb linphone_im_encryption_engine_cbs_get_generate_file_transfer_key(LinphoneImEncryptionEngineCbs *cbs); + +LINPHONE_PUBLIC void linphone_im_encryption_engine_cbs_set_generate_file_transfer_key(LinphoneImEncryptionEngineCbs *cbs, LinphoneImEncryptionEngineGenerateFileTransferKeyCb cb); + #endif /* IM_ENCRYPTION_ENGINE_H */ \ No newline at end of file diff --git a/coreapi/lime.c b/coreapi/lime.c index 575c8588a..9d3511af5 100644 --- a/coreapi/lime.c +++ b/coreapi/lime.c @@ -26,6 +26,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "private.h" #include "bctoolbox/crypto.h" +#define FILE_TRANSFER_KEY_SIZE 32 + /** * @brief check at runtime if LIME is available * @@ -996,7 +998,7 @@ int lime_im_encryption_engine_process_outgoing_message_cb(LinphoneCore* lc, Linp return errcode; } -int lime_im_encryption_engine_process_downloading_file_cb(LinphoneCore *lc, LinphoneChatMessage *msg, const char *buffer, size_t size, char **decrypted_buffer) { +int lime_im_encryption_engine_process_downloading_file_cb(LinphoneCore *lc, LinphoneChatMessage *msg, const char *buffer, size_t size, char *decrypted_buffer) { if (linphone_content_get_key(msg->file_transfer_information) == NULL) return -1; if (buffer == NULL || size == 0) { @@ -1004,10 +1006,38 @@ int lime_im_encryption_engine_process_downloading_file_cb(LinphoneCore *lc, Linp } return lime_decryptFile(linphone_content_get_cryptoContext_address(msg->file_transfer_information), - (unsigned char *)linphone_content_get_key(msg->file_transfer_information), size, *decrypted_buffer, + (unsigned char *)linphone_content_get_key(msg->file_transfer_information), size, decrypted_buffer, (char *)buffer); } +int lime_im_encryption_engine_process_uploading_file_cb(LinphoneCore *lc, LinphoneChatMessage *msg, size_t offset, const char *buffer, size_t *size, char *encrypted_buffer) { + if (linphone_content_get_key(msg->file_transfer_information) == NULL) return -1; + + if (buffer == NULL || *size == 0) { + return lime_encryptFile(linphone_content_get_cryptoContext_address(msg->file_transfer_information), NULL, 0, NULL, NULL); + } + + if (offset + *size < linphone_content_get_size(msg->file_transfer_information)) { + *size -= (*size % 16); + } + + return lime_encryptFile(linphone_content_get_cryptoContext_address(msg->file_transfer_information), + (unsigned char *)linphone_content_get_key(msg->file_transfer_information), *size, + (char *)buffer, encrypted_buffer); +} + +bool_t lime_im_encryption_engine_is_file_encryption_enabled_cb(LinphoneCore *lc, LinphoneChatRoom *room) { + return linphone_chat_room_lime_available(room) && linphone_core_lime_for_file_sharing_enabled(lc); +} + +void lime_im_encryption_engine_generate_file_transfer_key_cb(LinphoneCore *lc, LinphoneChatRoom *room, LinphoneChatMessage *msg) { + char keyBuffer [FILE_TRANSFER_KEY_SIZE]; /* temporary storage of generated key: 192 bits of key + 64 bits of initial vector */ + /* generate a random 192 bits key + 64 bits of initial vector and store it into the + * file_transfer_information->key field of the msg */ + sal_get_random_bytes((unsigned char *)keyBuffer, FILE_TRANSFER_KEY_SIZE); + linphone_content_set_key(msg->file_transfer_information, keyBuffer, FILE_TRANSFER_KEY_SIZE); /* key is duplicated in the content private structure */ +} + #else /* HAVE_LIME */ bool_t lime_is_available() { return FALSE; } @@ -1041,8 +1071,17 @@ int lime_im_encryption_engine_process_incoming_message_cb(LinphoneCore* lc, Linp int lime_im_encryption_engine_process_outgoing_message_cb(LinphoneCore* lc, LinphoneChatRoom *room, LinphoneChatMessage *msg) { return 500; } -int lime_im_encryption_engine_process_downloading_file_cb(LinphoneCore *lc, LinphoneChatMessage *msg, const char *buffer, size_t size, char **decrypted_buffer) { +int lime_im_encryption_engine_process_downloading_file_cb(LinphoneCore *lc, LinphoneChatMessage *msg, const char *buffer, size_t size, char *decrypted_buffer) { return 500; +} +int lime_im_encryption_engine_process_uploading_file_cb(LinphoneCore *lc, LinphoneChatMessage *msg, size_t offset, const char *buffer, size_t *size, char *encrypted_buffer) { + return 500; +} +bool_t lime_im_encryption_engine_is_file_encryption_enabled_cb(LinphoneCore *lc, LinphoneChatRoom *room) { + return FALSE; +} +void lime_im_encryption_engine_generate_file_transfer_key_cb(LinphoneCore *lc, LinphoneChatRoom *room, LinphoneChatMessage *msg) { + } #endif /* HAVE_LIME */ diff --git a/coreapi/lime.h b/coreapi/lime.h index 932ff9bd3..1667a4b15 100644 --- a/coreapi/lime.h +++ b/coreapi/lime.h @@ -209,6 +209,12 @@ int lime_im_encryption_engine_process_incoming_message_cb(LinphoneCore* lc, Linp int lime_im_encryption_engine_process_outgoing_message_cb(LinphoneCore* lc, LinphoneChatRoom *room, LinphoneChatMessage *msg); -int lime_im_encryption_engine_process_downloading_file_cb(LinphoneCore *lc, LinphoneChatMessage *msg, const char *buffer, size_t size, char **decrypted_buffer); +int lime_im_encryption_engine_process_downloading_file_cb(LinphoneCore *lc, LinphoneChatMessage *msg, const char *buffer, size_t size, char *decrypted_buffer); + +int lime_im_encryption_engine_process_uploading_file_cb(LinphoneCore *lc, LinphoneChatMessage *msg, size_t offset, const char *buffer, size_t *size, char *encrypted_buffer); + +bool_t lime_im_encryption_engine_is_file_encryption_enabled_cb(LinphoneCore *lc, LinphoneChatRoom *room); + +void lime_im_encryption_engine_generate_file_transfer_key_cb(LinphoneCore *lc, LinphoneChatRoom *room, LinphoneChatMessage *msg); #endif /* LIME_H */ diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index b760a1c80..b226cb279 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -1957,6 +1957,9 @@ void linphone_core_enable_lime(LinphoneCore *lc, LinphoneLimeState val){ linphone_im_encryption_engine_cbs_set_process_incoming_message(cbs, lime_im_encryption_engine_process_incoming_message_cb); linphone_im_encryption_engine_cbs_set_process_outgoing_message(cbs, lime_im_encryption_engine_process_outgoing_message_cb); linphone_im_encryption_engine_cbs_set_process_downloading_file(cbs, lime_im_encryption_engine_process_downloading_file_cb); + linphone_im_encryption_engine_cbs_set_process_uploading_file(cbs, lime_im_encryption_engine_process_uploading_file_cb); + linphone_im_encryption_engine_cbs_set_is_encryption_enabled_for_file_transfer(cbs, lime_im_encryption_engine_is_file_encryption_enabled_cb); + linphone_im_encryption_engine_cbs_set_generate_file_transfer_key(cbs, lime_im_encryption_engine_generate_file_transfer_key_cb); lc->im_encryption_engine = imee; } else { if (lc->im_encryption_engine) { From 2a6e7ce24161980fec3579fa430aee3dd6fc6ec7 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Thu, 10 Nov 2016 15:56:42 +0100 Subject: [PATCH 15/21] Added more transfer tests to try all four combinations of upload/download body handlers --- tester/message_tester.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/tester/message_tester.c b/tester/message_tester.c index 957455a40..203264e16 100644 --- a/tester/message_tester.c +++ b/tester/message_tester.c @@ -443,7 +443,7 @@ static void text_message_with_external_body(void) { linphone_core_manager_destroy(pauline); } -void transfer_message_base2(LinphoneCoreManager* marie, LinphoneCoreManager* pauline, bool_t upload_error, bool_t download_error, bool_t use_file_body_handler) { +void transfer_message_base2(LinphoneCoreManager* marie, LinphoneCoreManager* pauline, bool_t upload_error, bool_t download_error, bool_t use_file_body_handler_in_upload, bool_t use_file_body_handler_in_download) { char *send_filepath = bc_tester_res("images/nowebcamCIF.jpg"); char *receive_filepath = bc_tester_file("receive_file.dump"); LinphoneChatRoom* chat_room; @@ -456,7 +456,7 @@ void transfer_message_base2(LinphoneCoreManager* marie, LinphoneCoreManager* pau /* create a chatroom on pauline's side */ chat_room = linphone_core_get_chat_room(pauline->lc, marie->identity); /* create a file transfer msg */ - if (use_file_body_handler) { + if (use_file_body_handler_in_upload) { msg = create_file_transfer_message_from_nowebcam(chat_room); } else { msg = create_message_from_nowebcam(chat_room); @@ -485,7 +485,7 @@ void transfer_message_base2(LinphoneCoreManager* marie, LinphoneCoreManager* pau linphone_chat_message_cbs_set_msg_state_changed(cbs, liblinphone_tester_chat_message_msg_state_changed); linphone_chat_message_cbs_set_file_transfer_recv(cbs, file_transfer_received); linphone_chat_message_cbs_set_file_transfer_progress_indication(cbs, file_transfer_progress_indication); - if (use_file_body_handler) { + if (use_file_body_handler_in_download) { linphone_chat_message_set_file_transfer_filepath(marie->stat.last_received_chat_message, receive_filepath); } linphone_chat_message_download_file(marie->stat.last_received_chat_message); @@ -511,29 +511,37 @@ void transfer_message_base2(LinphoneCoreManager* marie, LinphoneCoreManager* pau bc_free(receive_filepath); } -void transfer_message_base(bool_t upload_error, bool_t download_error, bool_t use_file_body_handler) { +void transfer_message_base(bool_t upload_error, bool_t download_error, bool_t use_file_body_handler_in_upload, bool_t use_file_body_handler_in_download) { if (transport_supported(LinphoneTransportTls)) { LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_tcp_rc"); - transfer_message_base2(marie,pauline,upload_error,download_error, use_file_body_handler); + transfer_message_base2(marie,pauline,upload_error,download_error, use_file_body_handler_in_upload, use_file_body_handler_in_download); linphone_core_manager_destroy(pauline); linphone_core_manager_destroy(marie); } } static void transfer_message(void) { - transfer_message_base(FALSE, FALSE, FALSE); + transfer_message_base(FALSE, FALSE, FALSE, FALSE); } static void transfer_message_2(void) { - transfer_message_base(FALSE, FALSE, TRUE); + transfer_message_base(FALSE, FALSE, TRUE, FALSE); +} + +static void transfer_message_3(void) { + transfer_message_base(FALSE, FALSE, FALSE, TRUE); +} + +static void transfer_message_4(void) { + transfer_message_base(FALSE, FALSE, TRUE, TRUE); } static void transfer_message_with_upload_io_error(void) { - transfer_message_base(TRUE, FALSE, FALSE); + transfer_message_base(TRUE, FALSE, FALSE, FALSE); } static void transfer_message_with_download_io_error(void) { - transfer_message_base(FALSE, TRUE, FALSE); + transfer_message_base(FALSE, TRUE, FALSE, FALSE); } static void transfer_message_upload_cancelled(void) { @@ -1887,7 +1895,7 @@ void file_transfer_with_http_proxy(void) { LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_tcp_rc"); linphone_core_set_http_proxy_host(marie->lc, "sip.linphone.org"); - transfer_message_base2(marie,pauline,FALSE,FALSE,FALSE); + transfer_message_base2(marie,pauline,FALSE,FALSE,FALSE,FALSE); linphone_core_manager_destroy(pauline); linphone_core_manager_destroy(marie); } @@ -1904,6 +1912,8 @@ test_t message_tests[] = { TEST_NO_TAG("Text message with external body", text_message_with_external_body), TEST_NO_TAG("Transfer message", transfer_message), TEST_NO_TAG("Transfer message 2", transfer_message_2), + TEST_NO_TAG("Transfer message 3", transfer_message_3), + TEST_NO_TAG("Transfer message 4", transfer_message_4), TEST_NO_TAG("Transfer message with http proxy", file_transfer_with_http_proxy), TEST_NO_TAG("Transfer message with upload io error", transfer_message_with_upload_io_error), TEST_NO_TAG("Transfer message with download io error", transfer_message_with_download_io_error), From c9b8fb6eb2104e28bb0d4cbe9adb59058bb2a746 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Thu, 10 Nov 2016 16:22:09 +0100 Subject: [PATCH 16/21] Added documentation in header files --- coreapi/im_encryption_engine.h | 155 +++++++++++++++++++++++++++++++++ coreapi/linphonecore.h | 12 +++ 2 files changed, 167 insertions(+) diff --git a/coreapi/im_encryption_engine.h b/coreapi/im_encryption_engine.h index ad6f4373d..68a14b7bb 100644 --- a/coreapi/im_encryption_engine.h +++ b/coreapi/im_encryption_engine.h @@ -26,16 +26,61 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #define LINPHONE_PUBLIC MS2_PUBLIC #endif +/** + * Callback to decrypt incoming LinphoneChatMessage + * @param lc the LinphoneCore object + * @param room the LinphoneChatRoom object + * @param msg the LinphoneChatMessage object + * @return -1 if nothing to be done, 0 on success or an integer > 0 for error +*/ typedef int (*LinphoneImEncryptionEngineIncomingMessageCb)(LinphoneCore* lc, LinphoneChatRoom *room, LinphoneChatMessage *msg); +/** + * Callback to encrypt outging LinphoneChatMessage + * @param lc the LinphoneCore object + * @param room the LinphoneChatRoom object + * @param msg the LinphoneChatMessage object + * @return -1 if nothing to be done, 0 on success or an integer > 0 for error +*/ typedef int (*LinphoneImEncryptionEngineOutgoingMessageCb)(LinphoneCore* lc, LinphoneChatRoom *room, LinphoneChatMessage *msg); +/** + * Callback to know whether or not the engine will encrypt files before uploading them + * @param lc the LinphoneCore object + * @param room the LinphoneChatRoom object + * @return TRUE if files will be encrypted, FALSE otherwise +*/ typedef bool_t (*LinphoneImEncryptionEngineIsEncryptionEnabledForFileTransferCb)(LinphoneCore *lc, LinphoneChatRoom *room); +/** + * Callback to generate the key used to encrypt the files before uploading them + * Key can be stored in the LinphoneContent object inside the LinphoneChatMessage using linphone_content_set_key + * @param lc the LinphoneCore object + * @param room the LinphoneChatRoom object + * @param msg the LinphoneChatMessage object +*/ typedef void (*LinphoneImEncryptionEngineGenerateFileTransferKeyCb)(LinphoneCore *lc, LinphoneChatRoom *room, LinphoneChatMessage *msg); +/** + * Callback to decrypt downloading file + * @param lc the LinphoneCore object + * @param msg the LinphoneChatMessage object + * @param buffer the encrypted data buffer + * @param size the size of the encrypted data buffer + * @param decrypted_buffer the buffer in which to write the decrypted data + * @return -1 if nothing to be done, 0 on success or an integer > 0 for error +*/ typedef int (*LinphoneImEncryptionEngineDownloadingFileCb)(LinphoneCore *lc, LinphoneChatMessage *msg, const char *buffer, size_t size, char *decrypted_buffer); +/** + * Callback to encrypt uploading file + * @param lc the LinphoneCore object + * @param msg the LinphoneChatMessage object + * @param buffer the encrypted data buffer + * @param size the size of the plain data buffer and the size of the encrypted data buffer once encryption is done + * @param encrypted_buffer the buffer in which to write the encrypted data + * @return -1 if nothing to be done, 0 on success or an integer > 0 for error +*/ typedef int (*LinphoneImEncryptionEngineUploadingFileCb)(LinphoneCore *lc, LinphoneChatMessage *msg, size_t offset, const char *buffer, size_t *size, char *encrypted_buffer); typedef struct _LinphoneImEncryptionEngineCbs LinphoneImEncryptionEngineCbs; @@ -46,42 +91,152 @@ LinphoneImEncryptionEngineCbs *linphone_im_encryption_engine_cbs_new(void); void linphone_im_encryption_engine_cbs_destory(LinphoneImEncryptionEngineCbs *cbs); +/** + * Gets the user data in the LinphoneImEncryptionEngineCbs object + * @param cbs the LinphoneImEncryptionEngineCbs + * @return the user data + * @ingroup misc +*/ LINPHONE_PUBLIC void *linphone_im_encryption_engine_cbs_get_user_data(const LinphoneImEncryptionEngineCbs *cbs); +/** + * Sets the user data in the LinphoneImEncryptionEngineCbs object + * @param cbs the LinphoneImEncryptionEngineCbs object + * @param data the user data + * @ingroup misc +*/ LINPHONE_PUBLIC void linphone_im_encryption_engine_cbs_set_user_data(LinphoneImEncryptionEngineCbs *cbs, void *data); +/** + * Creates a LinphoneImEncryptionEngine object +*/ LINPHONE_PUBLIC LinphoneImEncryptionEngine *linphone_im_encryption_engine_new(void); +/** + * Destroys the LinphoneImEncryptionEngine + * @param imee the LinphoneImEncryptionEngine object + * @ingroup misc +*/ LINPHONE_PUBLIC void linphone_im_encryption_engine_destory(LinphoneImEncryptionEngine *imee); +/** + * Gets the user data in the LinphoneImEncryptionEngine object + * @param imee the LinphoneImEncryptionEngine + * @return the user data + * @ingroup misc +*/ LINPHONE_PUBLIC void *linphone_im_encryption_engine_get_user_data(const LinphoneImEncryptionEngine *imee); +/** + * Sets the user data in the LinphoneImEncryptionEngine object + * @param imee the LinphoneImEncryptionEngine object + * @param data the user data + * @ingroup misc +*/ LINPHONE_PUBLIC void linphone_im_encryption_engine_set_user_data(LinphoneImEncryptionEngine *imee, void *data); +/** + * Gets the LinphoneImEncryptionEngineCbs object that holds the callbacks + * @param imee the LinphoneImEncryptionEngine object + * @return the LinphoneImEncryptionEngineCbs object + * @ingroup misc +*/ LINPHONE_PUBLIC LinphoneImEncryptionEngineCbs* linphone_im_encryption_engine_get_callbacks(const LinphoneImEncryptionEngine *imee); +/** + * Gets the callback that will decrypt the chat messages upon reception + * @param cbs the LinphoneImEncryptionEngineCbs object + * @return the callback + * @ingroup misc +*/ LINPHONE_PUBLIC LinphoneImEncryptionEngineIncomingMessageCb linphone_im_encryption_engine_cbs_get_process_incoming_message(LinphoneImEncryptionEngineCbs *cbs); +/** + * Sets the callback that will decrypt the chat messages upon reception + * @param cbs the LinphoneImEncryptionEngineCbs object + * @param cb the callback to call + * @ingroup misc +*/ LINPHONE_PUBLIC void linphone_im_encryption_engine_cbs_set_process_incoming_message(LinphoneImEncryptionEngineCbs *cbs, LinphoneImEncryptionEngineIncomingMessageCb cb); +/** + * Gets the callback that will encrypt the chat messages before sending them + * @param cbs the LinphoneImEncryptionEngineCbs object + * @return the callback + * @ingroup misc +*/ LINPHONE_PUBLIC LinphoneImEncryptionEngineOutgoingMessageCb linphone_im_encryption_engine_cbs_get_process_outgoing_message(LinphoneImEncryptionEngineCbs *cbs); +/** + * Sets the callback that will encrypt the chat messages before sending them + * @param cbs the LinphoneImEncryptionEngineCbs object + * @param cb the callback to call + * @ingroup misc +*/ LINPHONE_PUBLIC void linphone_im_encryption_engine_cbs_set_process_outgoing_message(LinphoneImEncryptionEngineCbs *cbs, LinphoneImEncryptionEngineOutgoingMessageCb cb); +/** + * Gets the callback that will decrypt the files while downloading them + * @param cbs the LinphoneImEncryptionEngineCbs object + * @return the callback + * @ingroup misc +*/ LINPHONE_PUBLIC LinphoneImEncryptionEngineDownloadingFileCb linphone_im_encryption_engine_cbs_get_process_downloading_file(LinphoneImEncryptionEngineCbs *cbs); +/** + * Sets the callback that will decrypt the files while downloading them + * @param cbs the LinphoneImEncryptionEngineCbs object + * @param cb the callback to call + * @ingroup misc +*/ LINPHONE_PUBLIC void linphone_im_encryption_engine_cbs_set_process_downloading_file(LinphoneImEncryptionEngineCbs *cbs, LinphoneImEncryptionEngineDownloadingFileCb cb); +/** + * Gets the callback that will will encrypt the files while uploading them + * @param cbs the LinphoneImEncryptionEngineCbs object + * @return the callback + * @ingroup misc +*/ LINPHONE_PUBLIC LinphoneImEncryptionEngineUploadingFileCb linphone_im_encryption_engine_cbs_get_process_uploading_file(LinphoneImEncryptionEngineCbs *cbs); +/** + * Sets the callback that will encrypt the files while uploading them + * @param cbs the LinphoneImEncryptionEngineCbs object + * @param cb the callback to call + * @ingroup misc +*/ LINPHONE_PUBLIC void linphone_im_encryption_engine_cbs_set_process_uploading_file(LinphoneImEncryptionEngineCbs *cbs, LinphoneImEncryptionEngineUploadingFileCb cb); +/** + * Gets the callback telling wheter or not to encrypt the files + * @param cbs the LinphoneImEncryptionEngineCbs object + * @return the callback + * @ingroup misc +*/ LINPHONE_PUBLIC LinphoneImEncryptionEngineIsEncryptionEnabledForFileTransferCb linphone_im_encryption_engine_cbs_get_is_encryption_enabled_for_file_transfer(LinphoneImEncryptionEngineCbs *cbs); +/** + * Sets the callback telling wheter or not to encrypt the files + * @param cbs the LinphoneImEncryptionEngineCbs object + * @param cb the callback to call + * @ingroup misc +*/ LINPHONE_PUBLIC void linphone_im_encryption_engine_cbs_set_is_encryption_enabled_for_file_transfer(LinphoneImEncryptionEngineCbs *cbs, LinphoneImEncryptionEngineIsEncryptionEnabledForFileTransferCb cb); +/** + * Gets the callback that will generate the key to encrypt the file before uploading it + * @param cbs the LinphoneImEncryptionEngineCbs object + * @return the callback + * @ingroup misc +*/ LINPHONE_PUBLIC LinphoneImEncryptionEngineGenerateFileTransferKeyCb linphone_im_encryption_engine_cbs_get_generate_file_transfer_key(LinphoneImEncryptionEngineCbs *cbs); +/** + * Sets the callback that will generate the key to encrypt the file before uploading it + * @param cbs the LinphoneImEncryptionEngineCbs object + * @param cb the callback to call + * @ingroup misc +*/ LINPHONE_PUBLIC void linphone_im_encryption_engine_cbs_set_generate_file_transfer_key(LinphoneImEncryptionEngineCbs *cbs, LinphoneImEncryptionEngineGenerateFileTransferKeyCb cb); #endif /* IM_ENCRYPTION_ENGINE_H */ \ No newline at end of file diff --git a/coreapi/linphonecore.h b/coreapi/linphonecore.h index 26cfa6817..69a375e62 100644 --- a/coreapi/linphonecore.h +++ b/coreapi/linphonecore.h @@ -4741,8 +4741,20 @@ LINPHONE_PUBLIC const char *linphone_core_get_tls_key_path(const LinphoneCore *l #include "linphone/im_encryption_engine.h" #endif +/** + * @ingroup chatroom + * Sets an IM Encryption Engine in the core + * @param lc LinphoneCore object + * @param imee LinphoneImEncryptionEngine object + */ LINPHONE_PUBLIC void linphone_core_set_im_encryption_engine(LinphoneCore *lc, LinphoneImEncryptionEngine *imee); +/** + * @ingroup chatroom + * Gets the IM Encryption Engine in the core if possible + * @param lc LinphoneCore object + * @return the IM Encryption Engine in the core or NULL + */ LINPHONE_PUBLIC LinphoneImEncryptionEngine * linphone_core_get_im_encryption_engine(const LinphoneCore *lc); #include "ringtoneplayer.h" From b45e6dcc8dc9624676d6f8a669ef6d670b5cadf3 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Mon, 14 Nov 2016 10:40:10 +0100 Subject: [PATCH 17/21] Added remove custom header method for chat message + test --- coreapi/bellesip_sal/sal_impl.c | 8 ++++++++ coreapi/chat.c | 4 ++++ coreapi/linphonecore.h | 8 +++++++- include/sal/sal.h | 1 + tester/message_tester.c | 30 ++++++++++++++++++++++++++++++ 5 files changed, 50 insertions(+), 1 deletion(-) diff --git a/coreapi/bellesip_sal/sal_impl.c b/coreapi/bellesip_sal/sal_impl.c index 8ccde1378..e01faa9a9 100644 --- a/coreapi/bellesip_sal/sal_impl.c +++ b/coreapi/bellesip_sal/sal_impl.c @@ -993,6 +993,14 @@ const char *sal_custom_header_find(const SalCustomHeader *ch, const char *name){ return NULL; } +SalCustomHeader *sal_custom_header_remove(SalCustomHeader *ch, const char *name) { + belle_sip_message_t *msg=(belle_sip_message_t*)ch; + if (msg==NULL) return NULL; + + belle_sip_message_remove_header(msg, name); + return (SalCustomHeader*)msg; +} + void sal_custom_header_free(SalCustomHeader *ch){ if (ch==NULL) return; belle_sip_object_unref((belle_sip_message_t*)ch); diff --git a/coreapi/chat.c b/coreapi/chat.c index 174555ded..1e9d8af9e 100644 --- a/coreapi/chat.c +++ b/coreapi/chat.c @@ -1129,6 +1129,10 @@ const char *linphone_chat_message_get_custom_header(LinphoneChatMessage *msg, co return sal_custom_header_find(msg->custom_headers, header_name); } +void linphone_chat_message_remove_custom_header(LinphoneChatMessage *msg, const char *header_name) { + msg->custom_headers = sal_custom_header_remove(msg->custom_headers, header_name); +} + bool_t linphone_chat_message_is_read(LinphoneChatMessage *msg) { return msg->is_read; } diff --git a/coreapi/linphonecore.h b/coreapi/linphonecore.h index 69a375e62..2622c0610 100644 --- a/coreapi/linphonecore.h +++ b/coreapi/linphonecore.h @@ -1804,7 +1804,7 @@ LINPHONE_PUBLIC LinphoneAddress *linphone_chat_message_get_local_address(const L /** * Add custom headers to the message. * @param message the message - * @param header_name name of the header_name + * @param header_name name of the header * @param header_value header value **/ LINPHONE_PUBLIC void linphone_chat_message_add_custom_header(LinphoneChatMessage* message, const char *header_name, const char *header_value); @@ -1814,6 +1814,12 @@ LINPHONE_PUBLIC void linphone_chat_message_add_custom_header(LinphoneChatMessage * @param header_name header name searched **/ LINPHONE_PUBLIC const char * linphone_chat_message_get_custom_header(LinphoneChatMessage* message, const char *header_name); +/** + * Removes a custom header from the message. + * @param message the message + * @param header_name name of the header to remove +**/ +LINPHONE_PUBLIC void linphone_chat_message_remove_custom_header(LinphoneChatMessage *msg, const char *header_name); /** * Returns TRUE if the message has been read, otherwise returns FALSE. * @param message the message diff --git a/include/sal/sal.h b/include/sal/sal.h index f9fd31e4a..65de05736 100644 --- a/include/sal/sal.h +++ b/include/sal/sal.h @@ -851,6 +851,7 @@ void sal_resolve_cancel(SalResolverContext *ctx); SalCustomHeader *sal_custom_header_append(SalCustomHeader *ch, const char *name, const char *value); const char *sal_custom_header_find(const SalCustomHeader *ch, const char *name); +SalCustomHeader *sal_custom_header_remove(SalCustomHeader *ch, const char *name); void sal_custom_header_free(SalCustomHeader *ch); SalCustomHeader *sal_custom_header_clone(const SalCustomHeader *ch); diff --git a/tester/message_tester.c b/tester/message_tester.c index 203264e16..694b24c64 100644 --- a/tester/message_tester.c +++ b/tester/message_tester.c @@ -1901,6 +1901,35 @@ void file_transfer_with_http_proxy(void) { } } +void chat_message_custom_headers(void) { + LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc"); + LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_tcp_rc"); + LinphoneChatRoom* chat_room = linphone_core_get_chat_room(pauline->lc, marie->identity); + LinphoneChatMessage* msg = linphone_chat_room_create_message(chat_room, "Lorem Ipsum"); + LinphoneChatMessageCbs *cbs = linphone_chat_message_get_callbacks(msg); + + linphone_chat_message_add_custom_header(msg, "Test1", "Value1"); + linphone_chat_message_add_custom_header(msg, "Test2", "Value2"); + linphone_chat_message_remove_custom_header(msg, "Test1"); + + linphone_chat_message_cbs_set_msg_state_changed(cbs,liblinphone_tester_chat_message_msg_state_changed); + linphone_chat_room_send_chat_message(chat_room,msg); + + BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneMessageReceived,1)); + BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneMessageDelivered,1)); + + if (marie->stat.last_received_chat_message) { + const char *header = linphone_chat_message_get_custom_header(marie->stat.last_received_chat_message, "Test2"); + BC_ASSERT_STRING_EQUAL(header, "Value2"); + header = linphone_chat_message_get_custom_header(marie->stat.last_received_chat_message, "Test1"); + BC_ASSERT_PTR_NULL(header); + BC_ASSERT_STRING_EQUAL(marie->stat.last_received_chat_message->message, "Lorem Ipsum"); + } + + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); +} + test_t message_tests[] = { TEST_NO_TAG("Text message", text_message), TEST_NO_TAG("Text message within call dialog", text_message_within_call_dialog), @@ -1956,6 +1985,7 @@ test_t message_tests[] = { TEST_ONE_TAG("Real Time Text offer answer with different payload numbers (sender side)", real_time_text_message_different_text_codecs_payload_numbers_sender_side, "RTT"), TEST_ONE_TAG("Real Time Text offer answer with different payload numbers (receiver side)", real_time_text_message_different_text_codecs_payload_numbers_receiver_side, "RTT"), TEST_ONE_TAG("Real Time Text copy paste", real_time_text_copy_paste, "RTT"), + TEST_NO_TAG("IM Encryption Engine custom headers", chat_message_custom_headers), }; test_suite_t message_test_suite = { From e51fee9e5bb6816299d70a45b0acda6c9f259533 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Mon, 14 Nov 2016 14:39:50 +0100 Subject: [PATCH 18/21] Fixed some message tests by removing previously downloaded file --- tester/message_tester.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tester/message_tester.c b/tester/message_tester.c index 694b24c64..e273453b5 100644 --- a/tester/message_tester.c +++ b/tester/message_tester.c @@ -450,6 +450,9 @@ void transfer_message_base2(LinphoneCoreManager* marie, LinphoneCoreManager* pau LinphoneChatMessage* msg; LinphoneChatMessageCbs *cbs; + /* Remove any previously downloaded file */ + remove(receive_filepath); + /* Globally configure an http file transfer server. */ linphone_core_set_file_transfer_server(pauline->lc,"https://www.linphone.org:444/lft.php"); @@ -656,6 +659,9 @@ static void file_transfer_2_messages_simultaneously(void) { char *receive_filepath = bc_tester_file("receive_file.dump"); LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_tcp_rc"); + /* Remove any previously downloaded file */ + remove(receive_filepath); + /* Globally configure an http file transfer server. */ linphone_core_set_file_transfer_server(pauline->lc,"https://www.linphone.org:444/lft.php"); @@ -919,6 +925,9 @@ void lime_transfer_message_base(bool_t encrypt_file,bool_t download_file_from_st char *send_filepath = bc_tester_res("images/nowebcamCIF.jpg"); char *receive_filepath = bc_tester_file("receive_file.dump"); MSList * msg_list = NULL; + + /* Remove any previously downloaded file */ + remove(receive_filepath); marie = linphone_core_manager_new( "marie_rc"); pauline = linphone_core_manager_new( "pauline_tcp_rc"); From d3333be0717aba0ee76296a3686473e789a6d476 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Mon, 14 Nov 2016 16:49:22 +0100 Subject: [PATCH 19/21] More tests for lime file transfer + few improvements --- coreapi/chat.c | 2 +- coreapi/chat_file_transfer.c | 36 ++++++++++++++++++++---------------- tester/message_tester.c | 26 ++++++++++++++++++-------- 3 files changed, 39 insertions(+), 25 deletions(-) diff --git a/coreapi/chat.c b/coreapi/chat.c index 1e9d8af9e..7f5187d2b 100644 --- a/coreapi/chat.c +++ b/coreapi/chat.c @@ -586,7 +586,7 @@ LinphoneReason linphone_core_message_received(LinphoneCore *lc, SalOp *op, const uint8_t *keyBuffer = (uint8_t *)malloc(keyLength); /* decode the key into local key buffer */ b64_decode((char *)keyb64, strlen((char *)keyb64), keyBuffer, keyLength); - linphone_content_set_key(msg->file_transfer_information, (char *)keyBuffer, strlen((char *)keyBuffer)); + linphone_content_set_key(msg->file_transfer_information, (char *)keyBuffer, keyLength); /* duplicate key value into the linphone content private structure */ xmlFree(keyb64); free(keyBuffer); diff --git a/coreapi/chat_file_transfer.c b/coreapi/chat_file_transfer.c index 7078191e4..1773df4fe 100644 --- a/coreapi/chat_file_transfer.c +++ b/coreapi/chat_file_transfer.c @@ -199,11 +199,11 @@ static void linphone_chat_message_process_response_from_post_file(void *data, /* create a user body handler to take care of the file and add the content disposition and content-type * headers */ if (msg->file_transfer_filepath != NULL) { - first_part_bh = (belle_sip_body_handler_t *)belle_sip_file_body_handler_new(msg->file_transfer_filepath, NULL, msg); + first_part_bh = (belle_sip_body_handler_t *)belle_sip_file_body_handler_new(msg->file_transfer_filepath, linphone_chat_message_file_transfer_on_progress, msg); } else if (linphone_content_get_buffer(msg->file_transfer_information) != NULL) { first_part_bh = (belle_sip_body_handler_t *)belle_sip_memory_body_handler_new_from_buffer( linphone_content_get_buffer(msg->file_transfer_information), - linphone_content_get_size(msg->file_transfer_information), NULL, msg); + linphone_content_get_size(msg->file_transfer_information), linphone_chat_message_file_transfer_on_progress, msg); } else { first_part_bh = (belle_sip_body_handler_t *)belle_sip_user_body_handler_new( linphone_content_get_size(msg->file_transfer_information), NULL, NULL, @@ -231,6 +231,7 @@ static void linphone_chat_message_process_response_from_post_file(void *data, /* if we have an encryption key for the file, we must insert it into the msg and restore the correct * filename */ const char *content_key = linphone_content_get_key(msg->file_transfer_information); + size_t content_key_size = linphone_content_get_key_size(msg->file_transfer_information); if (content_key != NULL) { /* parse the msg body */ xmlDocPtr xmlMessageBody = xmlParseDoc((const xmlChar *)body); @@ -250,11 +251,11 @@ static void linphone_chat_message_process_response_from_post_file(void *data, ->xmlChildrenNode; /* need to parse the children node to update the file-name one */ /* convert key to base64 */ - size_t b64Size = b64_encode(NULL, strlen(content_key), NULL, 0); + size_t b64Size = b64_encode(NULL, content_key_size, NULL, 0); char *keyb64 = (char *)ms_malloc0(b64Size + 1); int xmlStringLength; - b64Size = b64_encode(content_key, strlen(content_key), keyb64, b64Size); + b64Size = b64_encode(content_key, content_key_size, keyb64, b64Size); keyb64[b64Size] = '\0'; /* libxml need a null terminated string */ /* add the node containing the key to the file-info node */ @@ -455,24 +456,27 @@ static void linphone_chat_process_response_from_get_file(void *data, const belle if (msg->file_transfer_filepath == NULL) { retval = cb_process_downloading_file(lc, msg, NULL, 0, NULL); } else { + ssize_t file_ret; bctbx_vfs_t *vfs = bctbx_vfs_get_default(); - bctbx_vfs_file_t *decrypted_file; - bctbx_vfs_file_t *encrypted_file = bctbx_file_open(vfs, msg->file_transfer_filepath, "r"); - size_t encrypted_file_size = (size_t)bctbx_file_size(encrypted_file); + bctbx_vfs_file_t *file = bctbx_file_open(vfs, msg->file_transfer_filepath, "r+"); + size_t encrypted_file_size = (size_t)bctbx_file_size(file); char *encrypted_content = bctbx_malloc(encrypted_file_size); char *decrypted_content = bctbx_malloc(encrypted_file_size); - retval = (int)bctbx_file_read(encrypted_file, encrypted_content, encrypted_file_size, 0); - bctbx_file_close(encrypted_file); - if (retval != BCTBX_VFS_ERROR && retval == (int)encrypted_file_size) { + + file_ret = (int)bctbx_file_read(file, encrypted_content, encrypted_file_size, 0); + if (file_ret != BCTBX_VFS_ERROR && encrypted_file_size == (size_t)file_ret) { retval = cb_process_downloading_file(lc, msg, encrypted_content, encrypted_file_size, decrypted_content); cb_process_downloading_file(lc, msg, NULL, 0, NULL); - decrypted_file = bctbx_file_open(vfs, msg->file_transfer_filepath, "w"); - bctbx_file_write(decrypted_file, decrypted_content, encrypted_file_size, 0); - bctbx_file_close(decrypted_file); + file_ret = bctbx_file_write(file, decrypted_content, encrypted_file_size, 0); + if (file_ret == BCTBX_VFS_ERROR) { + ms_error("file %s write failed: expected %lu, got %lu", msg->file_transfer_filepath, encrypted_file_size, file_ret); + retval = 503; + } } else { - ms_error("file %s read failed: expected %d, got %d", msg->file_transfer_filepath, (int)encrypted_file_size, retval); - retval = 500; + ms_error("file %s read failed: expected %lu, got %lu", msg->file_transfer_filepath, encrypted_file_size, file_ret); + retval = 503; } + bctbx_file_close(file); bctbx_free(encrypted_content); bctbx_free(decrypted_content); } @@ -493,7 +497,7 @@ static void linphone_chat_process_response_from_get_file(void *data, const belle if (retval <= 0) { linphone_chat_message_set_state(msg, LinphoneChatMessageStateFileTransferDone); } else { - ms_warning("File transfer decrypt failed with code %d", code); + ms_warning("File transfer decrypt failed with code %d and http code %d", (int)retval, code); linphone_chat_message_set_state(msg, LinphoneChatMessageStateFileTransferError); } } else if (code >= 400 && code < 500) { diff --git a/tester/message_tester.c b/tester/message_tester.c index e273453b5..7e8fa0ab7 100644 --- a/tester/message_tester.c +++ b/tester/message_tester.c @@ -915,7 +915,7 @@ end: linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); } -void lime_transfer_message_base(bool_t encrypt_file,bool_t download_file_from_stored_msg, bool_t use_file_body_handler) { +void lime_transfer_message_base(bool_t encrypt_file,bool_t download_file_from_stored_msg, bool_t use_file_body_handler_in_upload, bool_t use_file_body_handler_in_download) { FILE *ZIDCacheMarieFD, *ZIDCachePaulineFD; LinphoneCoreManager *marie, *pauline; LinphoneChatMessage *msg; @@ -968,7 +968,7 @@ void lime_transfer_message_base(bool_t encrypt_file,bool_t download_file_from_st linphone_core_set_file_transfer_server(pauline->lc,"https://www.linphone.org:444/lft.php"); /* create a file transfer msg */ - if (use_file_body_handler) { + if (use_file_body_handler_in_upload) { msg = create_file_transfer_message_from_nowebcam(linphone_core_get_chat_room(pauline->lc, marie->identity)); } else { msg = create_message_from_nowebcam(linphone_core_get_chat_room(pauline->lc, marie->identity)); @@ -998,7 +998,7 @@ void lime_transfer_message_base(bool_t encrypt_file,bool_t download_file_from_st else BC_ASSERT_PTR_NULL(linphone_content_get_key(content)); - if (use_file_body_handler) { + if (use_file_body_handler_in_download) { linphone_chat_message_set_file_transfer_filepath(recv_msg, receive_filepath); } linphone_chat_message_download_file(recv_msg); @@ -1018,23 +1018,31 @@ end: } static void lime_transfer_message(void) { - lime_transfer_message_base(TRUE,FALSE,FALSE); + lime_transfer_message_base(TRUE, FALSE, FALSE, FALSE); } static void lime_transfer_message_2(void) { - lime_transfer_message_base(TRUE,FALSE,TRUE); + lime_transfer_message_base(TRUE, FALSE, TRUE, FALSE); +} + +static void lime_transfer_message_3(void) { + lime_transfer_message_base(TRUE, FALSE, FALSE, TRUE); +} + +static void lime_transfer_message_4(void) { + lime_transfer_message_base(TRUE, FALSE, TRUE, TRUE); } static void lime_transfer_message_from_history(void) { - lime_transfer_message_base(TRUE,TRUE,FALSE); + lime_transfer_message_base(TRUE, TRUE, FALSE, FALSE); } static void lime_transfer_message_without_encryption(void) { - lime_transfer_message_base(FALSE,FALSE,FALSE); + lime_transfer_message_base(FALSE, FALSE, FALSE, FALSE); } static void lime_transfer_message_without_encryption_2(void) { - lime_transfer_message_base(FALSE,FALSE,TRUE); + lime_transfer_message_base(FALSE, FALSE, TRUE, FALSE); } static void printHex(char *title, uint8_t *data, size_t length) { @@ -1967,6 +1975,8 @@ test_t message_tests[] = { TEST_NO_TAG("Lime text message to non lime", lime_text_message_to_non_lime), TEST_NO_TAG("Lime transfer message", lime_transfer_message), TEST_NO_TAG("Lime transfer message 2", lime_transfer_message_2), + TEST_NO_TAG("Lime transfer message 3", lime_transfer_message_3), + TEST_NO_TAG("Lime transfer message 4", lime_transfer_message_4), TEST_NO_TAG("Lime transfer message from history", lime_transfer_message_from_history), TEST_NO_TAG("Lime transfer message without encryption", lime_transfer_message_without_encryption), TEST_NO_TAG("Lime transfer message without encryption 2", lime_transfer_message_without_encryption_2), From 8aa812b1332c60718363e78aa95e0b694cdbaa26 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Tue, 15 Nov 2016 12:20:41 +0100 Subject: [PATCH 20/21] Fixed uploaded file not being encrypted when using file body handler for upload (requires commit e69a6d2c1b3edb0dff47f072e1cddc6ded06eaba from belle-sip branch dev_body_handler_inception) --- coreapi/chat_file_transfer.c | 119 ++++++++++++++--------------------- tester/message_tester.c | 46 +++++++------- 2 files changed, 71 insertions(+), 94 deletions(-) diff --git a/coreapi/chat_file_transfer.c b/coreapi/chat_file_transfer.c index 1773df4fe..3dc0ce9b7 100644 --- a/coreapi/chat_file_transfer.c +++ b/coreapi/chat_file_transfer.c @@ -92,7 +92,7 @@ static void linphone_chat_message_file_transfer_on_progress(belle_sip_body_handl } } -static int linphone_chat_message_file_transfer_on_send_body(belle_sip_user_body_handler_t *bh, belle_sip_message_t *m, +static int on_send_body(belle_sip_user_body_handler_t *bh, belle_sip_message_t *m, void *data, size_t offset, uint8_t *buffer, size_t *size) { LinphoneChatMessage *msg = (LinphoneChatMessage *)data; LinphoneCore *lc = NULL; @@ -108,10 +108,9 @@ static int linphone_chat_message_file_transfer_on_send_body(belle_sip_user_body_ } lc = msg->chat_room->lc; - /* if we've not reach the end of file yet, ask for more data*/ + /* if we've not reach the end of file yet, ask for more data */ + /* in case of file body handler, won't be called */ if (offset < linphone_content_get_size(msg->file_transfer_information)) { - char *plainBuffer = (char *)ms_malloc0(*size); - /* get data from call back */ LinphoneChatMessageCbsFileTransferSendCb file_transfer_send_cb = linphone_chat_message_cbs_get_file_transfer_send(msg->callbacks); if (file_transfer_send_cb) { @@ -120,30 +119,31 @@ static int linphone_chat_message_file_transfer_on_send_body(belle_sip_user_body_ *size = 0; } else { *size = linphone_buffer_get_size(lb); - memcpy(plainBuffer, linphone_buffer_get_content(lb), *size); + memcpy(buffer, linphone_buffer_get_content(lb), *size); linphone_buffer_unref(lb); } } else { /* Legacy */ - linphone_core_notify_file_transfer_send(lc, msg, msg->file_transfer_information, plainBuffer, size); + linphone_core_notify_file_transfer_send(lc, msg, msg->file_transfer_information, (char *)buffer, size); } + } - imee = linphone_core_get_im_encryption_engine(lc); - if (imee) { - LinphoneImEncryptionEngineCbs *imee_cbs = linphone_im_encryption_engine_get_callbacks(imee); - LinphoneImEncryptionEngineUploadingFileCb cb_process_uploading_file = linphone_im_encryption_engine_cbs_get_process_uploading_file(imee_cbs); - if (cb_process_uploading_file) { - retval = cb_process_uploading_file(lc, msg, offset, plainBuffer, size, (char *)buffer); - if (offset + *size >= linphone_content_get_size(msg->file_transfer_information)) { - /* conclude file ciphering by calling it context with a zero size */ - cb_process_uploading_file(lc, msg, 0, NULL, NULL, NULL); - } + imee = linphone_core_get_im_encryption_engine(lc); + if (imee) { + LinphoneImEncryptionEngineCbs *imee_cbs = linphone_im_encryption_engine_get_callbacks(imee); + LinphoneImEncryptionEngineUploadingFileCb cb_process_uploading_file = linphone_im_encryption_engine_cbs_get_process_uploading_file(imee_cbs); + if (cb_process_uploading_file) { + char *encrypted_buffer = (char *)ms_malloc0(*size); + retval = cb_process_uploading_file(lc, msg, offset, (char *)buffer, size, encrypted_buffer); + if (offset + *size >= linphone_content_get_size(msg->file_transfer_information)) { + /* conclude file ciphering by calling it context with a zero size */ + cb_process_uploading_file(lc, msg, 0, NULL, NULL, NULL); } + if (retval == 0) { + memcpy(buffer, encrypted_buffer, *size); + } + ms_free(encrypted_buffer); } - if (retval < 0) { - memcpy(buffer, plainBuffer, *size); - } - ms_free(plainBuffer); } return retval <= 0 ? BELLE_SIP_CONTINUE : BELLE_SIP_STOP; @@ -198,17 +198,21 @@ static void linphone_chat_message_process_response_from_post_file(void *data, /* create a user body handler to take care of the file and add the content disposition and content-type * headers */ + first_part_bh = (belle_sip_body_handler_t *)belle_sip_user_body_handler_new( + linphone_content_get_size(msg->file_transfer_information), + linphone_chat_message_file_transfer_on_progress, NULL, + on_send_body, msg); if (msg->file_transfer_filepath != NULL) { - first_part_bh = (belle_sip_body_handler_t *)belle_sip_file_body_handler_new(msg->file_transfer_filepath, linphone_chat_message_file_transfer_on_progress, msg); + belle_sip_user_body_handler_t *body_handler = (belle_sip_user_body_handler_t *)first_part_bh; + first_part_bh = (belle_sip_body_handler_t *)belle_sip_file_body_handler_new(msg->file_transfer_filepath, + linphone_chat_message_file_transfer_on_progress, msg); + belle_sip_file_body_handler_set_user_body_handler((belle_sip_file_body_handler_t *)first_part_bh, body_handler); } else if (linphone_content_get_buffer(msg->file_transfer_information) != NULL) { first_part_bh = (belle_sip_body_handler_t *)belle_sip_memory_body_handler_new_from_buffer( linphone_content_get_buffer(msg->file_transfer_information), linphone_content_get_size(msg->file_transfer_information), linphone_chat_message_file_transfer_on_progress, msg); - } else { - first_part_bh = (belle_sip_body_handler_t *)belle_sip_user_body_handler_new( - linphone_content_get_size(msg->file_transfer_information), NULL, NULL, - linphone_chat_message_file_transfer_on_send_body, msg); } + belle_sip_body_handler_add_header(first_part_bh, belle_sip_header_create("Content-disposition", first_part_header)); belle_sip_free(first_part_header); @@ -318,8 +322,7 @@ const LinphoneContent *linphone_chat_message_get_file_transfer_information(const return msg->file_transfer_information; } -static void on_recv_body(belle_sip_user_body_handler_t *bh, belle_sip_message_t *m, void *data, size_t offset, - const uint8_t *buffer, size_t size) { +static void on_recv_body(belle_sip_user_body_handler_t *bh, belle_sip_message_t *m, void *data, size_t offset, uint8_t *buffer, size_t size) { LinphoneChatMessage *msg = (LinphoneChatMessage *)data; LinphoneCore *lc = NULL; LinphoneImEncryptionEngine *imee = NULL; @@ -353,25 +356,23 @@ static void on_recv_body(belle_sip_user_body_handler_t *bh, belle_sip_message_t LinphoneImEncryptionEngineDownloadingFileCb cb_process_downloading_file = linphone_im_encryption_engine_cbs_get_process_downloading_file(imee_cbs); if (cb_process_downloading_file) { retval = cb_process_downloading_file(lc, msg, (const char *)buffer, size, decrypted_buffer); + if (retval == 0) { + memcpy(buffer, decrypted_buffer, size); + } } } + ms_free(decrypted_buffer); if (retval <= 0) { - const uint8_t *buffer_to_use = buffer; - if (retval == 0) { - buffer_to_use = (const uint8_t *)decrypted_buffer; - } - if (linphone_chat_message_cbs_get_file_transfer_recv(msg->callbacks)) { - LinphoneBuffer *lb = linphone_buffer_new_from_data(buffer_to_use, size); + LinphoneBuffer *lb = linphone_buffer_new_from_data(buffer, size); linphone_chat_message_cbs_get_file_transfer_recv(msg->callbacks)(msg, msg->file_transfer_information, lb); linphone_buffer_unref(lb); } else { /* Legacy: call back given by application level */ - linphone_core_notify_file_transfer_recv(lc, msg, msg->file_transfer_information, (const char *)buffer_to_use, size); + linphone_core_notify_file_transfer_recv(lc, msg, msg->file_transfer_information, (const char *)buffer, size); } } - ms_free(decrypted_buffer); return; } @@ -411,6 +412,7 @@ static void linphone_chat_process_response_headers_from_get_file(void *data, con /*we are receiving a response, set a specific body handler to acquire the response. * if not done, belle-sip will create a memory body handler, the default*/ belle_sip_message_t *response = BELLE_SIP_MESSAGE(event->response); + belle_sip_body_handler_t *body_handler = NULL; size_t body_size = 0; if (msg->file_transfer_information == NULL) { @@ -422,21 +424,20 @@ static void linphone_chat_process_response_headers_from_get_file(void *data, con body_size = linphone_content_get_size(msg->file_transfer_information); } - if (msg->file_transfer_filepath == NULL) { - belle_sip_message_set_body_handler( - (belle_sip_message_t *)event->response, - (belle_sip_body_handler_t *)belle_sip_user_body_handler_new( - body_size, linphone_chat_message_file_transfer_on_progress, on_recv_body, NULL, msg)); - } else { - belle_sip_body_handler_t *bh = (belle_sip_body_handler_t *)belle_sip_file_body_handler_new( + + body_handler = (belle_sip_body_handler_t *)belle_sip_user_body_handler_new(body_size, linphone_chat_message_file_transfer_on_progress, on_recv_body, NULL, msg); + if (msg->file_transfer_filepath != NULL) { + belle_sip_user_body_handler_t *bh = (belle_sip_user_body_handler_t *)body_handler; + body_handler = (belle_sip_body_handler_t *)belle_sip_file_body_handler_new( msg->file_transfer_filepath, linphone_chat_message_file_transfer_on_progress, msg); - if (belle_sip_body_handler_get_size(bh) == 0) { + if (belle_sip_body_handler_get_size((belle_sip_body_handler_t *)body_handler) == 0) { /* If the size of the body has not been initialized from the file stat, use the one from the * file_transfer_information. */ - belle_sip_body_handler_set_size(bh, body_size); + belle_sip_body_handler_set_size((belle_sip_body_handler_t *)body_handler, body_size); } - belle_sip_message_set_body_handler((belle_sip_message_t *)event->response, bh); + belle_sip_file_body_handler_set_user_body_handler((belle_sip_file_body_handler_t *)body_handler, bh); } + belle_sip_message_set_body_handler((belle_sip_message_t *)event->response, body_handler); } } @@ -453,33 +454,7 @@ static void linphone_chat_process_response_from_get_file(void *data, const belle LinphoneImEncryptionEngineCbs *imee_cbs = linphone_im_encryption_engine_get_callbacks(imee); LinphoneImEncryptionEngineDownloadingFileCb cb_process_downloading_file = linphone_im_encryption_engine_cbs_get_process_downloading_file(imee_cbs); if (cb_process_downloading_file) { - if (msg->file_transfer_filepath == NULL) { - retval = cb_process_downloading_file(lc, msg, NULL, 0, NULL); - } else { - ssize_t file_ret; - bctbx_vfs_t *vfs = bctbx_vfs_get_default(); - bctbx_vfs_file_t *file = bctbx_file_open(vfs, msg->file_transfer_filepath, "r+"); - size_t encrypted_file_size = (size_t)bctbx_file_size(file); - char *encrypted_content = bctbx_malloc(encrypted_file_size); - char *decrypted_content = bctbx_malloc(encrypted_file_size); - - file_ret = (int)bctbx_file_read(file, encrypted_content, encrypted_file_size, 0); - if (file_ret != BCTBX_VFS_ERROR && encrypted_file_size == (size_t)file_ret) { - retval = cb_process_downloading_file(lc, msg, encrypted_content, encrypted_file_size, decrypted_content); - cb_process_downloading_file(lc, msg, NULL, 0, NULL); - file_ret = bctbx_file_write(file, decrypted_content, encrypted_file_size, 0); - if (file_ret == BCTBX_VFS_ERROR) { - ms_error("file %s write failed: expected %lu, got %lu", msg->file_transfer_filepath, encrypted_file_size, file_ret); - retval = 503; - } - } else { - ms_error("file %s read failed: expected %lu, got %lu", msg->file_transfer_filepath, encrypted_file_size, file_ret); - retval = 503; - } - bctbx_file_close(file); - bctbx_free(encrypted_content); - bctbx_free(decrypted_content); - } + retval = cb_process_downloading_file(lc, msg, NULL, 0, NULL); } } diff --git a/tester/message_tester.c b/tester/message_tester.c index 7e8fa0ab7..4b1921b08 100644 --- a/tester/message_tester.c +++ b/tester/message_tester.c @@ -79,28 +79,30 @@ void file_transfer_received(LinphoneChatMessage *msg, const LinphoneContent* con LinphoneCore *lc = linphone_chat_room_get_core(cr); if (linphone_chat_message_get_file_transfer_filepath(msg) != NULL) { - stats* counters = get_stats(lc); - counters->number_of_LinphoneFileTransferDownloadSuccessful++; - return; - } - - receive_file = bc_tester_file("receive_file.dump"); - if (!linphone_chat_message_get_user_data(msg)) { - /*first chunk, creating file*/ - file = fopen(receive_file,"wb"); - linphone_chat_message_set_user_data(msg,(void*)file); /*store fd for next chunks*/ - } - bc_free(receive_file); - file = (FILE*)linphone_chat_message_get_user_data(msg); - BC_ASSERT_PTR_NOT_NULL(file); - if (linphone_buffer_is_empty(buffer)) { /* tranfer complete */ - stats* counters = get_stats(lc); - counters->number_of_LinphoneFileTransferDownloadSuccessful++; - linphone_chat_message_set_user_data(msg, NULL); - fclose(file); - } else { /* store content on a file*/ - if (fwrite(linphone_buffer_get_content(buffer),linphone_buffer_get_size(buffer),1,file)==0){ - ms_error("file_transfer_received(): write() failed: %s",strerror(errno)); + if (linphone_buffer_is_empty(buffer)) { + stats* counters = get_stats(lc); + counters->number_of_LinphoneFileTransferDownloadSuccessful++; + return; + } + } else { + receive_file = bc_tester_file("receive_file.dump"); + if (!linphone_chat_message_get_user_data(msg)) { + /*first chunk, creating file*/ + file = fopen(receive_file,"wb"); + linphone_chat_message_set_user_data(msg,(void*)file); /*store fd for next chunks*/ + } + bc_free(receive_file); + file = (FILE*)linphone_chat_message_get_user_data(msg); + BC_ASSERT_PTR_NOT_NULL(file); + if (linphone_buffer_is_empty(buffer)) { /* tranfer complete */ + stats* counters = get_stats(lc); + counters->number_of_LinphoneFileTransferDownloadSuccessful++; + linphone_chat_message_set_user_data(msg, NULL); + fclose(file); + } else { /* store content on a file*/ + if (fwrite(linphone_buffer_get_content(buffer),linphone_buffer_get_size(buffer),1,file)==0){ + ms_error("file_transfer_received(): write() failed: %s",strerror(errno)); + } } } } From a47db2730ef666e15bea9e1136369630a92f7cf8 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Tue, 15 Nov 2016 14:11:43 +0100 Subject: [PATCH 21/21] Using new start/stop callbacks from user body handler to simplify code (requires belle-sip commit 288dc8ede808a0033aaf5da4add7b11f034c82f8 from dev_body_handler_inception branch) --- coreapi/chat_file_transfer.c | 90 +++++++++++++++++++++--------------- coreapi/linphonecore.c | 2 +- 2 files changed, 53 insertions(+), 39 deletions(-) diff --git a/coreapi/chat_file_transfer.c b/coreapi/chat_file_transfer.c index 3dc0ce9b7..d9158a622 100644 --- a/coreapi/chat_file_transfer.c +++ b/coreapi/chat_file_transfer.c @@ -135,10 +135,6 @@ static int on_send_body(belle_sip_user_body_handler_t *bh, belle_sip_message_t * if (cb_process_uploading_file) { char *encrypted_buffer = (char *)ms_malloc0(*size); retval = cb_process_uploading_file(lc, msg, offset, (char *)buffer, size, encrypted_buffer); - if (offset + *size >= linphone_content_get_size(msg->file_transfer_information)) { - /* conclude file ciphering by calling it context with a zero size */ - cb_process_uploading_file(lc, msg, 0, NULL, NULL, NULL); - } if (retval == 0) { memcpy(buffer, encrypted_buffer, *size); } @@ -149,6 +145,20 @@ static int on_send_body(belle_sip_user_body_handler_t *bh, belle_sip_message_t * return retval <= 0 ? BELLE_SIP_CONTINUE : BELLE_SIP_STOP; } +static void on_send_end(belle_sip_user_body_handler_t *bh, void *data) { + LinphoneChatMessage *msg = (LinphoneChatMessage *)data; + LinphoneCore *lc = msg->chat_room->lc; + LinphoneImEncryptionEngine *imee = linphone_core_get_im_encryption_engine(lc); + + if (imee) { + LinphoneImEncryptionEngineCbs *imee_cbs = linphone_im_encryption_engine_get_callbacks(imee); + LinphoneImEncryptionEngineUploadingFileCb cb_process_uploading_file = linphone_im_encryption_engine_cbs_get_process_uploading_file(imee_cbs); + if (cb_process_uploading_file) { + cb_process_uploading_file(lc, msg, 0, NULL, NULL, NULL); + } + } +} + static void linphone_chat_message_process_response_from_post_file(void *data, const belle_http_response_event_t *event) { LinphoneChatMessage *msg = (LinphoneChatMessage *)data; @@ -200,8 +210,8 @@ static void linphone_chat_message_process_response_from_post_file(void *data, * headers */ first_part_bh = (belle_sip_body_handler_t *)belle_sip_user_body_handler_new( linphone_content_get_size(msg->file_transfer_information), - linphone_chat_message_file_transfer_on_progress, NULL, - on_send_body, msg); + linphone_chat_message_file_transfer_on_progress, NULL, NULL, + on_send_body, on_send_end, msg); if (msg->file_transfer_filepath != NULL) { belle_sip_user_body_handler_t *body_handler = (belle_sip_user_body_handler_t *)first_part_bh; first_part_bh = (belle_sip_body_handler_t *)belle_sip_file_body_handler_new(msg->file_transfer_filepath, @@ -372,11 +382,44 @@ static void on_recv_body(belle_sip_user_body_handler_t *bh, belle_sip_message_t /* Legacy: call back given by application level */ linphone_core_notify_file_transfer_recv(lc, msg, msg->file_transfer_information, (const char *)buffer, size); } + } else { + ms_warning("File transfer decrypt failed with code %d", (int)retval); + linphone_chat_message_set_state(msg, LinphoneChatMessageStateFileTransferError); } return; } +static void on_recv_end(belle_sip_user_body_handler_t *bh, void *data) { + LinphoneChatMessage *msg = (LinphoneChatMessage *)data; + LinphoneCore *lc = msg->chat_room->lc; + LinphoneImEncryptionEngine *imee = linphone_core_get_im_encryption_engine(lc); + int retval = -1; + + if (imee) { + LinphoneImEncryptionEngineCbs *imee_cbs = linphone_im_encryption_engine_get_callbacks(imee); + LinphoneImEncryptionEngineDownloadingFileCb cb_process_downloading_file = linphone_im_encryption_engine_cbs_get_process_downloading_file(imee_cbs); + if (cb_process_downloading_file) { + retval = cb_process_downloading_file(lc, msg, NULL, 0, NULL); + } + } + + if (retval <= 0) { + if (linphone_chat_message_cbs_get_file_transfer_recv(msg->callbacks)) { + LinphoneBuffer *lb = linphone_buffer_new(); + linphone_chat_message_cbs_get_file_transfer_recv(msg->callbacks)(msg, msg->file_transfer_information, lb); + linphone_buffer_unref(lb); + } else { + /* Legacy: call back given by application level */ + linphone_core_notify_file_transfer_recv(lc, msg, msg->file_transfer_information, NULL, 0); + } + } + + if (retval <= 0 && linphone_chat_message_get_state(msg) != LinphoneChatMessageStateFileTransferError) { + linphone_chat_message_set_state(msg, LinphoneChatMessageStateFileTransferDone); + } +} + static LinphoneContent *linphone_chat_create_file_transfer_information_from_headers(const belle_sip_message_t *m) { LinphoneContent *content = linphone_content_new(); @@ -425,7 +468,7 @@ static void linphone_chat_process_response_headers_from_get_file(void *data, con } - body_handler = (belle_sip_body_handler_t *)belle_sip_user_body_handler_new(body_size, linphone_chat_message_file_transfer_on_progress, on_recv_body, NULL, msg); + body_handler = (belle_sip_body_handler_t *)belle_sip_user_body_handler_new(body_size, linphone_chat_message_file_transfer_on_progress, NULL, on_recv_body, NULL, on_recv_end, msg); if (msg->file_transfer_filepath != NULL) { belle_sip_user_body_handler_t *bh = (belle_sip_user_body_handler_t *)body_handler; body_handler = (belle_sip_body_handler_t *)belle_sip_file_body_handler_new( @@ -446,39 +489,10 @@ static void linphone_chat_process_response_from_get_file(void *data, const belle /* check the answer code */ if (event->response) { int code = belle_http_response_get_status_code(event->response); - if (code == 200) { - LinphoneCore *lc = msg->chat_room->lc; - int retval = -1; - LinphoneImEncryptionEngine *imee = linphone_core_get_im_encryption_engine(lc); - if (imee) { - LinphoneImEncryptionEngineCbs *imee_cbs = linphone_im_encryption_engine_get_callbacks(imee); - LinphoneImEncryptionEngineDownloadingFileCb cb_process_downloading_file = linphone_im_encryption_engine_cbs_get_process_downloading_file(imee_cbs); - if (cb_process_downloading_file) { - retval = cb_process_downloading_file(lc, msg, NULL, 0, NULL); - } - } - - if (retval <= 0) { - if (linphone_chat_message_cbs_get_file_transfer_recv(msg->callbacks)) { - LinphoneBuffer *lb = linphone_buffer_new(); - linphone_chat_message_cbs_get_file_transfer_recv(msg->callbacks)(msg, msg->file_transfer_information, lb); - linphone_buffer_unref(lb); - } else { - /* Legacy: call back given by application level */ - linphone_core_notify_file_transfer_recv(lc, msg, msg->file_transfer_information, NULL, 0); - } - } - - if (retval <= 0) { - linphone_chat_message_set_state(msg, LinphoneChatMessageStateFileTransferDone); - } else { - ms_warning("File transfer decrypt failed with code %d and http code %d", (int)retval, code); - linphone_chat_message_set_state(msg, LinphoneChatMessageStateFileTransferError); - } - } else if (code >= 400 && code < 500) { + if (code >= 400 && code < 500) { ms_warning("File transfer failed with code %d", code); linphone_chat_message_set_state(msg, LinphoneChatMessageStateFileTransferError); - } else { + } else if (code != 200) { ms_warning("Unhandled HTTP code response %d for file transfer", code); } _release_http_request(msg); diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index b226cb279..47f5d860e 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -514,7 +514,7 @@ static void process_response_from_post_file_log_collection(void *data, const bel first_part_header = belle_sip_strdup_printf("form-data; name=\"File\"; filename=\"%s\"", linphone_content_get_name(core->log_collection_upload_information)); /* Create a user body handler to take care of the file and add the content disposition and content-type headers */ - first_part_bh = belle_sip_user_body_handler_new(linphone_content_get_size(core->log_collection_upload_information), NULL, NULL, log_collection_upload_on_send_body, core); + first_part_bh = belle_sip_user_body_handler_new(linphone_content_get_size(core->log_collection_upload_information), NULL, NULL, NULL, log_collection_upload_on_send_body, NULL, core); belle_sip_body_handler_add_header((belle_sip_body_handler_t *)first_part_bh, belle_sip_header_create("Content-disposition", first_part_header)); belle_sip_free(first_part_header); belle_sip_body_handler_add_header((belle_sip_body_handler_t *)first_part_bh,