On Fri, 2006-11-17 at 14:26 -0800, Mike Mason wrote:
Attached is a sockets tapset and a script that uses the tapset.
Very nice!
It seems like tokenize() and str2long() (perhaps renamed simply strtol)
would be good candidates to put in the string tapset so others could use
them.
Since yesterday, we can now access parameters in return probes (BZ
1382). This could simplify some of your script because yo no longer need
to cache parameters on entry probes and then lookup their values in the
return probe.
In print_activity, you can simply do this:
foreach ([pid, prot, fam] in sk_pid- limit max) { ... }
Then you don't need "if (!--max) break"
This is a bit cleaer and generates faster code.
Mapping functions are something I think script writers need, not just for sockets,
but in a lot of other areas. Some of these functions using mapping arrays.
What do people think of this approach?
It is simple and elegant. However, in time-critical code (which your
example is probably not) it may be better to write them in C. A
complicated example would be what I did in errno.stp. Of course that
example doesn't include the reverse map.