Hello,

I am working on a network game. To connect to the server, I have to find out
the IP Adress of the 770's WLAN Interface. When I compile the code direct in
the SDK (2.1), it compiles without problems. When I use the the
automake/conf'd version, it breaks during compiling with the error:

bomberman.c:74: error: storage size of 'ifa' isn't known

I think it is because of the defines created by automake/conf. But I have no
idea what breaks.
I did a "hack", compiled it without the ifa struct and created a beta package. 
Anyone who is interessted may look under www.rotters.de, it's 
called "bomberman". I am interessted if someone could test it with multiple 
N770 in a real network game!

Thanks for any help,

-Klaus

-------------------------- 8< ---------------------------
[sbox-SDK_ARMEL: ~/bomberman-deb] > make
if gcc -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\"
-DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE=\"bomberman-
app\"
-DVERSION=\"0.93\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -
DHAVE_SYS_STAT_H=1
-DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -
DHAVE_STRINGS_H=1
-DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -
DHAVE_DLFCN_H=1
-I. -I/home/klaus/bomberman-deb    -D_XOPEN_SOURCE=500 -DXTHREADS
-DXUSE_MTSAFE_API -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include
-I/usr/X11R6/include -I/usr/include/atk-1.0 -I/usr/include/pango-1.0
-I/usr/include/freetype2 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include
-I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include -I/usr/include/glib-2.0
-I/usr/lib/glib-2.0/include   -g -O2 -MT bomberman-bomberman.o -MD -MP -MF
".deps/bomberman-bomberman.Tpo" \
  -c -o bomberman-bomberman.o est -f 'bomberman.c' || echo
'/home/klaus/bomberman-deb/'omberman.c; \
then mv -f ".deps/bomberman-bomberman.Tpo" ".deps/bomberman-bomberman.Po"; \
else rm -f ".deps/bomberman-bomberman.Tpo"; exit 1; \
fi
bomberman.c: In function get_ip_addr':
bomberman.c:74: error: storage size of 'ifa' isn't known
make: *** [bomberman-bomberman.o] Error 1
[sbox-SDK_ARMEL: ~/bomberman-deb] >

Parts of the source code:

...
21 #include <string.h>
22 #include <stdlib.h>
23 #include <stdio.h>
24 
25 // To get IP Adress
26 
27 #include <sys/socket.h>
28 #include <sys/types.h>
29 #include <sys/ioctl.h>
30 #include <netinet/in.h>
31 #include <net/if.h>
32 #include <arpa/inet.h>
...
72 char *get_ip_addr(void)
73 {
74     struct ifreq ifa;
75     struct sockaddr_in *i;
76     int fd;
77 
78     strcpy (retstr, "error: not available");
79
80     strcpy (ifa.ifr_name, "eth1"); // For Nokia 770, use wlan0
81 
82     if((fd = socket(AF_INET, SOCK_DGRAM, 0)) == -1)
83       return(retstr); // Error: return "error: not available"
84
85     if(ioctl(fd, SIOCGIFADDR, &ifa))
86       return(retstr); // Error: return "error: not available"
87 
88     i = (struct sockaddr_in*) &ifa.ifr_addr;
89     strcpy(retstr,inet_ntoa(i->sin_addr));
90     close (fd);
91 
92     return (retstr);
93 }
-------------------------- 8< ---------------------------

-- 
 Klaus Rotter * klaus <at> rotters <dot> de * www.rotters.de
_______________________________________________
maemo-developers mailing list
maemo-developers@maemo.org
https://maemo.org/mailman/listinfo/maemo-developers

Reply via email to