2 /* Python wrapper functions auto-generated by pidl */
6 #include "librpc/rpc/pyrpc.h"
7 #include "librpc/rpc/pyrpc_util.h"
8 #include "bin/default/librpc/gen_ndr/ndr_witness.h"
9 #include "bin/default/librpc/gen_ndr/ndr_witness_c.h"
11 #include "librpc/gen_ndr/misc.h"
12 staticforward PyTypeObject witness_interfaceInfo_Type;
13 staticforward PyTypeObject witness_interfaceList_Type;
14 staticforward PyTypeObject witness_notifyResponse_Type;
15 staticforward PyTypeObject witness_InterfaceType;
17 void initwitness(void);static PyTypeObject *Object_Type;
18 static PyTypeObject *policy_handle_Type;
19 static PyTypeObject *ClientConnection_Type;
20 static PyTypeObject *ndr_syntax_id_Type;
22 static PyObject *py_witness_interfaceInfo_get_group_name(PyObject *obj, void *closure)
24 struct witness_interfaceInfo *object = (struct witness_interfaceInfo *)pytalloc_get_ptr(obj);
25 PyObject *py_group_name;
26 if (object->group_name == NULL) {
27 py_group_name = Py_None;
28 Py_INCREF(py_group_name);
30 py_group_name = PyUnicode_Decode(object->group_name, strlen(object->group_name), "utf-8", "ignore");
35 static int py_witness_interfaceInfo_set_group_name(PyObject *py_obj, PyObject *value, void *closure)
37 struct witness_interfaceInfo *object = (struct witness_interfaceInfo *)pytalloc_get_ptr(py_obj);
38 if (PyUnicode_Check(value)) {
39 object->group_name = PyString_AS_STRING(PyUnicode_AsEncodedString(value, "utf-8", "ignore"));
40 } else if (PyString_Check(value)) {
41 object->group_name = PyString_AS_STRING(value);
43 PyErr_Format(PyExc_TypeError, "Expected string or unicode object, got %s", Py_TYPE(value)->tp_name);
49 static PyObject *py_witness_interfaceInfo_get_version(PyObject *obj, void *closure)
51 struct witness_interfaceInfo *object = (struct witness_interfaceInfo *)pytalloc_get_ptr(obj);
53 py_version = PyInt_FromLong(object->version);
57 static int py_witness_interfaceInfo_set_version(PyObject *py_obj, PyObject *value, void *closure)
59 struct witness_interfaceInfo *object = (struct witness_interfaceInfo *)pytalloc_get_ptr(py_obj);
60 if (PyLong_Check(value)) {
61 object->version = PyLong_AsLongLong(value);
62 } else if (PyInt_Check(value)) {
63 object->version = PyInt_AsLong(value);
65 PyErr_Format(PyExc_TypeError, "Expected type %s or %s",\
66 PyInt_Type.tp_name, PyLong_Type.tp_name);
72 static PyObject *py_witness_interfaceInfo_get_state(PyObject *obj, void *closure)
74 struct witness_interfaceInfo *object = (struct witness_interfaceInfo *)pytalloc_get_ptr(obj);
76 py_state = PyInt_FromLong(object->state);
80 static int py_witness_interfaceInfo_set_state(PyObject *py_obj, PyObject *value, void *closure)
82 struct witness_interfaceInfo *object = (struct witness_interfaceInfo *)pytalloc_get_ptr(py_obj);
83 if (PyLong_Check(value)) {
84 object->state = PyLong_AsLongLong(value);
85 } else if (PyInt_Check(value)) {
86 object->state = PyInt_AsLong(value);
88 PyErr_Format(PyExc_TypeError, "Expected type %s or %s",\
89 PyInt_Type.tp_name, PyLong_Type.tp_name);
95 static PyObject *py_witness_interfaceInfo_get_ipv4(PyObject *obj, void *closure)
97 struct witness_interfaceInfo *object = (struct witness_interfaceInfo *)pytalloc_get_ptr(obj);
99 py_ipv4 = PyString_FromStringOrNULL(object->ipv4);
103 static int py_witness_interfaceInfo_set_ipv4(PyObject *py_obj, PyObject *value, void *closure)
105 struct witness_interfaceInfo *object = (struct witness_interfaceInfo *)pytalloc_get_ptr(py_obj);
106 object->ipv4 = PyString_AS_STRING(value);
110 static PyObject *py_witness_interfaceInfo_get_ipv6(PyObject *obj, void *closure)
112 struct witness_interfaceInfo *object = (struct witness_interfaceInfo *)pytalloc_get_ptr(obj);
114 py_ipv6 = PyString_FromStringOrNULL(object->ipv6);
118 static int py_witness_interfaceInfo_set_ipv6(PyObject *py_obj, PyObject *value, void *closure)
120 struct witness_interfaceInfo *object = (struct witness_interfaceInfo *)pytalloc_get_ptr(py_obj);
121 object->ipv6 = PyString_AsString(value);
125 static PyObject *py_witness_interfaceInfo_get_flags(PyObject *obj, void *closure)
127 struct witness_interfaceInfo *object = (struct witness_interfaceInfo *)pytalloc_get_ptr(obj);
129 py_flags = PyInt_FromLong(object->flags);
133 static int py_witness_interfaceInfo_set_flags(PyObject *py_obj, PyObject *value, void *closure)
135 struct witness_interfaceInfo *object = (struct witness_interfaceInfo *)pytalloc_get_ptr(py_obj);
136 if (PyLong_Check(value)) {
137 object->flags = PyLong_AsLongLong(value);
138 } else if (PyInt_Check(value)) {
139 object->flags = PyInt_AsLong(value);
141 PyErr_Format(PyExc_TypeError, "Expected type %s or %s",\
142 PyInt_Type.tp_name, PyLong_Type.tp_name);
148 static PyGetSetDef py_witness_interfaceInfo_getsetters[] = {
149 { discard_const_p(char, "group_name"), py_witness_interfaceInfo_get_group_name, py_witness_interfaceInfo_set_group_name },
150 { discard_const_p(char, "version"), py_witness_interfaceInfo_get_version, py_witness_interfaceInfo_set_version },
151 { discard_const_p(char, "state"), py_witness_interfaceInfo_get_state, py_witness_interfaceInfo_set_state },
152 { discard_const_p(char, "ipv4"), py_witness_interfaceInfo_get_ipv4, py_witness_interfaceInfo_set_ipv4 },
153 { discard_const_p(char, "ipv6"), py_witness_interfaceInfo_get_ipv6, py_witness_interfaceInfo_set_ipv6 },
154 { discard_const_p(char, "flags"), py_witness_interfaceInfo_get_flags, py_witness_interfaceInfo_set_flags },
158 static PyObject *py_witness_interfaceInfo_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
160 return pytalloc_new(struct witness_interfaceInfo, type);
164 static PyTypeObject witness_interfaceInfo_Type = {
165 PyObject_HEAD_INIT(NULL) 0,
166 .tp_name = "witness.interfaceInfo",
167 .tp_getset = py_witness_interfaceInfo_getsetters,
169 .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
170 .tp_basicsize = sizeof(pytalloc_Object),
171 .tp_new = py_witness_interfaceInfo_new,
175 static PyObject *py_witness_interfaceList_get_num_interfaces(PyObject *obj, void *closure)
177 struct witness_interfaceList *object = (struct witness_interfaceList *)pytalloc_get_ptr(obj);
178 PyObject *py_num_interfaces;
179 py_num_interfaces = PyInt_FromLong(object->num_interfaces);
180 return py_num_interfaces;
183 static int py_witness_interfaceList_set_num_interfaces(PyObject *py_obj, PyObject *value, void *closure)
185 struct witness_interfaceList *object = (struct witness_interfaceList *)pytalloc_get_ptr(py_obj);
186 PY_CHECK_TYPE(&PyInt_Type, value, return -1;);
187 object->num_interfaces = PyInt_AsLong(value);
191 static PyObject *py_witness_interfaceList_get_interfaces(PyObject *obj, void *closure)
193 struct witness_interfaceList *object = (struct witness_interfaceList *)pytalloc_get_ptr(obj);
194 PyObject *py_interfaces;
195 if (object->interfaces == NULL) {
196 py_interfaces = Py_None;
197 Py_INCREF(py_interfaces);
199 py_interfaces = PyList_New(object->num_interfaces);
200 if (py_interfaces == NULL) {
204 int interfaces_cntr_1;
205 for (interfaces_cntr_1 = 0; interfaces_cntr_1 < object->num_interfaces; interfaces_cntr_1++) {
206 PyObject *py_interfaces_1;
207 py_interfaces_1 = pytalloc_reference_ex(&witness_interfaceInfo_Type, object->interfaces, &object->interfaces[interfaces_cntr_1]);
208 PyList_SetItem(py_interfaces, interfaces_cntr_1, py_interfaces_1);
212 return py_interfaces;
215 static int py_witness_interfaceList_set_interfaces(PyObject *py_obj, PyObject *value, void *closure)
217 struct witness_interfaceList *object = (struct witness_interfaceList *)pytalloc_get_ptr(py_obj);
218 talloc_unlink(pytalloc_get_mem_ctx(py_obj), object->interfaces);
219 if (value == Py_None) {
220 object->interfaces = NULL;
222 object->interfaces = NULL;
223 PY_CHECK_TYPE(&PyList_Type, value, return -1;);
225 int interfaces_cntr_1;
226 object->interfaces = talloc_array_ptrtype(pytalloc_get_mem_ctx(py_obj), object->interfaces, PyList_GET_SIZE(value));
227 if (!object->interfaces) { return -1;; }
228 talloc_set_name_const(object->interfaces, "ARRAY: object->interfaces");
229 for (interfaces_cntr_1 = 0; interfaces_cntr_1 < PyList_GET_SIZE(value); interfaces_cntr_1++) {
230 PY_CHECK_TYPE(&witness_interfaceInfo_Type, PyList_GET_ITEM(value, interfaces_cntr_1), return -1;);
231 if (talloc_reference(object->interfaces, pytalloc_get_mem_ctx(PyList_GET_ITEM(value, interfaces_cntr_1))) == NULL) {
235 object->interfaces[interfaces_cntr_1] = *(struct witness_interfaceInfo *)pytalloc_get_ptr(PyList_GET_ITEM(value, interfaces_cntr_1));
242 static PyGetSetDef py_witness_interfaceList_getsetters[] = {
243 { discard_const_p(char, "num_interfaces"), py_witness_interfaceList_get_num_interfaces, py_witness_interfaceList_set_num_interfaces },
244 { discard_const_p(char, "interfaces"), py_witness_interfaceList_get_interfaces, py_witness_interfaceList_set_interfaces },
248 static PyObject *py_witness_interfaceList_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
250 return pytalloc_new(struct witness_interfaceList, type);
254 static PyTypeObject witness_interfaceList_Type = {
255 PyObject_HEAD_INIT(NULL) 0,
256 .tp_name = "witness.interfaceList",
257 .tp_getset = py_witness_interfaceList_getsetters,
259 .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
260 .tp_basicsize = sizeof(pytalloc_Object),
261 .tp_new = py_witness_interfaceList_new,
265 static PyObject *py_witness_notifyResponse_get_message_type(PyObject *obj, void *closure)
267 struct witness_notifyResponse *object = (struct witness_notifyResponse *)pytalloc_get_ptr(obj);
268 PyObject *py_message_type;
269 py_message_type = PyInt_FromLong(object->message_type);
270 return py_message_type;
273 static int py_witness_notifyResponse_set_message_type(PyObject *py_obj, PyObject *value, void *closure)
275 struct witness_notifyResponse *object = (struct witness_notifyResponse *)pytalloc_get_ptr(py_obj);
276 if (PyLong_Check(value)) {
277 object->message_type = PyLong_AsLongLong(value);
278 } else if (PyInt_Check(value)) {
279 object->message_type = PyInt_AsLong(value);
281 PyErr_Format(PyExc_TypeError, "Expected type %s or %s",\
282 PyInt_Type.tp_name, PyLong_Type.tp_name);
288 static PyObject *py_witness_notifyResponse_get_length(PyObject *obj, void *closure)
290 struct witness_notifyResponse *object = (struct witness_notifyResponse *)pytalloc_get_ptr(obj);
292 py_length = PyInt_FromLong(object->length);
296 static int py_witness_notifyResponse_set_length(PyObject *py_obj, PyObject *value, void *closure)
298 struct witness_notifyResponse *object = (struct witness_notifyResponse *)pytalloc_get_ptr(py_obj);
299 PY_CHECK_TYPE(&PyInt_Type, value, return -1;);
300 object->length = PyInt_AsLong(value);
304 static PyObject *py_witness_notifyResponse_get_num_messages(PyObject *obj, void *closure)
306 struct witness_notifyResponse *object = (struct witness_notifyResponse *)pytalloc_get_ptr(obj);
307 PyObject *py_num_messages;
308 py_num_messages = PyInt_FromLong(object->num_messages);
309 return py_num_messages;
312 static int py_witness_notifyResponse_set_num_messages(PyObject *py_obj, PyObject *value, void *closure)
314 struct witness_notifyResponse *object = (struct witness_notifyResponse *)pytalloc_get_ptr(py_obj);
315 PY_CHECK_TYPE(&PyInt_Type, value, return -1;);
316 object->num_messages = PyInt_AsLong(value);
320 static PyObject *py_witness_notifyResponse_get_message_buffer(PyObject *obj, void *closure)
322 struct witness_notifyResponse *object = (struct witness_notifyResponse *)pytalloc_get_ptr(obj);
323 PyObject *py_message_buffer;
324 if (object->message_buffer == NULL) {
325 py_message_buffer = Py_None;
326 Py_INCREF(py_message_buffer);
328 py_message_buffer = PyList_New(object->length);
329 if (py_message_buffer == NULL) {
333 int message_buffer_cntr_1;
334 for (message_buffer_cntr_1 = 0; message_buffer_cntr_1 < object->length; message_buffer_cntr_1++) {
335 PyObject *py_message_buffer_1;
336 py_message_buffer_1 = PyInt_FromLong(object->message_buffer[message_buffer_cntr_1]);
337 PyList_SetItem(py_message_buffer, message_buffer_cntr_1, py_message_buffer_1);
341 return py_message_buffer;
344 static int py_witness_notifyResponse_set_message_buffer(PyObject *py_obj, PyObject *value, void *closure)
346 struct witness_notifyResponse *object = (struct witness_notifyResponse *)pytalloc_get_ptr(py_obj);
347 talloc_unlink(pytalloc_get_mem_ctx(py_obj), object->message_buffer);
348 if (value == Py_None) {
349 object->message_buffer = NULL;
351 object->message_buffer = NULL;
352 PY_CHECK_TYPE(&PyList_Type, value, return -1;);
354 int message_buffer_cntr_1;
355 object->message_buffer = talloc_array_ptrtype(pytalloc_get_mem_ctx(py_obj), object->message_buffer, PyList_GET_SIZE(value));
356 if (!object->message_buffer) { return -1;; }
357 talloc_set_name_const(object->message_buffer, "ARRAY: object->message_buffer");
358 for (message_buffer_cntr_1 = 0; message_buffer_cntr_1 < PyList_GET_SIZE(value); message_buffer_cntr_1++) {
359 PY_CHECK_TYPE(&PyInt_Type, PyList_GET_ITEM(value, message_buffer_cntr_1), return -1;);
360 object->message_buffer[message_buffer_cntr_1] = PyInt_AsLong(PyList_GET_ITEM(value, message_buffer_cntr_1));
367 static PyGetSetDef py_witness_notifyResponse_getsetters[] = {
368 { discard_const_p(char, "message_type"), py_witness_notifyResponse_get_message_type, py_witness_notifyResponse_set_message_type },
369 { discard_const_p(char, "length"), py_witness_notifyResponse_get_length, py_witness_notifyResponse_set_length },
370 { discard_const_p(char, "num_messages"), py_witness_notifyResponse_get_num_messages, py_witness_notifyResponse_set_num_messages },
371 { discard_const_p(char, "message_buffer"), py_witness_notifyResponse_get_message_buffer, py_witness_notifyResponse_set_message_buffer },
375 static PyObject *py_witness_notifyResponse_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
377 return pytalloc_new(struct witness_notifyResponse, type);
381 static PyTypeObject witness_notifyResponse_Type = {
382 PyObject_HEAD_INIT(NULL) 0,
383 .tp_name = "witness.notifyResponse",
384 .tp_getset = py_witness_notifyResponse_getsetters,
386 .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
387 .tp_basicsize = sizeof(pytalloc_Object),
388 .tp_new = py_witness_notifyResponse_new,
392 static bool pack_py_witness_GetInterfaceList_args_in(PyObject *args, PyObject *kwargs, struct witness_GetInterfaceList *r)
394 const char *kwnames[] = {
398 if (!PyArg_ParseTupleAndKeywords(args, kwargs, ":witness_GetInterfaceList", discard_const_p(char *, kwnames))) {
405 static PyObject *unpack_py_witness_GetInterfaceList_args_out(struct witness_GetInterfaceList *r)
408 PyObject *py_interface_list;
409 if (*r->out.interface_list == NULL) {
410 py_interface_list = Py_None;
411 Py_INCREF(py_interface_list);
413 py_interface_list = pytalloc_reference_ex(&witness_interfaceList_Type, *r->out.interface_list, *r->out.interface_list);
415 result = py_interface_list;
416 if (!W_ERROR_IS_OK(r->out.result)) {
417 PyErr_SetWERROR(r->out.result);
424 static bool pack_py_witness_Register_args_in(PyObject *args, PyObject *kwargs, struct witness_Register *r)
426 PyObject *py_version;
427 PyObject *py_net_name;
428 PyObject *py_ip_address;
429 PyObject *py_client_computer_name;
430 const char *kwnames[] = {
431 "version", "net_name", "ip_address", "client_computer_name", NULL
434 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OOOO:witness_Register", discard_const_p(char *, kwnames), &py_version, &py_net_name, &py_ip_address, &py_client_computer_name)) {
438 if (PyLong_Check(py_version)) {
439 r->in.version = PyLong_AsLongLong(py_version);
440 } else if (PyInt_Check(py_version)) {
441 r->in.version = PyInt_AsLong(py_version);
443 PyErr_Format(PyExc_TypeError, "Expected type %s or %s",\
444 PyInt_Type.tp_name, PyLong_Type.tp_name);
447 if (py_net_name == Py_None) {
448 r->in.net_name = NULL;
450 r->in.net_name = NULL;
451 if (PyUnicode_Check(py_net_name)) {
452 r->in.net_name = PyString_AS_STRING(PyUnicode_AsEncodedString(py_net_name, "utf-8", "ignore"));
453 } else if (PyString_Check(py_net_name)) {
454 r->in.net_name = PyString_AS_STRING(py_net_name);
456 PyErr_Format(PyExc_TypeError, "Expected string or unicode object, got %s", Py_TYPE(py_net_name)->tp_name);
460 if (py_ip_address == Py_None) {
461 r->in.ip_address = NULL;
463 r->in.ip_address = NULL;
464 if (PyUnicode_Check(py_ip_address)) {
465 r->in.ip_address = PyString_AS_STRING(PyUnicode_AsEncodedString(py_ip_address, "utf-8", "ignore"));
466 } else if (PyString_Check(py_ip_address)) {
467 r->in.ip_address = PyString_AS_STRING(py_ip_address);
469 PyErr_Format(PyExc_TypeError, "Expected string or unicode object, got %s", Py_TYPE(py_ip_address)->tp_name);
473 if (py_client_computer_name == Py_None) {
474 r->in.client_computer_name = NULL;
476 r->in.client_computer_name = NULL;
477 if (PyUnicode_Check(py_client_computer_name)) {
478 r->in.client_computer_name = PyString_AS_STRING(PyUnicode_AsEncodedString(py_client_computer_name, "utf-8", "ignore"));
479 } else if (PyString_Check(py_client_computer_name)) {
480 r->in.client_computer_name = PyString_AS_STRING(py_client_computer_name);
482 PyErr_Format(PyExc_TypeError, "Expected string or unicode object, got %s", Py_TYPE(py_client_computer_name)->tp_name);
489 static PyObject *unpack_py_witness_Register_args_out(struct witness_Register *r)
492 PyObject *py_context_handle;
493 py_context_handle = pytalloc_reference_ex(policy_handle_Type, r->out.context_handle, r->out.context_handle);
494 result = py_context_handle;
495 if (!W_ERROR_IS_OK(r->out.result)) {
496 PyErr_SetWERROR(r->out.result);
503 static bool pack_py_witness_UnRegister_args_in(PyObject *args, PyObject *kwargs, struct witness_UnRegister *r)
505 PyObject *py_context_handle;
506 const char *kwnames[] = {
507 "context_handle", NULL
510 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:witness_UnRegister", discard_const_p(char *, kwnames), &py_context_handle)) {
514 PY_CHECK_TYPE(policy_handle_Type, py_context_handle, return false;);
515 if (talloc_reference(r, pytalloc_get_mem_ctx(py_context_handle)) == NULL) {
519 r->in.context_handle = *(struct policy_handle *)pytalloc_get_ptr(py_context_handle);
523 static PyObject *unpack_py_witness_UnRegister_args_out(struct witness_UnRegister *r)
528 if (!W_ERROR_IS_OK(r->out.result)) {
529 PyErr_SetWERROR(r->out.result);
536 static bool pack_py_witness_AsyncNotify_args_in(PyObject *args, PyObject *kwargs, struct witness_AsyncNotify *r)
538 PyObject *py_context_handle;
539 const char *kwnames[] = {
540 "context_handle", NULL
543 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:witness_AsyncNotify", discard_const_p(char *, kwnames), &py_context_handle)) {
547 PY_CHECK_TYPE(policy_handle_Type, py_context_handle, return false;);
548 if (talloc_reference(r, pytalloc_get_mem_ctx(py_context_handle)) == NULL) {
552 r->in.context_handle = *(struct policy_handle *)pytalloc_get_ptr(py_context_handle);
556 static PyObject *unpack_py_witness_AsyncNotify_args_out(struct witness_AsyncNotify *r)
559 PyObject *py_response;
560 if (*r->out.response == NULL) {
561 py_response = Py_None;
562 Py_INCREF(py_response);
564 py_response = pytalloc_reference_ex(&witness_notifyResponse_Type, *r->out.response, *r->out.response);
566 result = py_response;
567 if (!W_ERROR_IS_OK(r->out.result)) {
568 PyErr_SetWERROR(r->out.result);
575 static bool pack_py_witness_RegisterEx_args_in(PyObject *args, PyObject *kwargs, struct witness_RegisterEx *r)
577 PyObject *py_version;
578 PyObject *py_net_name;
579 PyObject *py_share_name;
580 PyObject *py_ip_address;
581 PyObject *py_client_computer_name;
583 PyObject *py_timeout;
584 const char *kwnames[] = {
585 "version", "net_name", "share_name", "ip_address", "client_computer_name", "flags", "timeout", NULL
588 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OOOOOOO:witness_RegisterEx", discard_const_p(char *, kwnames), &py_version, &py_net_name, &py_share_name, &py_ip_address, &py_client_computer_name, &py_flags, &py_timeout)) {
592 if (PyLong_Check(py_version)) {
593 r->in.version = PyLong_AsLongLong(py_version);
594 } else if (PyInt_Check(py_version)) {
595 r->in.version = PyInt_AsLong(py_version);
597 PyErr_Format(PyExc_TypeError, "Expected type %s or %s",\
598 PyInt_Type.tp_name, PyLong_Type.tp_name);
601 if (py_net_name == Py_None) {
602 r->in.net_name = NULL;
604 r->in.net_name = NULL;
605 if (PyUnicode_Check(py_net_name)) {
606 r->in.net_name = PyString_AS_STRING(PyUnicode_AsEncodedString(py_net_name, "utf-8", "ignore"));
607 } else if (PyString_Check(py_net_name)) {
608 r->in.net_name = PyString_AS_STRING(py_net_name);
610 PyErr_Format(PyExc_TypeError, "Expected string or unicode object, got %s", Py_TYPE(py_net_name)->tp_name);
614 if (py_share_name == Py_None) {
615 r->in.share_name = NULL;
617 r->in.share_name = NULL;
618 if (PyUnicode_Check(py_share_name)) {
619 r->in.share_name = PyString_AS_STRING(PyUnicode_AsEncodedString(py_share_name, "utf-8", "ignore"));
620 } else if (PyString_Check(py_share_name)) {
621 r->in.share_name = PyString_AS_STRING(py_share_name);
623 PyErr_Format(PyExc_TypeError, "Expected string or unicode object, got %s", Py_TYPE(py_share_name)->tp_name);
627 if (py_ip_address == Py_None) {
628 r->in.ip_address = NULL;
630 r->in.ip_address = NULL;
631 if (PyUnicode_Check(py_ip_address)) {
632 r->in.ip_address = PyString_AS_STRING(PyUnicode_AsEncodedString(py_ip_address, "utf-8", "ignore"));
633 } else if (PyString_Check(py_ip_address)) {
634 r->in.ip_address = PyString_AS_STRING(py_ip_address);
636 PyErr_Format(PyExc_TypeError, "Expected string or unicode object, got %s", Py_TYPE(py_ip_address)->tp_name);
640 if (py_client_computer_name == Py_None) {
641 r->in.client_computer_name = NULL;
643 r->in.client_computer_name = NULL;
644 if (PyUnicode_Check(py_client_computer_name)) {
645 r->in.client_computer_name = PyString_AS_STRING(PyUnicode_AsEncodedString(py_client_computer_name, "utf-8", "ignore"));
646 } else if (PyString_Check(py_client_computer_name)) {
647 r->in.client_computer_name = PyString_AS_STRING(py_client_computer_name);
649 PyErr_Format(PyExc_TypeError, "Expected string or unicode object, got %s", Py_TYPE(py_client_computer_name)->tp_name);
653 if (PyLong_Check(py_flags)) {
654 r->in.flags = PyLong_AsLongLong(py_flags);
655 } else if (PyInt_Check(py_flags)) {
656 r->in.flags = PyInt_AsLong(py_flags);
658 PyErr_Format(PyExc_TypeError, "Expected type %s or %s",\
659 PyInt_Type.tp_name, PyLong_Type.tp_name);
662 PY_CHECK_TYPE(&PyInt_Type, py_timeout, return false;);
663 r->in.timeout = PyInt_AsLong(py_timeout);
667 static PyObject *unpack_py_witness_RegisterEx_args_out(struct witness_RegisterEx *r)
670 PyObject *py_context_handle;
671 py_context_handle = pytalloc_reference_ex(policy_handle_Type, r->out.context_handle, r->out.context_handle);
672 result = py_context_handle;
673 if (!W_ERROR_IS_OK(r->out.result)) {
674 PyErr_SetWERROR(r->out.result);
681 const struct PyNdrRpcMethodDef py_ndr_witness_methods[] = {
682 { "GetInterfaceList", "S.GetInterfaceList() -> interface_list", (py_dcerpc_call_fn)dcerpc_witness_GetInterfaceList_r, (py_data_pack_fn)pack_py_witness_GetInterfaceList_args_in, (py_data_unpack_fn)unpack_py_witness_GetInterfaceList_args_out, 0, &ndr_table_witness },
683 { "Register", "S.Register(version, net_name, ip_address, client_computer_name) -> context_handle", (py_dcerpc_call_fn)dcerpc_witness_Register_r, (py_data_pack_fn)pack_py_witness_Register_args_in, (py_data_unpack_fn)unpack_py_witness_Register_args_out, 1, &ndr_table_witness },
684 { "UnRegister", "S.UnRegister(context_handle) -> None", (py_dcerpc_call_fn)dcerpc_witness_UnRegister_r, (py_data_pack_fn)pack_py_witness_UnRegister_args_in, (py_data_unpack_fn)unpack_py_witness_UnRegister_args_out, 2, &ndr_table_witness },
685 { "AsyncNotify", "S.AsyncNotify(context_handle) -> response", (py_dcerpc_call_fn)dcerpc_witness_AsyncNotify_r, (py_data_pack_fn)pack_py_witness_AsyncNotify_args_in, (py_data_unpack_fn)unpack_py_witness_AsyncNotify_args_out, 3, &ndr_table_witness },
686 { "RegisterEx", "S.RegisterEx(version, net_name, share_name, ip_address, client_computer_name, flags, timeout) -> context_handle", (py_dcerpc_call_fn)dcerpc_witness_RegisterEx_r, (py_data_pack_fn)pack_py_witness_RegisterEx_args_in, (py_data_unpack_fn)unpack_py_witness_RegisterEx_args_out, 4, &ndr_table_witness },
690 static PyObject *interface_witness_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
692 return py_dcerpc_interface_init_helper(type, args, kwargs, &ndr_table_witness);
695 #define PY_DOC_WITNESS "SMB Witness Service"
696 static PyTypeObject witness_InterfaceType = {
697 PyObject_HEAD_INIT(NULL) 0,
698 .tp_name = "witness.witness",
699 .tp_basicsize = sizeof(dcerpc_InterfaceObject),
700 .tp_doc = "witness(binding, lp_ctx=None, credentials=None) -> connection\n"
702 "binding should be a DCE/RPC binding string (for example: ncacn_ip_tcp:127.0.0.1)\n"
703 "lp_ctx should be a path to a smb.conf file or a param.LoadParm object\n"
704 "credentials should be a credentials.Credentials object.\n\n"PY_DOC_WITNESS,
705 .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
706 .tp_new = interface_witness_new,
709 static PyObject *syntax_witness_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
711 return py_dcerpc_syntax_init_helper(type, args, kwargs, &ndr_table_witness.syntax_id);
714 #define PY_DOC_WITNESS_SYNTAX "SMB Witness Service"
715 static PyTypeObject witness_SyntaxType = {
716 PyObject_HEAD_INIT(NULL) 0,
717 .tp_name = "witness.witness",
718 .tp_basicsize = sizeof(pytalloc_Object),
719 .tp_doc = "abstract_syntax()\n"PY_DOC_WITNESS_SYNTAX,
720 .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
721 .tp_new = syntax_witness_new,
724 static PyMethodDef witness_methods[] = {
725 { NULL, NULL, 0, NULL }
728 void initwitness(void)
731 PyObject *dep_samba_dcerpc_misc;
732 PyObject *dep_talloc;
733 PyObject *dep_samba_dcerpc_base;
735 dep_samba_dcerpc_misc = PyImport_ImportModule("samba.dcerpc.misc");
736 if (dep_samba_dcerpc_misc == NULL)
739 dep_talloc = PyImport_ImportModule("talloc");
740 if (dep_talloc == NULL)
743 dep_samba_dcerpc_base = PyImport_ImportModule("samba.dcerpc.base");
744 if (dep_samba_dcerpc_base == NULL)
747 Object_Type = (PyTypeObject *)PyObject_GetAttrString(dep_talloc, "Object");
748 if (Object_Type == NULL)
751 policy_handle_Type = (PyTypeObject *)PyObject_GetAttrString(dep_samba_dcerpc_misc, "policy_handle");
752 if (policy_handle_Type == NULL)
755 ClientConnection_Type = (PyTypeObject *)PyObject_GetAttrString(dep_samba_dcerpc_base, "ClientConnection");
756 if (ClientConnection_Type == NULL)
759 ndr_syntax_id_Type = (PyTypeObject *)PyObject_GetAttrString(dep_samba_dcerpc_misc, "ndr_syntax_id");
760 if (ndr_syntax_id_Type == NULL)
763 witness_interfaceInfo_Type.tp_base = Object_Type;
765 witness_interfaceList_Type.tp_base = Object_Type;
767 witness_notifyResponse_Type.tp_base = Object_Type;
769 witness_InterfaceType.tp_base = ClientConnection_Type;
771 witness_SyntaxType.tp_base = ndr_syntax_id_Type;
773 if (PyType_Ready(&witness_interfaceInfo_Type) < 0)
775 if (PyType_Ready(&witness_interfaceList_Type) < 0)
777 if (PyType_Ready(&witness_notifyResponse_Type) < 0)
779 if (PyType_Ready(&witness_InterfaceType) < 0)
781 if (PyType_Ready(&witness_SyntaxType) < 0)
783 if (!PyInterface_AddNdrRpcMethods(&witness_InterfaceType, py_ndr_witness_methods))
786 #ifdef PY_INTERFACEINFO_PATCH
787 PY_INTERFACEINFO_PATCH(&witness_interfaceInfo_Type);
789 #ifdef PY_INTERFACELIST_PATCH
790 PY_INTERFACELIST_PATCH(&witness_interfaceList_Type);
792 #ifdef PY_NOTIFYRESPONSE_PATCH
793 PY_NOTIFYRESPONSE_PATCH(&witness_notifyResponse_Type);
795 #ifdef PY_WITNESS_PATCH
796 PY_WITNESS_PATCH(&witness_InterfaceType);
798 #ifdef PY_ABSTRACT_SYNTAX_PATCH
799 PY_ABSTRACT_SYNTAX_PATCH(&witness_SyntaxType);
802 m = Py_InitModule3("witness", witness_methods, "witness DCE/RPC");
806 PyModule_AddObject(m, "WITNESS_V1", PyInt_FromLong(WITNESS_V1));
807 PyModule_AddObject(m, "WITNESS_V2", PyInt_FromLong(WITNESS_V2));
808 PyModule_AddObject(m, "WITNESS_STATE_UNKNOWN", PyInt_FromLong(WITNESS_STATE_UNKNOWN));
809 PyModule_AddObject(m, "WITNESS_STATE_AVAILABLE", PyInt_FromLong(WITNESS_STATE_AVAILABLE));
810 PyModule_AddObject(m, "WITNESS_STATE_UNAVAILABLE", PyInt_FromLong(WITNESS_STATE_UNAVAILABLE));
811 PyModule_AddObject(m, "WITNESS_INFO_IPv4_VALID", PyInt_FromLong(WITNESS_INFO_IPv4_VALID));
812 PyModule_AddObject(m, "WITNESS_INFO_IPv6_VALID", PyInt_FromLong(WITNESS_INFO_IPv6_VALID));
813 PyModule_AddObject(m, "WITNESS_INFO_WITNESS_IF", PyInt_FromLong(WITNESS_INFO_WITNESS_IF));
814 PyModule_AddObject(m, "WITNESS_NOTIFY_RESOURCE_CHANGE", PyInt_FromLong(WITNESS_NOTIFY_RESOURCE_CHANGE));
815 PyModule_AddObject(m, "WITNESS_NOTIFY_CLIENT_MOVE", PyInt_FromLong(WITNESS_NOTIFY_CLIENT_MOVE));
816 PyModule_AddObject(m, "WITNESS_NOTIFY_SHARE_MOVE", PyInt_FromLong(WITNESS_NOTIFY_SHARE_MOVE));
817 PyModule_AddObject(m, "WITNESS_NOTIFY_IP_CHANGE", PyInt_FromLong(WITNESS_NOTIFY_IP_CHANGE));
818 PyModule_AddObject(m, "WITNESS_REGISTER_NONE", PyInt_FromLong(WITNESS_REGISTER_NONE));
819 PyModule_AddObject(m, "WITNESS_REGISTER_IP_NOTIFICATION", PyInt_FromLong(WITNESS_REGISTER_IP_NOTIFICATION));
820 Py_INCREF((PyObject *)(void *)&witness_interfaceInfo_Type);
821 PyModule_AddObject(m, "interfaceInfo", (PyObject *)(void *)&witness_interfaceInfo_Type);
822 Py_INCREF((PyObject *)(void *)&witness_interfaceList_Type);
823 PyModule_AddObject(m, "interfaceList", (PyObject *)(void *)&witness_interfaceList_Type);
824 Py_INCREF((PyObject *)(void *)&witness_notifyResponse_Type);
825 PyModule_AddObject(m, "notifyResponse", (PyObject *)(void *)&witness_notifyResponse_Type);
826 Py_INCREF((PyObject *)(void *)&witness_InterfaceType);
827 PyModule_AddObject(m, "witness", (PyObject *)(void *)&witness_InterfaceType);
828 Py_INCREF((PyObject *)(void *)&witness_SyntaxType);
829 PyModule_AddObject(m, "abstract_syntax", (PyObject *)(void *)&witness_SyntaxType);
830 #ifdef PY_MOD_WITNESS_PATCH
831 PY_MOD_WITNESS_PATCH(m);