git add -f bin/default/librpc/gen_ndr/*.[ch] bin/default/source*/librpc/gen_ndr/...
[metze/samba/wip.git] / bin.gen_ndr / default / librpc / gen_ndr / ndr_unixinfo_s.c
1 /* server functions auto-generated by pidl */
2 #include "bin/default/librpc/gen_ndr/ndr_unixinfo.h"
3
4 NTSTATUS dcerpc_server_unixinfo_init(void);
5
6 /* unixinfo - dcerpc server boilerplate generated by pidl */
7
8
9 static NTSTATUS unixinfo__op_bind(struct dcesrv_call_state *dce_call, const struct dcesrv_interface *iface, uint32_t if_version)
10 {
11 #ifdef DCESRV_INTERFACE_UNIXINFO_BIND
12         return DCESRV_INTERFACE_UNIXINFO_BIND(dce_call,iface);
13 #else
14         return NT_STATUS_OK;
15 #endif
16 }
17
18 static void unixinfo__op_unbind(struct dcesrv_connection_context *context, const struct dcesrv_interface *iface)
19 {
20 #ifdef DCESRV_INTERFACE_UNIXINFO_UNBIND
21         DCESRV_INTERFACE_UNIXINFO_UNBIND(context, iface);
22 #else
23         return;
24 #endif
25 }
26
27 static NTSTATUS unixinfo__op_ndr_pull(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct ndr_pull *pull, void **r)
28 {
29         enum ndr_err_code ndr_err;
30         uint16_t opnum = dce_call->pkt.u.request.opnum;
31
32         dce_call->fault_code = 0;
33
34         if (opnum >= ndr_table_unixinfo.num_calls) {
35                 dce_call->fault_code = DCERPC_FAULT_OP_RNG_ERROR;
36                 return NT_STATUS_NET_WRITE_FAULT;
37         }
38
39         *r = talloc_named(mem_ctx,
40                           ndr_table_unixinfo.calls[opnum].struct_size,
41                           "struct %s",
42                           ndr_table_unixinfo.calls[opnum].name);
43         NT_STATUS_HAVE_NO_MEMORY(*r);
44
45         /* unravel the NDR for the packet */
46         ndr_err = ndr_table_unixinfo.calls[opnum].ndr_pull(pull, NDR_IN, *r);
47         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
48                 dcerpc_log_packet(dce_call->conn->packet_log_dir, 
49                                   &ndr_table_unixinfo, opnum, NDR_IN,
50                                   &dce_call->pkt.u.request.stub_and_verifier);
51                 dce_call->fault_code = DCERPC_FAULT_NDR;
52                 return NT_STATUS_NET_WRITE_FAULT;
53         }
54
55         return NT_STATUS_OK;
56 }
57
58 static NTSTATUS unixinfo__op_dispatch(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r)
59 {
60         uint16_t opnum = dce_call->pkt.u.request.opnum;
61
62         switch (opnum) {
63         case 0: {
64                 struct unixinfo_SidToUid *r2 = (struct unixinfo_SidToUid *)r;
65                 if (DEBUGLEVEL >= 10) {
66                         NDR_PRINT_FUNCTION_DEBUG(unixinfo_SidToUid, NDR_IN, r2);
67                 }
68                 r2->out.result = dcesrv_unixinfo_SidToUid(dce_call, mem_ctx, r2);
69                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
70                         DEBUG(5,("function unixinfo_SidToUid will reply async\n"));
71                 }
72                 break;
73         }
74         case 1: {
75                 struct unixinfo_UidToSid *r2 = (struct unixinfo_UidToSid *)r;
76                 if (DEBUGLEVEL >= 10) {
77                         NDR_PRINT_FUNCTION_DEBUG(unixinfo_UidToSid, NDR_IN, r2);
78                 }
79                 r2->out.result = dcesrv_unixinfo_UidToSid(dce_call, mem_ctx, r2);
80                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
81                         DEBUG(5,("function unixinfo_UidToSid will reply async\n"));
82                 }
83                 break;
84         }
85         case 2: {
86                 struct unixinfo_SidToGid *r2 = (struct unixinfo_SidToGid *)r;
87                 if (DEBUGLEVEL >= 10) {
88                         NDR_PRINT_FUNCTION_DEBUG(unixinfo_SidToGid, NDR_IN, r2);
89                 }
90                 r2->out.result = dcesrv_unixinfo_SidToGid(dce_call, mem_ctx, r2);
91                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
92                         DEBUG(5,("function unixinfo_SidToGid will reply async\n"));
93                 }
94                 break;
95         }
96         case 3: {
97                 struct unixinfo_GidToSid *r2 = (struct unixinfo_GidToSid *)r;
98                 if (DEBUGLEVEL >= 10) {
99                         NDR_PRINT_FUNCTION_DEBUG(unixinfo_GidToSid, NDR_IN, r2);
100                 }
101                 r2->out.result = dcesrv_unixinfo_GidToSid(dce_call, mem_ctx, r2);
102                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
103                         DEBUG(5,("function unixinfo_GidToSid will reply async\n"));
104                 }
105                 break;
106         }
107         case 4: {
108                 struct unixinfo_GetPWUid *r2 = (struct unixinfo_GetPWUid *)r;
109                 if (DEBUGLEVEL >= 10) {
110                         NDR_PRINT_FUNCTION_DEBUG(unixinfo_GetPWUid, NDR_IN, r2);
111                 }
112                 r2->out.result = dcesrv_unixinfo_GetPWUid(dce_call, mem_ctx, r2);
113                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
114                         DEBUG(5,("function unixinfo_GetPWUid will reply async\n"));
115                 }
116                 break;
117         }
118
119         default:
120                 dce_call->fault_code = DCERPC_FAULT_OP_RNG_ERROR;
121                 break;
122         }
123
124         if (dce_call->fault_code != 0) {
125                 dcerpc_log_packet(dce_call->conn->packet_log_dir, 
126                           &ndr_table_unixinfo, opnum, NDR_IN,
127                                   &dce_call->pkt.u.request.stub_and_verifier);
128                 return NT_STATUS_NET_WRITE_FAULT;
129         }
130
131         return NT_STATUS_OK;
132 }
133
134 static NTSTATUS unixinfo__op_reply(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r)
135 {
136         uint16_t opnum = dce_call->pkt.u.request.opnum;
137
138         switch (opnum) {
139         case 0: {
140                 struct unixinfo_SidToUid *r2 = (struct unixinfo_SidToUid *)r;
141                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
142                         DEBUG(5,("function unixinfo_SidToUid replied async\n"));
143                 }
144                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
145                         NDR_PRINT_FUNCTION_DEBUG(unixinfo_SidToUid, NDR_OUT | NDR_SET_VALUES, r2);
146                 }
147                 if (dce_call->fault_code != 0) {
148                         DEBUG(2,("dcerpc_fault %s in unixinfo_SidToUid\n", dcerpc_errstr(mem_ctx, dce_call->fault_code)));
149                 }
150                 break;
151         }
152         case 1: {
153                 struct unixinfo_UidToSid *r2 = (struct unixinfo_UidToSid *)r;
154                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
155                         DEBUG(5,("function unixinfo_UidToSid replied async\n"));
156                 }
157                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
158                         NDR_PRINT_FUNCTION_DEBUG(unixinfo_UidToSid, NDR_OUT | NDR_SET_VALUES, r2);
159                 }
160                 if (dce_call->fault_code != 0) {
161                         DEBUG(2,("dcerpc_fault %s in unixinfo_UidToSid\n", dcerpc_errstr(mem_ctx, dce_call->fault_code)));
162                 }
163                 break;
164         }
165         case 2: {
166                 struct unixinfo_SidToGid *r2 = (struct unixinfo_SidToGid *)r;
167                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
168                         DEBUG(5,("function unixinfo_SidToGid replied async\n"));
169                 }
170                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
171                         NDR_PRINT_FUNCTION_DEBUG(unixinfo_SidToGid, NDR_OUT | NDR_SET_VALUES, r2);
172                 }
173                 if (dce_call->fault_code != 0) {
174                         DEBUG(2,("dcerpc_fault %s in unixinfo_SidToGid\n", dcerpc_errstr(mem_ctx, dce_call->fault_code)));
175                 }
176                 break;
177         }
178         case 3: {
179                 struct unixinfo_GidToSid *r2 = (struct unixinfo_GidToSid *)r;
180                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
181                         DEBUG(5,("function unixinfo_GidToSid replied async\n"));
182                 }
183                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
184                         NDR_PRINT_FUNCTION_DEBUG(unixinfo_GidToSid, NDR_OUT | NDR_SET_VALUES, r2);
185                 }
186                 if (dce_call->fault_code != 0) {
187                         DEBUG(2,("dcerpc_fault %s in unixinfo_GidToSid\n", dcerpc_errstr(mem_ctx, dce_call->fault_code)));
188                 }
189                 break;
190         }
191         case 4: {
192                 struct unixinfo_GetPWUid *r2 = (struct unixinfo_GetPWUid *)r;
193                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
194                         DEBUG(5,("function unixinfo_GetPWUid replied async\n"));
195                 }
196                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
197                         NDR_PRINT_FUNCTION_DEBUG(unixinfo_GetPWUid, NDR_OUT | NDR_SET_VALUES, r2);
198                 }
199                 if (dce_call->fault_code != 0) {
200                         DEBUG(2,("dcerpc_fault %s in unixinfo_GetPWUid\n", dcerpc_errstr(mem_ctx, dce_call->fault_code)));
201                 }
202                 break;
203         }
204
205         default:
206                 dce_call->fault_code = DCERPC_FAULT_OP_RNG_ERROR;
207                 break;
208         }
209
210         if (dce_call->fault_code != 0) {
211                 dcerpc_log_packet(dce_call->conn->packet_log_dir,
212                           &ndr_table_unixinfo, opnum, NDR_IN,
213                                   &dce_call->pkt.u.request.stub_and_verifier);
214                 return NT_STATUS_NET_WRITE_FAULT;
215         }
216
217         return NT_STATUS_OK;
218 }
219
220 static NTSTATUS unixinfo__op_ndr_push(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct ndr_push *push, const void *r)
221 {
222         enum ndr_err_code ndr_err;
223         uint16_t opnum = dce_call->pkt.u.request.opnum;
224
225         ndr_err = ndr_table_unixinfo.calls[opnum].ndr_push(push, NDR_OUT, r);
226         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
227                 dce_call->fault_code = DCERPC_FAULT_NDR;
228                 return NT_STATUS_NET_WRITE_FAULT;
229         }
230
231         return NT_STATUS_OK;
232 }
233
234 const struct dcesrv_interface dcesrv_unixinfo_interface = {
235         .name           = "unixinfo",
236         .syntax_id  = {{0x9c54e310,0xa955,0x4885,{0xbd,0x31},{0x78,0x78,0x71,0x47,0xdf,0xa6}},0.0},
237         .bind           = unixinfo__op_bind,
238         .unbind         = unixinfo__op_unbind,
239         .ndr_pull       = unixinfo__op_ndr_pull,
240         .dispatch       = unixinfo__op_dispatch,
241         .reply          = unixinfo__op_reply,
242         .ndr_push       = unixinfo__op_ndr_push
243 };
244
245
246 static NTSTATUS unixinfo__op_init_server(struct dcesrv_context *dce_ctx, const struct dcesrv_endpoint_server *ep_server)
247 {
248         int i;
249
250         for (i=0;i<ndr_table_unixinfo.endpoints->count;i++) {
251                 NTSTATUS ret;
252                 const char *name = ndr_table_unixinfo.endpoints->names[i];
253
254                 ret = dcesrv_interface_register(dce_ctx, name, &dcesrv_unixinfo_interface, NULL);
255                 if (!NT_STATUS_IS_OK(ret)) {
256                         DEBUG(1,("unixinfo_op_init_server: failed to register endpoint '%s'\n",name));
257                         return ret;
258                 }
259         }
260
261         return NT_STATUS_OK;
262 }
263
264 static bool unixinfo__op_interface_by_uuid(struct dcesrv_interface *iface, const struct GUID *uuid, uint32_t if_version)
265 {
266         if (dcesrv_unixinfo_interface.syntax_id.if_version == if_version &&
267                 GUID_equal(&dcesrv_unixinfo_interface.syntax_id.uuid, uuid)) {
268                 memcpy(iface,&dcesrv_unixinfo_interface, sizeof(*iface));
269                 return true;
270         }
271
272         return false;
273 }
274
275 static bool unixinfo__op_interface_by_name(struct dcesrv_interface *iface, const char *name)
276 {
277         if (strcmp(dcesrv_unixinfo_interface.name, name)==0) {
278                 memcpy(iface, &dcesrv_unixinfo_interface, sizeof(*iface));
279                 return true;
280         }
281
282         return false;
283 }
284
285 NTSTATUS dcerpc_server_unixinfo_init(void)
286 {
287         NTSTATUS ret;
288         struct dcesrv_endpoint_server ep_server;
289
290         /* fill in our name */
291         ep_server.name = "unixinfo";
292
293         /* fill in all the operations */
294         ep_server.init_server = unixinfo__op_init_server;
295
296         ep_server.interface_by_uuid = unixinfo__op_interface_by_uuid;
297         ep_server.interface_by_name = unixinfo__op_interface_by_name;
298
299         /* register ourselves with the DCERPC subsystem. */
300         ret = dcerpc_register_ep_server(&ep_server);
301
302         if (!NT_STATUS_IS_OK(ret)) {
303                 DEBUG(0,("Failed to register 'unixinfo' endpoint server!\n"));
304                 return ret;
305         }
306
307         return ret;
308 }
309