struct nbt_name name;
int16_t num_addrs;
const char **reply_addrs;
+ uint8_t rcode;
} out;
};
const char *reply_from;
struct nbt_name name;
struct nbt_rdata_status status;
+ uint8_t rcode;
} out;
};
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);
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);
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;
+}
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",