/*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 */
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;
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;
}
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))
}
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;
}
/********************************************************
/****************************************************************************
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 );
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;
prs_mem_free(&rbuf);
prs_mem_free(&buf );
+ cli_connection_unlink(con);
+
return valid_info;
}
#define DEBUG_TESTING
-extern struct cli_state *smb_cli;
-
extern FILE* out_hnd;
****************************************************************************/
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;
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)
{