]> granicus.if.org Git - strace/blobdiff - sock.c
tests: add a test for -yy option
[strace] / sock.c
diff --git a/sock.c b/sock.c
index bbbdd5b9908352e3eb1df3fb5ba08b8d8a08fa3e..dca9bfd4713a45857c1391e011bc90d1bdfefaf4 100644 (file)
--- a/sock.c
+++ b/sock.c
  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- *     $Id$
  */
 
 #include "defs.h"
-
-#ifdef LINUX
 #include <sys/socket.h>
 #include <linux/sockios.h>
-#else
-#include <sys/socket.h>
-#include <sys/sockio.h>
-#endif
 #include <arpa/inet.h>
-
-#if defined (ALPHA) || defined(SH) || defined(SH64)
-#ifdef HAVE_SYS_IOCTL_H
-#include <sys/ioctl.h>
-#elif defined(HAVE_IOCTLS_H)
-#include <ioctls.h>
-#endif
+#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>
 
-static const struct xlat iffflags[] = {
-       { IFF_UP,               "IFF_UP"                },
-       { IFF_BROADCAST,        "IFF_BROADCAST"         },
-       { IFF_DEBUG,            "IFF_DEBUG"             },
-       { IFF_LOOPBACK,         "IFF_LOOPBACK"          },
-       { IFF_POINTOPOINT,      "IFF_POINTOPOINT"       },
-       { IFF_NOTRAILERS,       "IFF_NOTRAILERS"        },
-       { IFF_RUNNING,          "IFF_RUNNING"           },
-       { IFF_NOARP,            "IFF_NOARP"             },
-       { IFF_PROMISC,          "IFF_PROMISC"           },
-       { IFF_ALLMULTI,         "IFF_ALLMULTI"          },
-       { IFF_MASTER,           "IFF_MASTER"            },
-       { IFF_SLAVE,            "IFF_SLAVE"             },
-       { IFF_MULTICAST,        "IFF_MULTICAST"         },
-       { IFF_PORTSEL,          "IFF_PORTSEL"           },
-       { IFF_AUTOMEDIA,        "IFF_AUTOMEDIA"         },
-       { 0,                    NULL                    }
-};
-
+#include "xlat/iffflags.h"
 
 static void
 print_addr(struct tcb *tcp, long addr, struct ifreq *ifr)
@@ -92,7 +65,7 @@ sock_ioctl(struct tcb *tcp, long code, long arg)
                            && ifc.ifc_buf == NULL)
                                tprintf(", {%d -> ", ifc.ifc_len);
                        else
-                               tprintf(", {");
+                               tprints(", {");
                }
                return 0;
        }
@@ -127,7 +100,6 @@ sock_ioctl(struct tcb *tcp, long code, long arg)
 #endif
                printnum(tcp, arg, ", %#d");
                return 1;
-#ifdef LINUX
        case SIOCGIFNAME:
        case SIOCSIFNAME:
        case SIOCGIFINDEX:
@@ -188,12 +160,12 @@ sock_ioctl(struct tcb *tcp, long code, long arg)
                                printxval(addrfams,
                                          ifr.ifr_addr.sa_family,
                                          "AF_???");
-                               tprintf(", ");
+                               tprints(", ");
                                print_addr(tcp, ((long) tcp->u_arg[2]
                                                 + offsetof(struct ifreq,
                                                             ifr_addr.sa_data)),
                                           &ifr);
-                               tprintf("}");
+                               tprints("}");
                                break;
                        case SIOCGIFHWADDR:
                        case SIOCSIFHWADDR:
@@ -206,7 +178,7 @@ sock_ioctl(struct tcb *tcp, long code, long arg)
                                break;
                        case SIOCGIFFLAGS:
                        case SIOCSIFFLAGS:
-                               tprintf("ifr_flags=");
+                               tprints("ifr_flags=");
                                printflags(iffflags, ifr.ifr_flags, "IFF_???");
                                break;
                        case SIOCGIFMETRIC:
@@ -238,22 +210,22 @@ sock_ioctl(struct tcb *tcp, long code, long arg)
                                        (unsigned) ifr.ifr_map.port);
                                break;
                        }
-                       tprintf("}");
+                       tprints("}");
                }
                return 1;
        case SIOCGIFCONF:
                if (umove(tcp, tcp->u_arg[2], &ifc) < 0) {
-                       tprintf("???}");
+                       tprints("???}");
                        return 1;
                }
                tprintf("%d, ", ifc.ifc_len);
                if (syserror(tcp)) {
                        tprintf("%lx", (unsigned long) ifc.ifc_buf);
                } else if (ifc.ifc_buf == NULL) {
-                       tprintf("NULL");
+                       tprints("NULL");
                } else {
-                       int i;
-                       unsigned nifra = ifc.ifc_len / sizeof(struct ifreq);
+                       unsigned int i;
+                       unsigned int nifra = ifc.ifc_len / sizeof(struct ifreq);
                        struct ifreq ifra[nifra];
 
                        if (umoven(tcp, (unsigned long) ifc.ifc_buf,
@@ -261,17 +233,17 @@ sock_ioctl(struct tcb *tcp, long code, long arg)
                                tprintf("%lx}", (unsigned long) ifc.ifc_buf);
                                return 1;
                        }
-                       tprintf("{");
+                       tprints("{");
                        for (i = 0; i < nifra; ++i ) {
                                if (i > 0)
-                                       tprintf(", ");
+                                       tprints(", ");
                                tprintf("{\"%s\", {",
                                        ifra[i].ifr_name);
                                if (verbose(tcp)) {
                                        printxval(addrfams,
                                                  ifra[i].ifr_addr.sa_family,
                                                  "AF_???");
-                                       tprintf(", ");
+                                       tprints(", ");
                                        print_addr(tcp, ((long) tcp->u_arg[2]
                                                         + offsetof(struct ifreq,
                                                                     ifr_addr.sa_data)
@@ -279,15 +251,20 @@ sock_ioctl(struct tcb *tcp, long code, long arg)
                                                            - (char *) &ifra[0])),
                                                   &ifra[i]);
                                } else
-                                       tprintf("...");
-                               tprintf("}}");
+                                       tprints("...");
+                               tprints("}}");
                        }
-                       tprintf("}");
+                       tprints("}");
                }
-               tprintf("}");
+               tprints("}");
                return 1;
-#endif
        default:
                return 0;
        }
 }
+
+int
+sys_socketcall(struct tcb *tcp)
+{
+       return printargs(tcp);
+}