]> sjero.net Git - linphone/blob - coreapi/upnp.c
Starting uPNP integration
[linphone] / coreapi / upnp.c
1 /*
2 linphone
3 Copyright (C) 2012  Belledonne Communications SARL
4
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.
9
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.
14
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.
18 */
19
20 #include "upnp.h"
21 #include "private.h"
22
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;
26         switch(level) {
27         case UPNP_IGD_MESSAGE:
28                 ortp_level = ORTP_MESSAGE;
29                 break;
30         case UPNP_IGD_WARNING:
31                 ortp_level = ORTP_WARNING;
32                 break;
33         case UPNP_IGD_ERROR:
34                 ortp_level = ORTP_ERROR;
35                 break;
36         default:
37                 break;
38         }
39         ortp_logv(ortp_level, fmt, list);
40 }
41
42 void linphone_upnp_igd_callback(void *cookie, upnp_igd_event event, void *arg) {
43         LinphoneCore *lc = (LinphoneCore *)cookie;
44         UpnpContext *lupnp = &lc->upnp;
45         switch(event) {
46         case UPNP_IGD_EXTERNAL_IPADDRESS_CHANGED:
47         case UPNP_IGD_NAT_ENABLED_CHANGED:
48         case UPNP_IGD_CONNECTION_STATUS_CHANGED:
49                 break;
50
51         default:
52                 break;
53         }
54 }
55
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");
62                 return -1;
63         }
64         return 0;
65 }
66
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);
71         }
72 }
73
74 UpnpSession* upnp_session_new() {
75         return NULL;
76 }