summaryrefslogtreecommitdiff
path: root/plugins/dfnet/gui.c
diff options
context:
space:
mode:
authorSND\weimingzhi_cp <SND\weimingzhi_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97>2010-05-13 06:59:35 +0000
committerSND\weimingzhi_cp <SND\weimingzhi_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97>2010-05-13 06:59:35 +0000
commitd923b4329d7e2a8e48c57f503514bfeeca7c6b87 (patch)
tree28939b4ad90ada279567edf42794b0ba139528fa /plugins/dfnet/gui.c
parentdd5ee8b8101f704777a05805f1d88c0d40e60cf7 (diff)
downloadpcsxr-d923b4329d7e2a8e48c57f503514bfeeca7c6b87.tar.gz
git-svn-id: https://pcsxr.svn.codeplex.com/svn/pcsxr@47952 e17a0e51-4ae3-4d35-97c3-1a29b211df97
Diffstat (limited to 'plugins/dfnet/gui.c')
-rw-r--r--plugins/dfnet/gui.c45
1 files changed, 41 insertions, 4 deletions
diff --git a/plugins/dfnet/gui.c b/plugins/dfnet/gui.c
index 1f2dc69c..6425c9e5 100644
--- a/plugins/dfnet/gui.c
+++ b/plugins/dfnet/gui.c
@@ -38,17 +38,54 @@ void CFGconfigure() {
cfgSysMessage(_("Nothing to configure"));
}
+#ifdef __linux__
+
+#include <sys/ioctl.h>
+#include <linux/if.h>
+
+#define MAXINTERFACES 16
+
+void sockGetIP(char *IPAddress) {
+ int fd, intrface;
+ struct ifreq buf[MAXINTERFACES];
+ struct ifconf ifc;
+ struct sockaddr_in addr;
+
+ strcpy(IPAddress, "127.0.0.1");
+
+ if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) >= 0) {
+ ifc.ifc_len = sizeof(buf);
+ ifc.ifc_buf = (caddr_t)buf;
+ if (!ioctl (fd, SIOCGIFCONF, (char *)&ifc)) {
+ intrface = ifc.ifc_len / sizeof(struct ifreq);
+ while (intrface-- > 0) {
+ if (!(ioctl(fd, SIOCGIFADDR, (char *)&buf[intrface]))) {
+ memcpy(&addr, &(buf[intrface].ifr_addr), sizeof(addr));
+ strcpy(IPAddress, inet_ntoa(addr.sin_addr));
+ break;
+ }
+ }
+ }
+ close(fd);
+ }
+}
+
+#else
+
void sockGetIP(char *IPAddress) {
- char str[256];
struct hostent *host;
- unsigned char *addr;
+ char str[256];
gethostname(str, 256);
host = gethostbyname(str);
- addr = (unsigned char *)host->h_addr_list[0];
- sprintf(IPAddress, "%d.%d.%d.%d", addr[0], addr[1], addr[2], addr[3]);
+
+ if (host != NULL)
+ strcpy(IPAddress, inet_ntoa(*((struct in_addr *)host->h_addr_list[0])));
+ else strcpy(IPAddress, "127.0.0.1");
}
+#endif
+
void OnCopyIP(GtkWidget *widget, gpointer user_data) {
char str[256];