git add -f bin/default/librpc/gen_ndr/*.{c,h,ndr,pidl} bin/default/source*/librpc...
[metze/samba/wip.git] / bin / default / librpc / gen_ndr / py_witness.c
1
2 /* Python wrapper functions auto-generated by pidl */
3 #define PY_SSIZE_T_CLEAN 1 /* We use Py_ssize_t for PyArg_ParseTupleAndKeywords */
4 #include <Python.h>
5 #include "includes.h"
6 #include <pytalloc.h>
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"
11
12 /*
13  * These functions are here to ensure they can be optimized out by
14  * the compiler based on the constant input values
15  */
16
17 static inline unsigned long long ndr_sizeof2uintmax(size_t var_size)
18 {
19         switch (var_size) {
20         case 8:
21                 return UINT64_MAX;
22         case 4:
23                 return UINT32_MAX;
24         case 2:
25                 return UINT16_MAX;
26         case 1:
27                 return UINT8_MAX;
28         }
29
30         return 0;
31 }
32
33 static inline long long ndr_sizeof2intmax(size_t var_size)
34 {
35         switch (var_size) {
36         case 8:
37                 return INT64_MAX;
38         case 4:
39                 return INT32_MAX;
40         case 2:
41                 return INT16_MAX;
42         case 1:
43                 return INT8_MAX;
44         }
45
46         return 0;
47 }
48
49 static inline PyObject *ndr_PyLong_FromLongLong(long long v)
50 {
51         if (v > LONG_MAX || v < LONG_MIN) {
52                 return PyLong_FromLongLong(v);
53         } else {
54                 return PyInt_FromLong(v);
55         }
56 }
57
58 static inline PyObject *ndr_PyLong_FromUnsignedLongLong(unsigned long long v)
59 {
60         if (v > LONG_MAX) {
61                 return PyLong_FromUnsignedLongLong(v);
62         } else {
63                 return PyInt_FromLong(v);
64         }
65 }
66
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;
77
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;
82
83 static PyObject *py_witness_interfaceInfo_get_group_name(PyObject *obj, void *closure)
84 {
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);
90         } else {
91                 py_group_name = PyUnicode_Decode(object->group_name, strlen(object->group_name), "utf-8", "ignore");
92         }
93         return py_group_name;
94 }
95
96 static int py_witness_interfaceInfo_set_group_name(PyObject *py_obj, PyObject *value, void *closure)
97 {
98         struct witness_interfaceInfo *object = (struct witness_interfaceInfo *)pytalloc_get_ptr(py_obj);
99         if (value == NULL) {
100                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->group_name");
101                 return -1;
102         }
103         {
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) {
110                                 PyErr_NoMemory();
111                                 return -1;
112                         }
113                         test_str = PyString_AS_STRING(unicode);
114                 } else if (PyString_Check(value)) {
115                         test_str = PyString_AS_STRING(value);
116                 } else {
117                         PyErr_Format(PyExc_TypeError, "Expected string or unicode object, got %s", Py_TYPE(value)->tp_name);
118                         return -1;
119                 }
120                 talloc_str = talloc_strdup(pytalloc_get_mem_ctx(py_obj), test_str);
121                 if (unicode != NULL) {
122                         Py_DECREF(unicode);
123                 }
124                 if (talloc_str == NULL) {
125                         PyErr_NoMemory();
126                         return -1;
127                 }
128                 object->group_name = talloc_str;
129         }
130         return 0;
131 }
132
133 static PyObject *py_witness_interfaceInfo_get_version(PyObject *obj, void *closure)
134 {
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);
138         return py_version;
139 }
140
141 static int py_witness_interfaceInfo_set_version(PyObject *py_obj, PyObject *value, void *closure)
142 {
143         struct witness_interfaceInfo *object = (struct witness_interfaceInfo *)pytalloc_get_ptr(py_obj);
144         if (value == NULL) {
145                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->version");
146                 return -1;
147         }
148         {
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) {
154                                 return -1;
155                         }
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);
159                                 return -1;
160                         }
161                         object->version = test_var;
162                 } else if (PyInt_Check(value)) {
163                         long test_var;
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);
168                                 return -1;
169                         }
170                         object->version = test_var;
171                 } else {
172                         PyErr_Format(PyExc_TypeError, "Expected type %s or %s",\
173                           PyInt_Type.tp_name, PyLong_Type.tp_name);
174                         return -1;
175                 }
176         }
177         return 0;
178 }
179
180 static PyObject *py_witness_interfaceInfo_get_state(PyObject *obj, void *closure)
181 {
182         struct witness_interfaceInfo *object = (struct witness_interfaceInfo *)pytalloc_get_ptr(obj);
183         PyObject *py_state;
184         py_state = PyInt_FromLong((uint16_t)object->state);
185         return py_state;
186 }
187
188 static int py_witness_interfaceInfo_set_state(PyObject *py_obj, PyObject *value, void *closure)
189 {
190         struct witness_interfaceInfo *object = (struct witness_interfaceInfo *)pytalloc_get_ptr(py_obj);
191         if (value == NULL) {
192                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->state");
193                 return -1;
194         }
195         {
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) {
201                                 return -1;
202                         }
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);
206                                 return -1;
207                         }
208                         object->state = test_var;
209                 } else if (PyInt_Check(value)) {
210                         long test_var;
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);
215                                 return -1;
216                         }
217                         object->state = test_var;
218                 } else {
219                         PyErr_Format(PyExc_TypeError, "Expected type %s or %s",\
220                           PyInt_Type.tp_name, PyLong_Type.tp_name);
221                         return -1;
222                 }
223         }
224         return 0;
225 }
226
227 static PyObject *py_witness_interfaceInfo_get_ipv4(PyObject *obj, void *closure)
228 {
229         struct witness_interfaceInfo *object = (struct witness_interfaceInfo *)pytalloc_get_ptr(obj);
230         PyObject *py_ipv4;
231         py_ipv4 = PyString_FromStringOrNULL(object->ipv4);
232         return py_ipv4;
233 }
234
235 static int py_witness_interfaceInfo_set_ipv4(PyObject *py_obj, PyObject *value, void *closure)
236 {
237         struct witness_interfaceInfo *object = (struct witness_interfaceInfo *)pytalloc_get_ptr(py_obj);
238         if (value == NULL) {
239                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->ipv4");
240                 return -1;
241         }
242         {
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) {
249                                 PyErr_NoMemory();
250                                 return -1;
251                         }
252                         test_str = PyString_AS_STRING(unicode);
253                 } else if (PyString_Check(value)) {
254                         test_str = PyString_AS_STRING(value);
255                 } else {
256                         PyErr_Format(PyExc_TypeError, "Expected string or unicode object, got %s", Py_TYPE(value)->tp_name);
257                         return -1;
258                 }
259                 talloc_str = talloc_strdup(pytalloc_get_mem_ctx(py_obj), test_str);
260                 if (unicode != NULL) {
261                         Py_DECREF(unicode);
262                 }
263                 if (talloc_str == NULL) {
264                         PyErr_NoMemory();
265                         return -1;
266                 }
267                 object->ipv4 = talloc_str;
268         }
269         return 0;
270 }
271
272 static PyObject *py_witness_interfaceInfo_get_ipv6(PyObject *obj, void *closure)
273 {
274         struct witness_interfaceInfo *object = (struct witness_interfaceInfo *)pytalloc_get_ptr(obj);
275         PyObject *py_ipv6;
276         py_ipv6 = PyString_FromStringOrNULL(object->ipv6);
277         return py_ipv6;
278 }
279
280 static int py_witness_interfaceInfo_set_ipv6(PyObject *py_obj, PyObject *value, void *closure)
281 {
282         struct witness_interfaceInfo *object = (struct witness_interfaceInfo *)pytalloc_get_ptr(py_obj);
283         if (value == NULL) {
284                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->ipv6");
285                 return -1;
286         }
287         {
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) {
294                                 PyErr_NoMemory();
295                                 return -1;
296                         }
297                         test_str = PyString_AS_STRING(unicode);
298                 } else if (PyString_Check(value)) {
299                         test_str = PyString_AS_STRING(value);
300                 } else {
301                         PyErr_Format(PyExc_TypeError, "Expected string or unicode object, got %s", Py_TYPE(value)->tp_name);
302                         return -1;
303                 }
304                 talloc_str = talloc_strdup(pytalloc_get_mem_ctx(py_obj), test_str);
305                 if (unicode != NULL) {
306                         Py_DECREF(unicode);
307                 }
308                 if (talloc_str == NULL) {
309                         PyErr_NoMemory();
310                         return -1;
311                 }
312                 object->ipv6 = talloc_str;
313         }
314         return 0;
315 }
316
317 static PyObject *py_witness_interfaceInfo_get_flags(PyObject *obj, void *closure)
318 {
319         struct witness_interfaceInfo *object = (struct witness_interfaceInfo *)pytalloc_get_ptr(obj);
320         PyObject *py_flags;
321         py_flags = ndr_PyLong_FromUnsignedLongLong((uint32_t)object->flags);
322         return py_flags;
323 }
324
325 static int py_witness_interfaceInfo_set_flags(PyObject *py_obj, PyObject *value, void *closure)
326 {
327         struct witness_interfaceInfo *object = (struct witness_interfaceInfo *)pytalloc_get_ptr(py_obj);
328         if (value == NULL) {
329                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->flags");
330                 return -1;
331         }
332         {
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) {
338                                 return -1;
339                         }
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);
343                                 return -1;
344                         }
345                         object->flags = test_var;
346                 } else if (PyInt_Check(value)) {
347                         long test_var;
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);
352                                 return -1;
353                         }
354                         object->flags = test_var;
355                 } else {
356                         PyErr_Format(PyExc_TypeError, "Expected type %s or %s",\
357                           PyInt_Type.tp_name, PyLong_Type.tp_name);
358                         return -1;
359                 }
360         }
361         return 0;
362 }
363
364 static PyGetSetDef py_witness_interfaceInfo_getsetters[] = {
365         {
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")
370         },
371         {
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")
376         },
377         {
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")
382         },
383         {
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")
388         },
389         {
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")
394         },
395         {
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")
400         },
401         { .name = NULL }
402 };
403
404 static PyObject *py_witness_interfaceInfo_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
405 {
406         return pytalloc_new(struct witness_interfaceInfo, type);
407 }
408
409
410 static PyTypeObject witness_interfaceInfo_Type = {
411         PyObject_HEAD_INIT(NULL) 0,
412         .tp_name = "witness.interfaceInfo",
413         .tp_getset = py_witness_interfaceInfo_getsetters,
414         .tp_methods = NULL,
415         .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
416         .tp_new = py_witness_interfaceInfo_new,
417 };
418
419
420 static PyObject *py_witness_interfaceList_get_num_interfaces(PyObject *obj, void *closure)
421 {
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;
426 }
427
428 static int py_witness_interfaceList_set_num_interfaces(PyObject *py_obj, PyObject *value, void *closure)
429 {
430         struct witness_interfaceList *object = (struct witness_interfaceList *)pytalloc_get_ptr(py_obj);
431         if (value == NULL) {
432                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->num_interfaces");
433                 return -1;
434         }
435         {
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) {
441                                 return -1;
442                         }
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);
446                                 return -1;
447                         }
448                         object->num_interfaces = test_var;
449                 } else if (PyInt_Check(value)) {
450                         long test_var;
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);
455                                 return -1;
456                         }
457                         object->num_interfaces = test_var;
458                 } else {
459                         PyErr_Format(PyExc_TypeError, "Expected type %s or %s",\
460                           PyInt_Type.tp_name, PyLong_Type.tp_name);
461                         return -1;
462                 }
463         }
464         return 0;
465 }
466
467 static PyObject *py_witness_interfaceList_get_interfaces(PyObject *obj, void *closure)
468 {
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);
474         } else {
475                 py_interfaces = PyList_New(object->num_interfaces);
476                 if (py_interfaces == NULL) {
477                         return NULL;
478                 }
479                 {
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);
485                         }
486                 }
487         }
488         return py_interfaces;
489 }
490
491 static int py_witness_interfaceList_set_interfaces(PyObject *py_obj, PyObject *value, void *closure)
492 {
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));
495         if (value == NULL) {
496                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->interfaces");
497                 return -1;
498         }
499         if (value == Py_None) {
500                 object->interfaces = NULL;
501         } else {
502                 object->interfaces = NULL;
503                 if (value == NULL) {
504                         PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct *object->interfaces");
505                         return -1;
506                 }
507                 PY_CHECK_TYPE(&PyList_Type, value, return -1;);
508                 {
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]");
516                                         return -1;
517                                 }
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) {
520                                         PyErr_NoMemory();
521                                         return -1;
522                                 }
523                                 object->interfaces[interfaces_cntr_1] = *(struct witness_interfaceInfo *)pytalloc_get_ptr(PyList_GET_ITEM(value, interfaces_cntr_1));
524                         }
525                 }
526         }
527         return 0;
528 }
529
530 static PyGetSetDef py_witness_interfaceList_getsetters[] = {
531         {
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")
536         },
537         {
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")
542         },
543         { .name = NULL }
544 };
545
546 static PyObject *py_witness_interfaceList_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
547 {
548         return pytalloc_new(struct witness_interfaceList, type);
549 }
550
551
552 static PyTypeObject witness_interfaceList_Type = {
553         PyObject_HEAD_INIT(NULL) 0,
554         .tp_name = "witness.interfaceList",
555         .tp_getset = py_witness_interfaceList_getsetters,
556         .tp_methods = NULL,
557         .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
558         .tp_new = py_witness_interfaceList_new,
559 };
560
561
562 static PyObject *py_witness_ResourceChange_get_length(PyObject *obj, void *closure)
563 {
564         struct witness_ResourceChange *object = (struct witness_ResourceChange *)pytalloc_get_ptr(obj);
565         PyObject *py_length;
566         py_length = ndr_PyLong_FromUnsignedLongLong((uint32_t)object->length);
567         return py_length;
568 }
569
570 static int py_witness_ResourceChange_set_length(PyObject *py_obj, PyObject *value, void *closure)
571 {
572         struct witness_ResourceChange *object = (struct witness_ResourceChange *)pytalloc_get_ptr(py_obj);
573         if (value == NULL) {
574                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->length");
575                 return -1;
576         }
577         {
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) {
583                                 return -1;
584                         }
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);
588                                 return -1;
589                         }
590                         object->length = test_var;
591                 } else if (PyInt_Check(value)) {
592                         long test_var;
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);
597                                 return -1;
598                         }
599                         object->length = test_var;
600                 } else {
601                         PyErr_Format(PyExc_TypeError, "Expected type %s or %s",\
602                           PyInt_Type.tp_name, PyLong_Type.tp_name);
603                         return -1;
604                 }
605         }
606         return 0;
607 }
608
609 static PyObject *py_witness_ResourceChange_get_type(PyObject *obj, void *closure)
610 {
611         struct witness_ResourceChange *object = (struct witness_ResourceChange *)pytalloc_get_ptr(obj);
612         PyObject *py_type;
613         py_type = ndr_PyLong_FromUnsignedLongLong((uint32_t)object->type);
614         return py_type;
615 }
616
617 static int py_witness_ResourceChange_set_type(PyObject *py_obj, PyObject *value, void *closure)
618 {
619         struct witness_ResourceChange *object = (struct witness_ResourceChange *)pytalloc_get_ptr(py_obj);
620         if (value == NULL) {
621                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->type");
622                 return -1;
623         }
624         {
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) {
630                                 return -1;
631                         }
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);
635                                 return -1;
636                         }
637                         object->type = test_var;
638                 } else if (PyInt_Check(value)) {
639                         long test_var;
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);
644                                 return -1;
645                         }
646                         object->type = test_var;
647                 } else {
648                         PyErr_Format(PyExc_TypeError, "Expected type %s or %s",\
649                           PyInt_Type.tp_name, PyLong_Type.tp_name);
650                         return -1;
651                 }
652         }
653         return 0;
654 }
655
656 static PyObject *py_witness_ResourceChange_get_name(PyObject *obj, void *closure)
657 {
658         struct witness_ResourceChange *object = (struct witness_ResourceChange *)pytalloc_get_ptr(obj);
659         PyObject *py_name;
660         py_name = PyString_FromStringOrNULL(object->name);
661         return py_name;
662 }
663
664 static int py_witness_ResourceChange_set_name(PyObject *py_obj, PyObject *value, void *closure)
665 {
666         struct witness_ResourceChange *object = (struct witness_ResourceChange *)pytalloc_get_ptr(py_obj);
667         if (value == NULL) {
668                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->name");
669                 return -1;
670         }
671         {
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) {
678                                 PyErr_NoMemory();
679                                 return -1;
680                         }
681                         test_str = PyString_AS_STRING(unicode);
682                 } else if (PyString_Check(value)) {
683                         test_str = PyString_AS_STRING(value);
684                 } else {
685                         PyErr_Format(PyExc_TypeError, "Expected string or unicode object, got %s", Py_TYPE(value)->tp_name);
686                         return -1;
687                 }
688                 talloc_str = talloc_strdup(pytalloc_get_mem_ctx(py_obj), test_str);
689                 if (unicode != NULL) {
690                         Py_DECREF(unicode);
691                 }
692                 if (talloc_str == NULL) {
693                         PyErr_NoMemory();
694                         return -1;
695                 }
696                 object->name = talloc_str;
697         }
698         return 0;
699 }
700
701 static PyGetSetDef py_witness_ResourceChange_getsetters[] = {
702         {
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")
707         },
708         {
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")
713         },
714         {
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")
719         },
720         { .name = NULL }
721 };
722
723 static PyObject *py_witness_ResourceChange_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
724 {
725         return pytalloc_new(struct witness_ResourceChange, type);
726 }
727
728 static PyObject *py_witness_ResourceChange_ndr_pack(PyObject *py_obj)
729 {
730         struct witness_ResourceChange *object = (struct witness_ResourceChange *)pytalloc_get_ptr(py_obj);
731         PyObject *ret = NULL;
732         DATA_BLOB blob;
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);
737                 return NULL;
738         }
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);
743                 return NULL;
744         }
745
746         ret = PyString_FromStringAndSize((char *)blob.data, blob.length);
747         TALLOC_FREE(tmp_ctx);
748         return ret;
749 }
750
751 static PyObject *py_witness_ResourceChange_ndr_unpack(PyObject *py_obj, PyObject *args, PyObject *kwargs)
752 {
753         struct witness_ResourceChange *object = (struct witness_ResourceChange *)pytalloc_get_ptr(py_obj);
754         DATA_BLOB blob;
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;
760
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)) {
765                 return NULL;
766         }
767         blob.length = blob_length;
768
769         if (allow_remaining_obj && PyObject_IsTrue(allow_remaining_obj)) {
770                 allow_remaining = true;
771         }
772
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);
775         } else {
776                 err = ndr_pull_struct_blob_all(&blob, pytalloc_get_mem_ctx(py_obj), object, (ndr_pull_flags_fn_t)ndr_pull_witness_ResourceChange);
777         }
778         if (err != NDR_ERR_SUCCESS) {
779                 PyErr_SetNdrError(err);
780                 return NULL;
781         }
782
783         Py_RETURN_NONE;
784 }
785
786 static PyObject *py_witness_ResourceChange_ndr_print(PyObject *py_obj)
787 {
788         struct witness_ResourceChange *object = (struct witness_ResourceChange *)pytalloc_get_ptr(py_obj);
789         PyObject *ret;
790         char *retstr;
791
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);
794         talloc_free(retstr);
795
796         return ret;
797 }
798
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 }
804 };
805
806
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,
814 };
815
816
817 static PyObject *py_witness_IPaddrInfo_get_flags(PyObject *obj, void *closure)
818 {
819         struct witness_IPaddrInfo *object = (struct witness_IPaddrInfo *)pytalloc_get_ptr(obj);
820         PyObject *py_flags;
821         py_flags = ndr_PyLong_FromUnsignedLongLong((uint32_t)object->flags);
822         return py_flags;
823 }
824
825 static int py_witness_IPaddrInfo_set_flags(PyObject *py_obj, PyObject *value, void *closure)
826 {
827         struct witness_IPaddrInfo *object = (struct witness_IPaddrInfo *)pytalloc_get_ptr(py_obj);
828         if (value == NULL) {
829                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->flags");
830                 return -1;
831         }
832         {
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) {
838                                 return -1;
839                         }
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);
843                                 return -1;
844                         }
845                         object->flags = test_var;
846                 } else if (PyInt_Check(value)) {
847                         long test_var;
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);
852                                 return -1;
853                         }
854                         object->flags = test_var;
855                 } else {
856                         PyErr_Format(PyExc_TypeError, "Expected type %s or %s",\
857                           PyInt_Type.tp_name, PyLong_Type.tp_name);
858                         return -1;
859                 }
860         }
861         return 0;
862 }
863
864 static PyObject *py_witness_IPaddrInfo_get_ipv4(PyObject *obj, void *closure)
865 {
866         struct witness_IPaddrInfo *object = (struct witness_IPaddrInfo *)pytalloc_get_ptr(obj);
867         PyObject *py_ipv4;
868         py_ipv4 = PyString_FromStringOrNULL(object->ipv4);
869         return py_ipv4;
870 }
871
872 static int py_witness_IPaddrInfo_set_ipv4(PyObject *py_obj, PyObject *value, void *closure)
873 {
874         struct witness_IPaddrInfo *object = (struct witness_IPaddrInfo *)pytalloc_get_ptr(py_obj);
875         if (value == NULL) {
876                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->ipv4");
877                 return -1;
878         }
879         {
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) {
886                                 PyErr_NoMemory();
887                                 return -1;
888                         }
889                         test_str = PyString_AS_STRING(unicode);
890                 } else if (PyString_Check(value)) {
891                         test_str = PyString_AS_STRING(value);
892                 } else {
893                         PyErr_Format(PyExc_TypeError, "Expected string or unicode object, got %s", Py_TYPE(value)->tp_name);
894                         return -1;
895                 }
896                 talloc_str = talloc_strdup(pytalloc_get_mem_ctx(py_obj), test_str);
897                 if (unicode != NULL) {
898                         Py_DECREF(unicode);
899                 }
900                 if (talloc_str == NULL) {
901                         PyErr_NoMemory();
902                         return -1;
903                 }
904                 object->ipv4 = talloc_str;
905         }
906         return 0;
907 }
908
909 static PyObject *py_witness_IPaddrInfo_get_ipv6(PyObject *obj, void *closure)
910 {
911         struct witness_IPaddrInfo *object = (struct witness_IPaddrInfo *)pytalloc_get_ptr(obj);
912         PyObject *py_ipv6;
913         py_ipv6 = PyString_FromStringOrNULL(object->ipv6);
914         return py_ipv6;
915 }
916
917 static int py_witness_IPaddrInfo_set_ipv6(PyObject *py_obj, PyObject *value, void *closure)
918 {
919         struct witness_IPaddrInfo *object = (struct witness_IPaddrInfo *)pytalloc_get_ptr(py_obj);
920         if (value == NULL) {
921                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->ipv6");
922                 return -1;
923         }
924         {
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) {
931                                 PyErr_NoMemory();
932                                 return -1;
933                         }
934                         test_str = PyString_AS_STRING(unicode);
935                 } else if (PyString_Check(value)) {
936                         test_str = PyString_AS_STRING(value);
937                 } else {
938                         PyErr_Format(PyExc_TypeError, "Expected string or unicode object, got %s", Py_TYPE(value)->tp_name);
939                         return -1;
940                 }
941                 talloc_str = talloc_strdup(pytalloc_get_mem_ctx(py_obj), test_str);
942                 if (unicode != NULL) {
943                         Py_DECREF(unicode);
944                 }
945                 if (talloc_str == NULL) {
946                         PyErr_NoMemory();
947                         return -1;
948                 }
949                 object->ipv6 = talloc_str;
950         }
951         return 0;
952 }
953
954 static PyGetSetDef py_witness_IPaddrInfo_getsetters[] = {
955         {
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")
960         },
961         {
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")
966         },
967         {
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")
972         },
973         { .name = NULL }
974 };
975
976 static PyObject *py_witness_IPaddrInfo_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
977 {
978         return pytalloc_new(struct witness_IPaddrInfo, type);
979 }
980
981
982 static PyTypeObject witness_IPaddrInfo_Type = {
983         PyObject_HEAD_INIT(NULL) 0,
984         .tp_name = "witness.IPaddrInfo",
985         .tp_getset = py_witness_IPaddrInfo_getsetters,
986         .tp_methods = NULL,
987         .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
988         .tp_new = py_witness_IPaddrInfo_new,
989 };
990
991
992 static PyObject *py_witness_IPaddrInfoList_get_length(PyObject *obj, void *closure)
993 {
994         struct witness_IPaddrInfoList *object = (struct witness_IPaddrInfoList *)pytalloc_get_ptr(obj);
995         PyObject *py_length;
996         py_length = ndr_PyLong_FromUnsignedLongLong((uint32_t)object->length);
997         return py_length;
998 }
999
1000 static int py_witness_IPaddrInfoList_set_length(PyObject *py_obj, PyObject *value, void *closure)
1001 {
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");
1005                 return -1;
1006         }
1007         {
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) {
1013                                 return -1;
1014                         }
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);
1018                                 return -1;
1019                         }
1020                         object->length = test_var;
1021                 } else if (PyInt_Check(value)) {
1022                         long test_var;
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);
1027                                 return -1;
1028                         }
1029                         object->length = test_var;
1030                 } else {
1031                         PyErr_Format(PyExc_TypeError, "Expected type %s or %s",\
1032                           PyInt_Type.tp_name, PyLong_Type.tp_name);
1033                         return -1;
1034                 }
1035         }
1036         return 0;
1037 }
1038
1039 static PyObject *py_witness_IPaddrInfoList_get_reserved(PyObject *obj, void *closure)
1040 {
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);
1044         return py_reserved;
1045 }
1046
1047 static int py_witness_IPaddrInfoList_set_reserved(PyObject *py_obj, PyObject *value, void *closure)
1048 {
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");
1052                 return -1;
1053         }
1054         {
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) {
1060                                 return -1;
1061                         }
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);
1065                                 return -1;
1066                         }
1067                         object->reserved = test_var;
1068                 } else if (PyInt_Check(value)) {
1069                         long test_var;
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);
1074                                 return -1;
1075                         }
1076                         object->reserved = test_var;
1077                 } else {
1078                         PyErr_Format(PyExc_TypeError, "Expected type %s or %s",\
1079                           PyInt_Type.tp_name, PyLong_Type.tp_name);
1080                         return -1;
1081                 }
1082         }
1083         return 0;
1084 }
1085
1086 static PyObject *py_witness_IPaddrInfoList_get_num(PyObject *obj, void *closure)
1087 {
1088         struct witness_IPaddrInfoList *object = (struct witness_IPaddrInfoList *)pytalloc_get_ptr(obj);
1089         PyObject *py_num;
1090         py_num = ndr_PyLong_FromUnsignedLongLong((uint32_t)object->num);
1091         return py_num;
1092 }
1093
1094 static int py_witness_IPaddrInfoList_set_num(PyObject *py_obj, PyObject *value, void *closure)
1095 {
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");
1099                 return -1;
1100         }
1101         {
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) {
1107                                 return -1;
1108                         }
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);
1112                                 return -1;
1113                         }
1114                         object->num = test_var;
1115                 } else if (PyInt_Check(value)) {
1116                         long test_var;
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);
1121                                 return -1;
1122                         }
1123                         object->num = test_var;
1124                 } else {
1125                         PyErr_Format(PyExc_TypeError, "Expected type %s or %s",\
1126                           PyInt_Type.tp_name, PyLong_Type.tp_name);
1127                         return -1;
1128                 }
1129         }
1130         return 0;
1131 }
1132
1133 static PyObject *py_witness_IPaddrInfoList_get_addr(PyObject *obj, void *closure)
1134 {
1135         struct witness_IPaddrInfoList *object = (struct witness_IPaddrInfoList *)pytalloc_get_ptr(obj);
1136         PyObject *py_addr;
1137         py_addr = PyList_New(object->num);
1138         if (py_addr == NULL) {
1139                 return NULL;
1140         }
1141         {
1142                 int addr_cntr_0;
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);
1147                 }
1148         }
1149         return py_addr;
1150 }
1151
1152 static int py_witness_IPaddrInfoList_set_addr(PyObject *py_obj, PyObject *value, void *closure)
1153 {
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");
1157                 return -1;
1158         }
1159         PY_CHECK_TYPE(&PyList_Type, value, return -1;);
1160         {
1161                 int addr_cntr_0;
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]");
1168                                 return -1;
1169                         }
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) {
1172                                 PyErr_NoMemory();
1173                                 return -1;
1174                         }
1175                         object->addr[addr_cntr_0] = *(struct witness_IPaddrInfo *)pytalloc_get_ptr(PyList_GET_ITEM(value, addr_cntr_0));
1176                 }
1177         }
1178         return 0;
1179 }
1180
1181 static PyGetSetDef py_witness_IPaddrInfoList_getsetters[] = {
1182         {
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")
1187         },
1188         {
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")
1193         },
1194         {
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")
1199         },
1200         {
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")
1205         },
1206         { .name = NULL }
1207 };
1208
1209 static PyObject *py_witness_IPaddrInfoList_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
1210 {
1211         return pytalloc_new(struct witness_IPaddrInfoList, type);
1212 }
1213
1214
1215 static PyTypeObject witness_IPaddrInfoList_Type = {
1216         PyObject_HEAD_INIT(NULL) 0,
1217         .tp_name = "witness.IPaddrInfoList",
1218         .tp_getset = py_witness_IPaddrInfoList_getsetters,
1219         .tp_methods = NULL,
1220         .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
1221         .tp_new = py_witness_IPaddrInfoList_new,
1222 };
1223
1224 PyObject *py_import_witness_notifyResponse_message(TALLOC_CTX *mem_ctx, int level, union witness_notifyResponse_message *in)
1225 {
1226         PyObject *ret;
1227
1228         switch (level) {
1229                 case WITNESS_NOTIFY_RESOURCE_CHANGE:
1230                         ret = pytalloc_reference_ex(&witness_ResourceChange_Type, mem_ctx, &in->resource_change);
1231                         return ret;
1232
1233                 case WITNESS_NOTIFY_CLIENT_MOVE:
1234                         ret = pytalloc_reference_ex(&witness_IPaddrInfoList_Type, mem_ctx, &in->client_move);
1235                         return ret;
1236
1237                 case WITNESS_NOTIFY_SHARE_MOVE:
1238                         ret = pytalloc_reference_ex(&witness_IPaddrInfoList_Type, mem_ctx, &in->share_move);
1239                         return ret;
1240
1241                 case WITNESS_NOTIFY_IP_CHANGE:
1242                         ret = pytalloc_reference_ex(&witness_IPaddrInfoList_Type, mem_ctx, &in->ip_change);
1243                         return ret;
1244
1245                 default:
1246                         ret = PyString_FromStringAndSize((char *)(in->data).data, (in->data).length);
1247                         return ret;
1248
1249         }
1250         PyErr_SetString(PyExc_TypeError, "unknown union level");
1251         return NULL;
1252 }
1253
1254 union witness_notifyResponse_message *py_export_witness_notifyResponse_message(TALLOC_CTX *mem_ctx, int level, PyObject *in)
1255 {
1256         union witness_notifyResponse_message *ret = talloc_zero(mem_ctx, union witness_notifyResponse_message);
1257         switch (level) {
1258                 case WITNESS_NOTIFY_RESOURCE_CHANGE:
1259                         if (in == NULL) {
1260                                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct ret->resource_change");
1261                                 talloc_free(ret); return NULL;
1262                         }
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) {
1265                                 PyErr_NoMemory();
1266                                 talloc_free(ret); return NULL;
1267                         }
1268                         ret->resource_change = *(struct witness_ResourceChange *)pytalloc_get_ptr(in);
1269                         break;
1270
1271                 case WITNESS_NOTIFY_CLIENT_MOVE:
1272                         if (in == NULL) {
1273                                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct ret->client_move");
1274                                 talloc_free(ret); return NULL;
1275                         }
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) {
1278                                 PyErr_NoMemory();
1279                                 talloc_free(ret); return NULL;
1280                         }
1281                         ret->client_move = *(struct witness_IPaddrInfoList *)pytalloc_get_ptr(in);
1282                         break;
1283
1284                 case WITNESS_NOTIFY_SHARE_MOVE:
1285                         if (in == NULL) {
1286                                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct ret->share_move");
1287                                 talloc_free(ret); return NULL;
1288                         }
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) {
1291                                 PyErr_NoMemory();
1292                                 talloc_free(ret); return NULL;
1293                         }
1294                         ret->share_move = *(struct witness_IPaddrInfoList *)pytalloc_get_ptr(in);
1295                         break;
1296
1297                 case WITNESS_NOTIFY_IP_CHANGE:
1298                         if (in == NULL) {
1299                                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct ret->ip_change");
1300                                 talloc_free(ret); return NULL;
1301                         }
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) {
1304                                 PyErr_NoMemory();
1305                                 talloc_free(ret); return NULL;
1306                         }
1307                         ret->ip_change = *(struct witness_IPaddrInfoList *)pytalloc_get_ptr(in);
1308                         break;
1309
1310                 default:
1311                         if (in == NULL) {
1312                                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct ret->data");
1313                                 talloc_free(ret); return NULL;
1314                         }
1315                         ret->data = data_blob_talloc(mem_ctx, PyString_AS_STRING(in), PyString_GET_SIZE(in));
1316                         break;
1317
1318         }
1319
1320         return ret;
1321 }
1322
1323
1324 static PyObject *py_witness_notifyResponse_get_type(PyObject *obj, void *closure)
1325 {
1326         struct witness_notifyResponse *object = (struct witness_notifyResponse *)pytalloc_get_ptr(obj);
1327         PyObject *py_type;
1328         py_type = ndr_PyLong_FromUnsignedLongLong((uint32_t)object->type);
1329         return py_type;
1330 }
1331
1332 static int py_witness_notifyResponse_set_type(PyObject *py_obj, PyObject *value, void *closure)
1333 {
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");
1337                 return -1;
1338         }
1339         {
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) {
1345                                 return -1;
1346                         }
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);
1350                                 return -1;
1351                         }
1352                         object->type = test_var;
1353                 } else if (PyInt_Check(value)) {
1354                         long test_var;
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);
1359                                 return -1;
1360                         }
1361                         object->type = test_var;
1362                 } else {
1363                         PyErr_Format(PyExc_TypeError, "Expected type %s or %s",\
1364                           PyInt_Type.tp_name, PyLong_Type.tp_name);
1365                         return -1;
1366                 }
1367         }
1368         return 0;
1369 }
1370
1371 static PyObject *py_witness_notifyResponse_get_length(PyObject *obj, void *closure)
1372 {
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);
1376         return py_length;
1377 }
1378
1379 static int py_witness_notifyResponse_set_length(PyObject *py_obj, PyObject *value, void *closure)
1380 {
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");
1384                 return -1;
1385         }
1386         {
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) {
1392                                 return -1;
1393                         }
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);
1397                                 return -1;
1398                         }
1399                         object->length = test_var;
1400                 } else if (PyInt_Check(value)) {
1401                         long test_var;
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);
1406                                 return -1;
1407                         }
1408                         object->length = test_var;
1409                 } else {
1410                         PyErr_Format(PyExc_TypeError, "Expected type %s or %s",\
1411                           PyInt_Type.tp_name, PyLong_Type.tp_name);
1412                         return -1;
1413                 }
1414         }
1415         return 0;
1416 }
1417
1418 static PyObject *py_witness_notifyResponse_get_num(PyObject *obj, void *closure)
1419 {
1420         struct witness_notifyResponse *object = (struct witness_notifyResponse *)pytalloc_get_ptr(obj);
1421         PyObject *py_num;
1422         py_num = ndr_PyLong_FromUnsignedLongLong((uint32_t)object->num);
1423         return py_num;
1424 }
1425
1426 static int py_witness_notifyResponse_set_num(PyObject *py_obj, PyObject *value, void *closure)
1427 {
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");
1431                 return -1;
1432         }
1433         {
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) {
1439                                 return -1;
1440                         }
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);
1444                                 return -1;
1445                         }
1446                         object->num = test_var;
1447                 } else if (PyInt_Check(value)) {
1448                         long test_var;
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);
1453                                 return -1;
1454                         }
1455                         object->num = test_var;
1456                 } else {
1457                         PyErr_Format(PyExc_TypeError, "Expected type %s or %s",\
1458                           PyInt_Type.tp_name, PyLong_Type.tp_name);
1459                         return -1;
1460                 }
1461         }
1462         return 0;
1463 }
1464
1465 static PyObject *py_witness_notifyResponse_get_messages(PyObject *obj, void *closure)
1466 {
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) {
1471                 return NULL;
1472         }
1473         {
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) {
1479                                 return NULL;
1480                         }
1481                         PyList_SetItem(py_messages, messages_cntr_0, py_messages_0);
1482                 }
1483         }
1484         return py_messages;
1485 }
1486
1487 static int py_witness_notifyResponse_set_messages(PyObject *py_obj, PyObject *value, void *closure)
1488 {
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");
1492                 return -1;
1493         }
1494         PY_CHECK_TYPE(&PyList_Type, value, return -1;);
1495         {
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]");
1503                                 return -1;
1504                         }
1505                         {
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) {
1509                                         return -1;
1510                                 }
1511                                 object->messages[messages_cntr_0] = *messages_switch_2;
1512                         }
1513                 }
1514         }
1515         return 0;
1516 }
1517
1518 static PyGetSetDef py_witness_notifyResponse_getsetters[] = {
1519         {
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")
1524         },
1525         {
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")
1530         },
1531         {
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")
1536         },
1537         {
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")
1542         },
1543         { .name = NULL }
1544 };
1545
1546 static PyObject *py_witness_notifyResponse_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
1547 {
1548         return pytalloc_new(struct witness_notifyResponse, type);
1549 }
1550
1551 static PyObject *py_witness_notifyResponse_ndr_pack(PyObject *py_obj)
1552 {
1553         struct witness_notifyResponse *object = (struct witness_notifyResponse *)pytalloc_get_ptr(py_obj);
1554         PyObject *ret = NULL;
1555         DATA_BLOB blob;
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);
1560                 return NULL;
1561         }
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);
1566                 return NULL;
1567         }
1568
1569         ret = PyString_FromStringAndSize((char *)blob.data, blob.length);
1570         TALLOC_FREE(tmp_ctx);
1571         return ret;
1572 }
1573
1574 static PyObject *py_witness_notifyResponse_ndr_unpack(PyObject *py_obj, PyObject *args, PyObject *kwargs)
1575 {
1576         struct witness_notifyResponse *object = (struct witness_notifyResponse *)pytalloc_get_ptr(py_obj);
1577         DATA_BLOB blob;
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;
1583
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)) {
1588                 return NULL;
1589         }
1590         blob.length = blob_length;
1591
1592         if (allow_remaining_obj && PyObject_IsTrue(allow_remaining_obj)) {
1593                 allow_remaining = true;
1594         }
1595
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);
1598         } else {
1599                 err = ndr_pull_struct_blob_all(&blob, pytalloc_get_mem_ctx(py_obj), object, (ndr_pull_flags_fn_t)ndr_pull_witness_notifyResponse);
1600         }
1601         if (err != NDR_ERR_SUCCESS) {
1602                 PyErr_SetNdrError(err);
1603                 return NULL;
1604         }
1605
1606         Py_RETURN_NONE;
1607 }
1608
1609 static PyObject *py_witness_notifyResponse_ndr_print(PyObject *py_obj)
1610 {
1611         struct witness_notifyResponse *object = (struct witness_notifyResponse *)pytalloc_get_ptr(py_obj);
1612         PyObject *ret;
1613         char *retstr;
1614
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);
1618
1619         return ret;
1620 }
1621
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 }
1627 };
1628
1629
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,
1637 };
1638
1639
1640 static bool pack_py_witness_GetInterfaceList_args_in(PyObject *args, PyObject *kwargs, struct witness_GetInterfaceList *r)
1641 {
1642         const char *kwnames[] = {
1643                 NULL
1644         };
1645
1646         if (!PyArg_ParseTupleAndKeywords(args, kwargs, ":witness_GetInterfaceList", discard_const_p(char *, kwnames))) {
1647                 return false;
1648         }
1649
1650         return true;
1651 }
1652
1653 static PyObject *unpack_py_witness_GetInterfaceList_args_out(struct witness_GetInterfaceList *r)
1654 {
1655         PyObject *result;
1656         PyObject *py_interface_list;
1657         if (*r->out.interface_list == NULL) {
1658                 py_interface_list = Py_None;
1659                 Py_INCREF(py_interface_list);
1660         } else {
1661                 py_interface_list = pytalloc_reference_ex(&witness_interfaceList_Type, *r->out.interface_list, *r->out.interface_list);
1662         }
1663         result = py_interface_list;
1664         if (!W_ERROR_IS_OK(r->out.result)) {
1665                 PyErr_SetWERROR(r->out.result);
1666                 return NULL;
1667         }
1668
1669         return result;
1670 }
1671
1672 static bool pack_py_witness_Register_args_in(PyObject *args, PyObject *kwargs, struct witness_Register *r)
1673 {
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
1680         };
1681
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)) {
1683                 return false;
1684         }
1685
1686         if (py_version == NULL) {
1687                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct r->in.version");
1688                 return false;
1689         }
1690         {
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) {
1696                                 return false;
1697                         }
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);
1701                                 return false;
1702                         }
1703                         r->in.version = test_var;
1704                 } else if (PyInt_Check(py_version)) {
1705                         long test_var;
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);
1710                                 return false;
1711                         }
1712                         r->in.version = test_var;
1713                 } else {
1714                         PyErr_Format(PyExc_TypeError, "Expected type %s or %s",\
1715                           PyInt_Type.tp_name, PyLong_Type.tp_name);
1716                         return false;
1717                 }
1718         }
1719         if (py_net_name == NULL) {
1720                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct r->in.net_name");
1721                 return false;
1722         }
1723         if (py_net_name == Py_None) {
1724                 r->in.net_name = NULL;
1725         } else {
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");
1729                         return false;
1730                 }
1731                 {
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) {
1738                                         PyErr_NoMemory();
1739                                         return false;
1740                                 }
1741                                 test_str = PyString_AS_STRING(unicode);
1742                         } else if (PyString_Check(py_net_name)) {
1743                                 test_str = PyString_AS_STRING(py_net_name);
1744                         } else {
1745                                 PyErr_Format(PyExc_TypeError, "Expected string or unicode object, got %s", Py_TYPE(py_net_name)->tp_name);
1746                                 return false;
1747                         }
1748                         talloc_str = talloc_strdup(r, test_str);
1749                         if (unicode != NULL) {
1750                                 Py_DECREF(unicode);
1751                         }
1752                         if (talloc_str == NULL) {
1753                                 PyErr_NoMemory();
1754                                 return false;
1755                         }
1756                         r->in.net_name = talloc_str;
1757                 }
1758         }
1759         if (py_ip_address == NULL) {
1760                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct r->in.ip_address");
1761                 return false;
1762         }
1763         if (py_ip_address == Py_None) {
1764                 r->in.ip_address = NULL;
1765         } else {
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");
1769                         return false;
1770                 }
1771                 {
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) {
1778                                         PyErr_NoMemory();
1779                                         return false;
1780                                 }
1781                                 test_str = PyString_AS_STRING(unicode);
1782                         } else if (PyString_Check(py_ip_address)) {
1783                                 test_str = PyString_AS_STRING(py_ip_address);
1784                         } else {
1785                                 PyErr_Format(PyExc_TypeError, "Expected string or unicode object, got %s", Py_TYPE(py_ip_address)->tp_name);
1786                                 return false;
1787                         }
1788                         talloc_str = talloc_strdup(r, test_str);
1789                         if (unicode != NULL) {
1790                                 Py_DECREF(unicode);
1791                         }
1792                         if (talloc_str == NULL) {
1793                                 PyErr_NoMemory();
1794                                 return false;
1795                         }
1796                         r->in.ip_address = talloc_str;
1797                 }
1798         }
1799         if (py_client_computer_name == NULL) {
1800                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct r->in.client_computer_name");
1801                 return false;
1802         }
1803         if (py_client_computer_name == Py_None) {
1804                 r->in.client_computer_name = NULL;
1805         } else {
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");
1809                         return false;
1810                 }
1811                 {
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) {
1818                                         PyErr_NoMemory();
1819                                         return false;
1820                                 }
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);
1824                         } else {
1825                                 PyErr_Format(PyExc_TypeError, "Expected string or unicode object, got %s", Py_TYPE(py_client_computer_name)->tp_name);
1826                                 return false;
1827                         }
1828                         talloc_str = talloc_strdup(r, test_str);
1829                         if (unicode != NULL) {
1830                                 Py_DECREF(unicode);
1831                         }
1832                         if (talloc_str == NULL) {
1833                                 PyErr_NoMemory();
1834                                 return false;
1835                         }
1836                         r->in.client_computer_name = talloc_str;
1837                 }
1838         }
1839         return true;
1840 }
1841
1842 static PyObject *unpack_py_witness_Register_args_out(struct witness_Register *r)
1843 {
1844         PyObject *result;
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);
1850                 return NULL;
1851         }
1852
1853         return result;
1854 }
1855
1856 static bool pack_py_witness_UnRegister_args_in(PyObject *args, PyObject *kwargs, struct witness_UnRegister *r)
1857 {
1858         PyObject *py_context_handle;
1859         const char *kwnames[] = {
1860                 "context_handle", NULL
1861         };
1862
1863         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:witness_UnRegister", discard_const_p(char *, kwnames), &py_context_handle)) {
1864                 return false;
1865         }
1866
1867         if (py_context_handle == NULL) {
1868                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct r->in.context_handle");
1869                 return false;
1870         }
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) {
1873                 PyErr_NoMemory();
1874                 return false;
1875         }
1876         r->in.context_handle = *(struct policy_handle *)pytalloc_get_ptr(py_context_handle);
1877         return true;
1878 }
1879
1880 static PyObject *unpack_py_witness_UnRegister_args_out(struct witness_UnRegister *r)
1881 {
1882         PyObject *result;
1883         result = Py_None;
1884         Py_INCREF(result);
1885         if (!W_ERROR_IS_OK(r->out.result)) {
1886                 PyErr_SetWERROR(r->out.result);
1887                 return NULL;
1888         }
1889
1890         return result;
1891 }
1892
1893 static bool pack_py_witness_AsyncNotify_args_in(PyObject *args, PyObject *kwargs, struct witness_AsyncNotify *r)
1894 {
1895         PyObject *py_context_handle;
1896         const char *kwnames[] = {
1897                 "context_handle", NULL
1898         };
1899
1900         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:witness_AsyncNotify", discard_const_p(char *, kwnames), &py_context_handle)) {
1901                 return false;
1902         }
1903
1904         if (py_context_handle == NULL) {
1905                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct r->in.context_handle");
1906                 return false;
1907         }
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) {
1910                 PyErr_NoMemory();
1911                 return false;
1912         }
1913         r->in.context_handle = *(struct policy_handle *)pytalloc_get_ptr(py_context_handle);
1914         return true;
1915 }
1916
1917 static PyObject *unpack_py_witness_AsyncNotify_args_out(struct witness_AsyncNotify *r)
1918 {
1919         PyObject *result;
1920         PyObject *py_response;
1921         if (*r->out.response == NULL) {
1922                 py_response = Py_None;
1923                 Py_INCREF(py_response);
1924         } else {
1925                 py_response = pytalloc_reference_ex(&witness_notifyResponse_Type, *r->out.response, *r->out.response);
1926         }
1927         result = py_response;
1928         if (!W_ERROR_IS_OK(r->out.result)) {
1929                 PyErr_SetWERROR(r->out.result);
1930                 return NULL;
1931         }
1932
1933         return result;
1934 }
1935
1936 static bool pack_py_witness_RegisterEx_args_in(PyObject *args, PyObject *kwargs, struct witness_RegisterEx *r)
1937 {
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;
1943         PyObject *py_flags;
1944         PyObject *py_timeout;
1945         const char *kwnames[] = {
1946                 "version", "net_name", "share_name", "ip_address", "client_computer_name", "flags", "timeout", NULL
1947         };
1948
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)) {
1950                 return false;
1951         }
1952
1953         if (py_version == NULL) {
1954                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct r->in.version");
1955                 return false;
1956         }
1957         {
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) {
1963                                 return false;
1964                         }
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);
1968                                 return false;
1969                         }
1970                         r->in.version = test_var;
1971                 } else if (PyInt_Check(py_version)) {
1972                         long test_var;
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);
1977                                 return false;
1978                         }
1979                         r->in.version = test_var;
1980                 } else {
1981                         PyErr_Format(PyExc_TypeError, "Expected type %s or %s",\
1982                           PyInt_Type.tp_name, PyLong_Type.tp_name);
1983                         return false;
1984                 }
1985         }
1986         if (py_net_name == NULL) {
1987                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct r->in.net_name");
1988                 return false;
1989         }
1990         if (py_net_name == Py_None) {
1991                 r->in.net_name = NULL;
1992         } else {
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");
1996                         return false;
1997                 }
1998                 {
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) {
2005                                         PyErr_NoMemory();
2006                                         return false;
2007                                 }
2008                                 test_str = PyString_AS_STRING(unicode);
2009                         } else if (PyString_Check(py_net_name)) {
2010                                 test_str = PyString_AS_STRING(py_net_name);
2011                         } else {
2012                                 PyErr_Format(PyExc_TypeError, "Expected string or unicode object, got %s", Py_TYPE(py_net_name)->tp_name);
2013                                 return false;
2014                         }
2015                         talloc_str = talloc_strdup(r, test_str);
2016                         if (unicode != NULL) {
2017                                 Py_DECREF(unicode);
2018                         }
2019                         if (talloc_str == NULL) {
2020                                 PyErr_NoMemory();
2021                                 return false;
2022                         }
2023                         r->in.net_name = talloc_str;
2024                 }
2025         }
2026         if (py_share_name == NULL) {
2027                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct r->in.share_name");
2028                 return false;
2029         }
2030         if (py_share_name == Py_None) {
2031                 r->in.share_name = NULL;
2032         } else {
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");
2036                         return false;
2037                 }
2038                 {
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) {
2045                                         PyErr_NoMemory();
2046                                         return false;
2047                                 }
2048                                 test_str = PyString_AS_STRING(unicode);
2049                         } else if (PyString_Check(py_share_name)) {
2050                                 test_str = PyString_AS_STRING(py_share_name);
2051                         } else {
2052                                 PyErr_Format(PyExc_TypeError, "Expected string or unicode object, got %s", Py_TYPE(py_share_name)->tp_name);
2053                                 return false;
2054                         }
2055                         talloc_str = talloc_strdup(r, test_str);
2056                         if (unicode != NULL) {
2057                                 Py_DECREF(unicode);
2058                         }
2059                         if (talloc_str == NULL) {
2060                                 PyErr_NoMemory();
2061                                 return false;
2062                         }
2063                         r->in.share_name = talloc_str;
2064                 }
2065         }
2066         if (py_ip_address == NULL) {
2067                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct r->in.ip_address");
2068                 return false;
2069         }
2070         if (py_ip_address == Py_None) {
2071                 r->in.ip_address = NULL;
2072         } else {
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");
2076                         return false;
2077                 }
2078                 {
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) {
2085                                         PyErr_NoMemory();
2086                                         return false;
2087                                 }
2088                                 test_str = PyString_AS_STRING(unicode);
2089                         } else if (PyString_Check(py_ip_address)) {
2090                                 test_str = PyString_AS_STRING(py_ip_address);
2091                         } else {
2092                                 PyErr_Format(PyExc_TypeError, "Expected string or unicode object, got %s", Py_TYPE(py_ip_address)->tp_name);
2093                                 return false;
2094                         }
2095                         talloc_str = talloc_strdup(r, test_str);
2096                         if (unicode != NULL) {
2097                                 Py_DECREF(unicode);
2098                         }
2099                         if (talloc_str == NULL) {
2100                                 PyErr_NoMemory();
2101                                 return false;
2102                         }
2103                         r->in.ip_address = talloc_str;
2104                 }
2105         }
2106         if (py_client_computer_name == NULL) {
2107                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct r->in.client_computer_name");
2108                 return false;
2109         }
2110         if (py_client_computer_name == Py_None) {
2111                 r->in.client_computer_name = NULL;
2112         } else {
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");
2116                         return false;
2117                 }
2118                 {
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) {
2125                                         PyErr_NoMemory();
2126                                         return false;
2127                                 }
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);
2131                         } else {
2132                                 PyErr_Format(PyExc_TypeError, "Expected string or unicode object, got %s", Py_TYPE(py_client_computer_name)->tp_name);
2133                                 return false;
2134                         }
2135                         talloc_str = talloc_strdup(r, test_str);
2136                         if (unicode != NULL) {
2137                                 Py_DECREF(unicode);
2138                         }
2139                         if (talloc_str == NULL) {
2140                                 PyErr_NoMemory();
2141                                 return false;
2142                         }
2143                         r->in.client_computer_name = talloc_str;
2144                 }
2145         }
2146         if (py_flags == NULL) {
2147                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct r->in.flags");
2148                 return false;
2149         }
2150         {
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) {
2156                                 return false;
2157                         }
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);
2161                                 return false;
2162                         }
2163                         r->in.flags = test_var;
2164                 } else if (PyInt_Check(py_flags)) {
2165                         long test_var;
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);
2170                                 return false;
2171                         }
2172                         r->in.flags = test_var;
2173                 } else {
2174                         PyErr_Format(PyExc_TypeError, "Expected type %s or %s",\
2175                           PyInt_Type.tp_name, PyLong_Type.tp_name);
2176                         return false;
2177                 }
2178         }
2179         if (py_timeout == NULL) {
2180                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct r->in.timeout");
2181                 return false;
2182         }
2183         {
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) {
2189                                 return false;
2190                         }
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);
2194                                 return false;
2195                         }
2196                         r->in.timeout = test_var;
2197                 } else if (PyInt_Check(py_timeout)) {
2198                         long test_var;
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);
2203                                 return false;
2204                         }
2205                         r->in.timeout = test_var;
2206                 } else {
2207                         PyErr_Format(PyExc_TypeError, "Expected type %s or %s",\
2208                           PyInt_Type.tp_name, PyLong_Type.tp_name);
2209                         return false;
2210                 }
2211         }
2212         return true;
2213 }
2214
2215 static PyObject *unpack_py_witness_RegisterEx_args_out(struct witness_RegisterEx *r)
2216 {
2217         PyObject *result;
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);
2223                 return NULL;
2224         }
2225
2226         return result;
2227 }
2228
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 },
2235         { NULL }
2236 };
2237
2238 static PyObject *interface_witness_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
2239 {
2240         return py_dcerpc_interface_init_helper(type, args, kwargs, &ndr_table_witness);
2241 }
2242
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"
2249 "\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,
2255 };
2256
2257 static PyObject *syntax_witness_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
2258 {
2259         return py_dcerpc_syntax_init_helper(type, args, kwargs, &ndr_table_witness.syntax_id);
2260 }
2261
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,
2269 };
2270
2271 static PyMethodDef witness_methods[] = {
2272         { NULL, NULL, 0, NULL }
2273 };
2274
2275 void initwitness(void)
2276 {
2277         PyObject *m;
2278         PyObject *dep_samba_dcerpc_misc;
2279         PyObject *dep_talloc;
2280         PyObject *dep_samba_dcerpc_base;
2281
2282         dep_samba_dcerpc_misc = PyImport_ImportModule("samba.dcerpc.misc");
2283         if (dep_samba_dcerpc_misc == NULL)
2284                 return;
2285
2286         dep_talloc = PyImport_ImportModule("talloc");
2287         if (dep_talloc == NULL)
2288                 return;
2289
2290         dep_samba_dcerpc_base = PyImport_ImportModule("samba.dcerpc.base");
2291         if (dep_samba_dcerpc_base == NULL)
2292                 return;
2293
2294         BaseObject_Type = (PyTypeObject *)PyObject_GetAttrString(dep_talloc, "BaseObject");
2295         if (BaseObject_Type == NULL)
2296                 return;
2297
2298         policy_handle_Type = (PyTypeObject *)PyObject_GetAttrString(dep_samba_dcerpc_misc, "policy_handle");
2299         if (policy_handle_Type == NULL)
2300                 return;
2301
2302         ClientConnection_Type = (PyTypeObject *)PyObject_GetAttrString(dep_samba_dcerpc_base, "ClientConnection");
2303         if (ClientConnection_Type == NULL)
2304                 return;
2305
2306         ndr_syntax_id_Type = (PyTypeObject *)PyObject_GetAttrString(dep_samba_dcerpc_misc, "ndr_syntax_id");
2307         if (ndr_syntax_id_Type == NULL)
2308                 return;
2309
2310         witness_interfaceInfo_Type.tp_base = BaseObject_Type;
2311         witness_interfaceInfo_Type.tp_basicsize = pytalloc_BaseObject_size();
2312
2313         witness_interfaceList_Type.tp_base = BaseObject_Type;
2314         witness_interfaceList_Type.tp_basicsize = pytalloc_BaseObject_size();
2315
2316         witness_ResourceChange_Type.tp_base = BaseObject_Type;
2317         witness_ResourceChange_Type.tp_basicsize = pytalloc_BaseObject_size();
2318
2319         witness_IPaddrInfo_Type.tp_base = BaseObject_Type;
2320         witness_IPaddrInfo_Type.tp_basicsize = pytalloc_BaseObject_size();
2321
2322         witness_IPaddrInfoList_Type.tp_base = BaseObject_Type;
2323         witness_IPaddrInfoList_Type.tp_basicsize = pytalloc_BaseObject_size();
2324
2325         witness_notifyResponse_Type.tp_base = BaseObject_Type;
2326         witness_notifyResponse_Type.tp_basicsize = pytalloc_BaseObject_size();
2327
2328         witness_InterfaceType.tp_base = ClientConnection_Type;
2329
2330         witness_SyntaxType.tp_base = ndr_syntax_id_Type;
2331         witness_SyntaxType.tp_basicsize = pytalloc_BaseObject_size();
2332
2333         if (PyType_Ready(&witness_interfaceInfo_Type) < 0)
2334                 return;
2335         if (PyType_Ready(&witness_interfaceList_Type) < 0)
2336                 return;
2337         if (PyType_Ready(&witness_ResourceChange_Type) < 0)
2338                 return;
2339         if (PyType_Ready(&witness_IPaddrInfo_Type) < 0)
2340                 return;
2341         if (PyType_Ready(&witness_IPaddrInfoList_Type) < 0)
2342                 return;
2343         if (PyType_Ready(&witness_notifyResponse_Type) < 0)
2344                 return;
2345         if (PyType_Ready(&witness_InterfaceType) < 0)
2346                 return;
2347         if (PyType_Ready(&witness_SyntaxType) < 0)
2348                 return;
2349         if (!PyInterface_AddNdrRpcMethods(&witness_InterfaceType, py_ndr_witness_methods))
2350                 return;
2351
2352 #ifdef PY_INTERFACEINFO_PATCH
2353         PY_INTERFACEINFO_PATCH(&witness_interfaceInfo_Type);
2354 #endif
2355 #ifdef PY_INTERFACELIST_PATCH
2356         PY_INTERFACELIST_PATCH(&witness_interfaceList_Type);
2357 #endif
2358 #ifdef PY_RESOURCECHANGE_PATCH
2359         PY_RESOURCECHANGE_PATCH(&witness_ResourceChange_Type);
2360 #endif
2361 #ifdef PY_IPADDRINFO_PATCH
2362         PY_IPADDRINFO_PATCH(&witness_IPaddrInfo_Type);
2363 #endif
2364 #ifdef PY_IPADDRINFOLIST_PATCH
2365         PY_IPADDRINFOLIST_PATCH(&witness_IPaddrInfoList_Type);
2366 #endif
2367 #ifdef PY_NOTIFYRESPONSE_PATCH
2368         PY_NOTIFYRESPONSE_PATCH(&witness_notifyResponse_Type);
2369 #endif
2370 #ifdef PY_WITNESS_PATCH
2371         PY_WITNESS_PATCH(&witness_InterfaceType);
2372 #endif
2373 #ifdef PY_ABSTRACT_SYNTAX_PATCH
2374         PY_ABSTRACT_SYNTAX_PATCH(&witness_SyntaxType);
2375 #endif
2376
2377         m = Py_InitModule3("witness", witness_methods, "witness DCE/RPC");
2378         if (m == NULL)
2379                 return;
2380
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);
2421 #endif
2422
2423 }