#include "defs.h"
#include <sys/socket.h>
+#if defined ALPHA || defined SH || defined SH64
+# include <linux/ioctl.h>
+#endif
#include <linux/sockios.h>
#include <arpa/inet.h>
-#if defined(ALPHA) || defined(SH) || defined(SH64)
-# if defined(HAVE_SYS_IOCTL_H)
-# include <sys/ioctl.h>
-# elif defined(HAVE_IOCTLS_H)
-# include <ioctls.h>
-# endif
-#endif
#include <net/if.h>
#include "xlat/iffflags.h"
-static void
-print_ifreq_addr(struct tcb *tcp, const struct ifreq *ifr, const long addr)
-{
- tprintf("{");
- printxval(addrfams, ifr->ifr_addr.sa_family, "AF_???");
- tprints(", ");
- if (ifr->ifr_addr.sa_family == AF_INET) {
- const struct sockaddr_in *sinp =
- (struct sockaddr_in *) &ifr->ifr_addr;
- tprintf("inet_addr(\"%s\")", inet_ntoa(sinp->sin_addr));
- } else
- printstr(tcp, addr + offsetof(struct ifreq, ifr_addr.sa_data),
- sizeof(ifr->ifr_addr.sa_data));
- tprints("}");
-}
+#define PRINT_IFREQ_ADDR(tcp, ifr, sockaddr) \
+ do { \
+ tprints(#sockaddr "="); \
+ print_sockaddr(tcp, &((ifr)->sockaddr), \
+ sizeof((ifr)->sockaddr)); \
+ } while (0)
static void
print_ifname(const char *ifname)
}
static void
-print_ifreq(struct tcb *tcp, const unsigned int code, const long arg,
- const struct ifreq *ifr)
+print_ifreq(struct tcb *const tcp, const unsigned int code,
+ const kernel_ulong_t arg, const struct ifreq *const ifr)
{
switch (code) {
case SIOCSIFADDR:
case SIOCGIFADDR:
- tprints("ifr_addr=");
- print_ifreq_addr(tcp, ifr, arg);
+ PRINT_IFREQ_ADDR(tcp, ifr, ifr_addr);
break;
case SIOCSIFDSTADDR:
case SIOCGIFDSTADDR:
- tprints("ifr_dstaddr=");
- print_ifreq_addr(tcp, ifr, arg);
+ PRINT_IFREQ_ADDR(tcp, ifr, ifr_dstaddr);
break;
case SIOCSIFBRDADDR:
case SIOCGIFBRDADDR:
- tprints("ifr_broadaddr=");
- print_ifreq_addr(tcp, ifr, arg);
+ PRINT_IFREQ_ADDR(tcp, ifr, ifr_broadaddr);
break;
case SIOCSIFNETMASK:
case SIOCGIFNETMASK:
- tprints("ifr_netmask=");
- print_ifreq_addr(tcp, ifr, arg);
+ PRINT_IFREQ_ADDR(tcp, ifr, ifr_netmask);
break;
case SIOCSIFHWADDR:
case SIOCGIFHWADDR: {
case SIOCSIFFLAGS:
case SIOCGIFFLAGS:
tprints("ifr_flags=");
- printflags(iffflags, ifr->ifr_flags, "IFF_???");
+ printflags(iffflags, (unsigned short) ifr->ifr_flags, "IFF_???");
break;
case SIOCSIFMETRIC:
case SIOCGIFMETRIC:
}
static int
-decode_ifconf(struct tcb *tcp, const long addr)
+decode_ifconf(struct tcb *const tcp, const kernel_ulong_t addr)
{
struct ifconf ifc;
struct ifreq ifra[nifra > max_strlen ? max_strlen : nifra];
tprints(", ");
- if (umove_or_printaddr(tcp, (unsigned long) ifc.ifc_buf, &ifra)) {
+ if (umove_or_printaddr(tcp, ptr_to_kulong(ifc.ifc_buf), &ifra)) {
tprints("}");
return RVAL_DECODED | 1;
}
tprints("{ifr_name=");
print_ifname(ifra[i].ifr_name);
tprints(", ");
- if (verbose(tcp)) {
- tprints("ifr_addr=");
- print_ifreq_addr(tcp, &ifra[i],
- addr + i * sizeof(ifra[0]));
- } else
- tprints("...");
+ PRINT_IFREQ_ADDR(tcp, &ifra[i], ifr_addr);
tprints("}");
}
if (i < nifra)
}
int
-sock_ioctl(struct tcb *tcp, const unsigned int code, const long arg)
+sock_ioctl(struct tcb *const tcp, const unsigned int code, const kernel_ulong_t arg)
{
struct ifreq ifr;
case SIOCBRADDBR:
case SIOCBRDELBR:
tprints(", ");
- printstr(tcp, arg, -1);
+ printstr(tcp, arg);
break;
#endif
return RVAL_DECODED | 1;
}
-
-SYS_FUNC(socketcall)
-{
- return printargs(tcp);
-}