s3: Remove "struct ip_service" from resolve_wins
authorVolker Lendecke <vl@samba.org>
Fri, 3 Jun 2011 13:49:55 +0000 (15:49 +0200)
committerVolker Lendecke <vl@samba.org>
Sun, 12 Jun 2011 15:07:47 +0000 (17:07 +0200)
nsswitch/wins.c
source3/include/proto.h
source3/libsmb/namequery.c
source3/winbindd/winbindd_wins.c

index 5c9ad2fb05256b0a3282cdf89f9bc0e3f1d25062..d63968b2bc5a3a055de016ad666a1800544f7576 100644 (file)
@@ -60,8 +60,9 @@ static void nss_wins_init(void)
 static struct in_addr *lookup_byname_backend(const char *name, int *count)
 {
        TALLOC_CTX *frame = talloc_stackframe();
-       struct ip_service *address = NULL;
+       struct sockaddr_storage *address = NULL;
        struct in_addr *ret = NULL;
+       NTSTATUS status;
        int j;
 
        if (!initialised) {
@@ -71,21 +72,20 @@ static struct in_addr *lookup_byname_backend(const char *name, int *count)
        *count = 0;
 
        /* always try with wins first */
-       if (NT_STATUS_IS_OK(resolve_wins(name,0x00,&address,count))) {
+       status = resolve_wins(name, 0x00, talloc_tos(),
+                             &address, count);
+       if (NT_STATUS_IS_OK(status)) {
                if ( (ret = SMB_MALLOC_P(struct in_addr)) == NULL ) {
-                       free( address );
                        TALLOC_FREE(frame);
                        return NULL;
                }
-               if (address[0].ss.ss_family != AF_INET) {
-                       free(address);
+               if (address[0].ss_family != AF_INET) {
                        free(ret);
                        TALLOC_FREE(frame);
                        return NULL;
                }
-               *ret = ((struct sockaddr_in *)(void *)&address[0].ss)
+               *ret = ((struct sockaddr_in *)(void *)address)
                        ->sin_addr;
-               free( address );
                TALLOC_FREE(frame);
                return ret;
        }
@@ -95,7 +95,6 @@ static struct in_addr *lookup_byname_backend(const char *name, int *count)
                const struct in_addr *bcast = iface_n_bcast_v4(j);
                struct sockaddr_storage ss;
                struct sockaddr_storage *pss;
-               NTSTATUS status;
 
                if (!bcast) {
                        continue;
index 1cde4be9a6ab7b2e2539966dbed6cfc2b7277870..4a19f74d4c7f76c1661363ba8d8d58dd82820927 100644 (file)
@@ -1052,7 +1052,8 @@ NTSTATUS name_resolve_bcast(const char *name,
                        int *return_count);
 NTSTATUS resolve_wins(const char *name,
                int name_type,
-               struct ip_service **return_iplist,
+               TALLOC_CTX *mem_ctx,
+               struct sockaddr_storage **return_iplist,
                int *return_count);
 NTSTATUS internal_resolve_name(const char *name,
                                int name_type,
index 511eba4cbf3908ba31117d5fa2a7974b06461f98..5969f656c1b37ed8a7788df29c2b18bf0e2e48cf 100644 (file)
@@ -1799,12 +1799,13 @@ NTSTATUS name_resolve_bcast(const char *name,
 
 NTSTATUS resolve_wins(const char *name,
                int name_type,
-               struct ip_service **return_iplist,
+               TALLOC_CTX *mem_ctx,
+               struct sockaddr_storage **return_iplist,
                int *return_count)
 {
        int t, i;
        char **wins_tags;
-       struct sockaddr_storage src_ss, *ss_list = NULL;
+       struct sockaddr_storage src_ss;
        struct in_addr src_ip;
        NTSTATUS status;
 
@@ -1882,8 +1883,8 @@ NTSTATUS resolve_wins(const char *name,
                                                false,
                                                true,
                                                &wins_ss,
-                                               talloc_tos(),
-                                               &ss_list,
+                                               mem_ctx,
+                                               return_iplist,
                                                return_count,
                                                NULL);
 
@@ -1914,10 +1915,6 @@ NTSTATUS resolve_wins(const char *name,
 success:
 
        status = NT_STATUS_OK;
-       if (!convert_ss2service(return_iplist, ss_list, *return_count))
-               status = NT_STATUS_INVALID_PARAMETER;
-
-       TALLOC_FREE(ss_list);
        wins_srv_tags_free(wins_tags);
 
        return status;
@@ -2314,11 +2311,18 @@ NTSTATUS internal_resolve_name(const char *name,
                        }
                } else if(strequal( tok, "wins")) {
                        /* don't resolve 1D via WINS */
+                       struct sockaddr_storage *ss_list;
                        if (name_type != 0x1D) {
                                status = resolve_wins(name, name_type,
-                                                     return_iplist,
+                                                     talloc_tos(),
+                                                     &ss_list,
                                                      return_count);
                                if (NT_STATUS_IS_OK(status)) {
+                                       if (!convert_ss2service(return_iplist,
+                                                               ss_list,
+                                                               *return_count)) {
+                                               status = NT_STATUS_NO_MEMORY;
+                                       }
                                        goto done;
                                }
                        }
index 7ed330f81bcc4e127a51858664be278f04b3152a..25c04df6bc8d4ab619d620f07b80695fce699f24 100644 (file)
@@ -31,29 +31,17 @@ static struct sockaddr_storage *lookup_byname_backend(TALLOC_CTX *mem_ctx,
                                                      const char *name,
                                                      int *count)
 {
-       struct ip_service *ret = NULL;
        struct sockaddr_storage *return_ss = NULL;
-       int j, i;
+       int j;
        NTSTATUS status;
 
        *count = 0;
 
        /* always try with wins first */
-       if (NT_STATUS_IS_OK(resolve_wins(name,0x20,&ret,count))) {
+       status = resolve_wins(name, 0x20, mem_ctx, &return_ss, count);
+       if (NT_STATUS_IS_OK(status)) {
                if ( *count == 0 )
                        return NULL;
-               return_ss = talloc_array(mem_ctx, struct sockaddr_storage,
-                                        *count);
-               if (return_ss == NULL ) {
-                       free( ret );
-                       return NULL;
-               }
-
-               /* copy the IP addresses */
-               for ( i=0; i<(*count); i++ )
-                       return_ss[i] = ret[i].ss;
-
-               free( ret );
                return return_ss;
        }