1 /* server functions auto-generated by pidl */
2 #include "bin/default/librpc/gen_ndr/ndr_xattr.h"
4 NTSTATUS dcerpc_server_xattr_init(void);
6 /* xattr - dcerpc server boilerplate generated by pidl */
9 static NTSTATUS xattr__op_bind(struct dcesrv_call_state *dce_call, const struct dcesrv_interface *iface, uint32_t if_version)
11 #ifdef DCESRV_INTERFACE_XATTR_BIND
12 return DCESRV_INTERFACE_XATTR_BIND(dce_call,iface);
18 static void xattr__op_unbind(struct dcesrv_connection_context *context, const struct dcesrv_interface *iface)
20 #ifdef DCESRV_INTERFACE_XATTR_UNBIND
21 DCESRV_INTERFACE_XATTR_UNBIND(context, iface);
27 static NTSTATUS xattr__op_ndr_pull(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct ndr_pull *pull, void **r)
29 enum ndr_err_code ndr_err;
30 uint16_t opnum = dce_call->pkt.u.request.opnum;
32 dce_call->fault_code = 0;
34 if (opnum >= ndr_table_xattr.num_calls) {
35 dce_call->fault_code = DCERPC_FAULT_OP_RNG_ERROR;
36 return NT_STATUS_NET_WRITE_FAULT;
39 *r = talloc_named(mem_ctx,
40 ndr_table_xattr.calls[opnum].struct_size,
42 ndr_table_xattr.calls[opnum].name);
43 NT_STATUS_HAVE_NO_MEMORY(*r);
45 /* unravel the NDR for the packet */
46 ndr_err = ndr_table_xattr.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_xattr, 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;
58 static NTSTATUS xattr__op_dispatch(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r)
60 uint16_t opnum = dce_call->pkt.u.request.opnum;
64 struct xattr_parse_DOSATTRIB *r2 = (struct xattr_parse_DOSATTRIB *)r;
65 if (DEBUGLEVEL >= 10) {
66 NDR_PRINT_FUNCTION_DEBUG(xattr_parse_DOSATTRIB, NDR_IN, r2);
68 dcesrv_xattr_parse_DOSATTRIB(dce_call, mem_ctx, r2);
69 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
70 DEBUG(5,("function xattr_parse_DOSATTRIB will reply async\n"));
76 dce_call->fault_code = DCERPC_FAULT_OP_RNG_ERROR;
80 if (dce_call->fault_code != 0) {
81 dcerpc_log_packet(dce_call->conn->packet_log_dir,
82 &ndr_table_xattr, opnum, NDR_IN,
83 &dce_call->pkt.u.request.stub_and_verifier);
84 return NT_STATUS_NET_WRITE_FAULT;
90 static NTSTATUS xattr__op_reply(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r)
92 uint16_t opnum = dce_call->pkt.u.request.opnum;
96 struct xattr_parse_DOSATTRIB *r2 = (struct xattr_parse_DOSATTRIB *)r;
97 if (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {
98 DEBUG(5,("function xattr_parse_DOSATTRIB replied async\n"));
100 if (DEBUGLEVEL >= 10 && dce_call->fault_code == 0) {
101 NDR_PRINT_FUNCTION_DEBUG(xattr_parse_DOSATTRIB, NDR_OUT | NDR_SET_VALUES, r2);
103 if (dce_call->fault_code != 0) {
104 DEBUG(2,("dcerpc_fault %s in xattr_parse_DOSATTRIB\n", dcerpc_errstr(mem_ctx, dce_call->fault_code)));
110 dce_call->fault_code = DCERPC_FAULT_OP_RNG_ERROR;
114 if (dce_call->fault_code != 0) {
115 dcerpc_log_packet(dce_call->conn->packet_log_dir,
116 &ndr_table_xattr, opnum, NDR_IN,
117 &dce_call->pkt.u.request.stub_and_verifier);
118 return NT_STATUS_NET_WRITE_FAULT;
124 static NTSTATUS xattr__op_ndr_push(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct ndr_push *push, const void *r)
126 enum ndr_err_code ndr_err;
127 uint16_t opnum = dce_call->pkt.u.request.opnum;
129 ndr_err = ndr_table_xattr.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;
138 const struct dcesrv_interface dcesrv_xattr_interface = {
140 .syntax_id = {{0x12345778,0x1234,0xabcd,{0x00,0x01},{0x00,0x00,0x00,0x02}},0.0},
141 .bind = xattr__op_bind,
142 .unbind = xattr__op_unbind,
143 .ndr_pull = xattr__op_ndr_pull,
144 .dispatch = xattr__op_dispatch,
145 .reply = xattr__op_reply,
146 .ndr_push = xattr__op_ndr_push
150 static NTSTATUS xattr__op_init_server(struct dcesrv_context *dce_ctx, const struct dcesrv_endpoint_server *ep_server)
154 for (i=0;i<ndr_table_xattr.endpoints->count;i++) {
156 const char *name = ndr_table_xattr.endpoints->names[i];
158 ret = dcesrv_interface_register(dce_ctx, name, &dcesrv_xattr_interface, NULL);
159 if (!NT_STATUS_IS_OK(ret)) {
160 DEBUG(1,("xattr_op_init_server: failed to register endpoint '%s'\n",name));
168 static bool xattr__op_interface_by_uuid(struct dcesrv_interface *iface, const struct GUID *uuid, uint32_t if_version)
170 if (dcesrv_xattr_interface.syntax_id.if_version == if_version &&
171 GUID_equal(&dcesrv_xattr_interface.syntax_id.uuid, uuid)) {
172 memcpy(iface,&dcesrv_xattr_interface, sizeof(*iface));
179 static bool xattr__op_interface_by_name(struct dcesrv_interface *iface, const char *name)
181 if (strcmp(dcesrv_xattr_interface.name, name)==0) {
182 memcpy(iface, &dcesrv_xattr_interface, sizeof(*iface));
189 NTSTATUS dcerpc_server_xattr_init(void)
192 struct dcesrv_endpoint_server ep_server;
194 /* fill in our name */
195 ep_server.name = "xattr";
197 /* fill in all the operations */
198 ep_server.init_server = xattr__op_init_server;
200 ep_server.interface_by_uuid = xattr__op_interface_by_uuid;
201 ep_server.interface_by_name = xattr__op_interface_by_name;
203 /* register ourselves with the DCERPC subsystem. */
204 ret = dcerpc_register_ep_server(&ep_server);
206 if (!NT_STATUS_IS_OK(ret)) {
207 DEBUG(0,("Failed to register 'xattr' endpoint server!\n"));