2 /* Python wrapper functions auto-generated by pidl */
3 #define PY_SSIZE_T_CLEAN 1 /* We use Py_ssize_t for PyArg_ParseTupleAndKeywords */
7 #include "librpc/rpc/pyrpc.h"
8 #include "librpc/rpc/pyrpc_util.h"
9 #include "bin/default/librpc/gen_ndr/ndr_witness.h"
10 #include "bin/default/librpc/gen_ndr/ndr_witness_c.h"
13 * These functions are here to ensure they can be optimized out by
14 * the compiler based on the constant input values
17 static inline unsigned long long ndr_sizeof2uintmax(size_t var_size)
33 static inline long long ndr_sizeof2intmax(size_t var_size)
49 static inline PyObject *ndr_PyLong_FromLongLong(long long v)
51 if (v > LONG_MAX || v < LONG_MIN) {
52 return PyLong_FromLongLong(v);
54 return PyInt_FromLong(v);
58 static inline PyObject *ndr_PyLong_FromUnsignedLongLong(unsigned long long v)
61 return PyLong_FromUnsignedLongLong(v);
63 return PyInt_FromLong(v);
67 #include "librpc/gen_ndr/misc.h"
68 static PyTypeObject witness_interfaceInfo_Type;
69 static PyTypeObject witness_interfaceList_Type;
70 static PyTypeObject witness_ResourceChange_Type;
71 static PyTypeObject witness_IPaddrInfo_Type;
72 static PyTypeObject witness_IPaddrInfoList_Type;
73 PyObject *py_import_witness_notifyResponse_message(TALLOC_CTX *mem_ctx, int level, union witness_notifyResponse_message *in);
74 union witness_notifyResponse_message *py_export_witness_notifyResponse_message(TALLOC_CTX *mem_ctx, int level, PyObject *in);
75 static PyTypeObject witness_notifyResponse_Type;
76 static PyTypeObject witness_InterfaceType;
78 void initwitness(void);static PyTypeObject *BaseObject_Type;
79 static PyTypeObject *policy_handle_Type;
80 static PyTypeObject *ClientConnection_Type;
81 static PyTypeObject *ndr_syntax_id_Type;
83 static PyObject *py_witness_interfaceInfo_get_group_name(PyObject *obj, void *closure)
85 struct witness_interfaceInfo *object = (struct witness_interfaceInfo *)pytalloc_get_ptr(obj);
86 PyObject *py_group_name;
87 if (object->group_name == NULL) {
88 py_group_name = Py_None;
89 Py_INCREF(py_group_name);
91 py_group_name = PyUnicode_Decode(object->group_name, strlen(object->group_name), "utf-8", "ignore");
96 static int py_witness_interfaceInfo_set_group_name(PyObject *py_obj, PyObject *value, void *closure)
98 struct witness_interfaceInfo *object = (struct witness_interfaceInfo *)pytalloc_get_ptr(py_obj);
100 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->group_name");
104 const char *test_str;
105 const char *talloc_str;
106 PyObject *unicode = NULL;
107 if (PyUnicode_Check(value)) {
108 unicode = PyUnicode_AsEncodedString(value, "utf-8", "ignore");
109 if (unicode == NULL) {
113 test_str = PyString_AS_STRING(unicode);
114 } else if (PyString_Check(value)) {
115 test_str = PyString_AS_STRING(value);
117 PyErr_Format(PyExc_TypeError, "Expected string or unicode object, got %s", Py_TYPE(value)->tp_name);
120 talloc_str = talloc_strdup(pytalloc_get_mem_ctx(py_obj), test_str);
121 if (unicode != NULL) {
124 if (talloc_str == NULL) {
128 object->group_name = talloc_str;
133 static PyObject *py_witness_interfaceInfo_get_version(PyObject *obj, void *closure)
135 struct witness_interfaceInfo *object = (struct witness_interfaceInfo *)pytalloc_get_ptr(obj);
136 PyObject *py_version;
137 py_version = ndr_PyLong_FromUnsignedLongLong((uint32_t)object->version);
141 static int py_witness_interfaceInfo_set_version(PyObject *py_obj, PyObject *value, void *closure)
143 struct witness_interfaceInfo *object = (struct witness_interfaceInfo *)pytalloc_get_ptr(py_obj);
145 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->version");
149 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->version));
150 if (PyLong_Check(value)) {
151 unsigned long long test_var;
152 test_var = PyLong_AsUnsignedLongLong(value);
153 if (PyErr_Occurred() != NULL) {
156 if (test_var > uint_max) {
157 PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %llu",\
158 PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
161 object->version = test_var;
162 } else if (PyInt_Check(value)) {
164 test_var = PyInt_AsLong(value);
165 if (test_var < 0 || test_var > uint_max) {
166 PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %ld",\
167 PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
170 object->version = test_var;
172 PyErr_Format(PyExc_TypeError, "Expected type %s or %s",\
173 PyInt_Type.tp_name, PyLong_Type.tp_name);
180 static PyObject *py_witness_interfaceInfo_get_state(PyObject *obj, void *closure)
182 struct witness_interfaceInfo *object = (struct witness_interfaceInfo *)pytalloc_get_ptr(obj);
184 py_state = PyInt_FromLong((uint16_t)object->state);
188 static int py_witness_interfaceInfo_set_state(PyObject *py_obj, PyObject *value, void *closure)
190 struct witness_interfaceInfo *object = (struct witness_interfaceInfo *)pytalloc_get_ptr(py_obj);
192 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->state");
196 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->state));
197 if (PyLong_Check(value)) {
198 unsigned long long test_var;
199 test_var = PyLong_AsUnsignedLongLong(value);
200 if (PyErr_Occurred() != NULL) {
203 if (test_var > uint_max) {
204 PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %llu",\
205 PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
208 object->state = test_var;
209 } else if (PyInt_Check(value)) {
211 test_var = PyInt_AsLong(value);
212 if (test_var < 0 || test_var > uint_max) {
213 PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %ld",\
214 PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
217 object->state = test_var;
219 PyErr_Format(PyExc_TypeError, "Expected type %s or %s",\
220 PyInt_Type.tp_name, PyLong_Type.tp_name);
227 static PyObject *py_witness_interfaceInfo_get_ipv4(PyObject *obj, void *closure)
229 struct witness_interfaceInfo *object = (struct witness_interfaceInfo *)pytalloc_get_ptr(obj);
231 py_ipv4 = PyString_FromStringOrNULL(object->ipv4);
235 static int py_witness_interfaceInfo_set_ipv4(PyObject *py_obj, PyObject *value, void *closure)
237 struct witness_interfaceInfo *object = (struct witness_interfaceInfo *)pytalloc_get_ptr(py_obj);
239 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->ipv4");
243 const char *test_str;
244 const char *talloc_str;
245 PyObject *unicode = NULL;
246 if (PyUnicode_Check(value)) {
247 unicode = PyUnicode_AsEncodedString(value, "utf-8", "ignore");
248 if (unicode == NULL) {
252 test_str = PyString_AS_STRING(unicode);
253 } else if (PyString_Check(value)) {
254 test_str = PyString_AS_STRING(value);
256 PyErr_Format(PyExc_TypeError, "Expected string or unicode object, got %s", Py_TYPE(value)->tp_name);
259 talloc_str = talloc_strdup(pytalloc_get_mem_ctx(py_obj), test_str);
260 if (unicode != NULL) {
263 if (talloc_str == NULL) {
267 object->ipv4 = talloc_str;
272 static PyObject *py_witness_interfaceInfo_get_ipv6(PyObject *obj, void *closure)
274 struct witness_interfaceInfo *object = (struct witness_interfaceInfo *)pytalloc_get_ptr(obj);
276 py_ipv6 = PyString_FromStringOrNULL(object->ipv6);
280 static int py_witness_interfaceInfo_set_ipv6(PyObject *py_obj, PyObject *value, void *closure)
282 struct witness_interfaceInfo *object = (struct witness_interfaceInfo *)pytalloc_get_ptr(py_obj);
284 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->ipv6");
288 const char *test_str;
289 const char *talloc_str;
290 PyObject *unicode = NULL;
291 if (PyUnicode_Check(value)) {
292 unicode = PyUnicode_AsEncodedString(value, "utf-8", "ignore");
293 if (unicode == NULL) {
297 test_str = PyString_AS_STRING(unicode);
298 } else if (PyString_Check(value)) {
299 test_str = PyString_AS_STRING(value);
301 PyErr_Format(PyExc_TypeError, "Expected string or unicode object, got %s", Py_TYPE(value)->tp_name);
304 talloc_str = talloc_strdup(pytalloc_get_mem_ctx(py_obj), test_str);
305 if (unicode != NULL) {
308 if (talloc_str == NULL) {
312 object->ipv6 = talloc_str;
317 static PyObject *py_witness_interfaceInfo_get_flags(PyObject *obj, void *closure)
319 struct witness_interfaceInfo *object = (struct witness_interfaceInfo *)pytalloc_get_ptr(obj);
321 py_flags = ndr_PyLong_FromUnsignedLongLong((uint32_t)object->flags);
325 static int py_witness_interfaceInfo_set_flags(PyObject *py_obj, PyObject *value, void *closure)
327 struct witness_interfaceInfo *object = (struct witness_interfaceInfo *)pytalloc_get_ptr(py_obj);
329 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->flags");
333 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->flags));
334 if (PyLong_Check(value)) {
335 unsigned long long test_var;
336 test_var = PyLong_AsUnsignedLongLong(value);
337 if (PyErr_Occurred() != NULL) {
340 if (test_var > uint_max) {
341 PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %llu",\
342 PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
345 object->flags = test_var;
346 } else if (PyInt_Check(value)) {
348 test_var = PyInt_AsLong(value);
349 if (test_var < 0 || test_var > uint_max) {
350 PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %ld",\
351 PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
354 object->flags = test_var;
356 PyErr_Format(PyExc_TypeError, "Expected type %s or %s",\
357 PyInt_Type.tp_name, PyLong_Type.tp_name);
364 static PyGetSetDef py_witness_interfaceInfo_getsetters[] = {
366 .name = discard_const_p(char, "group_name"),
367 .get = py_witness_interfaceInfo_get_group_name,
368 .set = py_witness_interfaceInfo_set_group_name,
369 .doc = discard_const_p(char, "PIDL-generated element group_name")
372 .name = discard_const_p(char, "version"),
373 .get = py_witness_interfaceInfo_get_version,
374 .set = py_witness_interfaceInfo_set_version,
375 .doc = discard_const_p(char, "PIDL-generated element version")
378 .name = discard_const_p(char, "state"),
379 .get = py_witness_interfaceInfo_get_state,
380 .set = py_witness_interfaceInfo_set_state,
381 .doc = discard_const_p(char, "PIDL-generated element state")
384 .name = discard_const_p(char, "ipv4"),
385 .get = py_witness_interfaceInfo_get_ipv4,
386 .set = py_witness_interfaceInfo_set_ipv4,
387 .doc = discard_const_p(char, "PIDL-generated element ipv4")
390 .name = discard_const_p(char, "ipv6"),
391 .get = py_witness_interfaceInfo_get_ipv6,
392 .set = py_witness_interfaceInfo_set_ipv6,
393 .doc = discard_const_p(char, "PIDL-generated element ipv6")
396 .name = discard_const_p(char, "flags"),
397 .get = py_witness_interfaceInfo_get_flags,
398 .set = py_witness_interfaceInfo_set_flags,
399 .doc = discard_const_p(char, "PIDL-generated element flags")
404 static PyObject *py_witness_interfaceInfo_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
406 return pytalloc_new(struct witness_interfaceInfo, type);
410 static PyTypeObject witness_interfaceInfo_Type = {
411 PyObject_HEAD_INIT(NULL) 0,
412 .tp_name = "witness.interfaceInfo",
413 .tp_getset = py_witness_interfaceInfo_getsetters,
415 .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
416 .tp_new = py_witness_interfaceInfo_new,
420 static PyObject *py_witness_interfaceList_get_num_interfaces(PyObject *obj, void *closure)
422 struct witness_interfaceList *object = (struct witness_interfaceList *)pytalloc_get_ptr(obj);
423 PyObject *py_num_interfaces;
424 py_num_interfaces = ndr_PyLong_FromUnsignedLongLong((uint32_t)object->num_interfaces);
425 return py_num_interfaces;
428 static int py_witness_interfaceList_set_num_interfaces(PyObject *py_obj, PyObject *value, void *closure)
430 struct witness_interfaceList *object = (struct witness_interfaceList *)pytalloc_get_ptr(py_obj);
432 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->num_interfaces");
436 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->num_interfaces));
437 if (PyLong_Check(value)) {
438 unsigned long long test_var;
439 test_var = PyLong_AsUnsignedLongLong(value);
440 if (PyErr_Occurred() != NULL) {
443 if (test_var > uint_max) {
444 PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %llu",\
445 PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
448 object->num_interfaces = test_var;
449 } else if (PyInt_Check(value)) {
451 test_var = PyInt_AsLong(value);
452 if (test_var < 0 || test_var > uint_max) {
453 PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %ld",\
454 PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
457 object->num_interfaces = test_var;
459 PyErr_Format(PyExc_TypeError, "Expected type %s or %s",\
460 PyInt_Type.tp_name, PyLong_Type.tp_name);
467 static PyObject *py_witness_interfaceList_get_interfaces(PyObject *obj, void *closure)
469 struct witness_interfaceList *object = (struct witness_interfaceList *)pytalloc_get_ptr(obj);
470 PyObject *py_interfaces;
471 if (object->interfaces == NULL) {
472 py_interfaces = Py_None;
473 Py_INCREF(py_interfaces);
475 py_interfaces = PyList_New(object->num_interfaces);
476 if (py_interfaces == NULL) {
480 int interfaces_cntr_1;
481 for (interfaces_cntr_1 = 0; interfaces_cntr_1 < (object->num_interfaces); interfaces_cntr_1++) {
482 PyObject *py_interfaces_1;
483 py_interfaces_1 = pytalloc_reference_ex(&witness_interfaceInfo_Type, object->interfaces, &object->interfaces[interfaces_cntr_1]);
484 PyList_SetItem(py_interfaces, interfaces_cntr_1, py_interfaces_1);
488 return py_interfaces;
491 static int py_witness_interfaceList_set_interfaces(PyObject *py_obj, PyObject *value, void *closure)
493 struct witness_interfaceList *object = (struct witness_interfaceList *)pytalloc_get_ptr(py_obj);
494 talloc_unlink(pytalloc_get_mem_ctx(py_obj), discard_const(object->interfaces));
496 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->interfaces");
499 if (value == Py_None) {
500 object->interfaces = NULL;
502 object->interfaces = NULL;
504 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct *object->interfaces");
507 PY_CHECK_TYPE(&PyList_Type, value, return -1;);
509 int interfaces_cntr_1;
510 object->interfaces = talloc_array_ptrtype(pytalloc_get_mem_ctx(py_obj), object->interfaces, PyList_GET_SIZE(value));
511 if (!object->interfaces) { return -1;; }
512 talloc_set_name_const(object->interfaces, "ARRAY: object->interfaces");
513 for (interfaces_cntr_1 = 0; interfaces_cntr_1 < PyList_GET_SIZE(value); interfaces_cntr_1++) {
514 if (PyList_GET_ITEM(value, interfaces_cntr_1) == NULL) {
515 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->interfaces[interfaces_cntr_1]");
518 PY_CHECK_TYPE(&witness_interfaceInfo_Type, PyList_GET_ITEM(value, interfaces_cntr_1), return -1;);
519 if (talloc_reference(object->interfaces, pytalloc_get_mem_ctx(PyList_GET_ITEM(value, interfaces_cntr_1))) == NULL) {
523 object->interfaces[interfaces_cntr_1] = *(struct witness_interfaceInfo *)pytalloc_get_ptr(PyList_GET_ITEM(value, interfaces_cntr_1));
530 static PyGetSetDef py_witness_interfaceList_getsetters[] = {
532 .name = discard_const_p(char, "num_interfaces"),
533 .get = py_witness_interfaceList_get_num_interfaces,
534 .set = py_witness_interfaceList_set_num_interfaces,
535 .doc = discard_const_p(char, "PIDL-generated element num_interfaces")
538 .name = discard_const_p(char, "interfaces"),
539 .get = py_witness_interfaceList_get_interfaces,
540 .set = py_witness_interfaceList_set_interfaces,
541 .doc = discard_const_p(char, "PIDL-generated element interfaces")
546 static PyObject *py_witness_interfaceList_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
548 return pytalloc_new(struct witness_interfaceList, type);
552 static PyTypeObject witness_interfaceList_Type = {
553 PyObject_HEAD_INIT(NULL) 0,
554 .tp_name = "witness.interfaceList",
555 .tp_getset = py_witness_interfaceList_getsetters,
557 .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
558 .tp_new = py_witness_interfaceList_new,
562 static PyObject *py_witness_ResourceChange_get_length(PyObject *obj, void *closure)
564 struct witness_ResourceChange *object = (struct witness_ResourceChange *)pytalloc_get_ptr(obj);
566 py_length = ndr_PyLong_FromUnsignedLongLong((uint32_t)object->length);
570 static int py_witness_ResourceChange_set_length(PyObject *py_obj, PyObject *value, void *closure)
572 struct witness_ResourceChange *object = (struct witness_ResourceChange *)pytalloc_get_ptr(py_obj);
574 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->length");
578 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->length));
579 if (PyLong_Check(value)) {
580 unsigned long long test_var;
581 test_var = PyLong_AsUnsignedLongLong(value);
582 if (PyErr_Occurred() != NULL) {
585 if (test_var > uint_max) {
586 PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %llu",\
587 PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
590 object->length = test_var;
591 } else if (PyInt_Check(value)) {
593 test_var = PyInt_AsLong(value);
594 if (test_var < 0 || test_var > uint_max) {
595 PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %ld",\
596 PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
599 object->length = test_var;
601 PyErr_Format(PyExc_TypeError, "Expected type %s or %s",\
602 PyInt_Type.tp_name, PyLong_Type.tp_name);
609 static PyObject *py_witness_ResourceChange_get_type(PyObject *obj, void *closure)
611 struct witness_ResourceChange *object = (struct witness_ResourceChange *)pytalloc_get_ptr(obj);
613 py_type = ndr_PyLong_FromUnsignedLongLong((uint32_t)object->type);
617 static int py_witness_ResourceChange_set_type(PyObject *py_obj, PyObject *value, void *closure)
619 struct witness_ResourceChange *object = (struct witness_ResourceChange *)pytalloc_get_ptr(py_obj);
621 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->type");
625 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->type));
626 if (PyLong_Check(value)) {
627 unsigned long long test_var;
628 test_var = PyLong_AsUnsignedLongLong(value);
629 if (PyErr_Occurred() != NULL) {
632 if (test_var > uint_max) {
633 PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %llu",\
634 PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
637 object->type = test_var;
638 } else if (PyInt_Check(value)) {
640 test_var = PyInt_AsLong(value);
641 if (test_var < 0 || test_var > uint_max) {
642 PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %ld",\
643 PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
646 object->type = test_var;
648 PyErr_Format(PyExc_TypeError, "Expected type %s or %s",\
649 PyInt_Type.tp_name, PyLong_Type.tp_name);
656 static PyObject *py_witness_ResourceChange_get_name(PyObject *obj, void *closure)
658 struct witness_ResourceChange *object = (struct witness_ResourceChange *)pytalloc_get_ptr(obj);
660 py_name = PyString_FromStringOrNULL(object->name);
664 static int py_witness_ResourceChange_set_name(PyObject *py_obj, PyObject *value, void *closure)
666 struct witness_ResourceChange *object = (struct witness_ResourceChange *)pytalloc_get_ptr(py_obj);
668 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->name");
672 const char *test_str;
673 const char *talloc_str;
674 PyObject *unicode = NULL;
675 if (PyUnicode_Check(value)) {
676 unicode = PyUnicode_AsEncodedString(value, "utf-8", "ignore");
677 if (unicode == NULL) {
681 test_str = PyString_AS_STRING(unicode);
682 } else if (PyString_Check(value)) {
683 test_str = PyString_AS_STRING(value);
685 PyErr_Format(PyExc_TypeError, "Expected string or unicode object, got %s", Py_TYPE(value)->tp_name);
688 talloc_str = talloc_strdup(pytalloc_get_mem_ctx(py_obj), test_str);
689 if (unicode != NULL) {
692 if (talloc_str == NULL) {
696 object->name = talloc_str;
701 static PyGetSetDef py_witness_ResourceChange_getsetters[] = {
703 .name = discard_const_p(char, "length"),
704 .get = py_witness_ResourceChange_get_length,
705 .set = py_witness_ResourceChange_set_length,
706 .doc = discard_const_p(char, "PIDL-generated element length")
709 .name = discard_const_p(char, "type"),
710 .get = py_witness_ResourceChange_get_type,
711 .set = py_witness_ResourceChange_set_type,
712 .doc = discard_const_p(char, "PIDL-generated element type")
715 .name = discard_const_p(char, "name"),
716 .get = py_witness_ResourceChange_get_name,
717 .set = py_witness_ResourceChange_set_name,
718 .doc = discard_const_p(char, "PIDL-generated element name")
723 static PyObject *py_witness_ResourceChange_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
725 return pytalloc_new(struct witness_ResourceChange, type);
728 static PyObject *py_witness_ResourceChange_ndr_pack(PyObject *py_obj)
730 struct witness_ResourceChange *object = (struct witness_ResourceChange *)pytalloc_get_ptr(py_obj);
731 PyObject *ret = NULL;
733 enum ndr_err_code err;
734 TALLOC_CTX *tmp_ctx = talloc_new(pytalloc_get_mem_ctx(py_obj));
735 if (tmp_ctx == NULL) {
736 PyErr_SetNdrError(NDR_ERR_ALLOC);
739 err = ndr_push_struct_blob(&blob, tmp_ctx, object, (ndr_push_flags_fn_t)ndr_push_witness_ResourceChange);
740 if (err != NDR_ERR_SUCCESS) {
741 TALLOC_FREE(tmp_ctx);
742 PyErr_SetNdrError(err);
746 ret = PyString_FromStringAndSize((char *)blob.data, blob.length);
747 TALLOC_FREE(tmp_ctx);
751 static PyObject *py_witness_ResourceChange_ndr_unpack(PyObject *py_obj, PyObject *args, PyObject *kwargs)
753 struct witness_ResourceChange *object = (struct witness_ResourceChange *)pytalloc_get_ptr(py_obj);
755 Py_ssize_t blob_length = 0;
756 enum ndr_err_code err;
757 const char * const kwnames[] = { "data_blob", "allow_remaining", NULL };
758 PyObject *allow_remaining_obj = NULL;
759 bool allow_remaining = false;
761 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s#|O:__ndr_unpack__",
762 discard_const_p(char *, kwnames),
763 &blob.data, &blob_length,
764 &allow_remaining_obj)) {
767 blob.length = blob_length;
769 if (allow_remaining_obj && PyObject_IsTrue(allow_remaining_obj)) {
770 allow_remaining = true;
773 if (allow_remaining) {
774 err = ndr_pull_struct_blob(&blob, pytalloc_get_mem_ctx(py_obj), object, (ndr_pull_flags_fn_t)ndr_pull_witness_ResourceChange);
776 err = ndr_pull_struct_blob_all(&blob, pytalloc_get_mem_ctx(py_obj), object, (ndr_pull_flags_fn_t)ndr_pull_witness_ResourceChange);
778 if (err != NDR_ERR_SUCCESS) {
779 PyErr_SetNdrError(err);
786 static PyObject *py_witness_ResourceChange_ndr_print(PyObject *py_obj)
788 struct witness_ResourceChange *object = (struct witness_ResourceChange *)pytalloc_get_ptr(py_obj);
792 retstr = ndr_print_struct_string(pytalloc_get_mem_ctx(py_obj), (ndr_print_fn_t)ndr_print_witness_ResourceChange, "witness_ResourceChange", object);
793 ret = PyString_FromString(retstr);
799 static PyMethodDef py_witness_ResourceChange_methods[] = {
800 { "__ndr_pack__", (PyCFunction)py_witness_ResourceChange_ndr_pack, METH_NOARGS, "S.ndr_pack(object) -> blob\nNDR pack" },
801 { "__ndr_unpack__", (PyCFunction)py_witness_ResourceChange_ndr_unpack, METH_VARARGS|METH_KEYWORDS, "S.ndr_unpack(class, blob, allow_remaining=False) -> None\nNDR unpack" },
802 { "__ndr_print__", (PyCFunction)py_witness_ResourceChange_ndr_print, METH_VARARGS, "S.ndr_print(object) -> None\nNDR print" },
803 { NULL, NULL, 0, NULL }
807 static PyTypeObject witness_ResourceChange_Type = {
808 PyObject_HEAD_INIT(NULL) 0,
809 .tp_name = "witness.ResourceChange",
810 .tp_getset = py_witness_ResourceChange_getsetters,
811 .tp_methods = py_witness_ResourceChange_methods,
812 .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
813 .tp_new = py_witness_ResourceChange_new,
817 static PyObject *py_witness_IPaddrInfo_get_flags(PyObject *obj, void *closure)
819 struct witness_IPaddrInfo *object = (struct witness_IPaddrInfo *)pytalloc_get_ptr(obj);
821 py_flags = ndr_PyLong_FromUnsignedLongLong((uint32_t)object->flags);
825 static int py_witness_IPaddrInfo_set_flags(PyObject *py_obj, PyObject *value, void *closure)
827 struct witness_IPaddrInfo *object = (struct witness_IPaddrInfo *)pytalloc_get_ptr(py_obj);
829 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->flags");
833 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->flags));
834 if (PyLong_Check(value)) {
835 unsigned long long test_var;
836 test_var = PyLong_AsUnsignedLongLong(value);
837 if (PyErr_Occurred() != NULL) {
840 if (test_var > uint_max) {
841 PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %llu",\
842 PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
845 object->flags = test_var;
846 } else if (PyInt_Check(value)) {
848 test_var = PyInt_AsLong(value);
849 if (test_var < 0 || test_var > uint_max) {
850 PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %ld",\
851 PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
854 object->flags = test_var;
856 PyErr_Format(PyExc_TypeError, "Expected type %s or %s",\
857 PyInt_Type.tp_name, PyLong_Type.tp_name);
864 static PyObject *py_witness_IPaddrInfo_get_ipv4(PyObject *obj, void *closure)
866 struct witness_IPaddrInfo *object = (struct witness_IPaddrInfo *)pytalloc_get_ptr(obj);
868 py_ipv4 = PyString_FromStringOrNULL(object->ipv4);
872 static int py_witness_IPaddrInfo_set_ipv4(PyObject *py_obj, PyObject *value, void *closure)
874 struct witness_IPaddrInfo *object = (struct witness_IPaddrInfo *)pytalloc_get_ptr(py_obj);
876 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->ipv4");
880 const char *test_str;
881 const char *talloc_str;
882 PyObject *unicode = NULL;
883 if (PyUnicode_Check(value)) {
884 unicode = PyUnicode_AsEncodedString(value, "utf-8", "ignore");
885 if (unicode == NULL) {
889 test_str = PyString_AS_STRING(unicode);
890 } else if (PyString_Check(value)) {
891 test_str = PyString_AS_STRING(value);
893 PyErr_Format(PyExc_TypeError, "Expected string or unicode object, got %s", Py_TYPE(value)->tp_name);
896 talloc_str = talloc_strdup(pytalloc_get_mem_ctx(py_obj), test_str);
897 if (unicode != NULL) {
900 if (talloc_str == NULL) {
904 object->ipv4 = talloc_str;
909 static PyObject *py_witness_IPaddrInfo_get_ipv6(PyObject *obj, void *closure)
911 struct witness_IPaddrInfo *object = (struct witness_IPaddrInfo *)pytalloc_get_ptr(obj);
913 py_ipv6 = PyString_FromStringOrNULL(object->ipv6);
917 static int py_witness_IPaddrInfo_set_ipv6(PyObject *py_obj, PyObject *value, void *closure)
919 struct witness_IPaddrInfo *object = (struct witness_IPaddrInfo *)pytalloc_get_ptr(py_obj);
921 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->ipv6");
925 const char *test_str;
926 const char *talloc_str;
927 PyObject *unicode = NULL;
928 if (PyUnicode_Check(value)) {
929 unicode = PyUnicode_AsEncodedString(value, "utf-8", "ignore");
930 if (unicode == NULL) {
934 test_str = PyString_AS_STRING(unicode);
935 } else if (PyString_Check(value)) {
936 test_str = PyString_AS_STRING(value);
938 PyErr_Format(PyExc_TypeError, "Expected string or unicode object, got %s", Py_TYPE(value)->tp_name);
941 talloc_str = talloc_strdup(pytalloc_get_mem_ctx(py_obj), test_str);
942 if (unicode != NULL) {
945 if (talloc_str == NULL) {
949 object->ipv6 = talloc_str;
954 static PyGetSetDef py_witness_IPaddrInfo_getsetters[] = {
956 .name = discard_const_p(char, "flags"),
957 .get = py_witness_IPaddrInfo_get_flags,
958 .set = py_witness_IPaddrInfo_set_flags,
959 .doc = discard_const_p(char, "PIDL-generated element flags")
962 .name = discard_const_p(char, "ipv4"),
963 .get = py_witness_IPaddrInfo_get_ipv4,
964 .set = py_witness_IPaddrInfo_set_ipv4,
965 .doc = discard_const_p(char, "PIDL-generated element ipv4")
968 .name = discard_const_p(char, "ipv6"),
969 .get = py_witness_IPaddrInfo_get_ipv6,
970 .set = py_witness_IPaddrInfo_set_ipv6,
971 .doc = discard_const_p(char, "PIDL-generated element ipv6")
976 static PyObject *py_witness_IPaddrInfo_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
978 return pytalloc_new(struct witness_IPaddrInfo, type);
982 static PyTypeObject witness_IPaddrInfo_Type = {
983 PyObject_HEAD_INIT(NULL) 0,
984 .tp_name = "witness.IPaddrInfo",
985 .tp_getset = py_witness_IPaddrInfo_getsetters,
987 .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
988 .tp_new = py_witness_IPaddrInfo_new,
992 static PyObject *py_witness_IPaddrInfoList_get_length(PyObject *obj, void *closure)
994 struct witness_IPaddrInfoList *object = (struct witness_IPaddrInfoList *)pytalloc_get_ptr(obj);
996 py_length = ndr_PyLong_FromUnsignedLongLong((uint32_t)object->length);
1000 static int py_witness_IPaddrInfoList_set_length(PyObject *py_obj, PyObject *value, void *closure)
1002 struct witness_IPaddrInfoList *object = (struct witness_IPaddrInfoList *)pytalloc_get_ptr(py_obj);
1003 if (value == NULL) {
1004 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->length");
1008 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->length));
1009 if (PyLong_Check(value)) {
1010 unsigned long long test_var;
1011 test_var = PyLong_AsUnsignedLongLong(value);
1012 if (PyErr_Occurred() != NULL) {
1015 if (test_var > uint_max) {
1016 PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %llu",\
1017 PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
1020 object->length = test_var;
1021 } else if (PyInt_Check(value)) {
1023 test_var = PyInt_AsLong(value);
1024 if (test_var < 0 || test_var > uint_max) {
1025 PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %ld",\
1026 PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
1029 object->length = test_var;
1031 PyErr_Format(PyExc_TypeError, "Expected type %s or %s",\
1032 PyInt_Type.tp_name, PyLong_Type.tp_name);
1039 static PyObject *py_witness_IPaddrInfoList_get_reserved(PyObject *obj, void *closure)
1041 struct witness_IPaddrInfoList *object = (struct witness_IPaddrInfoList *)pytalloc_get_ptr(obj);
1042 PyObject *py_reserved;
1043 py_reserved = ndr_PyLong_FromUnsignedLongLong((uint32_t)object->reserved);
1047 static int py_witness_IPaddrInfoList_set_reserved(PyObject *py_obj, PyObject *value, void *closure)
1049 struct witness_IPaddrInfoList *object = (struct witness_IPaddrInfoList *)pytalloc_get_ptr(py_obj);
1050 if (value == NULL) {
1051 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->reserved");
1055 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->reserved));
1056 if (PyLong_Check(value)) {
1057 unsigned long long test_var;
1058 test_var = PyLong_AsUnsignedLongLong(value);
1059 if (PyErr_Occurred() != NULL) {
1062 if (test_var > uint_max) {
1063 PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %llu",\
1064 PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
1067 object->reserved = test_var;
1068 } else if (PyInt_Check(value)) {
1070 test_var = PyInt_AsLong(value);
1071 if (test_var < 0 || test_var > uint_max) {
1072 PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %ld",\
1073 PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
1076 object->reserved = test_var;
1078 PyErr_Format(PyExc_TypeError, "Expected type %s or %s",\
1079 PyInt_Type.tp_name, PyLong_Type.tp_name);
1086 static PyObject *py_witness_IPaddrInfoList_get_num(PyObject *obj, void *closure)
1088 struct witness_IPaddrInfoList *object = (struct witness_IPaddrInfoList *)pytalloc_get_ptr(obj);
1090 py_num = ndr_PyLong_FromUnsignedLongLong((uint32_t)object->num);
1094 static int py_witness_IPaddrInfoList_set_num(PyObject *py_obj, PyObject *value, void *closure)
1096 struct witness_IPaddrInfoList *object = (struct witness_IPaddrInfoList *)pytalloc_get_ptr(py_obj);
1097 if (value == NULL) {
1098 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->num");
1102 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->num));
1103 if (PyLong_Check(value)) {
1104 unsigned long long test_var;
1105 test_var = PyLong_AsUnsignedLongLong(value);
1106 if (PyErr_Occurred() != NULL) {
1109 if (test_var > uint_max) {
1110 PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %llu",\
1111 PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
1114 object->num = test_var;
1115 } else if (PyInt_Check(value)) {
1117 test_var = PyInt_AsLong(value);
1118 if (test_var < 0 || test_var > uint_max) {
1119 PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %ld",\
1120 PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
1123 object->num = test_var;
1125 PyErr_Format(PyExc_TypeError, "Expected type %s or %s",\
1126 PyInt_Type.tp_name, PyLong_Type.tp_name);
1133 static PyObject *py_witness_IPaddrInfoList_get_addr(PyObject *obj, void *closure)
1135 struct witness_IPaddrInfoList *object = (struct witness_IPaddrInfoList *)pytalloc_get_ptr(obj);
1137 py_addr = PyList_New(object->num);
1138 if (py_addr == NULL) {
1143 for (addr_cntr_0 = 0; addr_cntr_0 < (object->num); addr_cntr_0++) {
1144 PyObject *py_addr_0;
1145 py_addr_0 = pytalloc_reference_ex(&witness_IPaddrInfo_Type, object->addr, &object->addr[addr_cntr_0]);
1146 PyList_SetItem(py_addr, addr_cntr_0, py_addr_0);
1152 static int py_witness_IPaddrInfoList_set_addr(PyObject *py_obj, PyObject *value, void *closure)
1154 struct witness_IPaddrInfoList *object = (struct witness_IPaddrInfoList *)pytalloc_get_ptr(py_obj);
1155 if (value == NULL) {
1156 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->addr");
1159 PY_CHECK_TYPE(&PyList_Type, value, return -1;);
1162 object->addr = talloc_array_ptrtype(pytalloc_get_mem_ctx(py_obj), object->addr, PyList_GET_SIZE(value));
1163 if (!object->addr) { return -1;; }
1164 talloc_set_name_const(object->addr, "ARRAY: object->addr");
1165 for (addr_cntr_0 = 0; addr_cntr_0 < PyList_GET_SIZE(value); addr_cntr_0++) {
1166 if (PyList_GET_ITEM(value, addr_cntr_0) == NULL) {
1167 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->addr[addr_cntr_0]");
1170 PY_CHECK_TYPE(&witness_IPaddrInfo_Type, PyList_GET_ITEM(value, addr_cntr_0), return -1;);
1171 if (talloc_reference(object->addr, pytalloc_get_mem_ctx(PyList_GET_ITEM(value, addr_cntr_0))) == NULL) {
1175 object->addr[addr_cntr_0] = *(struct witness_IPaddrInfo *)pytalloc_get_ptr(PyList_GET_ITEM(value, addr_cntr_0));
1181 static PyGetSetDef py_witness_IPaddrInfoList_getsetters[] = {
1183 .name = discard_const_p(char, "length"),
1184 .get = py_witness_IPaddrInfoList_get_length,
1185 .set = py_witness_IPaddrInfoList_set_length,
1186 .doc = discard_const_p(char, "PIDL-generated element length")
1189 .name = discard_const_p(char, "reserved"),
1190 .get = py_witness_IPaddrInfoList_get_reserved,
1191 .set = py_witness_IPaddrInfoList_set_reserved,
1192 .doc = discard_const_p(char, "PIDL-generated element reserved")
1195 .name = discard_const_p(char, "num"),
1196 .get = py_witness_IPaddrInfoList_get_num,
1197 .set = py_witness_IPaddrInfoList_set_num,
1198 .doc = discard_const_p(char, "PIDL-generated element num")
1201 .name = discard_const_p(char, "addr"),
1202 .get = py_witness_IPaddrInfoList_get_addr,
1203 .set = py_witness_IPaddrInfoList_set_addr,
1204 .doc = discard_const_p(char, "PIDL-generated element addr")
1209 static PyObject *py_witness_IPaddrInfoList_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
1211 return pytalloc_new(struct witness_IPaddrInfoList, type);
1215 static PyTypeObject witness_IPaddrInfoList_Type = {
1216 PyObject_HEAD_INIT(NULL) 0,
1217 .tp_name = "witness.IPaddrInfoList",
1218 .tp_getset = py_witness_IPaddrInfoList_getsetters,
1220 .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
1221 .tp_new = py_witness_IPaddrInfoList_new,
1224 PyObject *py_import_witness_notifyResponse_message(TALLOC_CTX *mem_ctx, int level, union witness_notifyResponse_message *in)
1229 case WITNESS_NOTIFY_RESOURCE_CHANGE:
1230 ret = pytalloc_reference_ex(&witness_ResourceChange_Type, mem_ctx, &in->resource_change);
1233 case WITNESS_NOTIFY_CLIENT_MOVE:
1234 ret = pytalloc_reference_ex(&witness_IPaddrInfoList_Type, mem_ctx, &in->client_move);
1237 case WITNESS_NOTIFY_SHARE_MOVE:
1238 ret = pytalloc_reference_ex(&witness_IPaddrInfoList_Type, mem_ctx, &in->share_move);
1241 case WITNESS_NOTIFY_IP_CHANGE:
1242 ret = pytalloc_reference_ex(&witness_IPaddrInfoList_Type, mem_ctx, &in->ip_change);
1246 ret = PyString_FromStringAndSize((char *)(in->data).data, (in->data).length);
1250 PyErr_SetString(PyExc_TypeError, "unknown union level");
1254 union witness_notifyResponse_message *py_export_witness_notifyResponse_message(TALLOC_CTX *mem_ctx, int level, PyObject *in)
1256 union witness_notifyResponse_message *ret = talloc_zero(mem_ctx, union witness_notifyResponse_message);
1258 case WITNESS_NOTIFY_RESOURCE_CHANGE:
1260 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct ret->resource_change");
1261 talloc_free(ret); return NULL;
1263 PY_CHECK_TYPE(&witness_ResourceChange_Type, in, talloc_free(ret); return NULL;);
1264 if (talloc_reference(mem_ctx, pytalloc_get_mem_ctx(in)) == NULL) {
1266 talloc_free(ret); return NULL;
1268 ret->resource_change = *(struct witness_ResourceChange *)pytalloc_get_ptr(in);
1271 case WITNESS_NOTIFY_CLIENT_MOVE:
1273 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct ret->client_move");
1274 talloc_free(ret); return NULL;
1276 PY_CHECK_TYPE(&witness_IPaddrInfoList_Type, in, talloc_free(ret); return NULL;);
1277 if (talloc_reference(mem_ctx, pytalloc_get_mem_ctx(in)) == NULL) {
1279 talloc_free(ret); return NULL;
1281 ret->client_move = *(struct witness_IPaddrInfoList *)pytalloc_get_ptr(in);
1284 case WITNESS_NOTIFY_SHARE_MOVE:
1286 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct ret->share_move");
1287 talloc_free(ret); return NULL;
1289 PY_CHECK_TYPE(&witness_IPaddrInfoList_Type, in, talloc_free(ret); return NULL;);
1290 if (talloc_reference(mem_ctx, pytalloc_get_mem_ctx(in)) == NULL) {
1292 talloc_free(ret); return NULL;
1294 ret->share_move = *(struct witness_IPaddrInfoList *)pytalloc_get_ptr(in);
1297 case WITNESS_NOTIFY_IP_CHANGE:
1299 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct ret->ip_change");
1300 talloc_free(ret); return NULL;
1302 PY_CHECK_TYPE(&witness_IPaddrInfoList_Type, in, talloc_free(ret); return NULL;);
1303 if (talloc_reference(mem_ctx, pytalloc_get_mem_ctx(in)) == NULL) {
1305 talloc_free(ret); return NULL;
1307 ret->ip_change = *(struct witness_IPaddrInfoList *)pytalloc_get_ptr(in);
1312 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct ret->data");
1313 talloc_free(ret); return NULL;
1315 ret->data = data_blob_talloc(mem_ctx, PyString_AS_STRING(in), PyString_GET_SIZE(in));
1324 static PyObject *py_witness_notifyResponse_get_type(PyObject *obj, void *closure)
1326 struct witness_notifyResponse *object = (struct witness_notifyResponse *)pytalloc_get_ptr(obj);
1328 py_type = ndr_PyLong_FromUnsignedLongLong((uint32_t)object->type);
1332 static int py_witness_notifyResponse_set_type(PyObject *py_obj, PyObject *value, void *closure)
1334 struct witness_notifyResponse *object = (struct witness_notifyResponse *)pytalloc_get_ptr(py_obj);
1335 if (value == NULL) {
1336 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->type");
1340 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->type));
1341 if (PyLong_Check(value)) {
1342 unsigned long long test_var;
1343 test_var = PyLong_AsUnsignedLongLong(value);
1344 if (PyErr_Occurred() != NULL) {
1347 if (test_var > uint_max) {
1348 PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %llu",\
1349 PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
1352 object->type = test_var;
1353 } else if (PyInt_Check(value)) {
1355 test_var = PyInt_AsLong(value);
1356 if (test_var < 0 || test_var > uint_max) {
1357 PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %ld",\
1358 PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
1361 object->type = test_var;
1363 PyErr_Format(PyExc_TypeError, "Expected type %s or %s",\
1364 PyInt_Type.tp_name, PyLong_Type.tp_name);
1371 static PyObject *py_witness_notifyResponse_get_length(PyObject *obj, void *closure)
1373 struct witness_notifyResponse *object = (struct witness_notifyResponse *)pytalloc_get_ptr(obj);
1374 PyObject *py_length;
1375 py_length = ndr_PyLong_FromUnsignedLongLong((uint32_t)object->length);
1379 static int py_witness_notifyResponse_set_length(PyObject *py_obj, PyObject *value, void *closure)
1381 struct witness_notifyResponse *object = (struct witness_notifyResponse *)pytalloc_get_ptr(py_obj);
1382 if (value == NULL) {
1383 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->length");
1387 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->length));
1388 if (PyLong_Check(value)) {
1389 unsigned long long test_var;
1390 test_var = PyLong_AsUnsignedLongLong(value);
1391 if (PyErr_Occurred() != NULL) {
1394 if (test_var > uint_max) {
1395 PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %llu",\
1396 PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
1399 object->length = test_var;
1400 } else if (PyInt_Check(value)) {
1402 test_var = PyInt_AsLong(value);
1403 if (test_var < 0 || test_var > uint_max) {
1404 PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %ld",\
1405 PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
1408 object->length = test_var;
1410 PyErr_Format(PyExc_TypeError, "Expected type %s or %s",\
1411 PyInt_Type.tp_name, PyLong_Type.tp_name);
1418 static PyObject *py_witness_notifyResponse_get_num(PyObject *obj, void *closure)
1420 struct witness_notifyResponse *object = (struct witness_notifyResponse *)pytalloc_get_ptr(obj);
1422 py_num = ndr_PyLong_FromUnsignedLongLong((uint32_t)object->num);
1426 static int py_witness_notifyResponse_set_num(PyObject *py_obj, PyObject *value, void *closure)
1428 struct witness_notifyResponse *object = (struct witness_notifyResponse *)pytalloc_get_ptr(py_obj);
1429 if (value == NULL) {
1430 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->num");
1434 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->num));
1435 if (PyLong_Check(value)) {
1436 unsigned long long test_var;
1437 test_var = PyLong_AsUnsignedLongLong(value);
1438 if (PyErr_Occurred() != NULL) {
1441 if (test_var > uint_max) {
1442 PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %llu",\
1443 PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
1446 object->num = test_var;
1447 } else if (PyInt_Check(value)) {
1449 test_var = PyInt_AsLong(value);
1450 if (test_var < 0 || test_var > uint_max) {
1451 PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %ld",\
1452 PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
1455 object->num = test_var;
1457 PyErr_Format(PyExc_TypeError, "Expected type %s or %s",\
1458 PyInt_Type.tp_name, PyLong_Type.tp_name);
1465 static PyObject *py_witness_notifyResponse_get_messages(PyObject *obj, void *closure)
1467 struct witness_notifyResponse *object = (struct witness_notifyResponse *)pytalloc_get_ptr(obj);
1468 PyObject *py_messages;
1469 py_messages = PyList_New(object->num);
1470 if (py_messages == NULL) {
1474 int messages_cntr_0;
1475 for (messages_cntr_0 = 0; messages_cntr_0 < (object->num); messages_cntr_0++) {
1476 PyObject *py_messages_0;
1477 py_messages_0 = py_import_witness_notifyResponse_message(object->messages, object->type, &object->messages[messages_cntr_0]);
1478 if (py_messages_0 == NULL) {
1481 PyList_SetItem(py_messages, messages_cntr_0, py_messages_0);
1487 static int py_witness_notifyResponse_set_messages(PyObject *py_obj, PyObject *value, void *closure)
1489 struct witness_notifyResponse *object = (struct witness_notifyResponse *)pytalloc_get_ptr(py_obj);
1490 if (value == NULL) {
1491 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->messages");
1494 PY_CHECK_TYPE(&PyList_Type, value, return -1;);
1496 int messages_cntr_0;
1497 object->messages = talloc_array_ptrtype(pytalloc_get_mem_ctx(py_obj), object->messages, PyList_GET_SIZE(value));
1498 if (!object->messages) { return -1;; }
1499 talloc_set_name_const(object->messages, "ARRAY: object->messages");
1500 for (messages_cntr_0 = 0; messages_cntr_0 < PyList_GET_SIZE(value); messages_cntr_0++) {
1501 if (PyList_GET_ITEM(value, messages_cntr_0) == NULL) {
1502 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->messages[messages_cntr_0]");
1506 union witness_notifyResponse_message *messages_switch_2;
1507 messages_switch_2 = py_export_witness_notifyResponse_message(object->messages, object->type, PyList_GET_ITEM(value, messages_cntr_0));
1508 if (messages_switch_2 == NULL) {
1511 object->messages[messages_cntr_0] = *messages_switch_2;
1518 static PyGetSetDef py_witness_notifyResponse_getsetters[] = {
1520 .name = discard_const_p(char, "type"),
1521 .get = py_witness_notifyResponse_get_type,
1522 .set = py_witness_notifyResponse_set_type,
1523 .doc = discard_const_p(char, "PIDL-generated element type")
1526 .name = discard_const_p(char, "length"),
1527 .get = py_witness_notifyResponse_get_length,
1528 .set = py_witness_notifyResponse_set_length,
1529 .doc = discard_const_p(char, "PIDL-generated element length")
1532 .name = discard_const_p(char, "num"),
1533 .get = py_witness_notifyResponse_get_num,
1534 .set = py_witness_notifyResponse_set_num,
1535 .doc = discard_const_p(char, "PIDL-generated element num")
1538 .name = discard_const_p(char, "messages"),
1539 .get = py_witness_notifyResponse_get_messages,
1540 .set = py_witness_notifyResponse_set_messages,
1541 .doc = discard_const_p(char, "PIDL-generated element messages")
1546 static PyObject *py_witness_notifyResponse_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
1548 return pytalloc_new(struct witness_notifyResponse, type);
1551 static PyObject *py_witness_notifyResponse_ndr_pack(PyObject *py_obj)
1553 struct witness_notifyResponse *object = (struct witness_notifyResponse *)pytalloc_get_ptr(py_obj);
1554 PyObject *ret = NULL;
1556 enum ndr_err_code err;
1557 TALLOC_CTX *tmp_ctx = talloc_new(pytalloc_get_mem_ctx(py_obj));
1558 if (tmp_ctx == NULL) {
1559 PyErr_SetNdrError(NDR_ERR_ALLOC);
1562 err = ndr_push_struct_blob(&blob, tmp_ctx, object, (ndr_push_flags_fn_t)ndr_push_witness_notifyResponse);
1563 if (err != NDR_ERR_SUCCESS) {
1564 TALLOC_FREE(tmp_ctx);
1565 PyErr_SetNdrError(err);
1569 ret = PyString_FromStringAndSize((char *)blob.data, blob.length);
1570 TALLOC_FREE(tmp_ctx);
1574 static PyObject *py_witness_notifyResponse_ndr_unpack(PyObject *py_obj, PyObject *args, PyObject *kwargs)
1576 struct witness_notifyResponse *object = (struct witness_notifyResponse *)pytalloc_get_ptr(py_obj);
1578 Py_ssize_t blob_length = 0;
1579 enum ndr_err_code err;
1580 const char * const kwnames[] = { "data_blob", "allow_remaining", NULL };
1581 PyObject *allow_remaining_obj = NULL;
1582 bool allow_remaining = false;
1584 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s#|O:__ndr_unpack__",
1585 discard_const_p(char *, kwnames),
1586 &blob.data, &blob_length,
1587 &allow_remaining_obj)) {
1590 blob.length = blob_length;
1592 if (allow_remaining_obj && PyObject_IsTrue(allow_remaining_obj)) {
1593 allow_remaining = true;
1596 if (allow_remaining) {
1597 err = ndr_pull_struct_blob(&blob, pytalloc_get_mem_ctx(py_obj), object, (ndr_pull_flags_fn_t)ndr_pull_witness_notifyResponse);
1599 err = ndr_pull_struct_blob_all(&blob, pytalloc_get_mem_ctx(py_obj), object, (ndr_pull_flags_fn_t)ndr_pull_witness_notifyResponse);
1601 if (err != NDR_ERR_SUCCESS) {
1602 PyErr_SetNdrError(err);
1609 static PyObject *py_witness_notifyResponse_ndr_print(PyObject *py_obj)
1611 struct witness_notifyResponse *object = (struct witness_notifyResponse *)pytalloc_get_ptr(py_obj);
1615 retstr = ndr_print_struct_string(pytalloc_get_mem_ctx(py_obj), (ndr_print_fn_t)ndr_print_witness_notifyResponse, "witness_notifyResponse", object);
1616 ret = PyString_FromString(retstr);
1617 talloc_free(retstr);
1622 static PyMethodDef py_witness_notifyResponse_methods[] = {
1623 { "__ndr_pack__", (PyCFunction)py_witness_notifyResponse_ndr_pack, METH_NOARGS, "S.ndr_pack(object) -> blob\nNDR pack" },
1624 { "__ndr_unpack__", (PyCFunction)py_witness_notifyResponse_ndr_unpack, METH_VARARGS|METH_KEYWORDS, "S.ndr_unpack(class, blob, allow_remaining=False) -> None\nNDR unpack" },
1625 { "__ndr_print__", (PyCFunction)py_witness_notifyResponse_ndr_print, METH_VARARGS, "S.ndr_print(object) -> None\nNDR print" },
1626 { NULL, NULL, 0, NULL }
1630 static PyTypeObject witness_notifyResponse_Type = {
1631 PyObject_HEAD_INIT(NULL) 0,
1632 .tp_name = "witness.notifyResponse",
1633 .tp_getset = py_witness_notifyResponse_getsetters,
1634 .tp_methods = py_witness_notifyResponse_methods,
1635 .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
1636 .tp_new = py_witness_notifyResponse_new,
1640 static bool pack_py_witness_GetInterfaceList_args_in(PyObject *args, PyObject *kwargs, struct witness_GetInterfaceList *r)
1642 const char *kwnames[] = {
1646 if (!PyArg_ParseTupleAndKeywords(args, kwargs, ":witness_GetInterfaceList", discard_const_p(char *, kwnames))) {
1653 static PyObject *unpack_py_witness_GetInterfaceList_args_out(struct witness_GetInterfaceList *r)
1656 PyObject *py_interface_list;
1657 if (*r->out.interface_list == NULL) {
1658 py_interface_list = Py_None;
1659 Py_INCREF(py_interface_list);
1661 py_interface_list = pytalloc_reference_ex(&witness_interfaceList_Type, *r->out.interface_list, *r->out.interface_list);
1663 result = py_interface_list;
1664 if (!W_ERROR_IS_OK(r->out.result)) {
1665 PyErr_SetWERROR(r->out.result);
1672 static bool pack_py_witness_Register_args_in(PyObject *args, PyObject *kwargs, struct witness_Register *r)
1674 PyObject *py_version;
1675 PyObject *py_net_name;
1676 PyObject *py_ip_address;
1677 PyObject *py_client_computer_name;
1678 const char *kwnames[] = {
1679 "version", "net_name", "ip_address", "client_computer_name", NULL
1682 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)) {
1686 if (py_version == NULL) {
1687 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct r->in.version");
1691 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(r->in.version));
1692 if (PyLong_Check(py_version)) {
1693 unsigned long long test_var;
1694 test_var = PyLong_AsUnsignedLongLong(py_version);
1695 if (PyErr_Occurred() != NULL) {
1698 if (test_var > uint_max) {
1699 PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %llu",\
1700 PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
1703 r->in.version = test_var;
1704 } else if (PyInt_Check(py_version)) {
1706 test_var = PyInt_AsLong(py_version);
1707 if (test_var < 0 || test_var > uint_max) {
1708 PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %ld",\
1709 PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
1712 r->in.version = test_var;
1714 PyErr_Format(PyExc_TypeError, "Expected type %s or %s",\
1715 PyInt_Type.tp_name, PyLong_Type.tp_name);
1719 if (py_net_name == NULL) {
1720 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct r->in.net_name");
1723 if (py_net_name == Py_None) {
1724 r->in.net_name = NULL;
1726 r->in.net_name = NULL;
1727 if (py_net_name == NULL) {
1728 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct *r->in.net_name");
1732 const char *test_str;
1733 const char *talloc_str;
1734 PyObject *unicode = NULL;
1735 if (PyUnicode_Check(py_net_name)) {
1736 unicode = PyUnicode_AsEncodedString(py_net_name, "utf-8", "ignore");
1737 if (unicode == NULL) {
1741 test_str = PyString_AS_STRING(unicode);
1742 } else if (PyString_Check(py_net_name)) {
1743 test_str = PyString_AS_STRING(py_net_name);
1745 PyErr_Format(PyExc_TypeError, "Expected string or unicode object, got %s", Py_TYPE(py_net_name)->tp_name);
1748 talloc_str = talloc_strdup(r, test_str);
1749 if (unicode != NULL) {
1752 if (talloc_str == NULL) {
1756 r->in.net_name = talloc_str;
1759 if (py_ip_address == NULL) {
1760 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct r->in.ip_address");
1763 if (py_ip_address == Py_None) {
1764 r->in.ip_address = NULL;
1766 r->in.ip_address = NULL;
1767 if (py_ip_address == NULL) {
1768 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct *r->in.ip_address");
1772 const char *test_str;
1773 const char *talloc_str;
1774 PyObject *unicode = NULL;
1775 if (PyUnicode_Check(py_ip_address)) {
1776 unicode = PyUnicode_AsEncodedString(py_ip_address, "utf-8", "ignore");
1777 if (unicode == NULL) {
1781 test_str = PyString_AS_STRING(unicode);
1782 } else if (PyString_Check(py_ip_address)) {
1783 test_str = PyString_AS_STRING(py_ip_address);
1785 PyErr_Format(PyExc_TypeError, "Expected string or unicode object, got %s", Py_TYPE(py_ip_address)->tp_name);
1788 talloc_str = talloc_strdup(r, test_str);
1789 if (unicode != NULL) {
1792 if (talloc_str == NULL) {
1796 r->in.ip_address = talloc_str;
1799 if (py_client_computer_name == NULL) {
1800 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct r->in.client_computer_name");
1803 if (py_client_computer_name == Py_None) {
1804 r->in.client_computer_name = NULL;
1806 r->in.client_computer_name = NULL;
1807 if (py_client_computer_name == NULL) {
1808 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct *r->in.client_computer_name");
1812 const char *test_str;
1813 const char *talloc_str;
1814 PyObject *unicode = NULL;
1815 if (PyUnicode_Check(py_client_computer_name)) {
1816 unicode = PyUnicode_AsEncodedString(py_client_computer_name, "utf-8", "ignore");
1817 if (unicode == NULL) {
1821 test_str = PyString_AS_STRING(unicode);
1822 } else if (PyString_Check(py_client_computer_name)) {
1823 test_str = PyString_AS_STRING(py_client_computer_name);
1825 PyErr_Format(PyExc_TypeError, "Expected string or unicode object, got %s", Py_TYPE(py_client_computer_name)->tp_name);
1828 talloc_str = talloc_strdup(r, test_str);
1829 if (unicode != NULL) {
1832 if (talloc_str == NULL) {
1836 r->in.client_computer_name = talloc_str;
1842 static PyObject *unpack_py_witness_Register_args_out(struct witness_Register *r)
1845 PyObject *py_context_handle;
1846 py_context_handle = pytalloc_reference_ex(policy_handle_Type, r->out.context_handle, r->out.context_handle);
1847 result = py_context_handle;
1848 if (!W_ERROR_IS_OK(r->out.result)) {
1849 PyErr_SetWERROR(r->out.result);
1856 static bool pack_py_witness_UnRegister_args_in(PyObject *args, PyObject *kwargs, struct witness_UnRegister *r)
1858 PyObject *py_context_handle;
1859 const char *kwnames[] = {
1860 "context_handle", NULL
1863 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:witness_UnRegister", discard_const_p(char *, kwnames), &py_context_handle)) {
1867 if (py_context_handle == NULL) {
1868 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct r->in.context_handle");
1871 PY_CHECK_TYPE(policy_handle_Type, py_context_handle, return false;);
1872 if (talloc_reference(r, pytalloc_get_mem_ctx(py_context_handle)) == NULL) {
1876 r->in.context_handle = *(struct policy_handle *)pytalloc_get_ptr(py_context_handle);
1880 static PyObject *unpack_py_witness_UnRegister_args_out(struct witness_UnRegister *r)
1885 if (!W_ERROR_IS_OK(r->out.result)) {
1886 PyErr_SetWERROR(r->out.result);
1893 static bool pack_py_witness_AsyncNotify_args_in(PyObject *args, PyObject *kwargs, struct witness_AsyncNotify *r)
1895 PyObject *py_context_handle;
1896 const char *kwnames[] = {
1897 "context_handle", NULL
1900 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:witness_AsyncNotify", discard_const_p(char *, kwnames), &py_context_handle)) {
1904 if (py_context_handle == NULL) {
1905 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct r->in.context_handle");
1908 PY_CHECK_TYPE(policy_handle_Type, py_context_handle, return false;);
1909 if (talloc_reference(r, pytalloc_get_mem_ctx(py_context_handle)) == NULL) {
1913 r->in.context_handle = *(struct policy_handle *)pytalloc_get_ptr(py_context_handle);
1917 static PyObject *unpack_py_witness_AsyncNotify_args_out(struct witness_AsyncNotify *r)
1920 PyObject *py_response;
1921 if (*r->out.response == NULL) {
1922 py_response = Py_None;
1923 Py_INCREF(py_response);
1925 py_response = pytalloc_reference_ex(&witness_notifyResponse_Type, *r->out.response, *r->out.response);
1927 result = py_response;
1928 if (!W_ERROR_IS_OK(r->out.result)) {
1929 PyErr_SetWERROR(r->out.result);
1936 static bool pack_py_witness_RegisterEx_args_in(PyObject *args, PyObject *kwargs, struct witness_RegisterEx *r)
1938 PyObject *py_version;
1939 PyObject *py_net_name;
1940 PyObject *py_share_name;
1941 PyObject *py_ip_address;
1942 PyObject *py_client_computer_name;
1944 PyObject *py_timeout;
1945 const char *kwnames[] = {
1946 "version", "net_name", "share_name", "ip_address", "client_computer_name", "flags", "timeout", NULL
1949 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)) {
1953 if (py_version == NULL) {
1954 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct r->in.version");
1958 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(r->in.version));
1959 if (PyLong_Check(py_version)) {
1960 unsigned long long test_var;
1961 test_var = PyLong_AsUnsignedLongLong(py_version);
1962 if (PyErr_Occurred() != NULL) {
1965 if (test_var > uint_max) {
1966 PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %llu",\
1967 PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
1970 r->in.version = test_var;
1971 } else if (PyInt_Check(py_version)) {
1973 test_var = PyInt_AsLong(py_version);
1974 if (test_var < 0 || test_var > uint_max) {
1975 PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %ld",\
1976 PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
1979 r->in.version = test_var;
1981 PyErr_Format(PyExc_TypeError, "Expected type %s or %s",\
1982 PyInt_Type.tp_name, PyLong_Type.tp_name);
1986 if (py_net_name == NULL) {
1987 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct r->in.net_name");
1990 if (py_net_name == Py_None) {
1991 r->in.net_name = NULL;
1993 r->in.net_name = NULL;
1994 if (py_net_name == NULL) {
1995 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct *r->in.net_name");
1999 const char *test_str;
2000 const char *talloc_str;
2001 PyObject *unicode = NULL;
2002 if (PyUnicode_Check(py_net_name)) {
2003 unicode = PyUnicode_AsEncodedString(py_net_name, "utf-8", "ignore");
2004 if (unicode == NULL) {
2008 test_str = PyString_AS_STRING(unicode);
2009 } else if (PyString_Check(py_net_name)) {
2010 test_str = PyString_AS_STRING(py_net_name);
2012 PyErr_Format(PyExc_TypeError, "Expected string or unicode object, got %s", Py_TYPE(py_net_name)->tp_name);
2015 talloc_str = talloc_strdup(r, test_str);
2016 if (unicode != NULL) {
2019 if (talloc_str == NULL) {
2023 r->in.net_name = talloc_str;
2026 if (py_share_name == NULL) {
2027 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct r->in.share_name");
2030 if (py_share_name == Py_None) {
2031 r->in.share_name = NULL;
2033 r->in.share_name = NULL;
2034 if (py_share_name == NULL) {
2035 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct *r->in.share_name");
2039 const char *test_str;
2040 const char *talloc_str;
2041 PyObject *unicode = NULL;
2042 if (PyUnicode_Check(py_share_name)) {
2043 unicode = PyUnicode_AsEncodedString(py_share_name, "utf-8", "ignore");
2044 if (unicode == NULL) {
2048 test_str = PyString_AS_STRING(unicode);
2049 } else if (PyString_Check(py_share_name)) {
2050 test_str = PyString_AS_STRING(py_share_name);
2052 PyErr_Format(PyExc_TypeError, "Expected string or unicode object, got %s", Py_TYPE(py_share_name)->tp_name);
2055 talloc_str = talloc_strdup(r, test_str);
2056 if (unicode != NULL) {
2059 if (talloc_str == NULL) {
2063 r->in.share_name = talloc_str;
2066 if (py_ip_address == NULL) {
2067 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct r->in.ip_address");
2070 if (py_ip_address == Py_None) {
2071 r->in.ip_address = NULL;
2073 r->in.ip_address = NULL;
2074 if (py_ip_address == NULL) {
2075 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct *r->in.ip_address");
2079 const char *test_str;
2080 const char *talloc_str;
2081 PyObject *unicode = NULL;
2082 if (PyUnicode_Check(py_ip_address)) {
2083 unicode = PyUnicode_AsEncodedString(py_ip_address, "utf-8", "ignore");
2084 if (unicode == NULL) {
2088 test_str = PyString_AS_STRING(unicode);
2089 } else if (PyString_Check(py_ip_address)) {
2090 test_str = PyString_AS_STRING(py_ip_address);
2092 PyErr_Format(PyExc_TypeError, "Expected string or unicode object, got %s", Py_TYPE(py_ip_address)->tp_name);
2095 talloc_str = talloc_strdup(r, test_str);
2096 if (unicode != NULL) {
2099 if (talloc_str == NULL) {
2103 r->in.ip_address = talloc_str;
2106 if (py_client_computer_name == NULL) {
2107 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct r->in.client_computer_name");
2110 if (py_client_computer_name == Py_None) {
2111 r->in.client_computer_name = NULL;
2113 r->in.client_computer_name = NULL;
2114 if (py_client_computer_name == NULL) {
2115 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct *r->in.client_computer_name");
2119 const char *test_str;
2120 const char *talloc_str;
2121 PyObject *unicode = NULL;
2122 if (PyUnicode_Check(py_client_computer_name)) {
2123 unicode = PyUnicode_AsEncodedString(py_client_computer_name, "utf-8", "ignore");
2124 if (unicode == NULL) {
2128 test_str = PyString_AS_STRING(unicode);
2129 } else if (PyString_Check(py_client_computer_name)) {
2130 test_str = PyString_AS_STRING(py_client_computer_name);
2132 PyErr_Format(PyExc_TypeError, "Expected string or unicode object, got %s", Py_TYPE(py_client_computer_name)->tp_name);
2135 talloc_str = talloc_strdup(r, test_str);
2136 if (unicode != NULL) {
2139 if (talloc_str == NULL) {
2143 r->in.client_computer_name = talloc_str;
2146 if (py_flags == NULL) {
2147 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct r->in.flags");
2151 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(r->in.flags));
2152 if (PyLong_Check(py_flags)) {
2153 unsigned long long test_var;
2154 test_var = PyLong_AsUnsignedLongLong(py_flags);
2155 if (PyErr_Occurred() != NULL) {
2158 if (test_var > uint_max) {
2159 PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %llu",\
2160 PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
2163 r->in.flags = test_var;
2164 } else if (PyInt_Check(py_flags)) {
2166 test_var = PyInt_AsLong(py_flags);
2167 if (test_var < 0 || test_var > uint_max) {
2168 PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %ld",\
2169 PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
2172 r->in.flags = test_var;
2174 PyErr_Format(PyExc_TypeError, "Expected type %s or %s",\
2175 PyInt_Type.tp_name, PyLong_Type.tp_name);
2179 if (py_timeout == NULL) {
2180 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct r->in.timeout");
2184 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(r->in.timeout));
2185 if (PyLong_Check(py_timeout)) {
2186 unsigned long long test_var;
2187 test_var = PyLong_AsUnsignedLongLong(py_timeout);
2188 if (PyErr_Occurred() != NULL) {
2191 if (test_var > uint_max) {
2192 PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %llu",\
2193 PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
2196 r->in.timeout = test_var;
2197 } else if (PyInt_Check(py_timeout)) {
2199 test_var = PyInt_AsLong(py_timeout);
2200 if (test_var < 0 || test_var > uint_max) {
2201 PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %ld",\
2202 PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
2205 r->in.timeout = test_var;
2207 PyErr_Format(PyExc_TypeError, "Expected type %s or %s",\
2208 PyInt_Type.tp_name, PyLong_Type.tp_name);
2215 static PyObject *unpack_py_witness_RegisterEx_args_out(struct witness_RegisterEx *r)
2218 PyObject *py_context_handle;
2219 py_context_handle = pytalloc_reference_ex(policy_handle_Type, r->out.context_handle, r->out.context_handle);
2220 result = py_context_handle;
2221 if (!W_ERROR_IS_OK(r->out.result)) {
2222 PyErr_SetWERROR(r->out.result);
2229 const struct PyNdrRpcMethodDef py_ndr_witness_methods[] = {
2230 { "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 },
2231 { "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 },
2232 { "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 },
2233 { "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 },
2234 { "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 },
2238 static PyObject *interface_witness_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
2240 return py_dcerpc_interface_init_helper(type, args, kwargs, &ndr_table_witness);
2243 #define PY_DOC_WITNESS "SMB Witness Service"
2244 static PyTypeObject witness_InterfaceType = {
2245 PyObject_HEAD_INIT(NULL) 0,
2246 .tp_name = "witness.witness",
2247 .tp_basicsize = sizeof(dcerpc_InterfaceObject),
2248 .tp_doc = "witness(binding, lp_ctx=None, credentials=None) -> connection\n"
2250 "binding should be a DCE/RPC binding string (for example: ncacn_ip_tcp:127.0.0.1)\n"
2251 "lp_ctx should be a path to a smb.conf file or a param.LoadParm object\n"
2252 "credentials should be a credentials.Credentials object.\n\n"PY_DOC_WITNESS,
2253 .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
2254 .tp_new = interface_witness_new,
2257 static PyObject *syntax_witness_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
2259 return py_dcerpc_syntax_init_helper(type, args, kwargs, &ndr_table_witness.syntax_id);
2262 #define PY_DOC_WITNESS_SYNTAX "SMB Witness Service"
2263 static PyTypeObject witness_SyntaxType = {
2264 PyObject_HEAD_INIT(NULL) 0,
2265 .tp_name = "witness.witness",
2266 .tp_doc = "abstract_syntax()\n"PY_DOC_WITNESS_SYNTAX,
2267 .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
2268 .tp_new = syntax_witness_new,
2271 static PyMethodDef witness_methods[] = {
2272 { NULL, NULL, 0, NULL }
2275 void initwitness(void)
2278 PyObject *dep_samba_dcerpc_misc;
2279 PyObject *dep_talloc;
2280 PyObject *dep_samba_dcerpc_base;
2282 dep_samba_dcerpc_misc = PyImport_ImportModule("samba.dcerpc.misc");
2283 if (dep_samba_dcerpc_misc == NULL)
2286 dep_talloc = PyImport_ImportModule("talloc");
2287 if (dep_talloc == NULL)
2290 dep_samba_dcerpc_base = PyImport_ImportModule("samba.dcerpc.base");
2291 if (dep_samba_dcerpc_base == NULL)
2294 BaseObject_Type = (PyTypeObject *)PyObject_GetAttrString(dep_talloc, "BaseObject");
2295 if (BaseObject_Type == NULL)
2298 policy_handle_Type = (PyTypeObject *)PyObject_GetAttrString(dep_samba_dcerpc_misc, "policy_handle");
2299 if (policy_handle_Type == NULL)
2302 ClientConnection_Type = (PyTypeObject *)PyObject_GetAttrString(dep_samba_dcerpc_base, "ClientConnection");
2303 if (ClientConnection_Type == NULL)
2306 ndr_syntax_id_Type = (PyTypeObject *)PyObject_GetAttrString(dep_samba_dcerpc_misc, "ndr_syntax_id");
2307 if (ndr_syntax_id_Type == NULL)
2310 witness_interfaceInfo_Type.tp_base = BaseObject_Type;
2311 witness_interfaceInfo_Type.tp_basicsize = pytalloc_BaseObject_size();
2313 witness_interfaceList_Type.tp_base = BaseObject_Type;
2314 witness_interfaceList_Type.tp_basicsize = pytalloc_BaseObject_size();
2316 witness_ResourceChange_Type.tp_base = BaseObject_Type;
2317 witness_ResourceChange_Type.tp_basicsize = pytalloc_BaseObject_size();
2319 witness_IPaddrInfo_Type.tp_base = BaseObject_Type;
2320 witness_IPaddrInfo_Type.tp_basicsize = pytalloc_BaseObject_size();
2322 witness_IPaddrInfoList_Type.tp_base = BaseObject_Type;
2323 witness_IPaddrInfoList_Type.tp_basicsize = pytalloc_BaseObject_size();
2325 witness_notifyResponse_Type.tp_base = BaseObject_Type;
2326 witness_notifyResponse_Type.tp_basicsize = pytalloc_BaseObject_size();
2328 witness_InterfaceType.tp_base = ClientConnection_Type;
2330 witness_SyntaxType.tp_base = ndr_syntax_id_Type;
2331 witness_SyntaxType.tp_basicsize = pytalloc_BaseObject_size();
2333 if (PyType_Ready(&witness_interfaceInfo_Type) < 0)
2335 if (PyType_Ready(&witness_interfaceList_Type) < 0)
2337 if (PyType_Ready(&witness_ResourceChange_Type) < 0)
2339 if (PyType_Ready(&witness_IPaddrInfo_Type) < 0)
2341 if (PyType_Ready(&witness_IPaddrInfoList_Type) < 0)
2343 if (PyType_Ready(&witness_notifyResponse_Type) < 0)
2345 if (PyType_Ready(&witness_InterfaceType) < 0)
2347 if (PyType_Ready(&witness_SyntaxType) < 0)
2349 if (!PyInterface_AddNdrRpcMethods(&witness_InterfaceType, py_ndr_witness_methods))
2352 #ifdef PY_INTERFACEINFO_PATCH
2353 PY_INTERFACEINFO_PATCH(&witness_interfaceInfo_Type);
2355 #ifdef PY_INTERFACELIST_PATCH
2356 PY_INTERFACELIST_PATCH(&witness_interfaceList_Type);
2358 #ifdef PY_RESOURCECHANGE_PATCH
2359 PY_RESOURCECHANGE_PATCH(&witness_ResourceChange_Type);
2361 #ifdef PY_IPADDRINFO_PATCH
2362 PY_IPADDRINFO_PATCH(&witness_IPaddrInfo_Type);
2364 #ifdef PY_IPADDRINFOLIST_PATCH
2365 PY_IPADDRINFOLIST_PATCH(&witness_IPaddrInfoList_Type);
2367 #ifdef PY_NOTIFYRESPONSE_PATCH
2368 PY_NOTIFYRESPONSE_PATCH(&witness_notifyResponse_Type);
2370 #ifdef PY_WITNESS_PATCH
2371 PY_WITNESS_PATCH(&witness_InterfaceType);
2373 #ifdef PY_ABSTRACT_SYNTAX_PATCH
2374 PY_ABSTRACT_SYNTAX_PATCH(&witness_SyntaxType);
2377 m = Py_InitModule3("witness", witness_methods, "witness DCE/RPC");
2381 PyModule_AddObject(m, "WITNESS_V1", ndr_PyLong_FromUnsignedLongLong((uint32_t)WITNESS_V1));
2382 PyModule_AddObject(m, "WITNESS_V2", ndr_PyLong_FromUnsignedLongLong((uint32_t)WITNESS_V2));
2383 PyModule_AddObject(m, "WITNESS_UNSPECIFIED_VERSION", ndr_PyLong_FromUnsignedLongLong((uint32_t)WITNESS_UNSPECIFIED_VERSION));
2384 PyModule_AddObject(m, "WITNESS_STATE_UNKNOWN", PyInt_FromLong((uint16_t)WITNESS_STATE_UNKNOWN));
2385 PyModule_AddObject(m, "WITNESS_STATE_AVAILABLE", PyInt_FromLong((uint16_t)WITNESS_STATE_AVAILABLE));
2386 PyModule_AddObject(m, "WITNESS_STATE_UNAVAILABLE", PyInt_FromLong((uint16_t)WITNESS_STATE_UNAVAILABLE));
2387 PyModule_AddObject(m, "WITNESS_INFO_IPv4_VALID", ndr_PyLong_FromUnsignedLongLong((uint32_t)WITNESS_INFO_IPv4_VALID));
2388 PyModule_AddObject(m, "WITNESS_INFO_IPv6_VALID", ndr_PyLong_FromUnsignedLongLong((uint32_t)WITNESS_INFO_IPv6_VALID));
2389 PyModule_AddObject(m, "WITNESS_INFO_WITNESS_IF", ndr_PyLong_FromUnsignedLongLong((uint32_t)WITNESS_INFO_WITNESS_IF));
2390 PyModule_AddObject(m, "WITNESS_NOTIFY_RESOURCE_CHANGE", ndr_PyLong_FromUnsignedLongLong((uint32_t)WITNESS_NOTIFY_RESOURCE_CHANGE));
2391 PyModule_AddObject(m, "WITNESS_NOTIFY_CLIENT_MOVE", ndr_PyLong_FromUnsignedLongLong((uint32_t)WITNESS_NOTIFY_CLIENT_MOVE));
2392 PyModule_AddObject(m, "WITNESS_NOTIFY_SHARE_MOVE", ndr_PyLong_FromUnsignedLongLong((uint32_t)WITNESS_NOTIFY_SHARE_MOVE));
2393 PyModule_AddObject(m, "WITNESS_NOTIFY_IP_CHANGE", ndr_PyLong_FromUnsignedLongLong((uint32_t)WITNESS_NOTIFY_IP_CHANGE));
2394 PyModule_AddObject(m, "WITNESS_RESOURCE_STATE_UNKNOWN", ndr_PyLong_FromUnsignedLongLong((uint32_t)WITNESS_RESOURCE_STATE_UNKNOWN));
2395 PyModule_AddObject(m, "WITNESS_RESOURCE_STATE_AVAILABLE", ndr_PyLong_FromUnsignedLongLong((uint32_t)WITNESS_RESOURCE_STATE_AVAILABLE));
2396 PyModule_AddObject(m, "WITNESS_RESOURCE_STATE_UNAVAILABLE", ndr_PyLong_FromUnsignedLongLong((uint32_t)WITNESS_RESOURCE_STATE_UNAVAILABLE));
2397 PyModule_AddObject(m, "WITNESS_IPADDR_V4", ndr_PyLong_FromUnsignedLongLong((uint32_t)WITNESS_IPADDR_V4));
2398 PyModule_AddObject(m, "WITNESS_IPADDR_V6", ndr_PyLong_FromUnsignedLongLong((uint32_t)WITNESS_IPADDR_V6));
2399 PyModule_AddObject(m, "WITNESS_IPADDR_ONLINE", ndr_PyLong_FromUnsignedLongLong((uint32_t)WITNESS_IPADDR_ONLINE));
2400 PyModule_AddObject(m, "WITNESS_IPADDR_OFFLINE", ndr_PyLong_FromUnsignedLongLong((uint32_t)WITNESS_IPADDR_OFFLINE));
2401 PyModule_AddObject(m, "WITNESS_REGISTER_NONE", ndr_PyLong_FromUnsignedLongLong((uint32_t)WITNESS_REGISTER_NONE));
2402 PyModule_AddObject(m, "WITNESS_REGISTER_IP_NOTIFICATION", ndr_PyLong_FromUnsignedLongLong((uint32_t)WITNESS_REGISTER_IP_NOTIFICATION));
2403 Py_INCREF((PyObject *)(void *)&witness_interfaceInfo_Type);
2404 PyModule_AddObject(m, "interfaceInfo", (PyObject *)(void *)&witness_interfaceInfo_Type);
2405 Py_INCREF((PyObject *)(void *)&witness_interfaceList_Type);
2406 PyModule_AddObject(m, "interfaceList", (PyObject *)(void *)&witness_interfaceList_Type);
2407 Py_INCREF((PyObject *)(void *)&witness_ResourceChange_Type);
2408 PyModule_AddObject(m, "ResourceChange", (PyObject *)(void *)&witness_ResourceChange_Type);
2409 Py_INCREF((PyObject *)(void *)&witness_IPaddrInfo_Type);
2410 PyModule_AddObject(m, "IPaddrInfo", (PyObject *)(void *)&witness_IPaddrInfo_Type);
2411 Py_INCREF((PyObject *)(void *)&witness_IPaddrInfoList_Type);
2412 PyModule_AddObject(m, "IPaddrInfoList", (PyObject *)(void *)&witness_IPaddrInfoList_Type);
2413 Py_INCREF((PyObject *)(void *)&witness_notifyResponse_Type);
2414 PyModule_AddObject(m, "notifyResponse", (PyObject *)(void *)&witness_notifyResponse_Type);
2415 Py_INCREF((PyObject *)(void *)&witness_InterfaceType);
2416 PyModule_AddObject(m, "witness", (PyObject *)(void *)&witness_InterfaceType);
2417 Py_INCREF((PyObject *)(void *)&witness_SyntaxType);
2418 PyModule_AddObject(m, "abstract_syntax", (PyObject *)(void *)&witness_SyntaxType);
2419 #ifdef PY_MOD_WITNESS_PATCH
2420 PY_MOD_WITNESS_PATCH(m);