This is a large patch (sorry). Migrate from struct in_addr
[metze/samba/wip.git] / source3 / utils / netlookup.c
index 2d105335e8a7103387087431135ddc1c9f86399b..90f99e4c8b06661730dd7d3edc16f536ae23db74 100644 (file)
@@ -7,7 +7,7 @@
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
 
    This program is distributed in the hope that it will be useful,
@@ -16,8 +16,7 @@
    GNU General Public License for more details.
 
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 #include "includes.h"
@@ -28,7 +27,7 @@
 ********************************************************/
 
 struct con_struct {
-       BOOL failed_connect;
+       bool failed_connect;
        NTSTATUS err;
        struct cli_state *cli;
        struct rpc_pipe_client *lsapipe;
@@ -41,7 +40,7 @@ static struct con_struct *cs;
  Close connection on context destruction.
 ********************************************************/
 
-static int cs_destructor(void *p)
+static int cs_destructor(struct con_struct *p)
 {
        if (cs->cli) {
                cli_shutdown(cs->cli);
@@ -57,10 +56,15 @@ static int cs_destructor(void *p)
 static struct con_struct *create_cs(TALLOC_CTX *ctx, NTSTATUS *perr)
 {
        NTSTATUS nt_status;
-       struct in_addr loopback_ip = *interpret_addr2("127.0.0.1");;
+       struct sockaddr_storage loopback_ss;
 
        *perr = NT_STATUS_OK;
 
+       if (!interpret_string_addr(&loopback_ss, "127.0.0.1", AI_NUMERICHOST)) {
+               *perr = NT_STATUS_INVALID_PARAMETER;
+               return NULL;
+       }
+
        if (cs) {
                if (cs->failed_connect) {
                        *perr = cs->err;
@@ -90,7 +94,7 @@ static struct con_struct *create_cs(TALLOC_CTX *ctx, NTSTATUS *perr)
 #endif
 
        nt_status = cli_full_connection(&cs->cli, global_myname(), global_myname(),
-                                       &loopback_ip, 0,
+                                       &loopback_ss, 0,
                                        "IPC$", "IPC",
 #if 0
                                        opt_user_name,
@@ -157,7 +161,7 @@ NTSTATUS net_lookup_name_from_sid(TALLOC_CTX *ctx,
        struct con_struct *csp = NULL;
        char **domains;
        char **names;
-       enum SID_NAME_USE *types;
+       enum lsa_SidType *types;
 
        *ppdomain = NULL;
        *ppname = NULL;
@@ -195,7 +199,7 @@ NTSTATUS net_lookup_sid_from_name(TALLOC_CTX *ctx, const char *full_name, DOM_SI
        NTSTATUS nt_status;
        struct con_struct *csp = NULL;
        DOM_SID *sids = NULL;
-       enum SID_NAME_USE *types = NULL;
+       enum lsa_SidType *types = NULL;
 
        csp = create_cs(ctx, &nt_status);
        if (csp == NULL) {
@@ -206,8 +210,8 @@ NTSTATUS net_lookup_sid_from_name(TALLOC_CTX *ctx, const char *full_name, DOM_SI
                                                &csp->pol,
                                                1,
                                                &full_name,
-                                               NULL, &sids,
-                                               &types);
+                                               NULL, 1,
+                                               &sids, &types);
 
        if (!NT_STATUS_IS_OK(nt_status)) {
                return nt_status;