diff options
author | Gerald Carter <jerry@samba.org> | 2000-07-03 04:24:31 +0000 |
---|---|---|
committer | Gerald Carter <jerry@samba.org> | 2000-07-03 04:24:31 +0000 |
commit | 098b7b378c72632d8c3df0b795ac1e4c5dbfb04a (patch) | |
tree | d9766a7c9885fd33241d67f947b419bb22984092 /source3/libsmb/namequery.c | |
parent | 877c91bfdda53d2e93f4f4148361555d6461101a (diff) | |
download | samba-098b7b378c72632d8c3df0b795ac1e4c5dbfb04a.tar.gz samba-098b7b378c72632d8c3df0b795ac1e4c5dbfb04a.tar.bz2 samba-098b7b378c72632d8c3df0b795ac1e4c5dbfb04a.zip |
first pass at merging rpcclient from TNG to HEAD. You can get a
semi-connection and a rpcclient prompt, but no functionality there yet.
Will be a few more days on that.
These files changed only with the addition of some support functions
from TNG
--jerry
(This used to be commit a04ea15f723e559db3c60bed03318cc7be851f69)
Diffstat (limited to 'source3/libsmb/namequery.c')
-rw-r--r-- | source3/libsmb/namequery.c | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/source3/libsmb/namequery.c b/source3/libsmb/namequery.c index 5dadd4d474..8fb607bd8f 100644 --- a/source3/libsmb/namequery.c +++ b/source3/libsmb/namequery.c @@ -594,6 +594,23 @@ static BOOL resolve_hosts(const char *name, } /******************************************************** + 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 is_ip_address(const char *name) +{ + int i; + for (i=0; name[i]; i++) + if (!(isdigit((int)name[i]) || name[i] == '.')) + return False; + + return True; +} + + +/******************************************************** Internal interface to 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 @@ -686,6 +703,52 @@ BOOL resolve_name(const char *name, struct in_addr *return_ip, int name_type) return False; } + +/******************************************************** + resolve a name of format \\server_name or \\ipaddress + into a name. also, cut the \\ from the front for us. +*********************************************************/ + +BOOL resolve_srv_name(const char* srv_name, fstring dest_host, + struct in_addr *ip) +{ + BOOL ret; + const char *sv_name = srv_name; + + DEBUG(10,("resolve_srv_name: %s\n", srv_name)); + + if (srv_name == NULL || strequal("\\\\.", srv_name)) + { + extern pstring global_myname; + fstrcpy(dest_host, global_myname); + ip = interpret_addr2("127.0.0.1"); + return True; + } + + if (strnequal("\\\\", srv_name, 2)) + { + sv_name = &srv_name[2]; + } + + fstrcpy(dest_host, sv_name); + /* treat the '*' name specially - it is a magic name for the PDC */ + if (strcmp(dest_host,"*") == 0) { + extern pstring global_myname; + ret = resolve_name(lp_workgroup(), ip, 0x1B); + lookup_pdc_name(global_myname, lp_workgroup(), ip, dest_host); + } else { + ret = resolve_name(dest_host, ip, 0x20); + } + + if (is_ip_address(dest_host)) + { + fstrcpy(dest_host, "*SMBSERVER"); + } + + return ret; +} + + /******************************************************** Find the IP address of the master browser or DMB for a workgroup. *********************************************************/ |