3 Copyright (C) 2012 Belledonne Communications SARL
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 /* Convert uPnP IGD logs to ortp logs */
24 void linphone_upnp_igd_print(void *cookie, upnp_igd_print_level level, const char *fmt, va_list list) {
25 int ortp_level = ORTP_DEBUG;
27 case UPNP_IGD_MESSAGE:
28 ortp_level = ORTP_MESSAGE;
30 case UPNP_IGD_WARNING:
31 ortp_level = ORTP_WARNING;
34 ortp_level = ORTP_ERROR;
39 ortp_logv(ortp_level, fmt, list);
42 void linphone_upnp_igd_callback(void *cookie, upnp_igd_event event, void *arg) {
43 LinphoneCore *lc = (LinphoneCore *)cookie;
44 UpnpContext *lupnp = &lc->upnp;
46 case UPNP_IGD_EXTERNAL_IPADDRESS_CHANGED:
47 case UPNP_IGD_NAT_ENABLED_CHANGED:
48 case UPNP_IGD_CONNECTION_STATUS_CHANGED:
56 int upnp_context_init(LinphoneCore *lc) {
57 UpnpContext *lupnp = &lc->upnp;
58 lupnp->upnp_igd_ctxt = NULL;
59 lupnp->upnp_igd_ctxt = upnp_igd_create(linphone_upnp_igd_callback, linphone_upnp_igd_print, lc);
60 if(lupnp->upnp_igd_ctxt == NULL) {
61 ms_error("Can't create uPnP IGD context");
67 void upnp_context_uninit(LinphoneCore *lc) {
68 UpnpContext *lupnp = &lc->upnp;
69 if(lupnp->upnp_igd_ctxt != NULL) {
70 upnp_igd_destroy(lupnp->upnp_igd_ctxt);
74 UpnpSession* upnp_session_new() {