]> git.proxmox.com Git - mirror_qemu.git/commitdiff
linux-user: handle AF_PACKET sockaddrs in target_to_host_sockaddr
authorJoakim Tjernlund <joakim.tjernlund@transmode.se>
Sat, 12 Jul 2014 13:47:07 +0000 (15:47 +0200)
committerRiku Voipio <riku.voipio@linaro.org>
Tue, 15 Jul 2014 13:28:25 +0000 (16:28 +0300)
Implement conversion of the AF_PACKET sockaddr subtype
in target_to_host_sockaddr.

Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund@transmode.se>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
linux-user/syscall.c
linux-user/syscall_defs.h

index dcf13238e59148dfd753818ab833c02ad7e8dc25..7163ade3f3bd50077eecea4b3216427338ece520 100644 (file)
@@ -1140,6 +1140,13 @@ static inline abi_long target_to_host_sockaddr(struct sockaddr *addr,
 
     memcpy(addr, target_saddr, len);
     addr->sa_family = sa_family;
+    if (sa_family == AF_PACKET) {
+       struct target_sockaddr_ll *lladdr;
+
+       lladdr = (struct target_sockaddr_ll *)addr;
+       lladdr->sll_ifindex = tswap32(lladdr->sll_ifindex);
+       lladdr->sll_hatype = tswap16(lladdr->sll_hatype);
+    }
     unlock_user(target_saddr, target_addr, 0);
 
     return 0;
index 856302780ff59837c33bb6f33ee99e8ffdf86417..c9e6323905486452f518102bf40ba73143c9d601 100644 (file)
@@ -121,6 +121,16 @@ struct target_sockaddr {
     uint8_t sa_data[14];
 };
 
+struct target_sockaddr_ll {
+    uint16_t sll_family;   /* Always AF_PACKET */
+    uint16_t sll_protocol; /* Physical layer protocol */
+    int      sll_ifindex;  /* Interface number */
+    uint16_t sll_hatype;   /* ARP hardware type */
+    uint8_t  sll_pkttype;  /* Packet type */
+    uint8_t  sll_halen;    /* Length of address */
+    uint8_t  sll_addr[8];  /* Physical layer address */
+};
+
 struct target_sock_filter {
     abi_ushort code;
     uint8_t jt;