summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2010-10-21 23:31:41 +0200
committerStefan Metzmacher <metze@samba.org>2010-10-23 08:49:30 +0200
commit79c6572256a01279d9e4f0b436d334f4fd739866 (patch)
tree65afeb97733c86269e8c351c7cf8aacf330ffe5c /lib
parentd2c653629cdc3df8549c6faabfcdbe3045cd013c (diff)
downloadsamba-79c6572256a01279d9e4f0b436d334f4fd739866.tar.gz
tsocket: let tstream_inet_tcp_connect_recv() optionally return the used local address
tstream_inet_tcp_connect_send() usually only gets no local port number and it may use the wildcard address '0.0.0.0' or '::'. tstream_inet_tcp_connect_recv() provides the used local address and port which are used on the wire. metze
Diffstat (limited to 'lib')
-rw-r--r--lib/tsocket/tsocket.h13
-rw-r--r--lib/tsocket/tsocket_bsd.c3
2 files changed, 11 insertions, 5 deletions
diff --git a/lib/tsocket/tsocket.h b/lib/tsocket/tsocket.h
index 3dd96664eaa..3aca5361241 100644
--- a/lib/tsocket/tsocket.h
+++ b/lib/tsocket/tsocket.h
@@ -724,23 +724,28 @@ struct tevent_req *tstream_inet_tcp_connect_send(TALLOC_CTX *mem_ctx,
*
* @param[in] mem_ctx The talloc memory context to use.
*
- * @param[in] stream A tstream_context pointer to setup the tcp communication
+ * @param[out] stream A tstream_context pointer to setup the tcp communication
* on. This function will allocate the memory.
*
+ * @param[out] local The real 'inet' tsocket_address of the local endpoint.
+ * This parameter is optional and can be NULL.
+ *
* @return 0 on success, -1 on error with perrno set.
*/
int tstream_inet_tcp_connect_recv(struct tevent_req *req,
int *perrno,
TALLOC_CTX *mem_ctx,
- struct tstream_context **stream);
+ struct tstream_context **stream,
+ struct tsocket_address **local)
#else
int _tstream_inet_tcp_connect_recv(struct tevent_req *req,
int *perrno,
TALLOC_CTX *mem_ctx,
struct tstream_context **stream,
+ struct tsocket_address **local,
const char *location);
-#define tstream_inet_tcp_connect_recv(req, perrno, mem_ctx, stream) \
- _tstream_inet_tcp_connect_recv(req, perrno, mem_ctx, stream, \
+#define tstream_inet_tcp_connect_recv(req, perrno, mem_ctx, stream, local) \
+ _tstream_inet_tcp_connect_recv(req, perrno, mem_ctx, stream, local, \
__location__)
#endif
diff --git a/lib/tsocket/tsocket_bsd.c b/lib/tsocket/tsocket_bsd.c
index f544e8672e2..019bf4266b4 100644
--- a/lib/tsocket/tsocket_bsd.c
+++ b/lib/tsocket/tsocket_bsd.c
@@ -2302,10 +2302,11 @@ int _tstream_inet_tcp_connect_recv(struct tevent_req *req,
int *perrno,
TALLOC_CTX *mem_ctx,
struct tstream_context **stream,
+ struct tsocket_address **local,
const char *location)
{
return tstream_bsd_connect_recv(req, perrno,
- mem_ctx, stream, NULL,
+ mem_ctx, stream, local,
location);
}