tsocket: let tstream_inet_tcp_connect_recv() optionally return the used local address
authorStefan Metzmacher <metze@samba.org>
Thu, 21 Oct 2010 21:31:41 +0000 (23:31 +0200)
committerStefan Metzmacher <metze@samba.org>
Sat, 23 Oct 2010 06:49:30 +0000 (08:49 +0200)
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

lib/tsocket/tsocket.h
lib/tsocket/tsocket_bsd.c
source4/libcli/wrepl/winsrepl.c

index 3dd96664eaa4bb2af566b0a67461f301d3eb6cf1..3aca536124172c3f58842359dfd09769d75b664e 100644 (file)
@@ -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
 
index f544e8672e28ea8d741a5fb0d4dfb8b683da0b26..019bf4266b4d5634a789fe314d6a9db62496c3f9 100644 (file)
@@ -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);
 }
 
index 83da21700c7149bfdbfdf48c09e1b17d41e2607e..842a35175ec438c06121ceb6d270b248bbfe1942 100644 (file)
@@ -248,7 +248,7 @@ static void wrepl_connect_done(struct tevent_req *subreq)
        int sys_errno;
 
        ret = tstream_inet_tcp_connect_recv(subreq, &sys_errno,
-                                           state, &state->stream);
+                                           state, &state->stream, NULL);
        if (ret != 0) {
                NTSTATUS status = map_nt_error_from_unix(sys_errno);
                tevent_req_nterror(req, status);