summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2009-12-23 11:48:06 +0100
committerStefan Metzmacher <metze@samba.org>2009-12-24 17:38:33 +0100
commit500f55ca92efe0235758b131a33bc1645c0545ac (patch)
treeef3c4b24ac83895b457a77348c3a45113b26ae0c
parent4e2da423de260468f0457410b0556088f00420d4 (diff)
downloadsamba-500f55ca92efe0235758b131a33bc1645c0545ac.tar.gz
samba-500f55ca92efe0235758b131a33bc1645c0545ac.tar.bz2
samba-500f55ca92efe0235758b131a33bc1645c0545ac.zip
s4:smbd: hold tsocket_addresses on the stream_connection
metze
-rw-r--r--source4/smbd/config.mk2
-rw-r--r--source4/smbd/service_stream.c32
-rw-r--r--source4/smbd/service_stream.h3
3 files changed, 27 insertions, 10 deletions
diff --git a/source4/smbd/config.mk b/source4/smbd/config.mk
index b85beb0bc0..a77a18602f 100644
--- a/source4/smbd/config.mk
+++ b/source4/smbd/config.mk
@@ -4,7 +4,7 @@
PRIVATE_DEPENDENCIES = \
LIBTEVENT MESSAGING samba_socket \
NDR_NAMED_PIPE_AUTH NAMED_PIPE_AUTH_TSTREAM \
- HEIMDAL_GSSAPI CREDENTIALS
+ HEIMDAL_GSSAPI CREDENTIALS LIBTSOCKET
service_OBJ_FILES = $(addprefix $(smbdsrcdir)/, \
service.o \
diff --git a/source4/smbd/service_stream.c b/source4/smbd/service_stream.c
index ab35eb04bf..2d8b9559f4 100644
--- a/source4/smbd/service_stream.c
+++ b/source4/smbd/service_stream.c
@@ -26,6 +26,7 @@
#include "lib/messaging/irpc.h"
#include "cluster/cluster.h"
#include "param/param.h"
+#include "../lib/tsocket/tsocket.h"
/* the range of ports to try for dcerpc over tcp endpoints */
#define SERVER_TCP_LOW_PORT 1024
@@ -164,7 +165,6 @@ static void stream_new_connection(struct tevent_context *ev,
{
struct stream_socket *stream_socket = talloc_get_type(private_data, struct stream_socket);
struct stream_connection *srv_conn;
- struct socket_address *c, *s;
srv_conn = talloc_zero(ev, struct stream_connection);
if (!srv_conn) {
@@ -205,20 +205,34 @@ static void stream_new_connection(struct tevent_context *ev,
return;
}
- c = socket_get_peer_addr(sock, ev);
- s = socket_get_my_addr(sock, ev);
- if (s && c) {
+ srv_conn->remote_address = socket_get_remote_addr(srv_conn->socket, srv_conn);
+ if (!srv_conn->remote_address) {
+ stream_terminate_connection(srv_conn, "socket_get_remote_addr() failed");
+ return;
+ }
+
+ srv_conn->local_address = socket_get_local_addr(srv_conn->socket, srv_conn);
+ if (!srv_conn->local_address) {
+ stream_terminate_connection(srv_conn, "socket_get_local_addr() failed");
+ return;
+ }
+
+ {
+ TALLOC_CTX *tmp_ctx;
const char *title;
- title = talloc_asprintf(s, "conn[%s] c[%s:%u] s[%s:%u] server_id[%s]",
+
+ tmp_ctx = talloc_new(srv_conn);
+
+ title = talloc_asprintf(tmp_ctx, "conn[%s] c[%s] s[%s] server_id[%s]",
stream_socket->ops->name,
- c->addr, c->port, s->addr, s->port,
- cluster_id_string(s, server_id));
+ tsocket_address_string(srv_conn->remote_address, tmp_ctx),
+ tsocket_address_string(srv_conn->local_address, tmp_ctx),
+ cluster_id_string(tmp_ctx, server_id));
if (title) {
stream_connection_set_title(srv_conn, title);
}
+ talloc_free(tmp_ctx);
}
- talloc_free(c);
- talloc_free(s);
/* we're now ready to start receiving events on this stream */
TEVENT_FD_READABLE(srv_conn->event.fde);
diff --git a/source4/smbd/service_stream.h b/source4/smbd/service_stream.h
index 5d577d4dd8..685502a8ba 100644
--- a/source4/smbd/service_stream.h
+++ b/source4/smbd/service_stream.h
@@ -50,6 +50,9 @@ struct stream_connection {
struct messaging_context *msg_ctx;
struct loadparm_context *lp_ctx;
+ struct tsocket_address *local_address;
+ struct tsocket_address *remote_address;
+
/*
* this transport layer session info, normally NULL
* which means the same as an anonymous session info