comparison libpurple/network.c @ 29128:739886e6dac2

propagate from branch 'im.pidgin.pidgin' (head 667654b3309008b53bf4d9df02bd401d1ede8db5) to branch 'im.pidgin.pidgin.next.minor' (head e37d7dfead3e1864f8de0c0397a8f6471af07e29)
author John Bailey <rekkanoryo@rekkanoryo.org>
date Mon, 12 Oct 2009 22:40:37 +0000
parents df24cbb0d6e2
children ecd1aa92fd57
comparison
equal deleted inserted replaced
28378:f55bd60e2738 29128:739886e6dac2
196 } 196 }
197 } 197 }
198 } 198 }
199 199
200 return "0.0.0.0"; 200 return "0.0.0.0";
201 }
202
203 GList *
204 purple_network_get_all_local_system_ips(void)
205 {
206 GList *result = NULL;
207 int source = source = socket(PF_INET,SOCK_STREAM, 0);
208 char buffer[1024];
209 char *tmp;
210 struct ifconf ifc;
211 struct ifreq *ifr;
212
213 ifc.ifc_len = sizeof(buffer);
214 ifc.ifc_req = (struct ifreq *)buffer;
215 ioctl(source, SIOCGIFCONF, &ifc);
216 close(source);
217
218 tmp = buffer;
219 while (tmp < buffer + ifc.ifc_len) {
220 char dst[INET_ADDRSTRLEN];
221
222 ifr = (struct ifreq *)tmp;
223 tmp += HX_SIZE_OF_IFREQ(*ifr);
224
225 /* TODO: handle IPv6 */
226 if (ifr->ifr_addr.sa_family == AF_INET) {
227 struct sockaddr_in *sinptr = (struct sockaddr_in *)&ifr->ifr_addr;
228
229 inet_ntop(AF_INET, &sinptr->sin_addr, dst,
230 sizeof(dst));
231 purple_debug_info("network",
232 "found local i/f with address %s on IPv4\n", dst);
233 if (!purple_strequal(dst, "127.0.0.1")) {
234 result = g_list_append(result, g_strdup(dst));
235 }
236 }
237 }
238
239 return result;
201 } 240 }
202 241
203 const char * 242 const char *
204 purple_network_get_my_ip(int fd) 243 purple_network_get_my_ip(int fd)
205 { 244 {