linphone_tunnel_config.c 3.99 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
/***************************************************************************
 *            linphone_tunnel_config.c
 *
 *  Copyright  2012  Belledonne Communications
 ****************************************************************************/

/*
 *  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.
 */

23
#include "linphone/tunnel.h"
24

25
#include "c-wrapper/c-wrapper.h"
26

27 28 29
// TODO: From coreapi. Remove me later.
#include "private.h"

30
struct _LinphoneTunnelConfig {
31
	belle_sip_object_t base;
32 33 34
	char *host;
	int port;
	int remote_udp_mirror_port;
35 36
	int delay;
	void *user_data;
37 38
	char *host2;
	int port2;
39 40 41
};

LinphoneTunnelConfig *linphone_tunnel_config_new() {
42
	LinphoneTunnelConfig *ltc = belle_sip_object_new(LinphoneTunnelConfig);
43 44
	ltc->remote_udp_mirror_port = 12345;
	ltc->delay = 1000;
45
	ltc->port = 443;
46 47
	ltc->host2 = NULL;
	ltc->port2 = 0;
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
	return ltc;
}

void linphone_tunnel_config_set_host(LinphoneTunnelConfig *tunnel, const char *host) {
	if(tunnel->host != NULL) {
		ms_free(tunnel->host);
		tunnel->host = NULL;
	}
	if(host != NULL && strlen(host)) {
		tunnel->host = ms_strdup(host);
	}
}

const char *linphone_tunnel_config_get_host(const LinphoneTunnelConfig *tunnel) {
	return tunnel->host;
}

void linphone_tunnel_config_set_port(LinphoneTunnelConfig *tunnel, int port) {
	tunnel->port = port;
}

int linphone_tunnel_config_get_port(const LinphoneTunnelConfig *tunnel) {
	return tunnel->port;
}

73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
void linphone_tunnel_config_set_host2(LinphoneTunnelConfig *tunnel, const char *host) {
	if(tunnel->host2 != NULL) {
		ms_free(tunnel->host2);
		tunnel->host2 = NULL;
	}
	if(host != NULL && strlen(host)) {
		tunnel->host2 = ms_strdup(host);
	}
}

const char *linphone_tunnel_config_get_host2(const LinphoneTunnelConfig *tunnel) {
	return tunnel->host2;
}

void linphone_tunnel_config_set_port2(LinphoneTunnelConfig *tunnel, int port) {
	tunnel->port2 = port;
}

int linphone_tunnel_config_get_port2(const LinphoneTunnelConfig *tunnel) {
	return tunnel->port2;
}

95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
void linphone_tunnel_config_set_remote_udp_mirror_port(LinphoneTunnelConfig *tunnel, int remote_udp_mirror_port) {
	tunnel->remote_udp_mirror_port = remote_udp_mirror_port;
}

int linphone_tunnel_config_get_remote_udp_mirror_port(const LinphoneTunnelConfig *tunnel) {
	return tunnel->remote_udp_mirror_port;
}

void linphone_tunnel_config_set_delay(LinphoneTunnelConfig *tunnel, int delay) {
	tunnel->delay = delay;
}

int linphone_tunnel_config_get_delay(const LinphoneTunnelConfig *tunnel) {
	return tunnel->delay;
}

111
static void _linphone_tunnel_config_destroy(LinphoneTunnelConfig *tunnel) {
112 113 114 115 116
	if(tunnel->host != NULL) {
		ms_free(tunnel->host);
	}
}

117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
LinphoneTunnelConfig * linphone_tunnel_config_ref(LinphoneTunnelConfig *cfg){
	return (LinphoneTunnelConfig*)belle_sip_object_ref(cfg);
}

void linphone_tunnel_config_unref(LinphoneTunnelConfig *cfg){
	belle_sip_object_unref(cfg);
}

void linphone_tunnel_config_destroy(LinphoneTunnelConfig *tunnel){
	linphone_tunnel_config_unref(tunnel);
}

void linphone_tunnel_config_set_user_data(LinphoneTunnelConfig *cfg, void *ud){
	cfg->user_data = ud;
}

void *linphone_tunnel_config_get_user_data(LinphoneTunnelConfig *cfg){
	return cfg->user_data;
}

BELLE_SIP_DECLARE_NO_IMPLEMENTED_INTERFACES(LinphoneTunnelConfig);

BELLE_SIP_INSTANCIATE_VPTR(LinphoneTunnelConfig, belle_sip_object_t,
	(belle_sip_object_destroy_t)_linphone_tunnel_config_destroy,
	NULL, // clone
	NULL, // marshal
	FALSE
);