Mercurial > pidgin.yaz
annotate libpurple/network.c @ 32205:958621e23f5d
Fix the handling of IRC formatting following mIRC ^O.
Fixes #14436
author | Ethan Blanton <elb@pidgin.im> |
---|---|
date | Tue, 19 Jul 2011 16:56:23 +0000 |
parents | 8b434ffd4efc |
children | f22bc8b5b9dc |
rev | line source |
---|---|
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1 /** |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2 * @file network.c Network Implementation |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3 * @ingroup core |
20074
6bf32c9e15a7
remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@gmail.com>
parents:
19680
diff
changeset
|
4 */ |
6bf32c9e15a7
remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@gmail.com>
parents:
19680
diff
changeset
|
5 |
6bf32c9e15a7
remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@gmail.com>
parents:
19680
diff
changeset
|
6 /* purple |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
7 * |
15823 | 8 * Purple is the legal property of its developers, whose names are too numerous |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
9 * to list here. Please refer to the COPYRIGHT file distributed with this |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
10 * source distribution. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
11 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
12 * This program is free software; you can redistribute it and/or modify |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
13 * it under the terms of the GNU General Public License as published by |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
14 * the Free Software Foundation; either version 2 of the License, or |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
15 * (at your option) any later version. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
16 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
17 * This program is distributed in the hope that it will be useful, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
20 * GNU General Public License for more details. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
21 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
22 * You should have received a copy of the GNU General Public License |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
23 * along with this program; if not, write to the Free Software |
19680
44b4e8bd759b
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19653
diff
changeset
|
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
25 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
26 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
27 #include "internal.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
28 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
29 #ifndef _WIN32 |
23203
313b87adb730
A patch from Peter O'Gorman at The Written Word, Inc. to fix various
Peter O'Gorman <pogma@thewrittenword.com>
parents:
23045
diff
changeset
|
30 #include <arpa/nameser.h> |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
31 #include <resolv.h> |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
32 #include <netinet/in.h> |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
33 #include <net/if.h> |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
34 #include <sys/ioctl.h> |
29766
529233281dfe
network: Use getifaddrs() to enumerate local interfaces/IPs if available.
Paul Aurich <paul@darkrain42.org>
parents:
29760
diff
changeset
|
35 #ifdef HAVE_GETIFADDRS |
529233281dfe
network: Use getifaddrs() to enumerate local interfaces/IPs if available.
Paul Aurich <paul@darkrain42.org>
parents:
29760
diff
changeset
|
36 #include <ifaddrs.h> |
529233281dfe
network: Use getifaddrs() to enumerate local interfaces/IPs if available.
Paul Aurich <paul@darkrain42.org>
parents:
29760
diff
changeset
|
37 #endif |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
38 #else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
39 #include <nspapi.h> |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
40 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
41 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
42 /* Solaris */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
43 #if defined (__SVR4) && defined (__sun) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
44 #include <sys/sockio.h> |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
45 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
46 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
47 #include "debug.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
48 #include "account.h" |
15974
1a12ce76c4f4
The network module now registers the signal 'network-configuration-changed' and emits it when a network change is detected via libnm or the win32 network monitor. The UI could also emit this signal if it knows something network.c doesn't. UPnP and NAT-PMP respond to the signal by clearing their IP address caches; changing networks without quitting/relaunching will now lead to the new IP address being (lazily) determined. This commit also enables nat-pmp and adds nat-pmp.[h|c] to the build process; please let me know if there are any problems building, as I only have OS X test machines.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15949
diff
changeset
|
49 #include "nat-pmp.h" |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
50 #include "network.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
51 #include "prefs.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
52 #include "stun.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
53 #include "upnp.h" |
26132
ae3d25465d0f
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <ml@update.uu.se>
parents:
24856
diff
changeset
|
54 #include "dnsquery.h" |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
55 |
27711
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
56 #ifdef USE_IDN |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
57 #include <idna.h> |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
58 #endif |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
59 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
60 /* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
61 * Calling sizeof(struct ifreq) isn't always correct on |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
62 * Mac OS X (and maybe others). |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
63 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
64 #ifdef _SIZEOF_ADDR_IFREQ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
65 # define HX_SIZE_OF_IFREQ(a) _SIZEOF_ADDR_IFREQ(a) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
66 #else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
67 # define HX_SIZE_OF_IFREQ(a) sizeof(a) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
68 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
69 |
22867
0bd86dae2734
Use pkg-config to detect NetworkManager. Also, fail if it isn't present,
Richard Laager <rlaager@wiktel.com>
parents:
22862
diff
changeset
|
70 #ifdef HAVE_NETWORKMANAGER |
22847
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
71 #include <dbus/dbus-glib.h> |
22867
0bd86dae2734
Use pkg-config to detect NetworkManager. Also, fail if it isn't present,
Richard Laager <rlaager@wiktel.com>
parents:
22862
diff
changeset
|
72 #include <NetworkManager.h> |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
73 |
31905
f5a18dd894cc
Support new connection states in NetworkMakanter 0.9. Fixes #13505.
dcbw@redhat.com
parents:
31534
diff
changeset
|
74 #if !defined(NM_CHECK_VERSION) |
f5a18dd894cc
Support new connection states in NetworkMakanter 0.9. Fixes #13505.
dcbw@redhat.com
parents:
31534
diff
changeset
|
75 #define NM_CHECK_VERSION(x,y,z) 0 |
f5a18dd894cc
Support new connection states in NetworkMakanter 0.9. Fixes #13505.
dcbw@redhat.com
parents:
31534
diff
changeset
|
76 #endif |
f5a18dd894cc
Support new connection states in NetworkMakanter 0.9. Fixes #13505.
dcbw@redhat.com
parents:
31534
diff
changeset
|
77 |
22847
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
78 static DBusGConnection *nm_conn = NULL; |
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
79 static DBusGProxy *nm_proxy = NULL; |
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
80 static DBusGProxy *dbus_proxy = NULL; |
24243
785db7300ef2
Improve our NetworkManager support in a couple of ways:
Richard Laager <rlaager@wiktel.com>
parents:
23774
diff
changeset
|
81 static NMState nm_state = NM_STATE_UNKNOWN; |
785db7300ef2
Improve our NetworkManager support in a couple of ways:
Richard Laager <rlaager@wiktel.com>
parents:
23774
diff
changeset
|
82 static gboolean have_nm_state = FALSE; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
83 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
84 #elif defined _WIN32 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
85 static int current_network_count; |
24856
a6742d9eadf3
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <paul@darkrain42.org>
parents:
24243
diff
changeset
|
86 |
a6742d9eadf3
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <paul@darkrain42.org>
parents:
24243
diff
changeset
|
87 /* Mutex for the other global vars */ |
a6742d9eadf3
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <paul@darkrain42.org>
parents:
24243
diff
changeset
|
88 static GStaticMutex mutex = G_STATIC_MUTEX_INIT; |
25041
75f72178e361
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24856
diff
changeset
|
89 static gboolean network_initialized = FALSE; |
75f72178e361
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24856
diff
changeset
|
90 static HANDLE network_change_handle = NULL; |
75f72178e361
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24856
diff
changeset
|
91 static int (WSAAPI *MyWSANSPIoctl) ( |
75f72178e361
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24856
diff
changeset
|
92 HANDLE hLookup, DWORD dwControlCode, LPVOID lpvInBuffer, |
75f72178e361
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24856
diff
changeset
|
93 DWORD cbInBuffer, LPVOID lpvOutBuffer, DWORD cbOutBuffer, |
75f72178e361
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24856
diff
changeset
|
94 LPDWORD lpcbBytesReturned, LPWSACOMPLETION lpCompletion) = NULL; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
95 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
96 |
15823 | 97 struct _PurpleNetworkListenData { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
98 int listenfd; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
99 int socket_type; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
100 gboolean retry; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
101 gboolean adding; |
15823 | 102 PurpleNetworkListenCallback cb; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
103 gpointer cb_data; |
15441
56a2a0bb290a
Fix a crash when a network_listen_range process is canceled before its UPnP port mapping completes, which occurs regularly on certain routers when file transfers are initiated and then quickly finished. Much thanks to Elliott Harris and Eric Richie for their hard work with me hunting this down and fixing it.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15374
diff
changeset
|
104 UPnPMappingAddRemove *mapping_data; |
30777
c91976cf319c
Make sure we keep track of this timer and remove it if our caller frees
Mark Doliner <mark@kingant.net>
parents:
30153
diff
changeset
|
105 int timer; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
106 }; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
107 |
22867
0bd86dae2734
Use pkg-config to detect NetworkManager. Also, fail if it isn't present,
Richard Laager <rlaager@wiktel.com>
parents:
22862
diff
changeset
|
108 #ifdef HAVE_NETWORKMANAGER |
22847
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
109 static NMState nm_get_network_state(void); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
110 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
111 |
25343
b38cbefca6ad
Add a -f/--force-online option to Pidgin which tells libpurple to claim the
Richard Laager <rlaager@wiktel.com>
parents:
24243
diff
changeset
|
112 #if defined(HAVE_NETWORKMANAGER) || defined(_WIN32) |
b38cbefca6ad
Add a -f/--force-online option to Pidgin which tells libpurple to claim the
Richard Laager <rlaager@wiktel.com>
parents:
24243
diff
changeset
|
113 static gboolean force_online; |
b38cbefca6ad
Add a -f/--force-online option to Pidgin which tells libpurple to claim the
Richard Laager <rlaager@wiktel.com>
parents:
24243
diff
changeset
|
114 #endif |
b38cbefca6ad
Add a -f/--force-online option to Pidgin which tells libpurple to claim the
Richard Laager <rlaager@wiktel.com>
parents:
24243
diff
changeset
|
115 |
26137
c56e8826fed0
Added support to generate relayed candidates (TURN).
Marcus Lundblad <ml@update.uu.se>
parents:
26132
diff
changeset
|
116 /* Cached IP addresses for STUN and TURN servers (set globally in prefs) */ |
26132
ae3d25465d0f
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <ml@update.uu.se>
parents:
24856
diff
changeset
|
117 static gchar *stun_ip = NULL; |
26137
c56e8826fed0
Added support to generate relayed candidates (TURN).
Marcus Lundblad <ml@update.uu.se>
parents:
26132
diff
changeset
|
118 static gchar *turn_ip = NULL; |
26132
ae3d25465d0f
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <ml@update.uu.se>
parents:
24856
diff
changeset
|
119 |
27190
38c4973b5222
Add a function to remove a port mapping (UPnP or NAT-PMP) given a file
Marcus Lundblad <ml@update.uu.se>
parents:
26967
diff
changeset
|
120 /* Keep track of port mappings done with UPnP and NAT-PMP */ |
38c4973b5222
Add a function to remove a port mapping (UPnP or NAT-PMP) given a file
Marcus Lundblad <ml@update.uu.se>
parents:
26967
diff
changeset
|
121 static GHashTable *upnp_port_mappings = NULL; |
38c4973b5222
Add a function to remove a port mapping (UPnP or NAT-PMP) given a file
Marcus Lundblad <ml@update.uu.se>
parents:
26967
diff
changeset
|
122 static GHashTable *nat_pmp_port_mappings = NULL; |
38c4973b5222
Add a function to remove a port mapping (UPnP or NAT-PMP) given a file
Marcus Lundblad <ml@update.uu.se>
parents:
26967
diff
changeset
|
123 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
124 const unsigned char * |
15823 | 125 purple_network_ip_atoi(const char *ip) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
126 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
127 static unsigned char ret[4]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
128 gchar *delimiter = "."; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
129 gchar **split; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
130 int i; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
131 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
132 g_return_val_if_fail(ip != NULL, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
133 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
134 split = g_strsplit(ip, delimiter, 4); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
135 for (i = 0; split[i] != NULL; i++) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
136 ret[i] = atoi(split[i]); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
137 g_strfreev(split); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
138 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
139 /* i should always be 4 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
140 if (i != 4) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
141 return NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
142 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
143 return ret; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
144 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
145 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
146 void |
15823 | 147 purple_network_set_public_ip(const char *ip) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
148 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
149 g_return_if_fail(ip != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
150 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
151 /* XXX - Ensure the IP address is valid */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
152 |
16427
4999bbc52881
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents:
15974
diff
changeset
|
153 purple_prefs_set_string("/purple/network/public_ip", ip); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
154 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
155 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
156 const char * |
15823 | 157 purple_network_get_public_ip(void) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
158 { |
16427
4999bbc52881
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents:
15974
diff
changeset
|
159 return purple_prefs_get_string("/purple/network/public_ip"); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
160 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
161 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
162 const char * |
15823 | 163 purple_network_get_local_system_ip(int fd) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
164 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
165 char buffer[1024]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
166 static char ip[16]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
167 char *tmp; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
168 struct ifconf ifc; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
169 struct ifreq *ifr; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
170 struct sockaddr_in *sinptr; |
29760 | 171 guint32 lhost = htonl((127 << 24) + 1); /* 127.0.0.1 */ |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
172 long unsigned int add; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
173 int source = fd; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
174 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
175 if (fd < 0) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
176 source = socket(PF_INET,SOCK_STREAM, 0); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
177 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
178 ifc.ifc_len = sizeof(buffer); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
179 ifc.ifc_req = (struct ifreq *)buffer; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
180 ioctl(source, SIOCGIFCONF, &ifc); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
181 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
182 if (fd < 0) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
183 close(source); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
184 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
185 tmp = buffer; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
186 while (tmp < buffer + ifc.ifc_len) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
187 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
188 ifr = (struct ifreq *)tmp; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
189 tmp += HX_SIZE_OF_IFREQ(*ifr); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
190 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
191 if (ifr->ifr_addr.sa_family == AF_INET) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
192 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
193 sinptr = (struct sockaddr_in *)&ifr->ifr_addr; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
194 if (sinptr->sin_addr.s_addr != lhost) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
195 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
196 add = ntohl(sinptr->sin_addr.s_addr); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
197 g_snprintf(ip, 16, "%lu.%lu.%lu.%lu", |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
198 ((add >> 24) & 255), |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
199 ((add >> 16) & 255), |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
200 ((add >> 8) & 255), |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
201 add & 255); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
202 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
203 return ip; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
204 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
205 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
206 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
207 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
208 return "0.0.0.0"; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
209 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
210 |
29495
02f6f49da454
Add a function to enumerate all local IPs
Marcus Lundblad <ml@update.uu.se>
parents:
27711
diff
changeset
|
211 GList * |
29496
f1aa01ff26dd
Remove IPv6 support from _get_local_system_ips, since I couldn't get it to
Marcus Lundblad <ml@update.uu.se>
parents:
29495
diff
changeset
|
212 purple_network_get_all_local_system_ips(void) |
29495
02f6f49da454
Add a function to enumerate all local IPs
Marcus Lundblad <ml@update.uu.se>
parents:
27711
diff
changeset
|
213 { |
29768
ce3f4bd8939b
Oops, probably better if we have both getifaddrs() and inet_ntop()
Paul Aurich <paul@darkrain42.org>
parents:
29766
diff
changeset
|
214 #if defined(HAVE_GETIFADDRS) && defined(HAVE_INET_NTOP) |
29766
529233281dfe
network: Use getifaddrs() to enumerate local interfaces/IPs if available.
Paul Aurich <paul@darkrain42.org>
parents:
29760
diff
changeset
|
215 GList *result = NULL; |
529233281dfe
network: Use getifaddrs() to enumerate local interfaces/IPs if available.
Paul Aurich <paul@darkrain42.org>
parents:
29760
diff
changeset
|
216 struct ifaddrs *start, *ifa; |
529233281dfe
network: Use getifaddrs() to enumerate local interfaces/IPs if available.
Paul Aurich <paul@darkrain42.org>
parents:
29760
diff
changeset
|
217 int ret; |
529233281dfe
network: Use getifaddrs() to enumerate local interfaces/IPs if available.
Paul Aurich <paul@darkrain42.org>
parents:
29760
diff
changeset
|
218 |
529233281dfe
network: Use getifaddrs() to enumerate local interfaces/IPs if available.
Paul Aurich <paul@darkrain42.org>
parents:
29760
diff
changeset
|
219 ret = getifaddrs(&start); |
529233281dfe
network: Use getifaddrs() to enumerate local interfaces/IPs if available.
Paul Aurich <paul@darkrain42.org>
parents:
29760
diff
changeset
|
220 if (ret < 0) { |
529233281dfe
network: Use getifaddrs() to enumerate local interfaces/IPs if available.
Paul Aurich <paul@darkrain42.org>
parents:
29760
diff
changeset
|
221 purple_debug_warning("network", |
529233281dfe
network: Use getifaddrs() to enumerate local interfaces/IPs if available.
Paul Aurich <paul@darkrain42.org>
parents:
29760
diff
changeset
|
222 "getifaddrs() failed: %s\n", g_strerror(errno)); |
529233281dfe
network: Use getifaddrs() to enumerate local interfaces/IPs if available.
Paul Aurich <paul@darkrain42.org>
parents:
29760
diff
changeset
|
223 return NULL; |
529233281dfe
network: Use getifaddrs() to enumerate local interfaces/IPs if available.
Paul Aurich <paul@darkrain42.org>
parents:
29760
diff
changeset
|
224 } |
529233281dfe
network: Use getifaddrs() to enumerate local interfaces/IPs if available.
Paul Aurich <paul@darkrain42.org>
parents:
29760
diff
changeset
|
225 |
529233281dfe
network: Use getifaddrs() to enumerate local interfaces/IPs if available.
Paul Aurich <paul@darkrain42.org>
parents:
29760
diff
changeset
|
226 for (ifa = start; ifa; ifa = ifa->ifa_next) { |
529233281dfe
network: Use getifaddrs() to enumerate local interfaces/IPs if available.
Paul Aurich <paul@darkrain42.org>
parents:
29760
diff
changeset
|
227 int family = ifa->ifa_addr ? ifa->ifa_addr->sa_family : AF_UNSPEC; |
529233281dfe
network: Use getifaddrs() to enumerate local interfaces/IPs if available.
Paul Aurich <paul@darkrain42.org>
parents:
29760
diff
changeset
|
228 char host[INET6_ADDRSTRLEN]; |
529233281dfe
network: Use getifaddrs() to enumerate local interfaces/IPs if available.
Paul Aurich <paul@darkrain42.org>
parents:
29760
diff
changeset
|
229 const char *tmp = NULL; |
529233281dfe
network: Use getifaddrs() to enumerate local interfaces/IPs if available.
Paul Aurich <paul@darkrain42.org>
parents:
29760
diff
changeset
|
230 |
529233281dfe
network: Use getifaddrs() to enumerate local interfaces/IPs if available.
Paul Aurich <paul@darkrain42.org>
parents:
29760
diff
changeset
|
231 if ((family != AF_INET && family != AF_INET6) || ifa->ifa_flags & IFF_LOOPBACK) |
529233281dfe
network: Use getifaddrs() to enumerate local interfaces/IPs if available.
Paul Aurich <paul@darkrain42.org>
parents:
29760
diff
changeset
|
232 continue; |
529233281dfe
network: Use getifaddrs() to enumerate local interfaces/IPs if available.
Paul Aurich <paul@darkrain42.org>
parents:
29760
diff
changeset
|
233 |
529233281dfe
network: Use getifaddrs() to enumerate local interfaces/IPs if available.
Paul Aurich <paul@darkrain42.org>
parents:
29760
diff
changeset
|
234 if (family == AF_INET) |
529233281dfe
network: Use getifaddrs() to enumerate local interfaces/IPs if available.
Paul Aurich <paul@darkrain42.org>
parents:
29760
diff
changeset
|
235 tmp = inet_ntop(family, &((struct sockaddr_in *)ifa->ifa_addr)->sin_addr, host, sizeof(host)); |
529233281dfe
network: Use getifaddrs() to enumerate local interfaces/IPs if available.
Paul Aurich <paul@darkrain42.org>
parents:
29760
diff
changeset
|
236 else { |
529233281dfe
network: Use getifaddrs() to enumerate local interfaces/IPs if available.
Paul Aurich <paul@darkrain42.org>
parents:
29760
diff
changeset
|
237 struct sockaddr_in6 *sockaddr = (struct sockaddr_in6 *)ifa->ifa_addr; |
529233281dfe
network: Use getifaddrs() to enumerate local interfaces/IPs if available.
Paul Aurich <paul@darkrain42.org>
parents:
29760
diff
changeset
|
238 /* Peer-peer link-local communication is a big TODO. I am not sure |
529233281dfe
network: Use getifaddrs() to enumerate local interfaces/IPs if available.
Paul Aurich <paul@darkrain42.org>
parents:
29760
diff
changeset
|
239 * how communicating link-local addresses is supposed to work, and |
529233281dfe
network: Use getifaddrs() to enumerate local interfaces/IPs if available.
Paul Aurich <paul@darkrain42.org>
parents:
29760
diff
changeset
|
240 * it seems like it would require attempting the cartesian product |
529233281dfe
network: Use getifaddrs() to enumerate local interfaces/IPs if available.
Paul Aurich <paul@darkrain42.org>
parents:
29760
diff
changeset
|
241 * of the local and remote interfaces to see if any match (eww). |
529233281dfe
network: Use getifaddrs() to enumerate local interfaces/IPs if available.
Paul Aurich <paul@darkrain42.org>
parents:
29760
diff
changeset
|
242 */ |
529233281dfe
network: Use getifaddrs() to enumerate local interfaces/IPs if available.
Paul Aurich <paul@darkrain42.org>
parents:
29760
diff
changeset
|
243 if (!IN6_IS_ADDR_LINKLOCAL(&sockaddr->sin6_addr)) |
529233281dfe
network: Use getifaddrs() to enumerate local interfaces/IPs if available.
Paul Aurich <paul@darkrain42.org>
parents:
29760
diff
changeset
|
244 tmp = inet_ntop(family, &sockaddr->sin6_addr, host, sizeof(host)); |
529233281dfe
network: Use getifaddrs() to enumerate local interfaces/IPs if available.
Paul Aurich <paul@darkrain42.org>
parents:
29760
diff
changeset
|
245 } |
529233281dfe
network: Use getifaddrs() to enumerate local interfaces/IPs if available.
Paul Aurich <paul@darkrain42.org>
parents:
29760
diff
changeset
|
246 if (tmp != NULL) |
529233281dfe
network: Use getifaddrs() to enumerate local interfaces/IPs if available.
Paul Aurich <paul@darkrain42.org>
parents:
29760
diff
changeset
|
247 result = g_list_prepend(result, g_strdup(tmp)); |
529233281dfe
network: Use getifaddrs() to enumerate local interfaces/IPs if available.
Paul Aurich <paul@darkrain42.org>
parents:
29760
diff
changeset
|
248 } |
529233281dfe
network: Use getifaddrs() to enumerate local interfaces/IPs if available.
Paul Aurich <paul@darkrain42.org>
parents:
29760
diff
changeset
|
249 |
529233281dfe
network: Use getifaddrs() to enumerate local interfaces/IPs if available.
Paul Aurich <paul@darkrain42.org>
parents:
29760
diff
changeset
|
250 freeifaddrs(start); |
529233281dfe
network: Use getifaddrs() to enumerate local interfaces/IPs if available.
Paul Aurich <paul@darkrain42.org>
parents:
29760
diff
changeset
|
251 |
529233281dfe
network: Use getifaddrs() to enumerate local interfaces/IPs if available.
Paul Aurich <paul@darkrain42.org>
parents:
29760
diff
changeset
|
252 return g_list_reverse(result); |
29768
ce3f4bd8939b
Oops, probably better if we have both getifaddrs() and inet_ntop()
Paul Aurich <paul@darkrain42.org>
parents:
29766
diff
changeset
|
253 #else /* HAVE_GETIFADDRS && HAVE_INET_NTOP */ |
29495
02f6f49da454
Add a function to enumerate all local IPs
Marcus Lundblad <ml@update.uu.se>
parents:
27711
diff
changeset
|
254 GList *result = NULL; |
29760 | 255 int source = socket(PF_INET,SOCK_STREAM, 0); |
29495
02f6f49da454
Add a function to enumerate all local IPs
Marcus Lundblad <ml@update.uu.se>
parents:
27711
diff
changeset
|
256 char buffer[1024]; |
02f6f49da454
Add a function to enumerate all local IPs
Marcus Lundblad <ml@update.uu.se>
parents:
27711
diff
changeset
|
257 char *tmp; |
02f6f49da454
Add a function to enumerate all local IPs
Marcus Lundblad <ml@update.uu.se>
parents:
27711
diff
changeset
|
258 struct ifconf ifc; |
02f6f49da454
Add a function to enumerate all local IPs
Marcus Lundblad <ml@update.uu.se>
parents:
27711
diff
changeset
|
259 struct ifreq *ifr; |
29760 | 260 |
29495
02f6f49da454
Add a function to enumerate all local IPs
Marcus Lundblad <ml@update.uu.se>
parents:
27711
diff
changeset
|
261 ifc.ifc_len = sizeof(buffer); |
02f6f49da454
Add a function to enumerate all local IPs
Marcus Lundblad <ml@update.uu.se>
parents:
27711
diff
changeset
|
262 ifc.ifc_req = (struct ifreq *)buffer; |
02f6f49da454
Add a function to enumerate all local IPs
Marcus Lundblad <ml@update.uu.se>
parents:
27711
diff
changeset
|
263 ioctl(source, SIOCGIFCONF, &ifc); |
29496
f1aa01ff26dd
Remove IPv6 support from _get_local_system_ips, since I couldn't get it to
Marcus Lundblad <ml@update.uu.se>
parents:
29495
diff
changeset
|
264 close(source); |
29495
02f6f49da454
Add a function to enumerate all local IPs
Marcus Lundblad <ml@update.uu.se>
parents:
27711
diff
changeset
|
265 |
02f6f49da454
Add a function to enumerate all local IPs
Marcus Lundblad <ml@update.uu.se>
parents:
27711
diff
changeset
|
266 tmp = buffer; |
02f6f49da454
Add a function to enumerate all local IPs
Marcus Lundblad <ml@update.uu.se>
parents:
27711
diff
changeset
|
267 while (tmp < buffer + ifc.ifc_len) { |
29496
f1aa01ff26dd
Remove IPv6 support from _get_local_system_ips, since I couldn't get it to
Marcus Lundblad <ml@update.uu.se>
parents:
29495
diff
changeset
|
268 char dst[INET_ADDRSTRLEN]; |
29495
02f6f49da454
Add a function to enumerate all local IPs
Marcus Lundblad <ml@update.uu.se>
parents:
27711
diff
changeset
|
269 |
02f6f49da454
Add a function to enumerate all local IPs
Marcus Lundblad <ml@update.uu.se>
parents:
27711
diff
changeset
|
270 ifr = (struct ifreq *)tmp; |
02f6f49da454
Add a function to enumerate all local IPs
Marcus Lundblad <ml@update.uu.se>
parents:
27711
diff
changeset
|
271 tmp += HX_SIZE_OF_IFREQ(*ifr); |
02f6f49da454
Add a function to enumerate all local IPs
Marcus Lundblad <ml@update.uu.se>
parents:
27711
diff
changeset
|
272 |
02f6f49da454
Add a function to enumerate all local IPs
Marcus Lundblad <ml@update.uu.se>
parents:
27711
diff
changeset
|
273 if (ifr->ifr_addr.sa_family == AF_INET) { |
02f6f49da454
Add a function to enumerate all local IPs
Marcus Lundblad <ml@update.uu.se>
parents:
27711
diff
changeset
|
274 struct sockaddr_in *sinptr = (struct sockaddr_in *)&ifr->ifr_addr; |
02f6f49da454
Add a function to enumerate all local IPs
Marcus Lundblad <ml@update.uu.se>
parents:
27711
diff
changeset
|
275 |
02f6f49da454
Add a function to enumerate all local IPs
Marcus Lundblad <ml@update.uu.se>
parents:
27711
diff
changeset
|
276 inet_ntop(AF_INET, &sinptr->sin_addr, dst, |
02f6f49da454
Add a function to enumerate all local IPs
Marcus Lundblad <ml@update.uu.se>
parents:
27711
diff
changeset
|
277 sizeof(dst)); |
31534
a8cc50c2279f
Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents:
31423
diff
changeset
|
278 purple_debug_info("network", |
29495
02f6f49da454
Add a function to enumerate all local IPs
Marcus Lundblad <ml@update.uu.se>
parents:
27711
diff
changeset
|
279 "found local i/f with address %s on IPv4\n", dst); |
02f6f49da454
Add a function to enumerate all local IPs
Marcus Lundblad <ml@update.uu.se>
parents:
27711
diff
changeset
|
280 if (!purple_strequal(dst, "127.0.0.1")) { |
02f6f49da454
Add a function to enumerate all local IPs
Marcus Lundblad <ml@update.uu.se>
parents:
27711
diff
changeset
|
281 result = g_list_append(result, g_strdup(dst)); |
02f6f49da454
Add a function to enumerate all local IPs
Marcus Lundblad <ml@update.uu.se>
parents:
27711
diff
changeset
|
282 } |
02f6f49da454
Add a function to enumerate all local IPs
Marcus Lundblad <ml@update.uu.se>
parents:
27711
diff
changeset
|
283 } |
02f6f49da454
Add a function to enumerate all local IPs
Marcus Lundblad <ml@update.uu.se>
parents:
27711
diff
changeset
|
284 } |
02f6f49da454
Add a function to enumerate all local IPs
Marcus Lundblad <ml@update.uu.se>
parents:
27711
diff
changeset
|
285 |
02f6f49da454
Add a function to enumerate all local IPs
Marcus Lundblad <ml@update.uu.se>
parents:
27711
diff
changeset
|
286 return result; |
29768
ce3f4bd8939b
Oops, probably better if we have both getifaddrs() and inet_ntop()
Paul Aurich <paul@darkrain42.org>
parents:
29766
diff
changeset
|
287 #endif /* HAVE_GETIFADDRS && HAVE_INET_NTOP */ |
29495
02f6f49da454
Add a function to enumerate all local IPs
Marcus Lundblad <ml@update.uu.se>
parents:
27711
diff
changeset
|
288 } |
02f6f49da454
Add a function to enumerate all local IPs
Marcus Lundblad <ml@update.uu.se>
parents:
27711
diff
changeset
|
289 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
290 const char * |
15823 | 291 purple_network_get_my_ip(int fd) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
292 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
293 const char *ip = NULL; |
15823 | 294 PurpleStunNatDiscovery *stun; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
295 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
296 /* Check if the user specified an IP manually */ |
16427
4999bbc52881
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents:
15974
diff
changeset
|
297 if (!purple_prefs_get_bool("/purple/network/auto_ip")) { |
15823 | 298 ip = purple_network_get_public_ip(); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
299 /* Make sure the IP address entered by the user is valid */ |
15823 | 300 if ((ip != NULL) && (purple_network_ip_atoi(ip) != NULL)) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
301 return ip; |
21697
65ef019c000b
Allow UPnP and NAT-PMP port mapping to be disabled via a pref. This means that UPnP discovery will not occur if this new pref and the "Autodetect IP Address" pref are both unchecked. Fixes #4157.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21466
diff
changeset
|
302 } else { |
65ef019c000b
Allow UPnP and NAT-PMP port mapping to be disabled via a pref. This means that UPnP discovery will not occur if this new pref and the "Autodetect IP Address" pref are both unchecked. Fixes #4157.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21466
diff
changeset
|
303 /* Check if STUN discovery was already done */ |
65ef019c000b
Allow UPnP and NAT-PMP port mapping to be disabled via a pref. This means that UPnP discovery will not occur if this new pref and the "Autodetect IP Address" pref are both unchecked. Fixes #4157.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21466
diff
changeset
|
304 stun = purple_stun_discover(NULL); |
65ef019c000b
Allow UPnP and NAT-PMP port mapping to be disabled via a pref. This means that UPnP discovery will not occur if this new pref and the "Autodetect IP Address" pref are both unchecked. Fixes #4157.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21466
diff
changeset
|
305 if ((stun != NULL) && (stun->status == PURPLE_STUN_STATUS_DISCOVERED)) |
65ef019c000b
Allow UPnP and NAT-PMP port mapping to be disabled via a pref. This means that UPnP discovery will not occur if this new pref and the "Autodetect IP Address" pref are both unchecked. Fixes #4157.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21466
diff
changeset
|
306 return stun->publicip; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
307 |
21697
65ef019c000b
Allow UPnP and NAT-PMP port mapping to be disabled via a pref. This means that UPnP discovery will not occur if this new pref and the "Autodetect IP Address" pref are both unchecked. Fixes #4157.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21466
diff
changeset
|
308 /* Attempt to get the IP from a NAT device using UPnP */ |
65ef019c000b
Allow UPnP and NAT-PMP port mapping to be disabled via a pref. This means that UPnP discovery will not occur if this new pref and the "Autodetect IP Address" pref are both unchecked. Fixes #4157.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21466
diff
changeset
|
309 ip = purple_upnp_get_public_ip(); |
65ef019c000b
Allow UPnP and NAT-PMP port mapping to be disabled via a pref. This means that UPnP discovery will not occur if this new pref and the "Autodetect IP Address" pref are both unchecked. Fixes #4157.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21466
diff
changeset
|
310 if (ip != NULL) |
65ef019c000b
Allow UPnP and NAT-PMP port mapping to be disabled via a pref. This means that UPnP discovery will not occur if this new pref and the "Autodetect IP Address" pref are both unchecked. Fixes #4157.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21466
diff
changeset
|
311 return ip; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
312 |
21697
65ef019c000b
Allow UPnP and NAT-PMP port mapping to be disabled via a pref. This means that UPnP discovery will not occur if this new pref and the "Autodetect IP Address" pref are both unchecked. Fixes #4157.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21466
diff
changeset
|
313 /* Attempt to get the IP from a NAT device using NAT-PMP */ |
65ef019c000b
Allow UPnP and NAT-PMP port mapping to be disabled via a pref. This means that UPnP discovery will not occur if this new pref and the "Autodetect IP Address" pref are both unchecked. Fixes #4157.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21466
diff
changeset
|
314 ip = purple_pmp_get_public_ip(); |
65ef019c000b
Allow UPnP and NAT-PMP port mapping to be disabled via a pref. This means that UPnP discovery will not occur if this new pref and the "Autodetect IP Address" pref are both unchecked. Fixes #4157.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21466
diff
changeset
|
315 if (ip != NULL) |
65ef019c000b
Allow UPnP and NAT-PMP port mapping to be disabled via a pref. This means that UPnP discovery will not occur if this new pref and the "Autodetect IP Address" pref are both unchecked. Fixes #4157.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21466
diff
changeset
|
316 return ip; |
65ef019c000b
Allow UPnP and NAT-PMP port mapping to be disabled via a pref. This means that UPnP discovery will not occur if this new pref and the "Autodetect IP Address" pref are both unchecked. Fixes #4157.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21466
diff
changeset
|
317 } |
15647
552be3958d6a
Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15441
diff
changeset
|
318 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
319 /* Just fetch the IP of the local system */ |
15823 | 320 return purple_network_get_local_system_ip(fd); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
321 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
322 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
323 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
324 static void |
15823 | 325 purple_network_set_upnp_port_mapping_cb(gboolean success, gpointer data) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
326 { |
15823 | 327 PurpleNetworkListenData *listen_data; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
328 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
329 listen_data = data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
330 /* TODO: Once we're keeping track of upnp requests... */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
331 /* listen_data->pnp_data = NULL; */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
332 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
333 if (!success) { |
27313
627d23bfdb05
Increase the logging level of some debugging messages that seemed to be a
mauro.brasil@tqi.com.br
parents:
27192
diff
changeset
|
334 purple_debug_warning("network", "Couldn't create UPnP mapping\n"); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
335 if (listen_data->retry) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
336 listen_data->retry = FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
337 listen_data->adding = FALSE; |
15823 | 338 listen_data->mapping_data = purple_upnp_remove_port_mapping( |
339 purple_network_get_port_from_fd(listen_data->listenfd), | |
15441
56a2a0bb290a
Fix a crash when a network_listen_range process is canceled before its UPnP port mapping completes, which occurs regularly on certain routers when file transfers are initiated and then quickly finished. Much thanks to Elliott Harris and Eric Richie for their hard work with me hunting this down and fixing it.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15374
diff
changeset
|
340 (listen_data->socket_type == SOCK_STREAM) ? "TCP" : "UDP", |
15823 | 341 purple_network_set_upnp_port_mapping_cb, listen_data); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
342 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
343 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
344 } else if (!listen_data->adding) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
345 /* We've tried successfully to remove the port mapping. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
346 * Try to add it again */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
347 listen_data->adding = TRUE; |
15823 | 348 listen_data->mapping_data = purple_upnp_set_port_mapping( |
349 purple_network_get_port_from_fd(listen_data->listenfd), | |
15441
56a2a0bb290a
Fix a crash when a network_listen_range process is canceled before its UPnP port mapping completes, which occurs regularly on certain routers when file transfers are initiated and then quickly finished. Much thanks to Elliott Harris and Eric Richie for their hard work with me hunting this down and fixing it.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15374
diff
changeset
|
350 (listen_data->socket_type == SOCK_STREAM) ? "TCP" : "UDP", |
15823 | 351 purple_network_set_upnp_port_mapping_cb, listen_data); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
352 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
353 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
354 |
27190
38c4973b5222
Add a function to remove a port mapping (UPnP or NAT-PMP) given a file
Marcus Lundblad <ml@update.uu.se>
parents:
26967
diff
changeset
|
355 if (success) { |
38c4973b5222
Add a function to remove a port mapping (UPnP or NAT-PMP) given a file
Marcus Lundblad <ml@update.uu.se>
parents:
26967
diff
changeset
|
356 /* add port mapping to hash table */ |
31423
18d56b13fe8b
Cast back and forth between int and pointer instead of putting pointers
Mark Doliner <mark@kingant.net>
parents:
30983
diff
changeset
|
357 gint key = purple_network_get_port_from_fd(listen_data->listenfd); |
18d56b13fe8b
Cast back and forth between int and pointer instead of putting pointers
Mark Doliner <mark@kingant.net>
parents:
30983
diff
changeset
|
358 gint value = listen_data->socket_type; |
18d56b13fe8b
Cast back and forth between int and pointer instead of putting pointers
Mark Doliner <mark@kingant.net>
parents:
30983
diff
changeset
|
359 g_hash_table_insert(upnp_port_mappings, GINT_TO_POINTER(key), GINT_TO_POINTER(value)); |
27190
38c4973b5222
Add a function to remove a port mapping (UPnP or NAT-PMP) given a file
Marcus Lundblad <ml@update.uu.se>
parents:
26967
diff
changeset
|
360 } |
38c4973b5222
Add a function to remove a port mapping (UPnP or NAT-PMP) given a file
Marcus Lundblad <ml@update.uu.se>
parents:
26967
diff
changeset
|
361 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
362 if (listen_data->cb) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
363 listen_data->cb(listen_data->listenfd, listen_data->cb_data); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
364 |
31423
18d56b13fe8b
Cast back and forth between int and pointer instead of putting pointers
Mark Doliner <mark@kingant.net>
parents:
30983
diff
changeset
|
365 /* Clear the UPnP mapping data, since it's complete and purple_network_listen_cancel() will try to cancel |
15441
56a2a0bb290a
Fix a crash when a network_listen_range process is canceled before its UPnP port mapping completes, which occurs regularly on certain routers when file transfers are initiated and then quickly finished. Much thanks to Elliott Harris and Eric Richie for their hard work with me hunting this down and fixing it.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15374
diff
changeset
|
366 * it otherwise. */ |
56a2a0bb290a
Fix a crash when a network_listen_range process is canceled before its UPnP port mapping completes, which occurs regularly on certain routers when file transfers are initiated and then quickly finished. Much thanks to Elliott Harris and Eric Richie for their hard work with me hunting this down and fixing it.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15374
diff
changeset
|
367 listen_data->mapping_data = NULL; |
15823 | 368 purple_network_listen_cancel(listen_data); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
369 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
370 |
15856
9b875f0ecb86
nat-pmp is now functional with a compatible router. I'm not enabling this code yet because it hasn't been tested with a router which doesn't support nat-pmp.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15823
diff
changeset
|
371 static gboolean |
9b875f0ecb86
nat-pmp is now functional with a compatible router. I'm not enabling this code yet because it hasn't been tested with a router which doesn't support nat-pmp.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15823
diff
changeset
|
372 purple_network_finish_pmp_map_cb(gpointer data) |
9b875f0ecb86
nat-pmp is now functional with a compatible router. I'm not enabling this code yet because it hasn't been tested with a router which doesn't support nat-pmp.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15823
diff
changeset
|
373 { |
9b875f0ecb86
nat-pmp is now functional with a compatible router. I'm not enabling this code yet because it hasn't been tested with a router which doesn't support nat-pmp.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15823
diff
changeset
|
374 PurpleNetworkListenData *listen_data; |
31423
18d56b13fe8b
Cast back and forth between int and pointer instead of putting pointers
Mark Doliner <mark@kingant.net>
parents:
30983
diff
changeset
|
375 gint key; |
18d56b13fe8b
Cast back and forth between int and pointer instead of putting pointers
Mark Doliner <mark@kingant.net>
parents:
30983
diff
changeset
|
376 gint value; |
15902
3a45be1c3281
Whitespace and make sure stuff is #defined to an actual value.
Mark Doliner <mark@kingant.net>
parents:
15895
diff
changeset
|
377 |
15856
9b875f0ecb86
nat-pmp is now functional with a compatible router. I'm not enabling this code yet because it hasn't been tested with a router which doesn't support nat-pmp.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15823
diff
changeset
|
378 listen_data = data; |
30777
c91976cf319c
Make sure we keep track of this timer and remove it if our caller frees
Mark Doliner <mark@kingant.net>
parents:
30153
diff
changeset
|
379 listen_data->timer = 0; |
15902
3a45be1c3281
Whitespace and make sure stuff is #defined to an actual value.
Mark Doliner <mark@kingant.net>
parents:
15895
diff
changeset
|
380 |
27192
455e679ea0db
Remove port mappings from the hash tables when removing them.
Marcus Lundblad <ml@update.uu.se>
parents:
27190
diff
changeset
|
381 /* add port mapping to hash table */ |
31423
18d56b13fe8b
Cast back and forth between int and pointer instead of putting pointers
Mark Doliner <mark@kingant.net>
parents:
30983
diff
changeset
|
382 key = purple_network_get_port_from_fd(listen_data->listenfd); |
18d56b13fe8b
Cast back and forth between int and pointer instead of putting pointers
Mark Doliner <mark@kingant.net>
parents:
30983
diff
changeset
|
383 value = listen_data->socket_type; |
18d56b13fe8b
Cast back and forth between int and pointer instead of putting pointers
Mark Doliner <mark@kingant.net>
parents:
30983
diff
changeset
|
384 g_hash_table_insert(nat_pmp_port_mappings, GINT_TO_POINTER(key), GINT_TO_POINTER(value)); |
27192
455e679ea0db
Remove port mappings from the hash tables when removing them.
Marcus Lundblad <ml@update.uu.se>
parents:
27190
diff
changeset
|
385 |
15856
9b875f0ecb86
nat-pmp is now functional with a compatible router. I'm not enabling this code yet because it hasn't been tested with a router which doesn't support nat-pmp.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15823
diff
changeset
|
386 if (listen_data->cb) |
9b875f0ecb86
nat-pmp is now functional with a compatible router. I'm not enabling this code yet because it hasn't been tested with a router which doesn't support nat-pmp.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15823
diff
changeset
|
387 listen_data->cb(listen_data->listenfd, listen_data->cb_data); |
9b875f0ecb86
nat-pmp is now functional with a compatible router. I'm not enabling this code yet because it hasn't been tested with a router which doesn't support nat-pmp.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15823
diff
changeset
|
388 |
9b875f0ecb86
nat-pmp is now functional with a compatible router. I'm not enabling this code yet because it hasn't been tested with a router which doesn't support nat-pmp.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15823
diff
changeset
|
389 purple_network_listen_cancel(listen_data); |
9b875f0ecb86
nat-pmp is now functional with a compatible router. I'm not enabling this code yet because it hasn't been tested with a router which doesn't support nat-pmp.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15823
diff
changeset
|
390 |
9b875f0ecb86
nat-pmp is now functional with a compatible router. I'm not enabling this code yet because it hasn't been tested with a router which doesn't support nat-pmp.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15823
diff
changeset
|
391 return FALSE; |
9b875f0ecb86
nat-pmp is now functional with a compatible router. I'm not enabling this code yet because it hasn't been tested with a router which doesn't support nat-pmp.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15823
diff
changeset
|
392 } |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
393 |
21466
7a05b6f84545
Don't map the port used for bonjour file transfers externally. This adds a new function that will go away in 3.0.0 when we can modify purple_network_do_listen to take an additional parameter.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21121
diff
changeset
|
394 static gboolean listen_map_external = TRUE; |
7a05b6f84545
Don't map the port used for bonjour file transfers externally. This adds a new function that will go away in 3.0.0 when we can modify purple_network_do_listen to take an additional parameter.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21121
diff
changeset
|
395 void purple_network_listen_map_external(gboolean map_external) |
7a05b6f84545
Don't map the port used for bonjour file transfers externally. This adds a new function that will go away in 3.0.0 when we can modify purple_network_do_listen to take an additional parameter.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21121
diff
changeset
|
396 { |
7a05b6f84545
Don't map the port used for bonjour file transfers externally. This adds a new function that will go away in 3.0.0 when we can modify purple_network_do_listen to take an additional parameter.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21121
diff
changeset
|
397 listen_map_external = map_external; |
7a05b6f84545
Don't map the port used for bonjour file transfers externally. This adds a new function that will go away in 3.0.0 when we can modify purple_network_do_listen to take an additional parameter.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21121
diff
changeset
|
398 } |
7a05b6f84545
Don't map the port used for bonjour file transfers externally. This adds a new function that will go away in 3.0.0 when we can modify purple_network_do_listen to take an additional parameter.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21121
diff
changeset
|
399 |
15823 | 400 static PurpleNetworkListenData * |
30153
35a1cf247168
Add network listen functions that accept a family argument (AF_INET(6?)).
Paul Aurich <paul@darkrain42.org>
parents:
29768
diff
changeset
|
401 purple_network_do_listen(unsigned short port, int socket_family, int socket_type, PurpleNetworkListenCallback cb, gpointer cb_data) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
402 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
403 int listenfd = -1; |
20347
04fe5601fedb
applied changes from 2762c6075c0dc52a96098c5478c5bf68cfd890a3
Luke Schierer <lschiere@pidgin.im>
parents:
20074
diff
changeset
|
404 int flags; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
405 const int on = 1; |
15823 | 406 PurpleNetworkListenData *listen_data; |
15647
552be3958d6a
Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15441
diff
changeset
|
407 unsigned short actual_port; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
408 #ifdef HAVE_GETADDRINFO |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
409 int errnum; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
410 struct addrinfo hints, *res, *next; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
411 char serv[6]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
412 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
413 /* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
414 * Get a list of addresses on this machine. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
415 */ |
26967
8290e36a5a73
A patch from Scott Wolchok to replace snprintf() with g_snprintf() and
Richard Laager <rlaager@wiktel.com>
parents:
26633
diff
changeset
|
416 g_snprintf(serv, sizeof(serv), "%hu", port); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
417 memset(&hints, 0, sizeof(struct addrinfo)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
418 hints.ai_flags = AI_PASSIVE; |
30153
35a1cf247168
Add network listen functions that accept a family argument (AF_INET(6?)).
Paul Aurich <paul@darkrain42.org>
parents:
29768
diff
changeset
|
419 hints.ai_family = socket_family; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
420 hints.ai_socktype = socket_type; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
421 errnum = getaddrinfo(NULL /* any IP */, serv, &hints, &res); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
422 if (errnum != 0) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
423 #ifndef _WIN32 |
21862
ae58ffd5e929
Create a purple_gai_strerror() function similar to g_str_error() which
Mark Doliner <mark@kingant.net>
parents:
21774
diff
changeset
|
424 purple_debug_warning("network", "getaddrinfo: %s\n", purple_gai_strerror(errnum)); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
425 if (errnum == EAI_SYSTEM) |
21121
35b4f1dc4c8d
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
20347
diff
changeset
|
426 purple_debug_warning("network", "getaddrinfo: system error: %s\n", g_strerror(errno)); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
427 #else |
15823 | 428 purple_debug_warning("network", "getaddrinfo: Error Code = %d\n", errnum); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
429 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
430 return NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
431 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
432 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
433 /* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
434 * Go through the list of addresses and attempt to listen on |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
435 * one of them. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
436 * XXX - Try IPv6 addresses first? |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
437 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
438 for (next = res; next != NULL; next = next->ai_next) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
439 listenfd = socket(next->ai_family, next->ai_socktype, next->ai_protocol); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
440 if (listenfd < 0) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
441 continue; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
442 if (setsockopt(listenfd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) != 0) |
30153
35a1cf247168
Add network listen functions that accept a family argument (AF_INET(6?)).
Paul Aurich <paul@darkrain42.org>
parents:
29768
diff
changeset
|
443 purple_debug_warning("network", "setsockopt(SO_REUSEADDR): %s\n", g_strerror(errno)); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
444 if (bind(listenfd, next->ai_addr, next->ai_addrlen) == 0) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
445 break; /* success */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
446 /* XXX - It is unclear to me (datallah) whether we need to be |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
447 using a new socket each time */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
448 close(listenfd); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
449 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
450 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
451 freeaddrinfo(res); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
452 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
453 if (next == NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
454 return NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
455 #else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
456 struct sockaddr_in sockin; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
457 |
30153
35a1cf247168
Add network listen functions that accept a family argument (AF_INET(6?)).
Paul Aurich <paul@darkrain42.org>
parents:
29768
diff
changeset
|
458 if (socket_family != AF_INET && socket_family != AF_UNSPEC) { |
35a1cf247168
Add network listen functions that accept a family argument (AF_INET(6?)).
Paul Aurich <paul@darkrain42.org>
parents:
29768
diff
changeset
|
459 purple_debug_warning("network", "Address family %d only " |
35a1cf247168
Add network listen functions that accept a family argument (AF_INET(6?)).
Paul Aurich <paul@darkrain42.org>
parents:
29768
diff
changeset
|
460 "supported when built with getaddrinfo() " |
35a1cf247168
Add network listen functions that accept a family argument (AF_INET(6?)).
Paul Aurich <paul@darkrain42.org>
parents:
29768
diff
changeset
|
461 "support\n", socket_family); |
35a1cf247168
Add network listen functions that accept a family argument (AF_INET(6?)).
Paul Aurich <paul@darkrain42.org>
parents:
29768
diff
changeset
|
462 return NULL; |
35a1cf247168
Add network listen functions that accept a family argument (AF_INET(6?)).
Paul Aurich <paul@darkrain42.org>
parents:
29768
diff
changeset
|
463 } |
35a1cf247168
Add network listen functions that accept a family argument (AF_INET(6?)).
Paul Aurich <paul@darkrain42.org>
parents:
29768
diff
changeset
|
464 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
465 if ((listenfd = socket(AF_INET, socket_type, 0)) < 0) { |
21121
35b4f1dc4c8d
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
20347
diff
changeset
|
466 purple_debug_warning("network", "socket: %s\n", g_strerror(errno)); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
467 return NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
468 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
469 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
470 if (setsockopt(listenfd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) != 0) |
21121
35b4f1dc4c8d
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
20347
diff
changeset
|
471 purple_debug_warning("network", "setsockopt: %s\n", g_strerror(errno)); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
472 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
473 memset(&sockin, 0, sizeof(struct sockaddr_in)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
474 sockin.sin_family = PF_INET; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
475 sockin.sin_port = htons(port); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
476 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
477 if (bind(listenfd, (struct sockaddr *)&sockin, sizeof(struct sockaddr_in)) != 0) { |
21121
35b4f1dc4c8d
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
20347
diff
changeset
|
478 purple_debug_warning("network", "bind: %s\n", g_strerror(errno)); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
479 close(listenfd); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
480 return NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
481 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
482 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
483 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
484 if (socket_type == SOCK_STREAM && listen(listenfd, 4) != 0) { |
21121
35b4f1dc4c8d
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
20347
diff
changeset
|
485 purple_debug_warning("network", "listen: %s\n", g_strerror(errno)); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
486 close(listenfd); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
487 return NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
488 } |
20347
04fe5601fedb
applied changes from 2762c6075c0dc52a96098c5478c5bf68cfd890a3
Luke Schierer <lschiere@pidgin.im>
parents:
20074
diff
changeset
|
489 flags = fcntl(listenfd, F_GETFL); |
04fe5601fedb
applied changes from 2762c6075c0dc52a96098c5478c5bf68cfd890a3
Luke Schierer <lschiere@pidgin.im>
parents:
20074
diff
changeset
|
490 fcntl(listenfd, F_SETFL, flags | O_NONBLOCK); |
23774
91169093449d
More leaks of fds to client processes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23203
diff
changeset
|
491 #ifndef _WIN32 |
91169093449d
More leaks of fds to client processes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23203
diff
changeset
|
492 fcntl(listenfd, F_SETFD, FD_CLOEXEC); |
91169093449d
More leaks of fds to client processes.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
23203
diff
changeset
|
493 #endif |
15823 | 494 actual_port = purple_network_get_port_from_fd(listenfd); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
495 |
15823 | 496 purple_debug_info("network", "Listening on port: %hu\n", actual_port); |
15902
3a45be1c3281
Whitespace and make sure stuff is #defined to an actual value.
Mark Doliner <mark@kingant.net>
parents:
15895
diff
changeset
|
497 |
15823 | 498 listen_data = g_new0(PurpleNetworkListenData, 1); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
499 listen_data->listenfd = listenfd; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
500 listen_data->adding = TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
501 listen_data->retry = TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
502 listen_data->cb = cb; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
503 listen_data->cb_data = cb_data; |
19643
ec7b92cbf49f
Store the socket_type in the PurpleNetworkListenData correctly so that callback functions can use it correctly. Fixes #2933.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19408
diff
changeset
|
504 listen_data->socket_type = socket_type; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
505 |
30153
35a1cf247168
Add network listen functions that accept a family argument (AF_INET(6?)).
Paul Aurich <paul@darkrain42.org>
parents:
29768
diff
changeset
|
506 if (!purple_socket_speaks_ipv4(listenfd) || !listen_map_external || |
35a1cf247168
Add network listen functions that accept a family argument (AF_INET(6?)).
Paul Aurich <paul@darkrain42.org>
parents:
29768
diff
changeset
|
507 !purple_prefs_get_bool("/purple/network/map_ports")) |
21466
7a05b6f84545
Don't map the port used for bonjour file transfers externally. This adds a new function that will go away in 3.0.0 when we can modify purple_network_do_listen to take an additional parameter.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21121
diff
changeset
|
508 { |
7a05b6f84545
Don't map the port used for bonjour file transfers externally. This adds a new function that will go away in 3.0.0 when we can modify purple_network_do_listen to take an additional parameter.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21121
diff
changeset
|
509 purple_debug_info("network", "Skipping external port mapping.\n"); |
7a05b6f84545
Don't map the port used for bonjour file transfers externally. This adds a new function that will go away in 3.0.0 when we can modify purple_network_do_listen to take an additional parameter.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21121
diff
changeset
|
510 /* The pmp_map_cb does what we want to do */ |
30777
c91976cf319c
Make sure we keep track of this timer and remove it if our caller frees
Mark Doliner <mark@kingant.net>
parents:
30153
diff
changeset
|
511 listen_data->timer = purple_timeout_add(0, purple_network_finish_pmp_map_cb, listen_data); |
21466
7a05b6f84545
Don't map the port used for bonjour file transfers externally. This adds a new function that will go away in 3.0.0 when we can modify purple_network_do_listen to take an additional parameter.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21121
diff
changeset
|
512 } |
15647
552be3958d6a
Added nat-pmp implementation and #ifdef'd out changes to network.c which would utilize it.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15441
diff
changeset
|
513 /* Attempt a NAT-PMP Mapping, which will return immediately */ |
21466
7a05b6f84545
Don't map the port used for bonjour file transfers externally. This adds a new function that will go away in 3.0.0 when we can modify purple_network_do_listen to take an additional parameter.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21121
diff
changeset
|
514 else if (purple_pmp_create_map(((socket_type == SOCK_STREAM) ? PURPLE_PMP_TYPE_TCP : PURPLE_PMP_TYPE_UDP), |
15949
b4ab4812838a
purple_pmp_create_map() returns a gboolean now, not a pointer
Evan Schoenberg <evan.s@dreskin.net>
parents:
15902
diff
changeset
|
515 actual_port, actual_port, PURPLE_PMP_LIFETIME)) |
15856
9b875f0ecb86
nat-pmp is now functional with a compatible router. I'm not enabling this code yet because it hasn't been tested with a router which doesn't support nat-pmp.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15823
diff
changeset
|
516 { |
21466
7a05b6f84545
Don't map the port used for bonjour file transfers externally. This adds a new function that will go away in 3.0.0 when we can modify purple_network_do_listen to take an additional parameter.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21121
diff
changeset
|
517 purple_debug_info("network", "Created NAT-PMP mapping on port %i\n", actual_port); |
15856
9b875f0ecb86
nat-pmp is now functional with a compatible router. I'm not enabling this code yet because it hasn't been tested with a router which doesn't support nat-pmp.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15823
diff
changeset
|
518 /* We want to return listen_data now, and on the next run loop trigger the cb and destroy listen_data */ |
30777
c91976cf319c
Make sure we keep track of this timer and remove it if our caller frees
Mark Doliner <mark@kingant.net>
parents:
30153
diff
changeset
|
519 listen_data->timer = purple_timeout_add(0, purple_network_finish_pmp_map_cb, listen_data); |
15856
9b875f0ecb86
nat-pmp is now functional with a compatible router. I'm not enabling this code yet because it hasn't been tested with a router which doesn't support nat-pmp.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15823
diff
changeset
|
520 } |
9b875f0ecb86
nat-pmp is now functional with a compatible router. I'm not enabling this code yet because it hasn't been tested with a router which doesn't support nat-pmp.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15823
diff
changeset
|
521 else |
9b875f0ecb86
nat-pmp is now functional with a compatible router. I'm not enabling this code yet because it hasn't been tested with a router which doesn't support nat-pmp.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15823
diff
changeset
|
522 { |
9b875f0ecb86
nat-pmp is now functional with a compatible router. I'm not enabling this code yet because it hasn't been tested with a router which doesn't support nat-pmp.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15823
diff
changeset
|
523 /* Attempt a UPnP Mapping */ |
9b875f0ecb86
nat-pmp is now functional with a compatible router. I'm not enabling this code yet because it hasn't been tested with a router which doesn't support nat-pmp.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15823
diff
changeset
|
524 listen_data->mapping_data = purple_upnp_set_port_mapping( |
9b875f0ecb86
nat-pmp is now functional with a compatible router. I'm not enabling this code yet because it hasn't been tested with a router which doesn't support nat-pmp.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15823
diff
changeset
|
525 actual_port, |
9b875f0ecb86
nat-pmp is now functional with a compatible router. I'm not enabling this code yet because it hasn't been tested with a router which doesn't support nat-pmp.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15823
diff
changeset
|
526 (socket_type == SOCK_STREAM) ? "TCP" : "UDP", |
9b875f0ecb86
nat-pmp is now functional with a compatible router. I'm not enabling this code yet because it hasn't been tested with a router which doesn't support nat-pmp.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15823
diff
changeset
|
527 purple_network_set_upnp_port_mapping_cb, listen_data); |
9b875f0ecb86
nat-pmp is now functional with a compatible router. I'm not enabling this code yet because it hasn't been tested with a router which doesn't support nat-pmp.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15823
diff
changeset
|
528 } |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
529 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
530 return listen_data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
531 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
532 |
15823 | 533 PurpleNetworkListenData * |
30153
35a1cf247168
Add network listen functions that accept a family argument (AF_INET(6?)).
Paul Aurich <paul@darkrain42.org>
parents:
29768
diff
changeset
|
534 purple_network_listen_family(unsigned short port, int socket_family, |
35a1cf247168
Add network listen functions that accept a family argument (AF_INET(6?)).
Paul Aurich <paul@darkrain42.org>
parents:
29768
diff
changeset
|
535 int socket_type, PurpleNetworkListenCallback cb, |
35a1cf247168
Add network listen functions that accept a family argument (AF_INET(6?)).
Paul Aurich <paul@darkrain42.org>
parents:
29768
diff
changeset
|
536 gpointer cb_data) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
537 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
538 g_return_val_if_fail(port != 0, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
539 |
30153
35a1cf247168
Add network listen functions that accept a family argument (AF_INET(6?)).
Paul Aurich <paul@darkrain42.org>
parents:
29768
diff
changeset
|
540 return purple_network_do_listen(port, socket_family, socket_type, |
35a1cf247168
Add network listen functions that accept a family argument (AF_INET(6?)).
Paul Aurich <paul@darkrain42.org>
parents:
29768
diff
changeset
|
541 cb, cb_data); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
542 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
543 |
15823 | 544 PurpleNetworkListenData * |
30153
35a1cf247168
Add network listen functions that accept a family argument (AF_INET(6?)).
Paul Aurich <paul@darkrain42.org>
parents:
29768
diff
changeset
|
545 purple_network_listen(unsigned short port, int socket_type, |
35a1cf247168
Add network listen functions that accept a family argument (AF_INET(6?)).
Paul Aurich <paul@darkrain42.org>
parents:
29768
diff
changeset
|
546 PurpleNetworkListenCallback cb, gpointer cb_data) |
35a1cf247168
Add network listen functions that accept a family argument (AF_INET(6?)).
Paul Aurich <paul@darkrain42.org>
parents:
29768
diff
changeset
|
547 { |
35a1cf247168
Add network listen functions that accept a family argument (AF_INET(6?)).
Paul Aurich <paul@darkrain42.org>
parents:
29768
diff
changeset
|
548 return purple_network_listen_family(port, AF_UNSPEC, socket_type, |
35a1cf247168
Add network listen functions that accept a family argument (AF_INET(6?)).
Paul Aurich <paul@darkrain42.org>
parents:
29768
diff
changeset
|
549 cb, cb_data); |
35a1cf247168
Add network listen functions that accept a family argument (AF_INET(6?)).
Paul Aurich <paul@darkrain42.org>
parents:
29768
diff
changeset
|
550 } |
35a1cf247168
Add network listen functions that accept a family argument (AF_INET(6?)).
Paul Aurich <paul@darkrain42.org>
parents:
29768
diff
changeset
|
551 |
35a1cf247168
Add network listen functions that accept a family argument (AF_INET(6?)).
Paul Aurich <paul@darkrain42.org>
parents:
29768
diff
changeset
|
552 PurpleNetworkListenData * |
35a1cf247168
Add network listen functions that accept a family argument (AF_INET(6?)).
Paul Aurich <paul@darkrain42.org>
parents:
29768
diff
changeset
|
553 purple_network_listen_range_family(unsigned short start, unsigned short end, |
35a1cf247168
Add network listen functions that accept a family argument (AF_INET(6?)).
Paul Aurich <paul@darkrain42.org>
parents:
29768
diff
changeset
|
554 int socket_family, int socket_type, |
35a1cf247168
Add network listen functions that accept a family argument (AF_INET(6?)).
Paul Aurich <paul@darkrain42.org>
parents:
29768
diff
changeset
|
555 PurpleNetworkListenCallback cb, |
35a1cf247168
Add network listen functions that accept a family argument (AF_INET(6?)).
Paul Aurich <paul@darkrain42.org>
parents:
29768
diff
changeset
|
556 gpointer cb_data) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
557 { |
15823 | 558 PurpleNetworkListenData *ret = NULL; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
559 |
16427
4999bbc52881
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents:
15974
diff
changeset
|
560 if (purple_prefs_get_bool("/purple/network/ports_range_use")) { |
4999bbc52881
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents:
15974
diff
changeset
|
561 start = purple_prefs_get_int("/purple/network/ports_range_start"); |
4999bbc52881
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents:
15974
diff
changeset
|
562 end = purple_prefs_get_int("/purple/network/ports_range_end"); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
563 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
564 if (end < start) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
565 end = start; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
566 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
567 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
568 for (; start <= end; start++) { |
30153
35a1cf247168
Add network listen functions that accept a family argument (AF_INET(6?)).
Paul Aurich <paul@darkrain42.org>
parents:
29768
diff
changeset
|
569 ret = purple_network_do_listen(start, AF_UNSPEC, socket_type, cb, cb_data); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
570 if (ret != NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
571 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
572 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
573 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
574 return ret; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
575 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
576 |
30153
35a1cf247168
Add network listen functions that accept a family argument (AF_INET(6?)).
Paul Aurich <paul@darkrain42.org>
parents:
29768
diff
changeset
|
577 PurpleNetworkListenData * |
35a1cf247168
Add network listen functions that accept a family argument (AF_INET(6?)).
Paul Aurich <paul@darkrain42.org>
parents:
29768
diff
changeset
|
578 purple_network_listen_range(unsigned short start, unsigned short end, |
35a1cf247168
Add network listen functions that accept a family argument (AF_INET(6?)).
Paul Aurich <paul@darkrain42.org>
parents:
29768
diff
changeset
|
579 int socket_type, PurpleNetworkListenCallback cb, |
35a1cf247168
Add network listen functions that accept a family argument (AF_INET(6?)).
Paul Aurich <paul@darkrain42.org>
parents:
29768
diff
changeset
|
580 gpointer cb_data) |
35a1cf247168
Add network listen functions that accept a family argument (AF_INET(6?)).
Paul Aurich <paul@darkrain42.org>
parents:
29768
diff
changeset
|
581 { |
35a1cf247168
Add network listen functions that accept a family argument (AF_INET(6?)).
Paul Aurich <paul@darkrain42.org>
parents:
29768
diff
changeset
|
582 return purple_network_listen_range_family(start, end, AF_UNSPEC, |
35a1cf247168
Add network listen functions that accept a family argument (AF_INET(6?)).
Paul Aurich <paul@darkrain42.org>
parents:
29768
diff
changeset
|
583 socket_type, cb, cb_data); |
35a1cf247168
Add network listen functions that accept a family argument (AF_INET(6?)).
Paul Aurich <paul@darkrain42.org>
parents:
29768
diff
changeset
|
584 } |
35a1cf247168
Add network listen functions that accept a family argument (AF_INET(6?)).
Paul Aurich <paul@darkrain42.org>
parents:
29768
diff
changeset
|
585 |
15823 | 586 void purple_network_listen_cancel(PurpleNetworkListenData *listen_data) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
587 { |
15441
56a2a0bb290a
Fix a crash when a network_listen_range process is canceled before its UPnP port mapping completes, which occurs regularly on certain routers when file transfers are initiated and then quickly finished. Much thanks to Elliott Harris and Eric Richie for their hard work with me hunting this down and fixing it.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15374
diff
changeset
|
588 if (listen_data->mapping_data != NULL) |
15823 | 589 purple_upnp_cancel_port_mapping(listen_data->mapping_data); |
15441
56a2a0bb290a
Fix a crash when a network_listen_range process is canceled before its UPnP port mapping completes, which occurs regularly on certain routers when file transfers are initiated and then quickly finished. Much thanks to Elliott Harris and Eric Richie for their hard work with me hunting this down and fixing it.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15374
diff
changeset
|
590 |
30777
c91976cf319c
Make sure we keep track of this timer and remove it if our caller frees
Mark Doliner <mark@kingant.net>
parents:
30153
diff
changeset
|
591 if (listen_data->timer > 0) |
c91976cf319c
Make sure we keep track of this timer and remove it if our caller frees
Mark Doliner <mark@kingant.net>
parents:
30153
diff
changeset
|
592 purple_timeout_remove(listen_data->timer); |
c91976cf319c
Make sure we keep track of this timer and remove it if our caller frees
Mark Doliner <mark@kingant.net>
parents:
30153
diff
changeset
|
593 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
594 g_free(listen_data); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
595 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
596 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
597 unsigned short |
15823 | 598 purple_network_get_port_from_fd(int fd) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
599 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
600 struct sockaddr_in addr; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
601 socklen_t len; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
602 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
603 g_return_val_if_fail(fd >= 0, 0); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
604 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
605 len = sizeof(addr); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
606 if (getsockname(fd, (struct sockaddr *) &addr, &len) == -1) { |
21121
35b4f1dc4c8d
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
20347
diff
changeset
|
607 purple_debug_warning("network", "getsockname: %s\n", g_strerror(errno)); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
608 return 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
609 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
610 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
611 return ntohs(addr.sin_port); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
612 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
613 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
614 #ifdef _WIN32 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
615 #ifndef NS_NLA |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
616 #define NS_NLA 15 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
617 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
618 static gint |
15823 | 619 wpurple_get_connected_network_count(void) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
620 { |
19408
cc36a5aac908
Fix some conversion warnings about using negative values with unsigned types. There are more, but these were easy fixes. You may think that I'm changing the API, but I'm really not - it was just wrong.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18401
diff
changeset
|
621 gint net_cnt = 0; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
622 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
623 WSAQUERYSET qs; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
624 HANDLE h; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
625 gint retval; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
626 int errorid; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
627 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
628 memset(&qs, 0, sizeof(WSAQUERYSET)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
629 qs.dwSize = sizeof(WSAQUERYSET); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
630 qs.dwNameSpace = NS_NLA; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
631 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
632 retval = WSALookupServiceBegin(&qs, LUP_RETURN_ALL, &h); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
633 if (retval != ERROR_SUCCESS) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
634 gchar *msg; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
635 errorid = WSAGetLastError(); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
636 msg = g_win32_error_message(errorid); |
15823 | 637 purple_debug_warning("network", "Couldn't retrieve NLA SP lookup handle. " |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
638 "NLA service is probably not running. Message: %s (%d).\n", |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
639 msg, errorid); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
640 g_free(msg); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
641 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
642 return -1; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
643 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
644 char buf[4096]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
645 WSAQUERYSET *res = (LPWSAQUERYSET) buf; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
646 DWORD size = sizeof(buf); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
647 while ((retval = WSALookupServiceNext(h, 0, &size, res)) == ERROR_SUCCESS) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
648 net_cnt++; |
15823 | 649 purple_debug_info("network", "found network '%s'\n", |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
650 res->lpszServiceInstanceName ? res->lpszServiceInstanceName : "(NULL)"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
651 size = sizeof(buf); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
652 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
653 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
654 errorid = WSAGetLastError(); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
655 if (!(errorid == WSA_E_NO_MORE || errorid == WSAENOMORE)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
656 gchar *msg = g_win32_error_message(errorid); |
15823 | 657 purple_debug_error("network", "got unexpected NLA response %s (%d)\n", msg, errorid); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
658 g_free(msg); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
659 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
660 net_cnt = -1; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
661 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
662 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
663 retval = WSALookupServiceEnd(h); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
664 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
665 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
666 return net_cnt; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
667 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
668 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
669 |
15823 | 670 static gboolean wpurple_network_change_thread_cb(gpointer data) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
671 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
672 gint new_count; |
15823 | 673 PurpleConnectionUiOps *ui_ops = purple_connections_get_ui_ops(); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
674 |
15823 | 675 new_count = wpurple_get_connected_network_count(); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
676 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
677 if (new_count < 0) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
678 return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
679 |
15823 | 680 purple_debug_info("network", "Received Network Change Notification. Current network count is %d, previous count was %d.\n", new_count, current_network_count); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
681 |
15974
1a12ce76c4f4
The network module now registers the signal 'network-configuration-changed' and emits it when a network change is detected via libnm or the win32 network monitor. The UI could also emit this signal if it knows something network.c doesn't. UPnP and NAT-PMP respond to the signal by clearing their IP address caches; changing networks without quitting/relaunching will now lead to the new IP address being (lazily) determined. This commit also enables nat-pmp and adds nat-pmp.[h|c] to the build process; please let me know if there are any problems building, as I only have OS X test machines.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15949
diff
changeset
|
682 purple_signal_emit(purple_network_get_handle(), "network-configuration-changed", NULL); |
1a12ce76c4f4
The network module now registers the signal 'network-configuration-changed' and emits it when a network change is detected via libnm or the win32 network monitor. The UI could also emit this signal if it knows something network.c doesn't. UPnP and NAT-PMP respond to the signal by clearing their IP address caches; changing networks without quitting/relaunching will now lead to the new IP address being (lazily) determined. This commit also enables nat-pmp and adds nat-pmp.[h|c] to the build process; please let me know if there are any problems building, as I only have OS X test machines.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15949
diff
changeset
|
683 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
684 if (new_count > 0 && ui_ops != NULL && ui_ops->network_connected != NULL) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
685 ui_ops->network_connected(); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
686 } else if (new_count == 0 && current_network_count > 0 && |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
687 ui_ops != NULL && ui_ops->network_disconnected != NULL) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
688 ui_ops->network_disconnected(); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
689 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
690 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
691 current_network_count = new_count; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
692 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
693 return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
694 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
695 |
25041
75f72178e361
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24856
diff
changeset
|
696 static gboolean _print_debug_msg(gpointer data) { |
75f72178e361
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24856
diff
changeset
|
697 gchar *msg = data; |
30983
47ea27481972
Fix some cases where an arbitrary string was being specified as a printf format.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
30915
diff
changeset
|
698 purple_debug_warning("network", "%s", msg); |
25041
75f72178e361
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24856
diff
changeset
|
699 g_free(msg); |
75f72178e361
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24856
diff
changeset
|
700 return FALSE; |
75f72178e361
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24856
diff
changeset
|
701 } |
75f72178e361
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24856
diff
changeset
|
702 |
15823 | 703 static gpointer wpurple_network_change_thread(gpointer data) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
704 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
705 WSAQUERYSET qs; |
24856
a6742d9eadf3
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <paul@darkrain42.org>
parents:
24243
diff
changeset
|
706 WSAEVENT *nla_event; |
25041
75f72178e361
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24856
diff
changeset
|
707 time_t last_trigger = time(NULL) - 31; |
75f72178e361
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24856
diff
changeset
|
708 char buf[4096]; |
75f72178e361
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24856
diff
changeset
|
709 WSAQUERYSET *res = (LPWSAQUERYSET) buf; |
75f72178e361
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24856
diff
changeset
|
710 DWORD size; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
711 |
24856
a6742d9eadf3
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <paul@darkrain42.org>
parents:
24243
diff
changeset
|
712 if ((nla_event = WSACreateEvent()) == WSA_INVALID_EVENT) { |
a6742d9eadf3
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <paul@darkrain42.org>
parents:
24243
diff
changeset
|
713 int errorid = WSAGetLastError(); |
a6742d9eadf3
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <paul@darkrain42.org>
parents:
24243
diff
changeset
|
714 gchar *msg = g_win32_error_message(errorid); |
25041
75f72178e361
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24856
diff
changeset
|
715 purple_timeout_add(0, _print_debug_msg, |
75f72178e361
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24856
diff
changeset
|
716 g_strdup_printf("Couldn't create WSA event. " |
75f72178e361
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24856
diff
changeset
|
717 "Message: %s (%d).\n", msg, errorid)); |
24856
a6742d9eadf3
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <paul@darkrain42.org>
parents:
24243
diff
changeset
|
718 g_free(msg); |
a6742d9eadf3
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <paul@darkrain42.org>
parents:
24243
diff
changeset
|
719 g_thread_exit(NULL); |
a6742d9eadf3
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <paul@darkrain42.org>
parents:
24243
diff
changeset
|
720 return NULL; |
a6742d9eadf3
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <paul@darkrain42.org>
parents:
24243
diff
changeset
|
721 } |
a6742d9eadf3
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <paul@darkrain42.org>
parents:
24243
diff
changeset
|
722 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
723 while (TRUE) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
724 int retval; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
725 DWORD retLen = 0; |
24856
a6742d9eadf3
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <paul@darkrain42.org>
parents:
24243
diff
changeset
|
726 WSACOMPLETION completion; |
a6742d9eadf3
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <paul@darkrain42.org>
parents:
24243
diff
changeset
|
727 WSAOVERLAPPED overlapped; |
a6742d9eadf3
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <paul@darkrain42.org>
parents:
24243
diff
changeset
|
728 |
a6742d9eadf3
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <paul@darkrain42.org>
parents:
24243
diff
changeset
|
729 g_static_mutex_lock(&mutex); |
a6742d9eadf3
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <paul@darkrain42.org>
parents:
24243
diff
changeset
|
730 if (network_initialized == FALSE) { |
a6742d9eadf3
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <paul@darkrain42.org>
parents:
24243
diff
changeset
|
731 /* purple_network_uninit has been called */ |
a6742d9eadf3
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <paul@darkrain42.org>
parents:
24243
diff
changeset
|
732 WSACloseEvent(nla_event); |
a6742d9eadf3
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <paul@darkrain42.org>
parents:
24243
diff
changeset
|
733 g_static_mutex_unlock(&mutex); |
a6742d9eadf3
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <paul@darkrain42.org>
parents:
24243
diff
changeset
|
734 g_thread_exit(NULL); |
a6742d9eadf3
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <paul@darkrain42.org>
parents:
24243
diff
changeset
|
735 return NULL; |
a6742d9eadf3
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <paul@darkrain42.org>
parents:
24243
diff
changeset
|
736 } |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
737 |
25041
75f72178e361
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24856
diff
changeset
|
738 if (network_change_handle == NULL) { |
75f72178e361
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24856
diff
changeset
|
739 memset(&qs, 0, sizeof(WSAQUERYSET)); |
75f72178e361
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24856
diff
changeset
|
740 qs.dwSize = sizeof(WSAQUERYSET); |
75f72178e361
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24856
diff
changeset
|
741 qs.dwNameSpace = NS_NLA; |
75f72178e361
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24856
diff
changeset
|
742 if (WSALookupServiceBegin(&qs, 0, &network_change_handle) == SOCKET_ERROR) { |
75f72178e361
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24856
diff
changeset
|
743 int errorid = WSAGetLastError(); |
75f72178e361
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24856
diff
changeset
|
744 gchar *msg = g_win32_error_message(errorid); |
75f72178e361
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24856
diff
changeset
|
745 purple_timeout_add(0, _print_debug_msg, |
75f72178e361
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24856
diff
changeset
|
746 g_strdup_printf("Couldn't retrieve NLA SP lookup handle. " |
75f72178e361
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24856
diff
changeset
|
747 "NLA service is probably not running. Message: %s (%d).\n", |
75f72178e361
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24856
diff
changeset
|
748 msg, errorid)); |
75f72178e361
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24856
diff
changeset
|
749 g_free(msg); |
75f72178e361
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24856
diff
changeset
|
750 WSACloseEvent(nla_event); |
75f72178e361
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24856
diff
changeset
|
751 g_static_mutex_unlock(&mutex); |
75f72178e361
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24856
diff
changeset
|
752 g_thread_exit(NULL); |
75f72178e361
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24856
diff
changeset
|
753 return NULL; |
75f72178e361
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24856
diff
changeset
|
754 } |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
755 } |
24856
a6742d9eadf3
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <paul@darkrain42.org>
parents:
24243
diff
changeset
|
756 g_static_mutex_unlock(&mutex); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
757 |
24856
a6742d9eadf3
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <paul@darkrain42.org>
parents:
24243
diff
changeset
|
758 memset(&completion, 0, sizeof(WSACOMPLETION)); |
a6742d9eadf3
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <paul@darkrain42.org>
parents:
24243
diff
changeset
|
759 completion.Type = NSP_NOTIFY_EVENT; |
a6742d9eadf3
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <paul@darkrain42.org>
parents:
24243
diff
changeset
|
760 overlapped.hEvent = nla_event; |
a6742d9eadf3
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <paul@darkrain42.org>
parents:
24243
diff
changeset
|
761 completion.Parameters.Event.lpOverlapped = &overlapped; |
a6742d9eadf3
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <paul@darkrain42.org>
parents:
24243
diff
changeset
|
762 |
a6742d9eadf3
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <paul@darkrain42.org>
parents:
24243
diff
changeset
|
763 if (MyWSANSPIoctl(network_change_handle, SIO_NSP_NOTIFY_CHANGE, NULL, 0, NULL, 0, &retLen, &completion) == SOCKET_ERROR) { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
764 int errorid = WSAGetLastError(); |
25041
75f72178e361
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24856
diff
changeset
|
765 if (errorid == WSA_INVALID_HANDLE) { |
75f72178e361
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24856
diff
changeset
|
766 purple_timeout_add(0, _print_debug_msg, |
75f72178e361
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24856
diff
changeset
|
767 g_strdup("Invalid NLA handle; resetting.\n")); |
75f72178e361
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24856
diff
changeset
|
768 g_static_mutex_lock(&mutex); |
75f72178e361
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24856
diff
changeset
|
769 retval = WSALookupServiceEnd(network_change_handle); |
75f72178e361
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24856
diff
changeset
|
770 network_change_handle = NULL; |
75f72178e361
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24856
diff
changeset
|
771 g_static_mutex_unlock(&mutex); |
75f72178e361
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24856
diff
changeset
|
772 continue; |
24856
a6742d9eadf3
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <paul@darkrain42.org>
parents:
24243
diff
changeset
|
773 /* WSA_IO_PENDING indicates successful async notification will happen */ |
25041
75f72178e361
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24856
diff
changeset
|
774 } else if (errorid != WSA_IO_PENDING) { |
24856
a6742d9eadf3
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <paul@darkrain42.org>
parents:
24243
diff
changeset
|
775 gchar *msg = g_win32_error_message(errorid); |
25041
75f72178e361
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24856
diff
changeset
|
776 purple_timeout_add(0, _print_debug_msg, |
75f72178e361
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24856
diff
changeset
|
777 g_strdup_printf("Unable to wait for changes. Message: %s (%d).\n", |
75f72178e361
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24856
diff
changeset
|
778 msg, errorid)); |
24856
a6742d9eadf3
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <paul@darkrain42.org>
parents:
24243
diff
changeset
|
779 g_free(msg); |
a6742d9eadf3
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <paul@darkrain42.org>
parents:
24243
diff
changeset
|
780 } |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
781 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
782 |
25041
75f72178e361
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24856
diff
changeset
|
783 /* Make sure at least 30 seconds have elapsed since the last |
75f72178e361
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24856
diff
changeset
|
784 * notification so we don't peg the cpu if this keeps changing. */ |
75f72178e361
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24856
diff
changeset
|
785 if ((time(NULL) - last_trigger) < 30) |
75f72178e361
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24856
diff
changeset
|
786 Sleep(30000); |
75f72178e361
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24856
diff
changeset
|
787 |
24856
a6742d9eadf3
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <paul@darkrain42.org>
parents:
24243
diff
changeset
|
788 /* This will block until NLA notifies us */ |
a6742d9eadf3
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <paul@darkrain42.org>
parents:
24243
diff
changeset
|
789 retval = WaitForSingleObjectEx(nla_event, WSA_INFINITE, TRUE); |
a6742d9eadf3
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <paul@darkrain42.org>
parents:
24243
diff
changeset
|
790 |
25041
75f72178e361
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24856
diff
changeset
|
791 last_trigger = time(NULL); |
75f72178e361
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24856
diff
changeset
|
792 |
24856
a6742d9eadf3
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <paul@darkrain42.org>
parents:
24243
diff
changeset
|
793 g_static_mutex_lock(&mutex); |
a6742d9eadf3
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <paul@darkrain42.org>
parents:
24243
diff
changeset
|
794 if (network_initialized == FALSE) { |
a6742d9eadf3
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <paul@darkrain42.org>
parents:
24243
diff
changeset
|
795 /* Time to die */ |
a6742d9eadf3
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <paul@darkrain42.org>
parents:
24243
diff
changeset
|
796 WSACloseEvent(nla_event); |
a6742d9eadf3
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <paul@darkrain42.org>
parents:
24243
diff
changeset
|
797 g_static_mutex_unlock(&mutex); |
a6742d9eadf3
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <paul@darkrain42.org>
parents:
24243
diff
changeset
|
798 g_thread_exit(NULL); |
a6742d9eadf3
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <paul@darkrain42.org>
parents:
24243
diff
changeset
|
799 return NULL; |
a6742d9eadf3
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <paul@darkrain42.org>
parents:
24243
diff
changeset
|
800 } |
a6742d9eadf3
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <paul@darkrain42.org>
parents:
24243
diff
changeset
|
801 |
25041
75f72178e361
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24856
diff
changeset
|
802 size = sizeof(buf); |
75f72178e361
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24856
diff
changeset
|
803 while ((retval = WSALookupServiceNext(network_change_handle, 0, &size, res)) == ERROR_SUCCESS) { |
75f72178e361
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24856
diff
changeset
|
804 /*purple_timeout_add(0, _print_debug_msg, |
75f72178e361
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24856
diff
changeset
|
805 g_strdup_printf("thread found network '%s'\n", |
75f72178e361
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24856
diff
changeset
|
806 res->lpszServiceInstanceName ? res->lpszServiceInstanceName : "(NULL)"));*/ |
75f72178e361
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24856
diff
changeset
|
807 size = sizeof(buf); |
75f72178e361
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24856
diff
changeset
|
808 } |
75f72178e361
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24856
diff
changeset
|
809 |
24856
a6742d9eadf3
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <paul@darkrain42.org>
parents:
24243
diff
changeset
|
810 WSAResetEvent(nla_event); |
a6742d9eadf3
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <paul@darkrain42.org>
parents:
24243
diff
changeset
|
811 g_static_mutex_unlock(&mutex); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
812 |
21466
7a05b6f84545
Don't map the port used for bonjour file transfers externally. This adds a new function that will go away in 3.0.0 when we can modify purple_network_do_listen to take an additional parameter.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21121
diff
changeset
|
813 purple_timeout_add(0, wpurple_network_change_thread_cb, NULL); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
814 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
815 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
816 g_thread_exit(NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
817 return NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
818 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
819 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
820 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
821 gboolean |
15823 | 822 purple_network_is_available(void) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
823 { |
22867
0bd86dae2734
Use pkg-config to detect NetworkManager. Also, fail if it isn't present,
Richard Laager <rlaager@wiktel.com>
parents:
22862
diff
changeset
|
824 #ifdef HAVE_NETWORKMANAGER |
25343
b38cbefca6ad
Add a -f/--force-online option to Pidgin which tells libpurple to claim the
Richard Laager <rlaager@wiktel.com>
parents:
24243
diff
changeset
|
825 if (force_online) |
b38cbefca6ad
Add a -f/--force-online option to Pidgin which tells libpurple to claim the
Richard Laager <rlaager@wiktel.com>
parents:
24243
diff
changeset
|
826 return TRUE; |
b38cbefca6ad
Add a -f/--force-online option to Pidgin which tells libpurple to claim the
Richard Laager <rlaager@wiktel.com>
parents:
24243
diff
changeset
|
827 |
24243
785db7300ef2
Improve our NetworkManager support in a couple of ways:
Richard Laager <rlaager@wiktel.com>
parents:
23774
diff
changeset
|
828 if (!have_nm_state) |
22855
6421d275c85e
Fix some whitespace as noticed by QuLogic.
Richard Laager <rlaager@wiktel.com>
parents:
22849
diff
changeset
|
829 { |
24243
785db7300ef2
Improve our NetworkManager support in a couple of ways:
Richard Laager <rlaager@wiktel.com>
parents:
23774
diff
changeset
|
830 have_nm_state = TRUE; |
785db7300ef2
Improve our NetworkManager support in a couple of ways:
Richard Laager <rlaager@wiktel.com>
parents:
23774
diff
changeset
|
831 nm_state = nm_get_network_state(); |
785db7300ef2
Improve our NetworkManager support in a couple of ways:
Richard Laager <rlaager@wiktel.com>
parents:
23774
diff
changeset
|
832 if (nm_state == NM_STATE_UNKNOWN) |
785db7300ef2
Improve our NetworkManager support in a couple of ways:
Richard Laager <rlaager@wiktel.com>
parents:
23774
diff
changeset
|
833 purple_debug_warning("network", "NetworkManager not active. Assuming connection exists.\n"); |
22849
e6674df4cbf1
Changes suggested by QuLogic to fix my broken changes to the NetworkManager
Richard Laager <rlaager@wiktel.com>
parents:
22848
diff
changeset
|
834 } |
24243
785db7300ef2
Improve our NetworkManager support in a couple of ways:
Richard Laager <rlaager@wiktel.com>
parents:
23774
diff
changeset
|
835 |
785db7300ef2
Improve our NetworkManager support in a couple of ways:
Richard Laager <rlaager@wiktel.com>
parents:
23774
diff
changeset
|
836 if (nm_state == NM_STATE_UNKNOWN || nm_state == NM_STATE_CONNECTED) |
22848
4f6040bb6f7a
Update configure.ac to properly detect Network Manager (via NetworkManager.h instead of libnm_glib). Also, change the code so that if NetworkManager is dead, we'll assume we're connected to the network and try anyway.
Richard Laager <rlaager@wiktel.com>
parents:
22847
diff
changeset
|
837 return TRUE; |
22849
e6674df4cbf1
Changes suggested by QuLogic to fix my broken changes to the NetworkManager
Richard Laager <rlaager@wiktel.com>
parents:
22848
diff
changeset
|
838 |
e6674df4cbf1
Changes suggested by QuLogic to fix my broken changes to the NetworkManager
Richard Laager <rlaager@wiktel.com>
parents:
22848
diff
changeset
|
839 return FALSE; |
e6674df4cbf1
Changes suggested by QuLogic to fix my broken changes to the NetworkManager
Richard Laager <rlaager@wiktel.com>
parents:
22848
diff
changeset
|
840 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
841 #elif defined _WIN32 |
25343
b38cbefca6ad
Add a -f/--force-online option to Pidgin which tells libpurple to claim the
Richard Laager <rlaager@wiktel.com>
parents:
24243
diff
changeset
|
842 return (current_network_count > 0 || force_online); |
22849
e6674df4cbf1
Changes suggested by QuLogic to fix my broken changes to the NetworkManager
Richard Laager <rlaager@wiktel.com>
parents:
22848
diff
changeset
|
843 #else |
e6674df4cbf1
Changes suggested by QuLogic to fix my broken changes to the NetworkManager
Richard Laager <rlaager@wiktel.com>
parents:
22848
diff
changeset
|
844 return TRUE; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
845 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
846 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
847 |
25343
b38cbefca6ad
Add a -f/--force-online option to Pidgin which tells libpurple to claim the
Richard Laager <rlaager@wiktel.com>
parents:
24243
diff
changeset
|
848 void |
b38cbefca6ad
Add a -f/--force-online option to Pidgin which tells libpurple to claim the
Richard Laager <rlaager@wiktel.com>
parents:
24243
diff
changeset
|
849 purple_network_force_online() |
b38cbefca6ad
Add a -f/--force-online option to Pidgin which tells libpurple to claim the
Richard Laager <rlaager@wiktel.com>
parents:
24243
diff
changeset
|
850 { |
b38cbefca6ad
Add a -f/--force-online option to Pidgin which tells libpurple to claim the
Richard Laager <rlaager@wiktel.com>
parents:
24243
diff
changeset
|
851 #if defined(HAVE_NETWORKMANAGER) || defined(_WIN32) |
b38cbefca6ad
Add a -f/--force-online option to Pidgin which tells libpurple to claim the
Richard Laager <rlaager@wiktel.com>
parents:
24243
diff
changeset
|
852 force_online = TRUE; |
b38cbefca6ad
Add a -f/--force-online option to Pidgin which tells libpurple to claim the
Richard Laager <rlaager@wiktel.com>
parents:
24243
diff
changeset
|
853 #endif |
b38cbefca6ad
Add a -f/--force-online option to Pidgin which tells libpurple to claim the
Richard Laager <rlaager@wiktel.com>
parents:
24243
diff
changeset
|
854 } |
b38cbefca6ad
Add a -f/--force-online option to Pidgin which tells libpurple to claim the
Richard Laager <rlaager@wiktel.com>
parents:
24243
diff
changeset
|
855 |
22867
0bd86dae2734
Use pkg-config to detect NetworkManager. Also, fail if it isn't present,
Richard Laager <rlaager@wiktel.com>
parents:
22862
diff
changeset
|
856 #ifdef HAVE_NETWORKMANAGER |
22577
0e426ad6cc87
Make some more things static
Stu Tomlinson <stu@nosnilmot.com>
parents:
21862
diff
changeset
|
857 static void |
22847
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
858 nm_update_state(NMState state) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
859 { |
24243
785db7300ef2
Improve our NetworkManager support in a couple of ways:
Richard Laager <rlaager@wiktel.com>
parents:
23774
diff
changeset
|
860 NMState prev = nm_state; |
15823 | 861 PurpleConnectionUiOps *ui_ops = purple_connections_get_ui_ops(); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
862 |
24243
785db7300ef2
Improve our NetworkManager support in a couple of ways:
Richard Laager <rlaager@wiktel.com>
parents:
23774
diff
changeset
|
863 have_nm_state = TRUE; |
785db7300ef2
Improve our NetworkManager support in a couple of ways:
Richard Laager <rlaager@wiktel.com>
parents:
23774
diff
changeset
|
864 nm_state = state; |
785db7300ef2
Improve our NetworkManager support in a couple of ways:
Richard Laager <rlaager@wiktel.com>
parents:
23774
diff
changeset
|
865 |
15974
1a12ce76c4f4
The network module now registers the signal 'network-configuration-changed' and emits it when a network change is detected via libnm or the win32 network monitor. The UI could also emit this signal if it knows something network.c doesn't. UPnP and NAT-PMP respond to the signal by clearing their IP address caches; changing networks without quitting/relaunching will now lead to the new IP address being (lazily) determined. This commit also enables nat-pmp and adds nat-pmp.[h|c] to the build process; please let me know if there are any problems building, as I only have OS X test machines.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15949
diff
changeset
|
866 purple_signal_emit(purple_network_get_handle(), "network-configuration-changed", NULL); |
1a12ce76c4f4
The network module now registers the signal 'network-configuration-changed' and emits it when a network change is detected via libnm or the win32 network monitor. The UI could also emit this signal if it knows something network.c doesn't. UPnP and NAT-PMP respond to the signal by clearing their IP address caches; changing networks without quitting/relaunching will now lead to the new IP address being (lazily) determined. This commit also enables nat-pmp and adds nat-pmp.[h|c] to the build process; please let me know if there are any problems building, as I only have OS X test machines.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15949
diff
changeset
|
867 |
22847
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
868 switch(state) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
869 { |
31905
f5a18dd894cc
Support new connection states in NetworkMakanter 0.9. Fixes #13505.
dcbw@redhat.com
parents:
31534
diff
changeset
|
870 #if NM_CHECK_VERSION(0,8,992) |
f5a18dd894cc
Support new connection states in NetworkMakanter 0.9. Fixes #13505.
dcbw@redhat.com
parents:
31534
diff
changeset
|
871 case NM_STATE_CONNECTED_LOCAL: |
f5a18dd894cc
Support new connection states in NetworkMakanter 0.9. Fixes #13505.
dcbw@redhat.com
parents:
31534
diff
changeset
|
872 case NM_STATE_CONNECTED_SITE: |
f5a18dd894cc
Support new connection states in NetworkMakanter 0.9. Fixes #13505.
dcbw@redhat.com
parents:
31534
diff
changeset
|
873 case NM_STATE_CONNECTED_GLOBAL: |
f5a18dd894cc
Support new connection states in NetworkMakanter 0.9. Fixes #13505.
dcbw@redhat.com
parents:
31534
diff
changeset
|
874 #else |
22847
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
875 case NM_STATE_CONNECTED: |
31905
f5a18dd894cc
Support new connection states in NetworkMakanter 0.9. Fixes #13505.
dcbw@redhat.com
parents:
31534
diff
changeset
|
876 #endif |
22847
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
877 /* Call res_init in case DNS servers have changed */ |
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
878 res_init(); |
26132
ae3d25465d0f
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <ml@update.uu.se>
parents:
24856
diff
changeset
|
879 /* update STUN IP in case we it changed (theoretically we could |
ae3d25465d0f
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <ml@update.uu.se>
parents:
24856
diff
changeset
|
880 have gone from IPv4 to IPv6, f.ex. or we were previously |
ae3d25465d0f
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <ml@update.uu.se>
parents:
24856
diff
changeset
|
881 offline */ |
ae3d25465d0f
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <ml@update.uu.se>
parents:
24856
diff
changeset
|
882 purple_network_set_stun_server( |
ae3d25465d0f
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <ml@update.uu.se>
parents:
24856
diff
changeset
|
883 purple_prefs_get_string("/purple/network/stun_server")); |
26137
c56e8826fed0
Added support to generate relayed candidates (TURN).
Marcus Lundblad <ml@update.uu.se>
parents:
26132
diff
changeset
|
884 purple_network_set_turn_server( |
c56e8826fed0
Added support to generate relayed candidates (TURN).
Marcus Lundblad <ml@update.uu.se>
parents:
26132
diff
changeset
|
885 purple_prefs_get_string("/purple/network/turn_server")); |
31534
a8cc50c2279f
Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents:
31423
diff
changeset
|
886 |
22847
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
887 if (ui_ops != NULL && ui_ops->network_connected != NULL) |
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
888 ui_ops->network_connected(); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
889 break; |
22847
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
890 case NM_STATE_ASLEEP: |
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
891 case NM_STATE_CONNECTING: |
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
892 case NM_STATE_DISCONNECTED: |
31905
f5a18dd894cc
Support new connection states in NetworkMakanter 0.9. Fixes #13505.
dcbw@redhat.com
parents:
31534
diff
changeset
|
893 #if NM_CHECK_VERSION(0,8,992) |
f5a18dd894cc
Support new connection states in NetworkMakanter 0.9. Fixes #13505.
dcbw@redhat.com
parents:
31534
diff
changeset
|
894 case NM_STATE_DISCONNECTING: |
f5a18dd894cc
Support new connection states in NetworkMakanter 0.9. Fixes #13505.
dcbw@redhat.com
parents:
31534
diff
changeset
|
895 #endif |
24243
785db7300ef2
Improve our NetworkManager support in a couple of ways:
Richard Laager <rlaager@wiktel.com>
parents:
23774
diff
changeset
|
896 if (prev != NM_STATE_CONNECTED && prev != NM_STATE_UNKNOWN) |
22847
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
897 break; |
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
898 if (ui_ops != NULL && ui_ops->network_disconnected != NULL) |
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
899 ui_ops->network_disconnected(); |
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
900 break; |
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
901 case NM_STATE_UNKNOWN: |
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
902 default: |
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
903 break; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
904 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
905 } |
22847
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
906 |
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
907 static void |
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
908 nm_state_change_cb(DBusGProxy *proxy, NMState state, gpointer user_data) |
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
909 { |
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
910 purple_debug_info("network", "Got StateChange from NetworkManager: %d.\n", state); |
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
911 nm_update_state(state); |
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
912 } |
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
913 |
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
914 static NMState |
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
915 nm_get_network_state(void) |
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
916 { |
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
917 GError *err = NULL; |
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
918 NMState state = NM_STATE_UNKNOWN; |
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
919 |
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
920 if (!nm_proxy) |
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
921 return NM_STATE_UNKNOWN; |
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
922 |
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
923 if (!dbus_g_proxy_call(nm_proxy, "state", &err, G_TYPE_INVALID, G_TYPE_UINT, &state, G_TYPE_INVALID)) { |
23045 | 924 g_error_free(err); |
22847
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
925 return NM_STATE_UNKNOWN; |
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
926 } |
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
927 |
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
928 return state; |
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
929 } |
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
930 |
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
931 static void |
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
932 nm_dbus_name_owner_changed_cb(DBusGProxy *proxy, char *service, char *old_owner, char *new_owner, gpointer user_data) |
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
933 { |
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
934 if (g_str_equal(service, NM_DBUS_SERVICE)) { |
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
935 gboolean old_owner_good = old_owner && (old_owner[0] != '\0'); |
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
936 gboolean new_owner_good = new_owner && (new_owner[0] != '\0'); |
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
937 |
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
938 purple_debug_info("network", "Got NameOwnerChanged signal, service = '%s', old_owner = '%s', new_owner = '%s'\n", service, old_owner, new_owner); |
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
939 if (!old_owner_good && new_owner_good) { /* Equivalent to old ServiceCreated signal */ |
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
940 purple_debug_info("network", "NetworkManager has started.\n"); |
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
941 nm_update_state(nm_get_network_state()); |
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
942 } else if (old_owner_good && !new_owner_good) { /* Equivalent to old ServiceDeleted signal */ |
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
943 purple_debug_info("network", "NetworkManager has gone away.\n"); |
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
944 nm_update_state(NM_STATE_UNKNOWN); |
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
945 } |
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
946 } |
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
947 } |
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
948 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
949 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
950 |
26132
ae3d25465d0f
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <ml@update.uu.se>
parents:
24856
diff
changeset
|
951 static void |
31534
a8cc50c2279f
Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents:
31423
diff
changeset
|
952 purple_network_ip_lookup_cb(GSList *hosts, gpointer data, |
26132
ae3d25465d0f
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <ml@update.uu.se>
parents:
24856
diff
changeset
|
953 const char *error_message) |
ae3d25465d0f
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <ml@update.uu.se>
parents:
24856
diff
changeset
|
954 { |
31534
a8cc50c2279f
Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents:
31423
diff
changeset
|
955 const gchar **ip = (const gchar **) data; |
26138
4f0aec6d4ad7
Removed some extra tabs on blank lines
Marcus Lundblad <ml@update.uu.se>
parents:
26137
diff
changeset
|
956 |
26132
ae3d25465d0f
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <ml@update.uu.se>
parents:
24856
diff
changeset
|
957 if (error_message) { |
26137
c56e8826fed0
Added support to generate relayed candidates (TURN).
Marcus Lundblad <ml@update.uu.se>
parents:
26132
diff
changeset
|
958 purple_debug_error("network", "lookup of IP address failed: %s\n", |
26132
ae3d25465d0f
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <ml@update.uu.se>
parents:
24856
diff
changeset
|
959 error_message); |
ae3d25465d0f
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <ml@update.uu.se>
parents:
24856
diff
changeset
|
960 g_slist_free(hosts); |
ae3d25465d0f
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <ml@update.uu.se>
parents:
24856
diff
changeset
|
961 return; |
ae3d25465d0f
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <ml@update.uu.se>
parents:
24856
diff
changeset
|
962 } |
26138
4f0aec6d4ad7
Removed some extra tabs on blank lines
Marcus Lundblad <ml@update.uu.se>
parents:
26137
diff
changeset
|
963 |
26132
ae3d25465d0f
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <ml@update.uu.se>
parents:
24856
diff
changeset
|
964 if (hosts && g_slist_next(hosts)) { |
31534
a8cc50c2279f
Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents:
31423
diff
changeset
|
965 struct sockaddr *addr = g_slist_next(hosts)->data; |
26132
ae3d25465d0f
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <ml@update.uu.se>
parents:
24856
diff
changeset
|
966 char dst[INET6_ADDRSTRLEN]; |
31534
a8cc50c2279f
Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents:
31423
diff
changeset
|
967 |
26132
ae3d25465d0f
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <ml@update.uu.se>
parents:
24856
diff
changeset
|
968 if (addr->sa_family == AF_INET6) { |
31534
a8cc50c2279f
Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents:
31423
diff
changeset
|
969 inet_ntop(addr->sa_family, &((struct sockaddr_in6 *) addr)->sin6_addr, |
26132
ae3d25465d0f
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <ml@update.uu.se>
parents:
24856
diff
changeset
|
970 dst, sizeof(dst)); |
ae3d25465d0f
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <ml@update.uu.se>
parents:
24856
diff
changeset
|
971 } else { |
31534
a8cc50c2279f
Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents:
31423
diff
changeset
|
972 inet_ntop(addr->sa_family, &((struct sockaddr_in *) addr)->sin_addr, |
26132
ae3d25465d0f
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <ml@update.uu.se>
parents:
24856
diff
changeset
|
973 dst, sizeof(dst)); |
ae3d25465d0f
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <ml@update.uu.se>
parents:
24856
diff
changeset
|
974 } |
26138
4f0aec6d4ad7
Removed some extra tabs on blank lines
Marcus Lundblad <ml@update.uu.se>
parents:
26137
diff
changeset
|
975 |
26137
c56e8826fed0
Added support to generate relayed candidates (TURN).
Marcus Lundblad <ml@update.uu.se>
parents:
26132
diff
changeset
|
976 *ip = g_strdup(dst); |
c56e8826fed0
Added support to generate relayed candidates (TURN).
Marcus Lundblad <ml@update.uu.se>
parents:
26132
diff
changeset
|
977 purple_debug_info("network", "set IP address: %s\n", *ip); |
26132
ae3d25465d0f
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <ml@update.uu.se>
parents:
24856
diff
changeset
|
978 } |
26633
5d1140b0b10a
Don't leak the struct sockaddr* from purple_dnsquery_a.
Paul Aurich <paul@darkrain42.org>
parents:
26213
diff
changeset
|
979 |
5d1140b0b10a
Don't leak the struct sockaddr* from purple_dnsquery_a.
Paul Aurich <paul@darkrain42.org>
parents:
26213
diff
changeset
|
980 while (hosts != NULL) { |
5d1140b0b10a
Don't leak the struct sockaddr* from purple_dnsquery_a.
Paul Aurich <paul@darkrain42.org>
parents:
26213
diff
changeset
|
981 hosts = g_slist_delete_link(hosts, hosts); |
5d1140b0b10a
Don't leak the struct sockaddr* from purple_dnsquery_a.
Paul Aurich <paul@darkrain42.org>
parents:
26213
diff
changeset
|
982 /* Free the address */ |
5d1140b0b10a
Don't leak the struct sockaddr* from purple_dnsquery_a.
Paul Aurich <paul@darkrain42.org>
parents:
26213
diff
changeset
|
983 g_free(hosts->data); |
5d1140b0b10a
Don't leak the struct sockaddr* from purple_dnsquery_a.
Paul Aurich <paul@darkrain42.org>
parents:
26213
diff
changeset
|
984 hosts = g_slist_delete_link(hosts, hosts); |
5d1140b0b10a
Don't leak the struct sockaddr* from purple_dnsquery_a.
Paul Aurich <paul@darkrain42.org>
parents:
26213
diff
changeset
|
985 } |
26132
ae3d25465d0f
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <ml@update.uu.se>
parents:
24856
diff
changeset
|
986 } |
ae3d25465d0f
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <ml@update.uu.se>
parents:
24856
diff
changeset
|
987 |
ae3d25465d0f
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <ml@update.uu.se>
parents:
24856
diff
changeset
|
988 void |
ae3d25465d0f
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <ml@update.uu.se>
parents:
24856
diff
changeset
|
989 purple_network_set_stun_server(const gchar *stun_server) |
ae3d25465d0f
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <ml@update.uu.se>
parents:
24856
diff
changeset
|
990 { |
ae3d25465d0f
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <ml@update.uu.se>
parents:
24856
diff
changeset
|
991 if (stun_server && stun_server[0] != '\0') { |
ae3d25465d0f
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <ml@update.uu.se>
parents:
24856
diff
changeset
|
992 if (purple_network_is_available()) { |
ae3d25465d0f
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <ml@update.uu.se>
parents:
24856
diff
changeset
|
993 purple_debug_info("network", "running DNS query for STUN server\n"); |
31932
b671728e6ee9
Use the new account-contextual DNS API everywhere. Refs #11110
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31905
diff
changeset
|
994 purple_dnsquery_a_account(NULL, stun_server, 3478, purple_network_ip_lookup_cb, |
26137
c56e8826fed0
Added support to generate relayed candidates (TURN).
Marcus Lundblad <ml@update.uu.se>
parents:
26132
diff
changeset
|
995 &stun_ip); |
26132
ae3d25465d0f
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <ml@update.uu.se>
parents:
24856
diff
changeset
|
996 } else { |
31534
a8cc50c2279f
Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents:
31423
diff
changeset
|
997 purple_debug_info("network", |
26132
ae3d25465d0f
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <ml@update.uu.se>
parents:
24856
diff
changeset
|
998 "network is unavailable, don't try to update STUN IP"); |
ae3d25465d0f
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <ml@update.uu.se>
parents:
24856
diff
changeset
|
999 } |
ae3d25465d0f
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <ml@update.uu.se>
parents:
24856
diff
changeset
|
1000 } else if (stun_ip) { |
ae3d25465d0f
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <ml@update.uu.se>
parents:
24856
diff
changeset
|
1001 g_free(stun_ip); |
ae3d25465d0f
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <ml@update.uu.se>
parents:
24856
diff
changeset
|
1002 stun_ip = NULL; |
ae3d25465d0f
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <ml@update.uu.se>
parents:
24856
diff
changeset
|
1003 } |
ae3d25465d0f
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <ml@update.uu.se>
parents:
24856
diff
changeset
|
1004 } |
ae3d25465d0f
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <ml@update.uu.se>
parents:
24856
diff
changeset
|
1005 |
26137
c56e8826fed0
Added support to generate relayed candidates (TURN).
Marcus Lundblad <ml@update.uu.se>
parents:
26132
diff
changeset
|
1006 void |
c56e8826fed0
Added support to generate relayed candidates (TURN).
Marcus Lundblad <ml@update.uu.se>
parents:
26132
diff
changeset
|
1007 purple_network_set_turn_server(const gchar *turn_server) |
c56e8826fed0
Added support to generate relayed candidates (TURN).
Marcus Lundblad <ml@update.uu.se>
parents:
26132
diff
changeset
|
1008 { |
c56e8826fed0
Added support to generate relayed candidates (TURN).
Marcus Lundblad <ml@update.uu.se>
parents:
26132
diff
changeset
|
1009 if (turn_server && turn_server[0] != '\0') { |
c56e8826fed0
Added support to generate relayed candidates (TURN).
Marcus Lundblad <ml@update.uu.se>
parents:
26132
diff
changeset
|
1010 if (purple_network_is_available()) { |
c56e8826fed0
Added support to generate relayed candidates (TURN).
Marcus Lundblad <ml@update.uu.se>
parents:
26132
diff
changeset
|
1011 purple_debug_info("network", "running DNS query for TURN server\n"); |
31932
b671728e6ee9
Use the new account-contextual DNS API everywhere. Refs #11110
Daniel Atallah <daniel.atallah@gmail.com>
parents:
31905
diff
changeset
|
1012 purple_dnsquery_a_account(NULL, turn_server, |
31534
a8cc50c2279f
Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents:
31423
diff
changeset
|
1013 purple_prefs_get_int("/purple/network/turn_port"), |
26137
c56e8826fed0
Added support to generate relayed candidates (TURN).
Marcus Lundblad <ml@update.uu.se>
parents:
26132
diff
changeset
|
1014 purple_network_ip_lookup_cb, &turn_ip); |
c56e8826fed0
Added support to generate relayed candidates (TURN).
Marcus Lundblad <ml@update.uu.se>
parents:
26132
diff
changeset
|
1015 } else { |
31534
a8cc50c2279f
Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents:
31423
diff
changeset
|
1016 purple_debug_info("network", |
26137
c56e8826fed0
Added support to generate relayed candidates (TURN).
Marcus Lundblad <ml@update.uu.se>
parents:
26132
diff
changeset
|
1017 "network is unavailable, don't try to update TURN IP"); |
c56e8826fed0
Added support to generate relayed candidates (TURN).
Marcus Lundblad <ml@update.uu.se>
parents:
26132
diff
changeset
|
1018 } |
c56e8826fed0
Added support to generate relayed candidates (TURN).
Marcus Lundblad <ml@update.uu.se>
parents:
26132
diff
changeset
|
1019 } else if (turn_ip) { |
c56e8826fed0
Added support to generate relayed candidates (TURN).
Marcus Lundblad <ml@update.uu.se>
parents:
26132
diff
changeset
|
1020 g_free(turn_ip); |
c56e8826fed0
Added support to generate relayed candidates (TURN).
Marcus Lundblad <ml@update.uu.se>
parents:
26132
diff
changeset
|
1021 turn_ip = NULL; |
c56e8826fed0
Added support to generate relayed candidates (TURN).
Marcus Lundblad <ml@update.uu.se>
parents:
26132
diff
changeset
|
1022 } |
c56e8826fed0
Added support to generate relayed candidates (TURN).
Marcus Lundblad <ml@update.uu.se>
parents:
26132
diff
changeset
|
1023 } |
c56e8826fed0
Added support to generate relayed candidates (TURN).
Marcus Lundblad <ml@update.uu.se>
parents:
26132
diff
changeset
|
1024 |
c56e8826fed0
Added support to generate relayed candidates (TURN).
Marcus Lundblad <ml@update.uu.se>
parents:
26132
diff
changeset
|
1025 |
26132
ae3d25465d0f
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <ml@update.uu.se>
parents:
24856
diff
changeset
|
1026 const gchar * |
ae3d25465d0f
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <ml@update.uu.se>
parents:
24856
diff
changeset
|
1027 purple_network_get_stun_ip(void) |
ae3d25465d0f
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <ml@update.uu.se>
parents:
24856
diff
changeset
|
1028 { |
ae3d25465d0f
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <ml@update.uu.se>
parents:
24856
diff
changeset
|
1029 return stun_ip; |
ae3d25465d0f
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <ml@update.uu.se>
parents:
24856
diff
changeset
|
1030 } |
ae3d25465d0f
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <ml@update.uu.se>
parents:
24856
diff
changeset
|
1031 |
26137
c56e8826fed0
Added support to generate relayed candidates (TURN).
Marcus Lundblad <ml@update.uu.se>
parents:
26132
diff
changeset
|
1032 const gchar * |
c56e8826fed0
Added support to generate relayed candidates (TURN).
Marcus Lundblad <ml@update.uu.se>
parents:
26132
diff
changeset
|
1033 purple_network_get_turn_ip(void) |
c56e8826fed0
Added support to generate relayed candidates (TURN).
Marcus Lundblad <ml@update.uu.se>
parents:
26132
diff
changeset
|
1034 { |
c56e8826fed0
Added support to generate relayed candidates (TURN).
Marcus Lundblad <ml@update.uu.se>
parents:
26132
diff
changeset
|
1035 return turn_ip; |
c56e8826fed0
Added support to generate relayed candidates (TURN).
Marcus Lundblad <ml@update.uu.se>
parents:
26132
diff
changeset
|
1036 } |
c56e8826fed0
Added support to generate relayed candidates (TURN).
Marcus Lundblad <ml@update.uu.se>
parents:
26132
diff
changeset
|
1037 |
15974
1a12ce76c4f4
The network module now registers the signal 'network-configuration-changed' and emits it when a network change is detected via libnm or the win32 network monitor. The UI could also emit this signal if it knows something network.c doesn't. UPnP and NAT-PMP respond to the signal by clearing their IP address caches; changing networks without quitting/relaunching will now lead to the new IP address being (lazily) determined. This commit also enables nat-pmp and adds nat-pmp.[h|c] to the build process; please let me know if there are any problems building, as I only have OS X test machines.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15949
diff
changeset
|
1038 void * |
1a12ce76c4f4
The network module now registers the signal 'network-configuration-changed' and emits it when a network change is detected via libnm or the win32 network monitor. The UI could also emit this signal if it knows something network.c doesn't. UPnP and NAT-PMP respond to the signal by clearing their IP address caches; changing networks without quitting/relaunching will now lead to the new IP address being (lazily) determined. This commit also enables nat-pmp and adds nat-pmp.[h|c] to the build process; please let me know if there are any problems building, as I only have OS X test machines.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15949
diff
changeset
|
1039 purple_network_get_handle(void) |
1a12ce76c4f4
The network module now registers the signal 'network-configuration-changed' and emits it when a network change is detected via libnm or the win32 network monitor. The UI could also emit this signal if it knows something network.c doesn't. UPnP and NAT-PMP respond to the signal by clearing their IP address caches; changing networks without quitting/relaunching will now lead to the new IP address being (lazily) determined. This commit also enables nat-pmp and adds nat-pmp.[h|c] to the build process; please let me know if there are any problems building, as I only have OS X test machines.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15949
diff
changeset
|
1040 { |
1a12ce76c4f4
The network module now registers the signal 'network-configuration-changed' and emits it when a network change is detected via libnm or the win32 network monitor. The UI could also emit this signal if it knows something network.c doesn't. UPnP and NAT-PMP respond to the signal by clearing their IP address caches; changing networks without quitting/relaunching will now lead to the new IP address being (lazily) determined. This commit also enables nat-pmp and adds nat-pmp.[h|c] to the build process; please let me know if there are any problems building, as I only have OS X test machines.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15949
diff
changeset
|
1041 static int handle; |
19408
cc36a5aac908
Fix some conversion warnings about using negative values with unsigned types. There are more, but these were easy fixes. You may think that I'm changing the API, but I'm really not - it was just wrong.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18401
diff
changeset
|
1042 |
15974
1a12ce76c4f4
The network module now registers the signal 'network-configuration-changed' and emits it when a network change is detected via libnm or the win32 network monitor. The UI could also emit this signal if it knows something network.c doesn't. UPnP and NAT-PMP respond to the signal by clearing their IP address caches; changing networks without quitting/relaunching will now lead to the new IP address being (lazily) determined. This commit also enables nat-pmp and adds nat-pmp.[h|c] to the build process; please let me know if there are any problems building, as I only have OS X test machines.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15949
diff
changeset
|
1043 return &handle; |
1a12ce76c4f4
The network module now registers the signal 'network-configuration-changed' and emits it when a network change is detected via libnm or the win32 network monitor. The UI could also emit this signal if it knows something network.c doesn't. UPnP and NAT-PMP respond to the signal by clearing their IP address caches; changing networks without quitting/relaunching will now lead to the new IP address being (lazily) determined. This commit also enables nat-pmp and adds nat-pmp.[h|c] to the build process; please let me know if there are any problems building, as I only have OS X test machines.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15949
diff
changeset
|
1044 } |
1a12ce76c4f4
The network module now registers the signal 'network-configuration-changed' and emits it when a network change is detected via libnm or the win32 network monitor. The UI could also emit this signal if it knows something network.c doesn't. UPnP and NAT-PMP respond to the signal by clearing their IP address caches; changing networks without quitting/relaunching will now lead to the new IP address being (lazily) determined. This commit also enables nat-pmp and adds nat-pmp.[h|c] to the build process; please let me know if there are any problems building, as I only have OS X test machines.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15949
diff
changeset
|
1045 |
27190
38c4973b5222
Add a function to remove a port mapping (UPnP or NAT-PMP) given a file
Marcus Lundblad <ml@update.uu.se>
parents:
26967
diff
changeset
|
1046 static void |
38c4973b5222
Add a function to remove a port mapping (UPnP or NAT-PMP) given a file
Marcus Lundblad <ml@update.uu.se>
parents:
26967
diff
changeset
|
1047 purple_network_upnp_mapping_remove_cb(gboolean sucess, gpointer data) |
38c4973b5222
Add a function to remove a port mapping (UPnP or NAT-PMP) given a file
Marcus Lundblad <ml@update.uu.se>
parents:
26967
diff
changeset
|
1048 { |
38c4973b5222
Add a function to remove a port mapping (UPnP or NAT-PMP) given a file
Marcus Lundblad <ml@update.uu.se>
parents:
26967
diff
changeset
|
1049 purple_debug_info("network", "done removing UPnP port mapping\n"); |
38c4973b5222
Add a function to remove a port mapping (UPnP or NAT-PMP) given a file
Marcus Lundblad <ml@update.uu.se>
parents:
26967
diff
changeset
|
1050 } |
38c4973b5222
Add a function to remove a port mapping (UPnP or NAT-PMP) given a file
Marcus Lundblad <ml@update.uu.se>
parents:
26967
diff
changeset
|
1051 |
38c4973b5222
Add a function to remove a port mapping (UPnP or NAT-PMP) given a file
Marcus Lundblad <ml@update.uu.se>
parents:
26967
diff
changeset
|
1052 /* the reason for these functions to have these signatures is to be able to |
38c4973b5222
Add a function to remove a port mapping (UPnP or NAT-PMP) given a file
Marcus Lundblad <ml@update.uu.se>
parents:
26967
diff
changeset
|
1053 use them for g_hash_table_foreach to clean remaining port mappings, which is |
38c4973b5222
Add a function to remove a port mapping (UPnP or NAT-PMP) given a file
Marcus Lundblad <ml@update.uu.se>
parents:
26967
diff
changeset
|
1054 not yet done */ |
38c4973b5222
Add a function to remove a port mapping (UPnP or NAT-PMP) given a file
Marcus Lundblad <ml@update.uu.se>
parents:
26967
diff
changeset
|
1055 static void |
38c4973b5222
Add a function to remove a port mapping (UPnP or NAT-PMP) given a file
Marcus Lundblad <ml@update.uu.se>
parents:
26967
diff
changeset
|
1056 purple_network_upnp_mapping_remove(gpointer key, gpointer value, |
38c4973b5222
Add a function to remove a port mapping (UPnP or NAT-PMP) given a file
Marcus Lundblad <ml@update.uu.se>
parents:
26967
diff
changeset
|
1057 gpointer user_data) |
38c4973b5222
Add a function to remove a port mapping (UPnP or NAT-PMP) given a file
Marcus Lundblad <ml@update.uu.se>
parents:
26967
diff
changeset
|
1058 { |
31423
18d56b13fe8b
Cast back and forth between int and pointer instead of putting pointers
Mark Doliner <mark@kingant.net>
parents:
30983
diff
changeset
|
1059 gint port = GPOINTER_TO_INT(key); |
18d56b13fe8b
Cast back and forth between int and pointer instead of putting pointers
Mark Doliner <mark@kingant.net>
parents:
30983
diff
changeset
|
1060 gint protocol = GPOINTER_TO_INT(value); |
27190
38c4973b5222
Add a function to remove a port mapping (UPnP or NAT-PMP) given a file
Marcus Lundblad <ml@update.uu.se>
parents:
26967
diff
changeset
|
1061 purple_debug_info("network", "removing UPnP port mapping for port %d\n", |
38c4973b5222
Add a function to remove a port mapping (UPnP or NAT-PMP) given a file
Marcus Lundblad <ml@update.uu.se>
parents:
26967
diff
changeset
|
1062 port); |
31423
18d56b13fe8b
Cast back and forth between int and pointer instead of putting pointers
Mark Doliner <mark@kingant.net>
parents:
30983
diff
changeset
|
1063 purple_upnp_remove_port_mapping(port, |
18d56b13fe8b
Cast back and forth between int and pointer instead of putting pointers
Mark Doliner <mark@kingant.net>
parents:
30983
diff
changeset
|
1064 protocol == SOCK_STREAM ? "TCP" : "UDP", |
27190
38c4973b5222
Add a function to remove a port mapping (UPnP or NAT-PMP) given a file
Marcus Lundblad <ml@update.uu.se>
parents:
26967
diff
changeset
|
1065 purple_network_upnp_mapping_remove_cb, NULL); |
31423
18d56b13fe8b
Cast back and forth between int and pointer instead of putting pointers
Mark Doliner <mark@kingant.net>
parents:
30983
diff
changeset
|
1066 g_hash_table_remove(upnp_port_mappings, GINT_TO_POINTER(port)); |
27190
38c4973b5222
Add a function to remove a port mapping (UPnP or NAT-PMP) given a file
Marcus Lundblad <ml@update.uu.se>
parents:
26967
diff
changeset
|
1067 } |
38c4973b5222
Add a function to remove a port mapping (UPnP or NAT-PMP) given a file
Marcus Lundblad <ml@update.uu.se>
parents:
26967
diff
changeset
|
1068 |
38c4973b5222
Add a function to remove a port mapping (UPnP or NAT-PMP) given a file
Marcus Lundblad <ml@update.uu.se>
parents:
26967
diff
changeset
|
1069 static void |
38c4973b5222
Add a function to remove a port mapping (UPnP or NAT-PMP) given a file
Marcus Lundblad <ml@update.uu.se>
parents:
26967
diff
changeset
|
1070 purple_network_nat_pmp_mapping_remove(gpointer key, gpointer value, |
38c4973b5222
Add a function to remove a port mapping (UPnP or NAT-PMP) given a file
Marcus Lundblad <ml@update.uu.se>
parents:
26967
diff
changeset
|
1071 gpointer user_data) |
38c4973b5222
Add a function to remove a port mapping (UPnP or NAT-PMP) given a file
Marcus Lundblad <ml@update.uu.se>
parents:
26967
diff
changeset
|
1072 { |
31423
18d56b13fe8b
Cast back and forth between int and pointer instead of putting pointers
Mark Doliner <mark@kingant.net>
parents:
30983
diff
changeset
|
1073 gint port = GPOINTER_TO_INT(key); |
18d56b13fe8b
Cast back and forth between int and pointer instead of putting pointers
Mark Doliner <mark@kingant.net>
parents:
30983
diff
changeset
|
1074 gint protocol = GPOINTER_TO_INT(value); |
27190
38c4973b5222
Add a function to remove a port mapping (UPnP or NAT-PMP) given a file
Marcus Lundblad <ml@update.uu.se>
parents:
26967
diff
changeset
|
1075 purple_debug_info("network", "removing NAT-PMP port mapping for port %d\n", |
38c4973b5222
Add a function to remove a port mapping (UPnP or NAT-PMP) given a file
Marcus Lundblad <ml@update.uu.se>
parents:
26967
diff
changeset
|
1076 port); |
38c4973b5222
Add a function to remove a port mapping (UPnP or NAT-PMP) given a file
Marcus Lundblad <ml@update.uu.se>
parents:
26967
diff
changeset
|
1077 purple_pmp_destroy_map( |
31423
18d56b13fe8b
Cast back and forth between int and pointer instead of putting pointers
Mark Doliner <mark@kingant.net>
parents:
30983
diff
changeset
|
1078 protocol == SOCK_STREAM ? PURPLE_PMP_TYPE_TCP : PURPLE_PMP_TYPE_UDP, |
27190
38c4973b5222
Add a function to remove a port mapping (UPnP or NAT-PMP) given a file
Marcus Lundblad <ml@update.uu.se>
parents:
26967
diff
changeset
|
1079 port); |
31423
18d56b13fe8b
Cast back and forth between int and pointer instead of putting pointers
Mark Doliner <mark@kingant.net>
parents:
30983
diff
changeset
|
1080 g_hash_table_remove(nat_pmp_port_mappings, GINT_TO_POINTER(port)); |
27190
38c4973b5222
Add a function to remove a port mapping (UPnP or NAT-PMP) given a file
Marcus Lundblad <ml@update.uu.se>
parents:
26967
diff
changeset
|
1081 } |
38c4973b5222
Add a function to remove a port mapping (UPnP or NAT-PMP) given a file
Marcus Lundblad <ml@update.uu.se>
parents:
26967
diff
changeset
|
1082 |
38c4973b5222
Add a function to remove a port mapping (UPnP or NAT-PMP) given a file
Marcus Lundblad <ml@update.uu.se>
parents:
26967
diff
changeset
|
1083 void |
38c4973b5222
Add a function to remove a port mapping (UPnP or NAT-PMP) given a file
Marcus Lundblad <ml@update.uu.se>
parents:
26967
diff
changeset
|
1084 purple_network_remove_port_mapping(gint fd) |
38c4973b5222
Add a function to remove a port mapping (UPnP or NAT-PMP) given a file
Marcus Lundblad <ml@update.uu.se>
parents:
26967
diff
changeset
|
1085 { |
38c4973b5222
Add a function to remove a port mapping (UPnP or NAT-PMP) given a file
Marcus Lundblad <ml@update.uu.se>
parents:
26967
diff
changeset
|
1086 int port = purple_network_get_port_from_fd(fd); |
31423
18d56b13fe8b
Cast back and forth between int and pointer instead of putting pointers
Mark Doliner <mark@kingant.net>
parents:
30983
diff
changeset
|
1087 gint protocol = GPOINTER_TO_INT(g_hash_table_lookup(upnp_port_mappings, GINT_TO_POINTER(port))); |
27190
38c4973b5222
Add a function to remove a port mapping (UPnP or NAT-PMP) given a file
Marcus Lundblad <ml@update.uu.se>
parents:
26967
diff
changeset
|
1088 |
38c4973b5222
Add a function to remove a port mapping (UPnP or NAT-PMP) given a file
Marcus Lundblad <ml@update.uu.se>
parents:
26967
diff
changeset
|
1089 if (protocol) { |
31423
18d56b13fe8b
Cast back and forth between int and pointer instead of putting pointers
Mark Doliner <mark@kingant.net>
parents:
30983
diff
changeset
|
1090 purple_network_upnp_mapping_remove(GINT_TO_POINTER(port), GINT_TO_POINTER(protocol), NULL); |
27190
38c4973b5222
Add a function to remove a port mapping (UPnP or NAT-PMP) given a file
Marcus Lundblad <ml@update.uu.se>
parents:
26967
diff
changeset
|
1091 } else { |
31423
18d56b13fe8b
Cast back and forth between int and pointer instead of putting pointers
Mark Doliner <mark@kingant.net>
parents:
30983
diff
changeset
|
1092 protocol = GPOINTER_TO_INT(g_hash_table_lookup(nat_pmp_port_mappings, GINT_TO_POINTER(port))); |
27190
38c4973b5222
Add a function to remove a port mapping (UPnP or NAT-PMP) given a file
Marcus Lundblad <ml@update.uu.se>
parents:
26967
diff
changeset
|
1093 if (protocol) { |
31423
18d56b13fe8b
Cast back and forth between int and pointer instead of putting pointers
Mark Doliner <mark@kingant.net>
parents:
30983
diff
changeset
|
1094 purple_network_nat_pmp_mapping_remove(GINT_TO_POINTER(port), GINT_TO_POINTER(protocol), NULL); |
27190
38c4973b5222
Add a function to remove a port mapping (UPnP or NAT-PMP) given a file
Marcus Lundblad <ml@update.uu.se>
parents:
26967
diff
changeset
|
1095 } |
38c4973b5222
Add a function to remove a port mapping (UPnP or NAT-PMP) given a file
Marcus Lundblad <ml@update.uu.se>
parents:
26967
diff
changeset
|
1096 } |
38c4973b5222
Add a function to remove a port mapping (UPnP or NAT-PMP) given a file
Marcus Lundblad <ml@update.uu.se>
parents:
26967
diff
changeset
|
1097 } |
27711
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
1098 |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
1099 int purple_network_convert_idn_to_ascii(const gchar *in, gchar **out) |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
1100 { |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
1101 #ifdef USE_IDN |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
1102 char *tmp; |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
1103 int ret; |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
1104 |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
1105 g_return_val_if_fail(out != NULL, -1); |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
1106 |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
1107 ret = idna_to_ascii_8z(in, &tmp, IDNA_USE_STD3_ASCII_RULES); |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
1108 if (ret != IDNA_SUCCESS) { |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
1109 *out = NULL; |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
1110 return ret; |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
1111 } |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
1112 |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
1113 *out = g_strdup(tmp); |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
1114 /* This *MUST* be freed with free, not g_free */ |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
1115 free(tmp); |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
1116 return 0; |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
1117 #else |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
1118 g_return_val_if_fail(out != NULL, -1); |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
1119 |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
1120 *out = g_strdup(in); |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
1121 return 0; |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
1122 #endif |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
1123 } |
7fbf964c6c6c
Move the IDN support into the DNS routines.
Paul Aurich <paul@darkrain42.org>
parents:
27313
diff
changeset
|
1124 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1125 void |
15823 | 1126 purple_network_init(void) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1127 { |
22867
0bd86dae2734
Use pkg-config to detect NetworkManager. Also, fail if it isn't present,
Richard Laager <rlaager@wiktel.com>
parents:
22862
diff
changeset
|
1128 #ifdef HAVE_NETWORKMANAGER |
22847
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
1129 GError *error = NULL; |
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
1130 #endif |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1131 #ifdef _WIN32 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1132 GError *err = NULL; |
15823 | 1133 gint cnt = wpurple_get_connected_network_count(); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1134 |
24856
a6742d9eadf3
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <paul@darkrain42.org>
parents:
24243
diff
changeset
|
1135 network_initialized = TRUE; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1136 if (cnt < 0) /* Assume there is a network */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1137 current_network_count = 1; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1138 /* Don't listen for network changes if we can't tell anyway */ |
25041
75f72178e361
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24856
diff
changeset
|
1139 else { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1140 current_network_count = cnt; |
25041
75f72178e361
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24856
diff
changeset
|
1141 if ((MyWSANSPIoctl = (void*) wpurple_find_and_loadproc("ws2_32.dll", "WSANSPIoctl"))) { |
75f72178e361
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24856
diff
changeset
|
1142 if (!g_thread_create(wpurple_network_change_thread, NULL, FALSE, &err)) |
75f72178e361
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24856
diff
changeset
|
1143 purple_debug_error("network", "Couldn't create Network Monitor thread: %s\n", err ? err->message : ""); |
75f72178e361
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24856
diff
changeset
|
1144 } |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1145 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1146 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1147 |
16427
4999bbc52881
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents:
15974
diff
changeset
|
1148 purple_prefs_add_none ("/purple/network"); |
26132
ae3d25465d0f
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <ml@update.uu.se>
parents:
24856
diff
changeset
|
1149 purple_prefs_add_string("/purple/network/stun_server", ""); |
26137
c56e8826fed0
Added support to generate relayed candidates (TURN).
Marcus Lundblad <ml@update.uu.se>
parents:
26132
diff
changeset
|
1150 purple_prefs_add_string("/purple/network/turn_server", ""); |
c56e8826fed0
Added support to generate relayed candidates (TURN).
Marcus Lundblad <ml@update.uu.se>
parents:
26132
diff
changeset
|
1151 purple_prefs_add_int ("/purple/network/turn_port", 3478); |
32077
8b434ffd4efc
Add support for using TCP relaying with TURN
Marcus Lundblad <ml@update.uu.se>
parents:
31932
diff
changeset
|
1152 purple_prefs_add_int ("/purple/network/turn_port_tcp", 3478); |
26137
c56e8826fed0
Added support to generate relayed candidates (TURN).
Marcus Lundblad <ml@update.uu.se>
parents:
26132
diff
changeset
|
1153 purple_prefs_add_string("/purple/network/turn_username", ""); |
c56e8826fed0
Added support to generate relayed candidates (TURN).
Marcus Lundblad <ml@update.uu.se>
parents:
26132
diff
changeset
|
1154 purple_prefs_add_string("/purple/network/turn_password", ""); |
16427
4999bbc52881
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents:
15974
diff
changeset
|
1155 purple_prefs_add_bool ("/purple/network/auto_ip", TRUE); |
4999bbc52881
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents:
15974
diff
changeset
|
1156 purple_prefs_add_string("/purple/network/public_ip", ""); |
21697
65ef019c000b
Allow UPnP and NAT-PMP port mapping to be disabled via a pref. This means that UPnP discovery will not occur if this new pref and the "Autodetect IP Address" pref are both unchecked. Fixes #4157.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21466
diff
changeset
|
1157 purple_prefs_add_bool ("/purple/network/map_ports", TRUE); |
16427
4999bbc52881
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents:
15974
diff
changeset
|
1158 purple_prefs_add_bool ("/purple/network/ports_range_use", FALSE); |
4999bbc52881
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents:
15974
diff
changeset
|
1159 purple_prefs_add_int ("/purple/network/ports_range_start", 1024); |
4999bbc52881
Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents:
15974
diff
changeset
|
1160 purple_prefs_add_int ("/purple/network/ports_range_end", 2048); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1161 |
21697
65ef019c000b
Allow UPnP and NAT-PMP port mapping to be disabled via a pref. This means that UPnP discovery will not occur if this new pref and the "Autodetect IP Address" pref are both unchecked. Fixes #4157.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21466
diff
changeset
|
1162 if(purple_prefs_get_bool("/purple/network/map_ports") || purple_prefs_get_bool("/purple/network/auto_ip")) |
65ef019c000b
Allow UPnP and NAT-PMP port mapping to be disabled via a pref. This means that UPnP discovery will not occur if this new pref and the "Autodetect IP Address" pref are both unchecked. Fixes #4157.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21466
diff
changeset
|
1163 purple_upnp_discover(NULL, NULL); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1164 |
22867
0bd86dae2734
Use pkg-config to detect NetworkManager. Also, fail if it isn't present,
Richard Laager <rlaager@wiktel.com>
parents:
22862
diff
changeset
|
1165 #ifdef HAVE_NETWORKMANAGER |
22847
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
1166 nm_conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error); |
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
1167 if (!nm_conn) { |
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
1168 purple_debug_warning("network", "Error connecting to DBus System service: %s.\n", error->message); |
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
1169 } else { |
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
1170 nm_proxy = dbus_g_proxy_new_for_name(nm_conn, |
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
1171 NM_DBUS_SERVICE, |
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
1172 NM_DBUS_PATH, |
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
1173 NM_DBUS_INTERFACE); |
22862
f5d39c44465a
Modify the NetworkManager support to use "StateChange" directly, instead of
Richard Laager <rlaager@wiktel.com>
parents:
22855
diff
changeset
|
1174 dbus_g_proxy_add_signal(nm_proxy, "StateChange", G_TYPE_UINT, G_TYPE_INVALID); |
f5d39c44465a
Modify the NetworkManager support to use "StateChange" directly, instead of
Richard Laager <rlaager@wiktel.com>
parents:
22855
diff
changeset
|
1175 dbus_g_proxy_connect_signal(nm_proxy, "StateChange", |
22847
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
1176 G_CALLBACK(nm_state_change_cb), NULL, NULL); |
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
1177 |
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
1178 dbus_proxy = dbus_g_proxy_new_for_name(nm_conn, |
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
1179 DBUS_SERVICE_DBUS, |
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
1180 DBUS_PATH_DBUS, |
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
1181 DBUS_INTERFACE_DBUS); |
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
1182 dbus_g_proxy_add_signal(dbus_proxy, "NameOwnerChanged", G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID); |
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
1183 dbus_g_proxy_connect_signal(dbus_proxy, "NameOwnerChanged", |
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
1184 G_CALLBACK(nm_dbus_name_owner_changed_cb), NULL, NULL); |
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
1185 } |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1186 #endif |
15974
1a12ce76c4f4
The network module now registers the signal 'network-configuration-changed' and emits it when a network change is detected via libnm or the win32 network monitor. The UI could also emit this signal if it knows something network.c doesn't. UPnP and NAT-PMP respond to the signal by clearing their IP address caches; changing networks without quitting/relaunching will now lead to the new IP address being (lazily) determined. This commit also enables nat-pmp and adds nat-pmp.[h|c] to the build process; please let me know if there are any problems building, as I only have OS X test machines.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15949
diff
changeset
|
1187 |
1a12ce76c4f4
The network module now registers the signal 'network-configuration-changed' and emits it when a network change is detected via libnm or the win32 network monitor. The UI could also emit this signal if it knows something network.c doesn't. UPnP and NAT-PMP respond to the signal by clearing their IP address caches; changing networks without quitting/relaunching will now lead to the new IP address being (lazily) determined. This commit also enables nat-pmp and adds nat-pmp.[h|c] to the build process; please let me know if there are any problems building, as I only have OS X test machines.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15949
diff
changeset
|
1188 purple_signal_register(purple_network_get_handle(), "network-configuration-changed", |
1a12ce76c4f4
The network module now registers the signal 'network-configuration-changed' and emits it when a network change is detected via libnm or the win32 network monitor. The UI could also emit this signal if it knows something network.c doesn't. UPnP and NAT-PMP respond to the signal by clearing their IP address caches; changing networks without quitting/relaunching will now lead to the new IP address being (lazily) determined. This commit also enables nat-pmp and adds nat-pmp.[h|c] to the build process; please let me know if there are any problems building, as I only have OS X test machines.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15949
diff
changeset
|
1189 purple_marshal_VOID, NULL, 0); |
19408
cc36a5aac908
Fix some conversion warnings about using negative values with unsigned types. There are more, but these were easy fixes. You may think that I'm changing the API, but I'm really not - it was just wrong.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18401
diff
changeset
|
1190 |
15974
1a12ce76c4f4
The network module now registers the signal 'network-configuration-changed' and emits it when a network change is detected via libnm or the win32 network monitor. The UI could also emit this signal if it knows something network.c doesn't. UPnP and NAT-PMP respond to the signal by clearing their IP address caches; changing networks without quitting/relaunching will now lead to the new IP address being (lazily) determined. This commit also enables nat-pmp and adds nat-pmp.[h|c] to the build process; please let me know if there are any problems building, as I only have OS X test machines.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15949
diff
changeset
|
1191 purple_pmp_init(); |
1a12ce76c4f4
The network module now registers the signal 'network-configuration-changed' and emits it when a network change is detected via libnm or the win32 network monitor. The UI could also emit this signal if it knows something network.c doesn't. UPnP and NAT-PMP respond to the signal by clearing their IP address caches; changing networks without quitting/relaunching will now lead to the new IP address being (lazily) determined. This commit also enables nat-pmp and adds nat-pmp.[h|c] to the build process; please let me know if there are any problems building, as I only have OS X test machines.
Evan Schoenberg <evan.s@dreskin.net>
parents:
15949
diff
changeset
|
1192 purple_upnp_init(); |
31423
18d56b13fe8b
Cast back and forth between int and pointer instead of putting pointers
Mark Doliner <mark@kingant.net>
parents:
30983
diff
changeset
|
1193 |
26132
ae3d25465d0f
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <ml@update.uu.se>
parents:
24856
diff
changeset
|
1194 purple_network_set_stun_server( |
ae3d25465d0f
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <ml@update.uu.se>
parents:
24856
diff
changeset
|
1195 purple_prefs_get_string("/purple/network/stun_server")); |
26137
c56e8826fed0
Added support to generate relayed candidates (TURN).
Marcus Lundblad <ml@update.uu.se>
parents:
26132
diff
changeset
|
1196 purple_network_set_turn_server( |
c56e8826fed0
Added support to generate relayed candidates (TURN).
Marcus Lundblad <ml@update.uu.se>
parents:
26132
diff
changeset
|
1197 purple_prefs_get_string("/purple/network/turn_server")); |
27190
38c4973b5222
Add a function to remove a port mapping (UPnP or NAT-PMP) given a file
Marcus Lundblad <ml@update.uu.se>
parents:
26967
diff
changeset
|
1198 |
31423
18d56b13fe8b
Cast back and forth between int and pointer instead of putting pointers
Mark Doliner <mark@kingant.net>
parents:
30983
diff
changeset
|
1199 upnp_port_mappings = g_hash_table_new(g_direct_hash, g_direct_equal); |
18d56b13fe8b
Cast back and forth between int and pointer instead of putting pointers
Mark Doliner <mark@kingant.net>
parents:
30983
diff
changeset
|
1200 nat_pmp_port_mappings = g_hash_table_new(g_direct_hash, g_direct_equal); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1201 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1202 |
27190
38c4973b5222
Add a function to remove a port mapping (UPnP or NAT-PMP) given a file
Marcus Lundblad <ml@update.uu.se>
parents:
26967
diff
changeset
|
1203 |
38c4973b5222
Add a function to remove a port mapping (UPnP or NAT-PMP) given a file
Marcus Lundblad <ml@update.uu.se>
parents:
26967
diff
changeset
|
1204 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1205 void |
15823 | 1206 purple_network_uninit(void) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1207 { |
22867
0bd86dae2734
Use pkg-config to detect NetworkManager. Also, fail if it isn't present,
Richard Laager <rlaager@wiktel.com>
parents:
22862
diff
changeset
|
1208 #ifdef HAVE_NETWORKMANAGER |
22847
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
1209 if (nm_proxy) { |
22862
f5d39c44465a
Modify the NetworkManager support to use "StateChange" directly, instead of
Richard Laager <rlaager@wiktel.com>
parents:
22855
diff
changeset
|
1210 dbus_g_proxy_disconnect_signal(nm_proxy, "StateChange", G_CALLBACK(nm_state_change_cb), NULL); |
22847
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
1211 g_object_unref(G_OBJECT(nm_proxy)); |
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
1212 } |
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
1213 if (dbus_proxy) { |
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
1214 dbus_g_proxy_disconnect_signal(dbus_proxy, "NameOwnerChanged", G_CALLBACK(nm_dbus_name_owner_changed_cb), NULL); |
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
1215 g_object_unref(G_OBJECT(dbus_proxy)); |
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
1216 } |
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
1217 if (nm_conn) |
790c606ff8a9
A patch from QuLogic to replace the libnm_glib calls with straight DBus
Richard Laager <rlaager@wiktel.com>
parents:
22577
diff
changeset
|
1218 dbus_g_connection_unref(nm_conn); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1219 #endif |
21067
96929e7acb86
Make purple_xfers_uninit, purple_network_uninit, and purple_plugins_uninit
Etan Reisner <pidgin@unreliablesource.net>
parents:
20347
diff
changeset
|
1220 |
24856
a6742d9eadf3
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <paul@darkrain42.org>
parents:
24243
diff
changeset
|
1221 #ifdef _WIN32 |
a6742d9eadf3
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <paul@darkrain42.org>
parents:
24243
diff
changeset
|
1222 g_static_mutex_lock(&mutex); |
a6742d9eadf3
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <paul@darkrain42.org>
parents:
24243
diff
changeset
|
1223 network_initialized = FALSE; |
a6742d9eadf3
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <paul@darkrain42.org>
parents:
24243
diff
changeset
|
1224 if (network_change_handle != NULL) { |
a6742d9eadf3
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <paul@darkrain42.org>
parents:
24243
diff
changeset
|
1225 int retval; |
a6742d9eadf3
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <paul@darkrain42.org>
parents:
24243
diff
changeset
|
1226 /* Trigger the NLA thread to stop waiting for network changes. Not |
a6742d9eadf3
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <paul@darkrain42.org>
parents:
24243
diff
changeset
|
1227 * doing this can cause hangs on WSACleanup. */ |
a6742d9eadf3
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <paul@darkrain42.org>
parents:
24243
diff
changeset
|
1228 purple_debug_warning("network", "Terminating the NLA thread\n"); |
a6742d9eadf3
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <paul@darkrain42.org>
parents:
24243
diff
changeset
|
1229 if ((retval = WSALookupServiceEnd(network_change_handle)) == SOCKET_ERROR) { |
a6742d9eadf3
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <paul@darkrain42.org>
parents:
24243
diff
changeset
|
1230 int errorid = WSAGetLastError(); |
a6742d9eadf3
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <paul@darkrain42.org>
parents:
24243
diff
changeset
|
1231 gchar *msg = g_win32_error_message(errorid); |
a6742d9eadf3
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <paul@darkrain42.org>
parents:
24243
diff
changeset
|
1232 purple_debug_warning("network", "Unable to kill NLA thread. Message: %s (%d).\n", |
a6742d9eadf3
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <paul@darkrain42.org>
parents:
24243
diff
changeset
|
1233 msg, errorid); |
a6742d9eadf3
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <paul@darkrain42.org>
parents:
24243
diff
changeset
|
1234 g_free(msg); |
a6742d9eadf3
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <paul@darkrain42.org>
parents:
24243
diff
changeset
|
1235 } |
25041
75f72178e361
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24856
diff
changeset
|
1236 network_change_handle = NULL; |
75f72178e361
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24856
diff
changeset
|
1237 |
24856
a6742d9eadf3
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <paul@darkrain42.org>
parents:
24243
diff
changeset
|
1238 } |
a6742d9eadf3
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <paul@darkrain42.org>
parents:
24243
diff
changeset
|
1239 g_static_mutex_unlock(&mutex); |
a6742d9eadf3
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <paul@darkrain42.org>
parents:
24243
diff
changeset
|
1240 |
a6742d9eadf3
Adjust the NLA code to prevent hang on exit for Windows XP and Windows Vista.
Paul Aurich <paul@darkrain42.org>
parents:
24243
diff
changeset
|
1241 #endif |
21067
96929e7acb86
Make purple_xfers_uninit, purple_network_uninit, and purple_plugins_uninit
Etan Reisner <pidgin@unreliablesource.net>
parents:
20347
diff
changeset
|
1242 purple_signal_unregister(purple_network_get_handle(), |
25041
75f72178e361
Fix 3 different race conditions in the win32 network management functionality.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24856
diff
changeset
|
1243 "network-configuration-changed"); |
31423
18d56b13fe8b
Cast back and forth between int and pointer instead of putting pointers
Mark Doliner <mark@kingant.net>
parents:
30983
diff
changeset
|
1244 |
26132
ae3d25465d0f
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <ml@update.uu.se>
parents:
24856
diff
changeset
|
1245 if (stun_ip) |
ae3d25465d0f
Run an asynchronous DNS lookup for the STUN server IP (to set as a property
Marcus Lundblad <ml@update.uu.se>
parents:
24856
diff
changeset
|
1246 g_free(stun_ip); |
27190
38c4973b5222
Add a function to remove a port mapping (UPnP or NAT-PMP) given a file
Marcus Lundblad <ml@update.uu.se>
parents:
26967
diff
changeset
|
1247 |
38c4973b5222
Add a function to remove a port mapping (UPnP or NAT-PMP) given a file
Marcus Lundblad <ml@update.uu.se>
parents:
26967
diff
changeset
|
1248 g_hash_table_destroy(upnp_port_mappings); |
38c4973b5222
Add a function to remove a port mapping (UPnP or NAT-PMP) given a file
Marcus Lundblad <ml@update.uu.se>
parents:
26967
diff
changeset
|
1249 g_hash_table_destroy(nat_pmp_port_mappings); |
38c4973b5222
Add a function to remove a port mapping (UPnP or NAT-PMP) given a file
Marcus Lundblad <ml@update.uu.se>
parents:
26967
diff
changeset
|
1250 |
31423
18d56b13fe8b
Cast back and forth between int and pointer instead of putting pointers
Mark Doliner <mark@kingant.net>
parents:
30983
diff
changeset
|
1251 /* TODO: clean up remaining port mappings, note calling |
27190
38c4973b5222
Add a function to remove a port mapping (UPnP or NAT-PMP) given a file
Marcus Lundblad <ml@update.uu.se>
parents:
26967
diff
changeset
|
1252 purple_upnp_remove_port_mapping from here doesn't quite work... */ |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1253 } |