git add -f bin/default/librpc/gen_ndr/*.[ch] bin/default/source*/librpc/gen_ndr/...
[metze/samba/wip.git] / bin.gen_ndr / default / source4 / librpc / gen_ndr / ndr_winstation_s.c
1 /* server functions auto-generated by pidl */
2 #include "bin/default/source4/librpc/gen_ndr/ndr_winstation.h"
3
4 NTSTATUS dcerpc_server_winstation_init(void);
5
6 /* winstation - dcerpc server boilerplate generated by pidl */
7
8
9 static NTSTATUS winstation__op_bind(struct dcesrv_call_state *dce_call, const struct dcesrv_interface *iface, uint32_t if_version)
10 {
11 #ifdef DCESRV_INTERFACE_WINSTATION_BIND
12         return DCESRV_INTERFACE_WINSTATION_BIND(dce_call,iface);
13 #else
14         return NT_STATUS_OK;
15 #endif
16 }
17
18 static void winstation__op_unbind(struct dcesrv_connection_context *context, const struct dcesrv_interface *iface)
19 {
20 #ifdef DCESRV_INTERFACE_WINSTATION_UNBIND
21         DCESRV_INTERFACE_WINSTATION_UNBIND(context, iface);
22 #else
23         return;
24 #endif
25 }
26
27 static NTSTATUS winstation__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_winstation.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_winstation.calls[opnum].struct_size,
41                           "struct %s",
42                           ndr_table_winstation.calls[opnum].name);
43         NT_STATUS_HAVE_NO_MEMORY(*r);
44
45         /* unravel the NDR for the packet */
46         ndr_err = ndr_table_winstation.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_winstation, 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 winstation__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 winstation_foo *r2 = (struct winstation_foo *)r;
65                 if (DEBUGLEVEL >= 10) {
66                         NDR_PRINT_FUNCTION_DEBUG(winstation_foo, NDR_IN, r2);
67                 }
68                 dcesrv_winstation_foo(dce_call, mem_ctx, r2);
69                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
70                         DEBUG(5,("function winstation_foo will reply async\n"));
71                 }
72                 break;
73         }
74
75         default:
76                 dce_call->fault_code = DCERPC_FAULT_OP_RNG_ERROR;
77                 break;
78         }
79
80         if (dce_call->fault_code != 0) {
81                 dcerpc_log_packet(dce_call->conn->packet_log_dir, 
82                           &ndr_table_winstation, opnum, NDR_IN,
83                                   &dce_call->pkt.u.request.stub_and_verifier);
84                 return NT_STATUS_NET_WRITE_FAULT;
85         }
86
87         return NT_STATUS_OK;
88 }
89
90 static NTSTATUS winstation__op_reply(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r)
91 {
92         uint16_t opnum = dce_call->pkt.u.request.opnum;
93
94         switch (opnum) {
95         case 0: {
96                 struct winstation_foo *r2 = (struct winstation_foo *)r;
97                 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
98                         DEBUG(5,("function winstation_foo replied async\n"));
99                 }
100                 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
101                         NDR_PRINT_FUNCTION_DEBUG(winstation_foo, NDR_OUT | NDR_SET_VALUES, r2);
102                 }
103                 if (dce_call->fault_code != 0) {
104                         DEBUG(2,("dcerpc_fault %s in winstation_foo\n", dcerpc_errstr(mem_ctx, dce_call->fault_code)));
105                 }
106                 break;
107         }
108
109         default:
110                 dce_call->fault_code = DCERPC_FAULT_OP_RNG_ERROR;
111                 break;
112         }
113
114         if (dce_call->fault_code != 0) {
115                 dcerpc_log_packet(dce_call->conn->packet_log_dir,
116                           &ndr_table_winstation, opnum, NDR_IN,
117                                   &dce_call->pkt.u.request.stub_and_verifier);
118                 return NT_STATUS_NET_WRITE_FAULT;
119         }
120
121         return NT_STATUS_OK;
122 }
123
124 static NTSTATUS winstation__op_ndr_push(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct ndr_push *push, const void *r)
125 {
126         enum ndr_err_code ndr_err;
127         uint16_t opnum = dce_call->pkt.u.request.opnum;
128
129         ndr_err = ndr_table_winstation.calls[opnum].ndr_push(push, NDR_OUT, r);
130         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
131                 dce_call->fault_code = DCERPC_FAULT_NDR;
132                 return NT_STATUS_NET_WRITE_FAULT;
133         }
134
135         return NT_STATUS_OK;
136 }
137
138 const struct dcesrv_interface dcesrv_winstation_interface = {
139         .name           = "winstation",
140         .syntax_id  = {{0x5ca4a760,0xebb1,0x11cf,{0x86,0x11},{0x00,0xa0,0x24,0x54,0x20,0xed}},1.0},
141         .bind           = winstation__op_bind,
142         .unbind         = winstation__op_unbind,
143         .ndr_pull       = winstation__op_ndr_pull,
144         .dispatch       = winstation__op_dispatch,
145         .reply          = winstation__op_reply,
146         .ndr_push       = winstation__op_ndr_push
147 };
148
149
150 static NTSTATUS winstation__op_init_server(struct dcesrv_context *dce_ctx, const struct dcesrv_endpoint_server *ep_server)
151 {
152         int i;
153
154         for (i=0;i<ndr_table_winstation.endpoints->count;i++) {
155                 NTSTATUS ret;
156                 const char *name = ndr_table_winstation.endpoints->names[i];
157
158                 ret = dcesrv_interface_register(dce_ctx, name, &dcesrv_winstation_interface, NULL);
159                 if (!NT_STATUS_IS_OK(ret)) {
160                         DEBUG(1,("winstation_op_init_server: failed to register endpoint '%s'\n",name));
161                         return ret;
162                 }
163         }
164
165         return NT_STATUS_OK;
166 }
167
168 static bool winstation__op_interface_by_uuid(struct dcesrv_interface *iface, const struct GUID *uuid, uint32_t if_version)
169 {
170         if (dcesrv_winstation_interface.syntax_id.if_version == if_version &&
171                 GUID_equal(&dcesrv_winstation_interface.syntax_id.uuid, uuid)) {
172                 memcpy(iface,&dcesrv_winstation_interface, sizeof(*iface));
173                 return true;
174         }
175
176         return false;
177 }
178
179 static bool winstation__op_interface_by_name(struct dcesrv_interface *iface, const char *name)
180 {
181         if (strcmp(dcesrv_winstation_interface.name, name)==0) {
182                 memcpy(iface, &dcesrv_winstation_interface, sizeof(*iface));
183                 return true;
184         }
185
186         return false;
187 }
188
189 NTSTATUS dcerpc_server_winstation_init(void)
190 {
191         NTSTATUS ret;
192         struct dcesrv_endpoint_server ep_server;
193
194         /* fill in our name */
195         ep_server.name = "winstation";
196
197         /* fill in all the operations */
198         ep_server.init_server = winstation__op_init_server;
199
200         ep_server.interface_by_uuid = winstation__op_interface_by_uuid;
201         ep_server.interface_by_name = winstation__op_interface_by_name;
202
203         /* register ourselves with the DCERPC subsystem. */
204         ret = dcerpc_register_ep_server(&ep_server);
205
206         if (!NT_STATUS_IS_OK(ret)) {
207                 DEBUG(0,("Failed to register 'winstation' endpoint server!\n"));
208                 return ret;
209         }
210
211         return ret;
212 }
213