diff options
author | Stefan Metzmacher <metze@samba.org> | 2005-11-07 15:07:41 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:45:53 -0500 |
commit | 57b98a7436e555dbcb988fbe50c6dce35c7ef68f (patch) | |
tree | fbea0a628a2cc3154a87367008a333bebb2eff81 | |
parent | 0c3376939930b216a6bef63c93bb5893161211f8 (diff) | |
download | samba-57b98a7436e555dbcb988fbe50c6dce35c7ef68f.tar.gz samba-57b98a7436e555dbcb988fbe50c6dce35c7ef68f.tar.bz2 samba-57b98a7436e555dbcb988fbe50c6dce35c7ef68f.zip |
r11553: give an error when the lookup failed
metze
(This used to be commit 363c000944ad40c3f8ba2b28f4cfed2bbd26fd65)
-rw-r--r-- | source4/utils/nmblookup.c | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/source4/utils/nmblookup.c b/source4/utils/nmblookup.c index 466c7d5382..9742440efe 100644 --- a/source4/utils/nmblookup.c +++ b/source4/utils/nmblookup.c @@ -100,7 +100,7 @@ static char *node_status_flags(TALLOC_CTX *mem_ctx, uint16_t flags) } /* do a single node status */ -static void do_node_status(struct nbt_name_socket *nbtsock, +static BOOL do_node_status(struct nbt_name_socket *nbtsock, const char *addr) { struct nbt_name_status io; @@ -131,7 +131,10 @@ static void do_node_status(struct nbt_name_socket *nbtsock, io.out.status.statistics.unit_id[3], io.out.status.statistics.unit_id[4], io.out.status.statistics.unit_id[5]); + return True; } + + return False; } /* do a single node query */ @@ -171,13 +174,14 @@ static NTSTATUS do_node_query(struct nbt_name_socket *nbtsock, } -static void process_one(const char *name) +static BOOL process_one(const char *name) { TALLOC_CTX *tmp_ctx = talloc_new(NULL); enum nbt_name_type node_type = NBT_NAME_CLIENT; char *node_name, *p; struct nbt_name_socket *nbtsock; NTSTATUS status = NT_STATUS_OK; + BOOL ret = True; if (!options.case_sensitive) { name = strupper_talloc(tmp_ctx, name); @@ -205,14 +209,15 @@ static void process_one(const char *name) status = socket_listen(nbtsock->sock, "0.0.0.0", NBT_NAME_SERVICE_PORT, 0, 0); if (!NT_STATUS_IS_OK(status)) { printf("Failed to bind to local port 137 - %s\n", nt_errstr(status)); - return; + talloc_free(tmp_ctx); + return False; } } if (options.lookup_by_ip) { - do_node_status(nbtsock, name); + ret = do_node_status(nbtsock, name); talloc_free(tmp_ctx); - return; + return ret; } if (options.broadcast_address) { @@ -230,16 +235,19 @@ static void process_one(const char *name) if (!NT_STATUS_IS_OK(status)) { printf("Lookup failed - %s\n", nt_errstr(status)); + ret = False; } talloc_free(tmp_ctx); - } + return ret; +} /* main program */ int main(int argc,char *argv[]) { + BOOL ret = True; poptContext pc; struct poptOption long_options[] = { POPT_AUTOHELP @@ -288,10 +296,14 @@ int main(int argc,char *argv[]) while (poptPeekArg(pc)) { const char *name = poptGetArg(pc); - process_one(name); + ret &= process_one(name); } poptFreeContext(pc); + if (!ret) { + return 1; + } + return 0; } |