Mercurial > pidgin.yaz
comparison libpurple/network.c @ 29502:0aac63e8489f
propagate from branch 'im.pidgin.pidgin' (head 84b4f3d9c0a8e1306eb70e9db0003177e2782269)
to branch 'im.pidgin.pidgin.next.minor' (head ff2751f3bf0343a572e3ab437dd01ff6efbaf336)
author | John Bailey <rekkanoryo@rekkanoryo.org> |
---|---|
date | Wed, 16 Sep 2009 16:25:59 +0000 |
parents | df24cbb0d6e2 |
children | ecd1aa92fd57 |
comparison
equal
deleted
inserted
replaced
28635:0e4b43fc68c0 | 29502:0aac63e8489f |
---|---|
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 { |