svn commit: samba r5261 - in branches/SAMBA_4_0/source: libcli/nbt
utils
tridge at samba.org
tridge at samba.org
Mon Feb 7 12:10:38 GMT 2005
Author: tridge
Date: 2005-02-07 12:10:38 +0000 (Mon, 07 Feb 2005)
New Revision: 5261
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=5261
Log:
translate nbt rcode errors to NTSTATUS codes
Modified:
branches/SAMBA_4_0/source/libcli/nbt/libnbt.h
branches/SAMBA_4_0/source/libcli/nbt/namequery.c
branches/SAMBA_4_0/source/libcli/nbt/nbtsocket.c
branches/SAMBA_4_0/source/utils/nmblookup.c
Changeset:
Modified: branches/SAMBA_4_0/source/libcli/nbt/libnbt.h
===================================================================
--- branches/SAMBA_4_0/source/libcli/nbt/libnbt.h 2005-02-07 11:56:34 UTC (rev 5260)
+++ branches/SAMBA_4_0/source/libcli/nbt/libnbt.h 2005-02-07 12:10:38 UTC (rev 5261)
@@ -132,6 +132,7 @@
struct nbt_name name;
int16_t num_addrs;
const char **reply_addrs;
+ uint8_t rcode;
} out;
};
@@ -147,6 +148,7 @@
const char *reply_from;
struct nbt_name name;
struct nbt_rdata_status status;
+ uint8_t rcode;
} out;
};
Modified: branches/SAMBA_4_0/source/libcli/nbt/namequery.c
===================================================================
--- branches/SAMBA_4_0/source/libcli/nbt/namequery.c 2005-02-07 11:56:34 UTC (rev 5260)
+++ branches/SAMBA_4_0/source/libcli/nbt/namequery.c 2005-02-07 12:10:38 UTC (rev 5261)
@@ -91,6 +91,7 @@
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 @@
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);
Modified: branches/SAMBA_4_0/source/libcli/nbt/nbtsocket.c
===================================================================
--- branches/SAMBA_4_0/source/libcli/nbt/nbtsocket.c 2005-02-07 11:56:34 UTC (rev 5260)
+++ branches/SAMBA_4_0/source/libcli/nbt/nbtsocket.c 2005-02-07 12:10:38 UTC (rev 5261)
@@ -484,3 +484,29 @@
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;
+}
Modified: branches/SAMBA_4_0/source/utils/nmblookup.c
===================================================================
--- branches/SAMBA_4_0/source/utils/nmblookup.c 2005-02-07 11:56:34 UTC (rev 5260)
+++ branches/SAMBA_4_0/source/utils/nmblookup.c 2005-02-07 12:10:38 UTC (rev 5261)
@@ -155,6 +155,10 @@
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",
More information about the samba-cvs
mailing list