diff options
-rw-r--r-- | source4/libcli/nbt/libnbt.h | 2 | ||||
-rw-r--r-- | source4/libcli/nbt/namequery.c | 2 | ||||
-rw-r--r-- | source4/libcli/nbt/nbtsocket.c | 26 | ||||
-rw-r--r-- | source4/utils/nmblookup.c | 4 |
4 files changed, 34 insertions, 0 deletions
diff --git a/source4/libcli/nbt/libnbt.h b/source4/libcli/nbt/libnbt.h index 7ccd6a51a4..c126f59280 100644 --- a/source4/libcli/nbt/libnbt.h +++ b/source4/libcli/nbt/libnbt.h @@ -132,6 +132,7 @@ struct nbt_name_query { struct nbt_name name; int16_t num_addrs; const char **reply_addrs; + uint8_t rcode; } out; }; @@ -147,6 +148,7 @@ struct nbt_name_status { const char *reply_from; struct nbt_name name; struct nbt_rdata_status status; + uint8_t rcode; } out; }; diff --git a/source4/libcli/nbt/namequery.c b/source4/libcli/nbt/namequery.c index ddef2a7d07..32fcad2052 100644 --- a/source4/libcli/nbt/namequery.c +++ b/source4/libcli/nbt/namequery.c @@ -91,6 +91,7 @@ NTSTATUS nbt_name_query_recv(struct nbt_name_request *req, return NT_STATUS_INVALID_NETWORK_RESPONSE; } + io->out.rcode = packet->operation & NBT_RCODE; io->out.name = packet->answers[0].name; io->out.num_addrs = packet->answers[0].rdata.netbios.length / 6; io->out.reply_addrs = talloc_array(mem_ctx, const char *, io->out.num_addrs); @@ -184,6 +185,7 @@ NTSTATUS nbt_name_status_recv(struct nbt_name_request *req, return NT_STATUS_INVALID_NETWORK_RESPONSE; } + io->out.rcode = packet->operation & NBT_RCODE; io->out.name = packet->answers[0].name; talloc_steal(mem_ctx, io->out.name.name); talloc_steal(mem_ctx, io->out.name.scope); diff --git a/source4/libcli/nbt/nbtsocket.c b/source4/libcli/nbt/nbtsocket.c index f6566e8a6e..38b356338c 100644 --- a/source4/libcli/nbt/nbtsocket.c +++ b/source4/libcli/nbt/nbtsocket.c @@ -484,3 +484,29 @@ NTSTATUS nbt_set_incoming_handler(struct nbt_name_socket *nbtsock, return NT_STATUS_OK; } + +/* + turn a NBT rcode into a NTSTATUS +*/ +NTSTATUS nbt_rcode_to_ntstatus(uint8_t rcode) +{ + int i; + struct { + enum nbt_rcode rcode; + NTSTATUS status; + } map[] = { + { NBT_RCODE_FMT, NT_STATUS_INVALID_PARAMETER }, + { NBT_RCODE_SVR, NT_STATUS_SERVER_DISABLED }, + { NBT_RCODE_NAM, NT_STATUS_OBJECT_NAME_NOT_FOUND }, + { NBT_RCODE_IMP, NT_STATUS_NOT_SUPPORTED }, + { NBT_RCODE_RFS, NT_STATUS_ACCESS_DENIED }, + { NBT_RCODE_ACT, NT_STATUS_ADDRESS_ALREADY_EXISTS }, + { NBT_RCODE_ACT, NT_STATUS_CONFLICTING_ADDRESSES } + }; + for (i=0;i<ARRAY_SIZE(map);i++) { + if (map[i].rcode == rcode) { + return map[i].status; + } + } + return NT_STATUS_UNSUCCESSFUL; +} diff --git a/source4/utils/nmblookup.c b/source4/utils/nmblookup.c index f41ab4cc6e..36550b8933 100644 --- a/source4/utils/nmblookup.c +++ b/source4/utils/nmblookup.c @@ -155,6 +155,10 @@ static NTSTATUS do_node_query(struct nbt_name_socket *nbtsock, status = nbt_name_query(nbtsock, nbtsock, &io); NT_STATUS_NOT_OK_RETURN(status); + + if (io.out.rcode != 0) { + return nbt_rcode_to_ntstatus(io.out.rcode); + } for (i=0;i<io.out.num_addrs;i++) { printf("%s %s<%02x>\n", |