Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/bin/systrace translation for socket system call
details: https://anonhg.NetBSD.org/src/rev/04d719e1f96c
branches: trunk
changeset: 538086:04d719e1f96c
user: provos <provos%NetBSD.org@localhost>
date: Fri Oct 11 04:40:11 2002 +0000
description:
translation for socket system call
diffstat:
bin/systrace/register.c | 10 ++++-
bin/systrace/systrace-translate.c | 85 ++++++++++++++++++++++++++++++++++++++-
bin/systrace/systrace.h | 4 +-
3 files changed, 96 insertions(+), 3 deletions(-)
diffs (159 lines):
diff -r c7081a498cac -r 04d719e1f96c bin/systrace/register.c
--- a/bin/systrace/register.c Fri Oct 11 04:11:28 2002 +0000
+++ b/bin/systrace/register.c Fri Oct 11 04:40:11 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: register.c,v 1.3 2002/08/28 03:52:46 itojun Exp $ */
+/* $NetBSD: register.c,v 1.4 2002/10/11 04:40:11 provos Exp $ */
/* $OpenBSD: register.c,v 1.11 2002/08/05 14:49:27 provos Exp $ */
/*
* Copyright 2002 Niels Provos <provos%citi.umich.edu@localhost>
@@ -157,6 +157,10 @@
intercept_register_translation("netbsd", "setgid", 0, &gidt);
X(intercept_register_sccb("netbsd", "setegid", trans_cb, NULL));
intercept_register_translation("netbsd", "setegid", 0, &gidt);
+
+ X(intercept_register_sccb("netbsd", "socket", trans_cb, NULL));
+ intercept_register_translation("netbsd", "socket", 0, &sockdom);
+ intercept_register_translation("netbsd", "socket", 1, &socktype);
#else
X(intercept_register_gencb(gen_cb, NULL));
X(intercept_register_sccb("native", "open", trans_cb, NULL));
@@ -252,6 +256,10 @@
intercept_register_translation("native", "setgid", 0, &gidt);
X(intercept_register_sccb("native", "setegid", trans_cb, NULL));
intercept_register_translation("native", "setegid", 0, &gidt);
+
+ X(intercept_register_sccb("native", "socket", trans_cb, NULL));
+ intercept_register_translation("native", "socket", 0, &sockdom);
+ intercept_register_translation("native", "socket", 1, &socktype);
#endif
#if !(defined(__NetBSD__) && !defined(HAVE_LINUX_FCNTL_H))
diff -r c7081a498cac -r 04d719e1f96c bin/systrace/systrace-translate.c
--- a/bin/systrace/systrace-translate.c Fri Oct 11 04:11:28 2002 +0000
+++ b/bin/systrace/systrace-translate.c Fri Oct 11 04:40:11 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: systrace-translate.c,v 1.7 2002/09/28 17:56:54 provos Exp $ */
+/* $NetBSD: systrace-translate.c,v 1.8 2002/10/11 04:40:11 provos Exp $ */
/* $OpenBSD: systrace-translate.c,v 1.10 2002/08/01 20:50:17 provos Exp $ */
/*
* Copyright 2002 Niels Provos <provos%citi.umich.edu@localhost>
@@ -33,6 +33,7 @@
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/tree.h>
+#include <sys/socket.h>
#include <inttypes.h>
#include <limits.h>
#include <stdlib.h>
@@ -190,6 +191,78 @@
}
static int
+print_sockdom(char *buf, size_t buflen, struct intercept_translate *tl)
+{
+ int domain = (intptr_t)tl->trans_addr;
+ char *what = NULL;
+
+ switch (domain) {
+ case AF_UNIX:
+ what = "AF_UNIX";
+ break;
+ case AF_INET:
+ what = "AF_INET";
+ break;
+ case AF_INET6:
+ what = "AF_INET6";
+ break;
+ case AF_ISO:
+ what = "AF_ISO";
+ break;
+ case AF_NS:
+ what = "AF_NS";
+ break;
+ case AF_IPX:
+ what = "AF_IPX";
+ break;
+ case AF_IMPLINK:
+ what = "AF_IMPLINK";
+ break;
+ default:
+ snprintf(buf, buflen, "AF_UNKNOWN(%d)", domain);
+ break;
+ }
+
+ if (what != NULL)
+ strlcpy(buf, what, buflen);
+
+ return (0);
+}
+
+static int
+print_socktype(char *buf, size_t buflen, struct intercept_translate *tl)
+{
+ int type = (intptr_t)tl->trans_addr;
+ char *what = NULL;
+
+ switch (type) {
+ case SOCK_STREAM:
+ what = "SOCK_STREAM";
+ break;
+ case SOCK_DGRAM:
+ what = "SOCK_DGRAM";
+ break;
+ case SOCK_RAW:
+ what = "SOCK_RAW";
+ break;
+ case SOCK_SEQPACKET:
+ what = "SOCK_SEQPACKET";
+ break;
+ case SOCK_RDM:
+ what = "SOCK_RDM";
+ break;
+ default:
+ snprintf(buf, buflen, "SOCK_UNKNOWN(%d)", type);
+ break;
+ }
+
+ if (what != NULL)
+ strlcpy(buf, what, buflen);
+
+ return (0);
+}
+
+static int
print_uname(char *buf, size_t buflen, struct intercept_translate *tl)
{
struct passwd *pw;
@@ -293,3 +366,13 @@
"fd",
NULL, print_number,
};
+
+struct intercept_translate sockdom = {
+ "sockdom",
+ NULL, print_sockdom,
+};
+
+struct intercept_translate socktype = {
+ "socktype",
+ NULL, print_socktype,
+};
diff -r c7081a498cac -r 04d719e1f96c bin/systrace/systrace.h
--- a/bin/systrace/systrace.h Fri Oct 11 04:11:28 2002 +0000
+++ b/bin/systrace/systrace.h Fri Oct 11 04:40:11 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: systrace.h,v 1.6 2002/10/08 14:49:24 provos Exp $ */
+/* $NetBSD: systrace.h,v 1.7 2002/10/11 04:40:11 provos Exp $ */
/* $OpenBSD: systrace.h,v 1.14 2002/08/05 23:27:53 provos Exp $ */
/*
* Copyright 2002 Niels Provos <provos%citi.umich.edu@localhost>
@@ -217,6 +217,8 @@
extern struct intercept_translate uname;
extern struct intercept_translate gidt;
extern struct intercept_translate trargv;
+extern struct intercept_translate sockdom;
+extern struct intercept_translate socktype;
extern struct intercept_translate linux_oflags;
Home |
Main Index |
Thread Index |
Old Index