s3:smbd: add smbXsrv_connection_dbg()
authorStefan Metzmacher <metze@samba.org>
Mon, 21 Jul 2014 16:58:52 +0000 (18:58 +0200)
committerMichael Adam <obnox@samba.org>
Wed, 6 Aug 2014 07:51:10 +0000 (09:51 +0200)
This is similar to fsp_fnum_dbg() and fsp_str_dbg().

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
source3/smbd/globals.h
source3/smbd/process.c

index 70148fb76aed1f3a17f37d13f2dddce8be8061be..3b9882d211782c465dd77db1eac4f42c66bfb1cf 100644 (file)
@@ -389,6 +389,8 @@ struct smbXsrv_connection {
        struct smbXsrv_open_table *open_table;
 };
 
+const char *smbXsrv_connection_dbg(const struct smbXsrv_connection *xconn);
+
 NTSTATUS smbXsrv_version_global_init(const struct server_id *server_id);
 uint32_t smbXsrv_version_global_current(void);
 
index 127bbb3e3905c2e8550d41d3075b97dd11a20b30..d1074e21d9f5c4ef4aec88dd6bf32f4b2d036f49 100644 (file)
@@ -3485,6 +3485,29 @@ static void smbd_tevent_trace_callback(enum tevent_trace_point point,
        }
 }
 
+/**
+ * Create a debug string for the connection
+ *
+ * This is allocated to talloc_tos() or a string constant
+ * in certain corner cases. The returned string should
+ * hence not be free'd directly but only via the talloc stack.
+ */
+const char *smbXsrv_connection_dbg(const struct smbXsrv_connection *xconn)
+{
+       const char *ret;
+
+       /*
+        * TODO: this can be improved later
+        * maybe including the client guid or more
+        */
+       ret = tsocket_address_string(xconn->remote_address, talloc_tos());
+       if (ret == NULL) {
+               return "<tsocket_address_string() failed>";
+       }
+
+       return ret;
+}
+
 /****************************************************************************
  Process commands from the client
 ****************************************************************************/