aboutsummaryrefslogtreecommitdiff
path: root/cursor.c
diff options
context:
space:
mode:
authorLaurent Vivier <laurent@vivier.eu>2011-03-30 00:12:12 +0200
committerRiku Voipio <riku.voipio@iki.fi>2011-04-26 10:15:40 +0300
commit059c2f2cd773e0f3d7284a6eab662fd26f9cbad2 (patch)
tree2b47afbe0de749868b8f7aecba53fc7d2be17a3e /cursor.c
parent608e55921770bbae1609135aa0c351238f57fc5f (diff)
downloadqemu-059c2f2cd773e0f3d7284a6eab662fd26f9cbad2.zip
qemu-059c2f2cd773e0f3d7284a6eab662fd26f9cbad2.tar.gz
qemu-059c2f2cd773e0f3d7284a6eab662fd26f9cbad2.tar.bz2
linux-user: convert ioctl(SIOCGIFCONF, ...) result.
The result needs to be converted as it is stored in an array of struct ifreq and sizeof(struct ifreq) differs according to target and host alignment rules. This patch allows to execute correctly the following program on arm and m68k: #include <stdio.h> #include <sys/ioctl.h> #include <net/if.h> #include <alloca.h> #include <string.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> int main(void) { int s, ret; struct ifconf ifc; int i; memset( &ifc, 0, sizeof( struct ifconf ) ); ifc.ifc_len = 8 * sizeof(struct ifreq); ifc.ifc_buf = alloca(ifc.ifc_len); s = socket( AF_INET, SOCK_DGRAM, 0 ); if (s < 0) { perror("Cannot open socket"); return 1; } ret = ioctl( s, SIOCGIFCONF, &ifc ); if (s < 0) { perror("ioctl() failed"); return 1; } for (i = 0; i < ifc.ifc_len / sizeof(struct ifreq) ; i ++) { struct sockaddr_in *s; s = (struct sockaddr_in*)&ifc.ifc_req[i].ifr_addr; printf("%s\n", ifc.ifc_req[i].ifr_name); printf("%s\n", inet_ntoa(s->sin_addr)); } } Signed-off-by: Laurent Vivier <laurent@vivier.eu> Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
Diffstat (limited to 'cursor.c')
0 files changed, 0 insertions, 0 deletions