summaryrefslogtreecommitdiff
path: root/source4/libcli/nbt
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2007-11-09 19:24:51 +0100
committerStefan Metzmacher <metze@samba.org>2007-12-21 05:45:02 +0100
commit529763a9aa192a6785ba878aceeb1683c2510913 (patch)
tree5fc843ffa644969ecd967d8b4133fc19333c33b5 /source4/libcli/nbt
parentb2ddeeb79d2622b3fd216465716dfa6b8c3e0b86 (diff)
downloadsamba-529763a9aa192a6785ba878aceeb1683c2510913.tar.gz
samba-529763a9aa192a6785ba878aceeb1683c2510913.tar.bz2
samba-529763a9aa192a6785ba878aceeb1683c2510913.zip
r25920: ndr: change NTSTAUS into enum ndr_err_code (samba4 callers)
lib/messaging/ lib/registry/ lib/ldb-samba/ librpc/rpc/ auth/auth_winbind.c auth/gensec/ auth/kerberos/ dsdb/repl/ dsdb/samdb/ dsdb/schema/ torture/ cluster/ctdb/ kdc/ ntvfs/ipc/ torture/rap/ ntvfs/ utils/getntacl.c ntptr/ smb_server/ libcli/wrepl/ wrepl_server/ libcli/cldap/ libcli/dgram/ libcli/ldap/ libcli/raw/ libcli/nbt/ libnet/ winbind/ rpc_server/ metze (This used to be commit 6223c7fddc972687eb577e04fc1c8e0604c35435)
Diffstat (limited to 'source4/libcli/nbt')
-rw-r--r--source4/libcli/nbt/nbtname.c95
-rw-r--r--source4/libcli/nbt/nbtsocket.c26
2 files changed, 69 insertions, 52 deletions
diff --git a/source4/libcli/nbt/nbtname.c b/source4/libcli/nbt/nbtname.c
index 1ee421b1f7..bdcd012556 100644
--- a/source4/libcli/nbt/nbtname.c
+++ b/source4/libcli/nbt/nbtname.c
@@ -42,8 +42,10 @@ _PUBLIC_ void ndr_print_nbt_string(struct ndr_print *ndr, const char *name, cons
/*
pull one component of a nbt_string
*/
-static NTSTATUS ndr_pull_component(struct ndr_pull *ndr, uint8_t **component,
- uint32_t *offset, uint32_t *max_offset)
+static enum ndr_err_code ndr_pull_component(struct ndr_pull *ndr,
+ uint8_t **component,
+ uint32_t *offset,
+ uint32_t *max_offset)
{
uint8_t len;
uint_t loops = 0;
@@ -57,7 +59,7 @@ static NTSTATUS ndr_pull_component(struct ndr_pull *ndr, uint8_t **component,
*offset += 1;
*max_offset = MAX(*max_offset, *offset);
*component = NULL;
- return NT_STATUS_OK;
+ return NDR_ERR_SUCCESS;
}
if ((len & 0xC0) == 0xC0) {
/* its a label pointer */
@@ -81,10 +83,10 @@ static NTSTATUS ndr_pull_component(struct ndr_pull *ndr, uint8_t **component,
"BAD NBT NAME component");
}
*component = (uint8_t*)talloc_strndup(ndr, (const char *)&ndr->data[1 + *offset], len);
- NT_STATUS_HAVE_NO_MEMORY(*component);
+ NDR_ERR_HAVE_NO_MEMORY(*component);
*offset += len + 1;
*max_offset = MAX(*max_offset, *offset);
- return NT_STATUS_OK;
+ return NDR_ERR_SUCCESS;
}
/* too many pointers */
@@ -94,7 +96,7 @@ static NTSTATUS ndr_pull_component(struct ndr_pull *ndr, uint8_t **component,
/**
pull a nbt_string from the wire
*/
-_PUBLIC_ NTSTATUS ndr_pull_nbt_string(struct ndr_pull *ndr, int ndr_flags, const char **s)
+_PUBLIC_ enum ndr_err_code ndr_pull_nbt_string(struct ndr_pull *ndr, int ndr_flags, const char **s)
{
uint32_t offset = ndr->offset;
uint32_t max_offset = offset;
@@ -102,7 +104,7 @@ _PUBLIC_ NTSTATUS ndr_pull_nbt_string(struct ndr_pull *ndr, int ndr_flags, const
char *name;
if (!(ndr_flags & NDR_SCALARS)) {
- return NT_STATUS_OK;
+ return NDR_ERR_SUCCESS;
}
name = NULL;
@@ -114,7 +116,7 @@ _PUBLIC_ NTSTATUS ndr_pull_nbt_string(struct ndr_pull *ndr, int ndr_flags, const
if (component == NULL) break;
if (name) {
name = talloc_asprintf_append_buffer(name, ".%s", component);
- NT_STATUS_HAVE_NO_MEMORY(name);
+ NDR_ERR_HAVE_NO_MEMORY(name);
} else {
name = (char *)component;
}
@@ -125,26 +127,26 @@ _PUBLIC_ NTSTATUS ndr_pull_nbt_string(struct ndr_pull *ndr, int ndr_flags, const
}
if (num_components == 0) {
name = talloc_strdup(ndr, "");
- NT_STATUS_HAVE_NO_MEMORY(name);
+ NDR_ERR_HAVE_NO_MEMORY(name);
}
(*s) = name;
ndr->offset = max_offset;
- return NT_STATUS_OK;
+ return NDR_ERR_SUCCESS;
}
/**
push a nbt string to the wire
*/
-_PUBLIC_ NTSTATUS ndr_push_nbt_string(struct ndr_push *ndr, int ndr_flags, const char *s)
+_PUBLIC_ enum ndr_err_code ndr_push_nbt_string(struct ndr_push *ndr, int ndr_flags, const char *s)
{
if (!(ndr_flags & NDR_SCALARS)) {
- return NT_STATUS_OK;
+ return NDR_ERR_SUCCESS;
}
while (s && *s) {
- NTSTATUS status;
+ enum ndr_err_code ndr_err;
char *compname;
size_t complen;
uint32_t offset;
@@ -152,8 +154,8 @@ _PUBLIC_ NTSTATUS ndr_push_nbt_string(struct ndr_push *ndr, int ndr_flags, const
/* see if we have pushed the remaing string allready,
* if so we use a label pointer to this string
*/
- status = ndr_token_retrieve_cmp_fn(&ndr->nbt_string_list, s, &offset, (comparison_fn_t)strcmp, false);
- if (NT_STATUS_IS_OK(status)) {
+ ndr_err = ndr_token_retrieve_cmp_fn(&ndr->nbt_string_list, s, &offset, (comparison_fn_t)strcmp, false);
+ if (NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
uint8_t b[2];
if (offset > 0x3FFF) {
@@ -181,7 +183,7 @@ _PUBLIC_ NTSTATUS ndr_push_nbt_string(struct ndr_push *ndr, int ndr_flags, const
(unsigned char)complen,
(unsigned char)complen,
(unsigned char)complen, s);
- NT_STATUS_HAVE_NO_MEMORY(compname);
+ NDR_ERR_HAVE_NO_MEMORY(compname);
/* remember the current componemt + the rest of the string
* so it can be reused later
@@ -279,7 +281,7 @@ static uint8_t *compress_name(TALLOC_CTX *mem_ctx,
/**
pull a nbt name from the wire
*/
-_PUBLIC_ NTSTATUS ndr_pull_nbt_name(struct ndr_pull *ndr, int ndr_flags, struct nbt_name *r)
+_PUBLIC_ enum ndr_err_code ndr_pull_nbt_name(struct ndr_pull *ndr, int ndr_flags, struct nbt_name *r)
{
uint8_t *scope;
char *cname;
@@ -287,7 +289,7 @@ _PUBLIC_ NTSTATUS ndr_pull_nbt_name(struct ndr_pull *ndr, int ndr_flags, struct
bool ok;
if (!(ndr_flags & NDR_SCALARS)) {
- return NT_STATUS_OK;
+ return NDR_ERR_SUCCESS;
}
NDR_CHECK(ndr_pull_nbt_string(ndr, ndr_flags, &s));
@@ -296,7 +298,7 @@ _PUBLIC_ NTSTATUS ndr_pull_nbt_name(struct ndr_pull *ndr, int ndr_flags, struct
if (scope) {
*scope = 0;
r->scope = talloc_strdup(ndr->current_mem_ctx, (const char *)&scope[1]);
- NT_STATUS_HAVE_NO_MEMORY(r->scope);
+ NDR_ERR_HAVE_NO_MEMORY(r->scope);
} else {
r->scope = NULL;
}
@@ -318,23 +320,23 @@ _PUBLIC_ NTSTATUS ndr_pull_nbt_name(struct ndr_pull *ndr, int ndr_flags, struct
}
r->name = talloc_strdup(ndr->current_mem_ctx, cname);
- NT_STATUS_HAVE_NO_MEMORY(r->name);
+ NDR_ERR_HAVE_NO_MEMORY(r->name);
talloc_free(cname);
- return NT_STATUS_OK;
+ return NDR_ERR_SUCCESS;
}
/**
push a nbt name to the wire
*/
-_PUBLIC_ NTSTATUS ndr_push_nbt_name(struct ndr_push *ndr, int ndr_flags, const struct nbt_name *r)
+_PUBLIC_ enum ndr_err_code ndr_push_nbt_name(struct ndr_push *ndr, int ndr_flags, const struct nbt_name *r)
{
uint8_t *cname, *fullname;
- NTSTATUS status;
+ enum ndr_err_code ndr_err;
if (!(ndr_flags & NDR_SCALARS)) {
- return NT_STATUS_OK;
+ return NDR_ERR_SUCCESS;
}
if (strlen(r->name) > 15) {
@@ -344,19 +346,19 @@ _PUBLIC_ NTSTATUS ndr_push_nbt_name(struct ndr_push *ndr, int ndr_flags, const s
}
cname = compress_name(ndr, (const uint8_t *)r->name, r->type);
- NT_STATUS_HAVE_NO_MEMORY(cname);
+ NDR_ERR_HAVE_NO_MEMORY(cname);
if (r->scope) {
fullname = (uint8_t *)talloc_asprintf(ndr, "%s.%s", cname, r->scope);
- NT_STATUS_HAVE_NO_MEMORY(fullname);
+ NDR_ERR_HAVE_NO_MEMORY(fullname);
talloc_free(cname);
} else {
fullname = cname;
}
- status = ndr_push_nbt_string(ndr, ndr_flags, (const char *)fullname);
+ ndr_err = ndr_push_nbt_string(ndr, ndr_flags, (const char *)fullname);
- return status;
+ return ndr_err;
}
@@ -380,18 +382,31 @@ _PUBLIC_ NTSTATUS nbt_name_dup(TALLOC_CTX *mem_ctx, struct nbt_name *name, struc
*/
_PUBLIC_ NTSTATUS nbt_name_to_blob(TALLOC_CTX *mem_ctx, DATA_BLOB *blob, struct nbt_name *name)
{
- return ndr_push_struct_blob(blob, mem_ctx, name,
- (ndr_push_flags_fn_t)ndr_push_nbt_name);
-}
+ enum ndr_err_code ndr_err;
+ ndr_err = ndr_push_struct_blob(blob, mem_ctx, name,
+ (ndr_push_flags_fn_t)ndr_push_nbt_name);
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+ return ndr_map_error2ntstatus(ndr_err);
+ }
+
+ return NT_STATUS_OK;
+}
/**
pull a nbt name from a blob
*/
_PUBLIC_ NTSTATUS nbt_name_from_blob(TALLOC_CTX *mem_ctx, const DATA_BLOB *blob, struct nbt_name *name)
{
- return ndr_pull_struct_blob(blob, mem_ctx, name,
- (ndr_pull_flags_fn_t)ndr_pull_nbt_name);
+ enum ndr_err_code ndr_err;
+
+ ndr_err = ndr_pull_struct_blob(blob, mem_ctx, name,
+ (ndr_pull_flags_fn_t)ndr_pull_nbt_name);
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+ return ndr_map_error2ntstatus(ndr_err);
+ }
+
+ return NT_STATUS_OK;
}
@@ -485,14 +500,14 @@ _PUBLIC_ char *nbt_name_string(TALLOC_CTX *mem_ctx, const struct nbt_name *name)
/**
pull a nbt name, WINS Replication uses another on wire format for nbt name
*/
-_PUBLIC_ NTSTATUS ndr_pull_wrepl_nbt_name(struct ndr_pull *ndr, int ndr_flags, struct nbt_name **_r)
+_PUBLIC_ enum ndr_err_code ndr_pull_wrepl_nbt_name(struct ndr_pull *ndr, int ndr_flags, struct nbt_name **_r)
{
struct nbt_name *r;
uint8_t *namebuf;
uint32_t namebuf_len;
if (!(ndr_flags & NDR_SCALARS)) {
- return NT_STATUS_OK;
+ return NDR_ERR_SUCCESS;
}
NDR_CHECK(ndr_pull_align(ndr, 4));
@@ -521,7 +536,7 @@ _PUBLIC_ NTSTATUS ndr_pull_wrepl_nbt_name(struct ndr_pull *ndr, int ndr_flags, s
talloc_free(namebuf);
*_r = r;
- return NT_STATUS_OK;
+ return NDR_ERR_SUCCESS;
}
r->type = namebuf[15];
@@ -540,13 +555,13 @@ _PUBLIC_ NTSTATUS ndr_pull_wrepl_nbt_name(struct ndr_pull *ndr, int ndr_flags, s
talloc_free(namebuf);
*_r = r;
- return NT_STATUS_OK;
+ return NDR_ERR_SUCCESS;
}
/**
push a nbt name, WINS Replication uses another on wire format for nbt name
*/
-_PUBLIC_ NTSTATUS ndr_push_wrepl_nbt_name(struct ndr_push *ndr, int ndr_flags, const struct nbt_name *r)
+_PUBLIC_ enum ndr_err_code ndr_push_wrepl_nbt_name(struct ndr_push *ndr, int ndr_flags, const struct nbt_name *r)
{
uint8_t *namebuf;
uint32_t namebuf_len;
@@ -559,7 +574,7 @@ _PUBLIC_ NTSTATUS ndr_push_wrepl_nbt_name(struct ndr_push *ndr, int ndr_flags, c
}
if (!(ndr_flags & NDR_SCALARS)) {
- return NT_STATUS_OK;
+ return NDR_ERR_SUCCESS;
}
name_len = strlen(r->name);
@@ -602,7 +617,7 @@ _PUBLIC_ NTSTATUS ndr_push_wrepl_nbt_name(struct ndr_push *ndr, int ndr_flags, c
NDR_CHECK(ndr_push_array_uint8(ndr, NDR_SCALARS, namebuf, namebuf_len));
talloc_free(namebuf);
- return NT_STATUS_OK;
+ return NDR_ERR_SUCCESS;
}
_PUBLIC_ void ndr_print_wrepl_nbt_name(struct ndr_print *ndr, const char *name, const struct nbt_name *r)
diff --git a/source4/libcli/nbt/nbtsocket.c b/source4/libcli/nbt/nbtsocket.c
index 7d88c83044..1f34b4583b 100644
--- a/source4/libcli/nbt/nbtsocket.c
+++ b/source4/libcli/nbt/nbtsocket.c
@@ -157,6 +157,7 @@ static void nbt_name_socket_recv(struct nbt_name_socket *nbtsock)
{
TALLOC_CTX *tmp_ctx = talloc_new(nbtsock);
NTSTATUS status;
+ enum ndr_err_code ndr_err;
struct socket_address *src;
DATA_BLOB blob;
size_t nread, dsize;
@@ -189,9 +190,10 @@ static void nbt_name_socket_recv(struct nbt_name_socket *nbtsock)
}
/* parse the request */
- status = ndr_pull_struct_blob(&blob, packet, packet,
- (ndr_pull_flags_fn_t)ndr_pull_nbt_name_packet);
- if (!NT_STATUS_IS_OK(status)) {
+ ndr_err = ndr_pull_struct_blob(&blob, packet, packet,
+ (ndr_pull_flags_fn_t)ndr_pull_nbt_name_packet);
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+ status = ndr_map_error2ntstatus(ndr_err);
DEBUG(2,("Failed to parse incoming NBT name packet - %s\n",
nt_errstr(status)));
talloc_free(tmp_ctx);
@@ -359,7 +361,7 @@ struct nbt_name_request *nbt_name_request_send(struct nbt_name_socket *nbtsock,
{
struct nbt_name_request *req;
int id;
- NTSTATUS status;
+ enum ndr_err_code ndr_err;
req = talloc_zero(nbtsock, struct nbt_name_request);
if (req == NULL) goto failed;
@@ -392,9 +394,9 @@ struct nbt_name_request *nbt_name_request_send(struct nbt_name_socket *nbtsock,
talloc_set_destructor(req, nbt_name_request_destructor);
- status = ndr_push_struct_blob(&req->encoded, req, request,
- (ndr_push_flags_fn_t)ndr_push_nbt_name_packet);
- if (!NT_STATUS_IS_OK(status)) goto failed;
+ ndr_err = ndr_push_struct_blob(&req->encoded, req, request,
+ (ndr_push_flags_fn_t)ndr_push_nbt_name_packet);
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) goto failed;
DLIST_ADD_END(nbtsock->send_queue, req, struct nbt_name_request *);
@@ -422,7 +424,7 @@ NTSTATUS nbt_name_reply_send(struct nbt_name_socket *nbtsock,
struct nbt_name_packet *request)
{
struct nbt_name_request *req;
- NTSTATUS status;
+ enum ndr_err_code ndr_err;
req = talloc_zero(nbtsock, struct nbt_name_request);
NT_STATUS_HAVE_NO_MEMORY(req);
@@ -439,11 +441,11 @@ NTSTATUS nbt_name_reply_send(struct nbt_name_socket *nbtsock,
NDR_PRINT_DEBUG(nbt_name_packet, request);
}
- status = ndr_push_struct_blob(&req->encoded, req, request,
- (ndr_push_flags_fn_t)ndr_push_nbt_name_packet);
- if (!NT_STATUS_IS_OK(status)) {
+ ndr_err = ndr_push_struct_blob(&req->encoded, req, request,
+ (ndr_push_flags_fn_t)ndr_push_nbt_name_packet);
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
talloc_free(req);
- return status;
+ return ndr_map_error2ntstatus(ndr_err);
}
DLIST_ADD_END(nbtsock->send_queue, req, struct nbt_name_request *);