Hi!

The following patch adds the names of all PACKET_* options that exist in
Linux kernel v2.6.31. The patch also adds decoding of arguments for
getsockopt(PACKET_STATISTICS) and setsockopt(PACKET_{RX,TX}_RING).

Gabor

diff --git a/net.c b/net.c
index 974e2bb..fc1dcdd 100644
--- a/net.c
+++ b/net.c
@@ -833,6 +833,30 @@ static const struct xlat sockpacketoptions[] = {
 #if defined(PACKET_STATISTICS)
        { PACKET_STATISTICS,            "PACKET_STATISTICS"     },
 #endif
+#if defined(PACKET_COPY_THRESH)
+       { PACKET_COPY_THRESH,           "PACKET_COPY_THRESH"    },
+#endif
+#if defined(PACKET_AUXDATA)
+       { PACKET_AUXDATA,               "PACKET_AUXDATA"        },
+#endif
+#if defined(PACKET_ORIGDEV)
+       { PACKET_ORIGDEV,               "PACKET_ORIGDEV"        },
+#endif
+#if defined(PACKET_VERSION)
+       { PACKET_VERSION,               "PACKET_VERSION"        },
+#endif
+#if defined(PACKET_HDRLEN)
+       { PACKET_HDRLEN,                "PACKET_HDRLEN" },
+#endif
+#if defined(PACKET_RESERVE)
+       { PACKET_RESERVE,               "PACKET_RESERVE"        },
+#endif
+#if defined(PACKET_TX_RING)
+       { PACKET_TX_RING,               "PACKET_TX_RING"        },
+#endif
+#if defined(PACKET_LOSS)
+       { PACKET_LOSS,                  "PACKET_LOSS"   },
+#endif
        { 0,                            NULL                    },
 };
 #endif /* SOL_PACKET */
@@ -1678,6 +1702,27 @@ struct tcb *tcp;
 #endif
                        }
                        break;
+               case SOL_PACKET:
+                       switch (tcp->u_arg[2]) {
+#ifdef PACKET_STATISTICS
+                       case PACKET_STATISTICS:
+                               if (len == sizeof(struct tpacket_stats)) {
+                                       struct tpacket_stats stats;
+                                       if (umove (tcp,
+                                                  tcp->u_arg[3],
+                                                  &stats) < 0)
+                                               break;
+                                       tprintf(", {packets=%u, drops=%u}, "
+                                               "[%d]",
+                                               stats.tp_packets,
+                                               stats.tp_drops,
+                                               len);
+                                       return 0;
+                               }
+                               break;
+#endif
+                       }
+                       break;
                }
 
                tprintf (", ");
@@ -1766,6 +1811,26 @@ int len;
            case SOL_PACKET:
                printxval(sockpacketoptions, name, "PACKET_???");
                /* TODO: decode packate_mreq for PACKET_*_MEMBERSHIP */
+               switch (name) {
+#ifdef PACKET_RX_RING
+                   case PACKET_RX_RING:
+#ifdef PACKET_TX_RING
+                   case PACKET_TX_RING:
+#endif
+                       if (len == sizeof(struct tpacket_req)) {
+                               struct tpacket_req req;
+                               if (umove(tcp, addr, &req) < 0)
+                                       break;
+                               tprintf(", {block_size=%u, block_nr=%u, 
frame_size=%u, frame_nr=%u}",
+                                       req.tp_block_size,
+                                       req.tp_block_nr,
+                                       req.tp_frame_size,
+                                       req.tp_frame_nr);
+                               return 0;
+                       }
+                       break;
+#endif
+               }
                break;
 #endif
 #ifdef SOL_TCP
-- 
1.6.5

-- 
     ---------------------------------------------------------
     MTA SZTAKI Computer and Automation Research Institute
                Hungarian Academy of Sciences
     ---------------------------------------------------------

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel

Reply via email to