aboutsummaryrefslogtreecommitdiff
path: root/sys/sys/unpcb.h
diff options
context:
space:
mode:
authorDima Dorfman <dd@FreeBSD.org>2001-08-17 22:01:18 +0000
committerDima Dorfman <dd@FreeBSD.org>2001-08-17 22:01:18 +0000
commit0c1bb4fbf1a07495aa163806e00ea56872c97286 (patch)
treea9fd833a0d5be8077a8bafc85a497fe0bae21cfa /sys/sys/unpcb.h
parent3da705c074bc4670cbe8a16676d1c5c8fc041607 (diff)
downloadsrc-0c1bb4fbf1a07495aa163806e00ea56872c97286.tar.gz
src-0c1bb4fbf1a07495aa163806e00ea56872c97286.zip
Implement a LOCAL_PEERCRED socket option which returns a
`struct xucred` with the credentials of the connected peer. Obviously this only works (and makes sense) on SOCK_STREAM sockets. This works for both the connect(2) and listen(2) callers. There is precise documentation of the semantics in unix(4). Reviewed by: dwmalone (eyeballed)
Notes
Notes: svn path=/head/; revision=81857
Diffstat (limited to 'sys/sys/unpcb.h')
-rw-r--r--sys/sys/unpcb.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/sys/sys/unpcb.h b/sys/sys/unpcb.h
index c0b8a373a197..cb9d1faab1c7 100644
--- a/sys/sys/unpcb.h
+++ b/sys/sys/unpcb.h
@@ -38,6 +38,7 @@
#define _SYS_UNPCB_H_
#include <sys/queue.h>
+#include <sys/ucred.h>
/*
* Protocol control block for an active
@@ -80,8 +81,26 @@ struct unpcb {
int unp_cc; /* copy of rcv.sb_cc */
int unp_mbcnt; /* copy of rcv.sb_mbcnt */
unp_gen_t unp_gencnt; /* generation count of this instance */
+ int unp_flags; /* flags */
+ struct xucred unp_peercred; /* peer credentials, if applicable */
};
+/*
+ * Flags in unp_flags.
+ *
+ * UNP_HAVEPC - indicates that the unp_peercred member is filled in
+ * and is really the credentials of the connected peer. This is used
+ * to determine whether the contents should be sent to the user or
+ * not.
+ *
+ * UNP_HAVEPCCACHED - indicates that the unp_peercred member is filled
+ * in, but does *not* contain the credentials of the connected peer
+ * (there may not even be a peer). This is set in unp_listen() when
+ * it fills in unp_peercred for later consumption by unp_connect().
+ */
+#define UNP_HAVEPC 0x001
+#define UNP_HAVEPCCACHED 0x002
+
#define sotounpcb(so) ((struct unpcb *)((so)->so_pcb))
/* Hack alert -- this structure depends on <sys/socketvar.h>. */