2 Unix SMB/CIFS implementation.
6 Copyright (C) Andrew Tridgell 2003
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
25 * Convert an ndr error to string
28 const char *ndr_errstr(enum ndr_err_code err)
32 return "NDR_ERR_SUCCESS";
34 case NDR_ERR_ARRAY_SIZE:
35 return "NDR_ERR_ARRAY_SIZE";
37 case NDR_ERR_BAD_SWITCH:
38 return "NDR_ERR_BAD_SWITCH";
41 return "NDR_ERR_OFFSET";
43 case NDR_ERR_RELATIVE:
44 return "NDR_ERR_RELATIVE";
47 return "NDR_ERR_CHARCNV";
50 return "NDR_ERR_LENGTH";
52 case NDR_ERR_SUBCONTEXT:
53 return "NDR_ERR_SUBCONTEXT";
55 case NDR_ERR_COMPRESSION:
56 return "NDR_ERR_COMPRESSION";
59 return "NDR_ERR_STRING";
61 case NDR_ERR_VALIDATE:
62 return "NDR_ERR_VALIDATE";
65 return "NDR_ERR_BUFSIZE";
68 return "NDR_ERR_ALLOC";
71 return "NDR_ERR_RANGE";
74 return "NDR_ERR_TOKEN";
76 case NDR_ERR_IPV4ADDRESS:
77 return "NDR_ERR_IPV4ADDRESS";
79 case NDR_ERR_IPV6ADDRESS:
80 return "NDR_ERR_IPV6ADDRESS";
82 case NDR_ERR_INVALID_POINTER:
83 return "NDR_ERR_INVALID_POINTER";
85 case NDR_ERR_UNREAD_BYTES:
86 return "NDR_ERR_UNREAD_BYTES";
89 return "NDR_ERR_NDR64";
93 return talloc_asprintf(talloc_tos(), "Unknown NDR error: %d", err);
96 enum ndr_err_code ndr_push_server_id(struct ndr_push *ndr, int ndr_flags, const struct server_id *r)
98 if (ndr_flags & NDR_SCALARS) {
99 NDR_CHECK(ndr_push_align(ndr, 4));
100 NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS,
102 #ifdef CLUSTER_SUPPORT
103 NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS,
107 if (ndr_flags & NDR_BUFFERS) {
109 return NDR_ERR_SUCCESS;
112 enum ndr_err_code ndr_pull_server_id(struct ndr_pull *ndr, int ndr_flags, struct server_id *r)
114 if (ndr_flags & NDR_SCALARS) {
116 NDR_CHECK(ndr_pull_align(ndr, 4));
117 NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &pid));
118 #ifdef CLUSTER_SUPPORT
119 NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->vnn));
123 if (ndr_flags & NDR_BUFFERS) {
125 return NDR_ERR_SUCCESS;
128 void ndr_print_server_id(struct ndr_print *ndr, const char *name, const struct server_id *r)
130 ndr_print_struct(ndr, name, "server_id");
132 ndr_print_uint32(ndr, "id", (uint32_t)r->pid);
133 #ifdef CLUSTER_SUPPORT
134 ndr_print_uint32(ndr, "vnn", (uint32_t)r->vnn);
139 _PUBLIC_ void ndr_print_sockaddr_storage(struct ndr_print *ndr, const char *name, const struct sockaddr_storage *ss)
141 char addr[INET6_ADDRSTRLEN];
142 ndr->print(ndr, "%-25s: %s", name, print_sockaddr(addr, sizeof(addr), ss));