updated \PIPE\wkssvc commands to use new abstracted connection system.
authorLuke Leighton <lkcl@samba.org>
Sat, 27 Nov 1999 22:34:12 +0000 (22:34 +0000)
committerLuke Leighton <lkcl@samba.org>
Sat, 27 Nov 1999 22:34:12 +0000 (22:34 +0000)
modified resolve_srv_name() to return dest host of *SMBSERVER if
server name is \\ip.add.ress.format
(This used to be commit 3204829225792974c8b20efb6ba6e24661a4f658)

source3/include/proto.h
source3/libsmb/namequery.c
source3/rpc_client/cli_wkssvc.c
source3/rpcclient/cmd_wkssvc.c

index 24b50d9bccadab1b31c247ef21c8d4756d0b59e6..38b4be92adab24820a1abfbf1727a38bc8c1a487 100644 (file)
@@ -2141,8 +2141,7 @@ BOOL svc_change_svc_cfg( POLICY_HND *hnd,
 
 /*The following definitions come from  rpc_client/cli_wkssvc.c  */
 
-BOOL do_wks_query_info(struct cli_state *cli, uint16 fnum, 
-                       char *server_name, uint32 switch_value,
+BOOL wks_query_info( char *srv_name, uint32 switch_value,
                        WKS_INFO_100 *wks100);
 
 /*The following definitions come from  rpc_client/msrpc_lsarpc.c  */
index 114f656d8cc709e999af2789eae2bec4aa78c145..e774dbae15af5d3703885bda632ce2e4f01037ab 100644 (file)
@@ -589,10 +589,24 @@ static BOOL resolve_hosts(const char *name, struct in_addr *return_ip)
  or NetBIOS name. This uses the name switch in the
  smb.conf to determine the order of name resolution.
 *********************************************************/
-BOOL resolve_name(const char *name, struct in_addr *return_ip, int name_type)
+BOOL is_ip_address(const char *name)
 {
   int i;
-  BOOL pure_address = True;
+  for (i=0; name[i]; i++)
+    if (!(isdigit((int)name[i]) || name[i] == '.'))
+       return False;
+   
+  return True;
+}
+
+/********************************************************
+ Resolve a name into an IP address. Use this function if
+ the string is either an IP address, DNS or host name
+ or NetBIOS name. This uses the name switch in the
+ smb.conf to determine the order of name resolution.
+*********************************************************/
+BOOL resolve_name(const char *name, struct in_addr *return_ip, int name_type)
+{
   pstring name_resolve_list;
   fstring tok;
   char *ptr;
@@ -606,12 +620,8 @@ BOOL resolve_name(const char *name, struct in_addr *return_ip, int name_type)
     return True;
   }
    
-  for (i=0; pure_address && name[i]; i++)
-    if (!(isdigit((int)name[i]) || name[i] == '.'))
-      pure_address = False;
-   
   /* if it's in the form of an IP address then get the lib to interpret it */
-  if (pure_address) {
+  if (is_ip_address(name)) {
     return_ip->s_addr = inet_addr(name);
     return True;
   }
@@ -654,6 +664,7 @@ BOOL resolve_name(const char *name, struct in_addr *return_ip, int name_type)
 BOOL resolve_srv_name(const char* srv_name, fstring dest_host,
                                struct in_addr *ip)
 {
+       BOOL ret;
        DEBUG(10,("resolve_srv_name: %s\n", srv_name));
 
        if (srv_name == NULL || strequal("\\\\.", srv_name))
@@ -669,7 +680,14 @@ BOOL resolve_srv_name(const char* srv_name, fstring dest_host,
        }
 
        fstrcpy(dest_host, &srv_name[2]);
-       return resolve_name(dest_host, ip, 0x20);
+       ret = resolve_name(dest_host, ip, 0x20);
+       
+       if (is_ip_address(dest_host))
+       {
+               fstrcpy(dest_host, "*SMBSERVER");
+       }
+       
+       return ret;
 }
 
 /********************************************************
index 06ba8b88c83107ecb264b3748e6e665b05168fe2..99141bae6ce044937b4ce69378a7f63df5af5eb2 100644 (file)
@@ -34,16 +34,21 @@ extern int DEBUGLEVEL;
 /****************************************************************************
 do a WKS Open Policy
 ****************************************************************************/
-BOOL do_wks_query_info(struct cli_state *cli, uint16 fnum, 
-                       char *server_name, uint32 switch_value,
+BOOL wks_query_info( char *srv_name, uint32 switch_value,
                        WKS_INFO_100 *wks100)
 {
        prs_struct rbuf;
        prs_struct buf; 
        WKS_Q_QUERY_INFO q_o;
        BOOL valid_info = False;
+       struct cli_connection *con = NULL;
 
-       if (server_name == 0 || wks100 == NULL) return False;
+       if (wks100 == NULL) return False;
+
+       if (!cli_connection_init(srv_name, PIPE_WKSSVC, &con))
+       {
+               return False;
+       }
 
        prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
        prs_init(&rbuf, 0   , 4, SAFETY_MARGIN, True );
@@ -53,13 +58,13 @@ BOOL do_wks_query_info(struct cli_state *cli, uint16 fnum,
        DEBUG(4,("WKS Query Info\n"));
 
        /* store the parameters */
-       make_wks_q_query_info(&q_o, server_name, switch_value);
+       make_wks_q_query_info(&q_o, srv_name, switch_value);
 
        /* turn parameters into data stream */
        wks_io_q_query_info("", &q_o, &buf, 0);
 
        /* send the data on \PIPE\ */
-       if (rpc_api_pipe_req(cli, fnum, WKS_QUERY_INFO, &buf, &rbuf))
+       if (rpc_con_pipe_req(con, WKS_QUERY_INFO, &buf, &rbuf))
        {
                WKS_R_QUERY_INFO r_o;
                BOOL p;
@@ -85,6 +90,8 @@ BOOL do_wks_query_info(struct cli_state *cli, uint16 fnum,
        prs_mem_free(&rbuf);
        prs_mem_free(&buf );
 
+       cli_connection_unlink(con);
+
        return valid_info;
 }
 
index 23f7a88d270359b104278deacf94990774b0aaca..474c53f347ee8716ca4cdbe2dccab2ccab481422 100644 (file)
@@ -33,8 +33,6 @@ extern int DEBUGLEVEL;
 
 #define DEBUG_TESTING
 
-extern struct cli_state *smb_cli;
-
 extern FILE* out_hnd;
 
 
@@ -43,7 +41,6 @@ workstation get info query
 ****************************************************************************/
 void cmd_wks_query_info(struct client_info *info, int argc, char *argv[])
 {
-       uint16 nt_pipe_fnum;
        fstring dest_wks;
        WKS_INFO_100 ctr;
        uint32 info_level = 100;
@@ -64,17 +61,8 @@ void cmd_wks_query_info(struct client_info *info, int argc, char *argv[])
        DEBUG(4,("cmd_wks_query_info: server:%s info level: %d\n",
                                dest_wks, info_level));
 
-       DEBUG(5, ("cmd_wks_query_info: smb_cli->fd:%d\n", smb_cli->fd));
-
-       /* open LSARPC session. */
-       res = res ? cli_nt_session_open(smb_cli, PIPE_WKSSVC, &nt_pipe_fnum) : False;
-
        /* send info level: receive requested info.  hopefully. */
-       res = res ? do_wks_query_info(smb_cli, nt_pipe_fnum,
-                               dest_wks, info_level, &ctr) : False;
-
-       /* close the session */
-       cli_nt_session_close(smb_cli, nt_pipe_fnum);
+       res = res ? wks_query_info( dest_wks, info_level, &ctr) : False;
 
        if (res)
        {