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 #include <Python.h>
4 #include "includes.h"
5 #include <pytalloc.h>
6 #include "librpc/rpc/pyrpc.h"
7 #include "librpc/rpc/pyrpc_util.h"
8 #include "bin/default/librpc/gen_ndr/ndr_witness.h"
9 #include "bin/default/librpc/gen_ndr/ndr_witness_c.h"
10
11 /*
12  * These functions are here to ensure they can be optomised out by
13  * the compiler based on the constant input values
14  */
15
16 static inline unsigned long long ndr_sizeof2uintmax(size_t var_size)
17 {
18         switch (var_size) {
19         case 8:
20                 return UINT64_MAX;
21         case 4:
22                 return UINT32_MAX;
23         case 2:
24                 return UINT16_MAX;
25         case 1:
26                 return UINT8_MAX;
27         }
28
29         return 0;
30 }
31
32 static inline long long ndr_sizeof2intmax(size_t var_size)
33 {
34         switch (var_size) {
35         case 8:
36                 return INT64_MAX;
37         case 4:
38                 return INT32_MAX;
39         case 2:
40                 return INT16_MAX;
41         case 1:
42                 return INT8_MAX;
43         }
44
45         return 0;
46 }
47
48 static inline PyObject *ndr_PyLong_FromLongLong(long long v)
49 {
50         if (v > LONG_MAX || v < LONG_MIN) {
51                 return PyLong_FromLongLong(v);
52         } else {
53                 return PyInt_FromLong(v);
54         }
55 }
56
57 static inline PyObject *ndr_PyLong_FromUnsignedLongLong(unsigned long long v)
58 {
59         if (v > LONG_MAX) {
60                 return PyLong_FromUnsignedLongLong(v);
61         } else {
62                 return PyInt_FromLong(v);
63         }
64 }
65
66 #include "librpc/gen_ndr/misc.h"
67 static PyTypeObject witness_interfaceInfo_Type;
68 static PyTypeObject witness_interfaceList_Type;
69 static PyTypeObject witness_ResourceChange_Type;
70 static PyTypeObject witness_IPaddrInfo_Type;
71 static PyTypeObject witness_IPaddrInfoList_Type;
72 PyObject *py_import_witness_notifyResponse_message(TALLOC_CTX *mem_ctx, int level, union witness_notifyResponse_message *in);
73 union witness_notifyResponse_message *py_export_witness_notifyResponse_message(TALLOC_CTX *mem_ctx, int level, PyObject *in);
74 static PyTypeObject witness_notifyResponse_Type;
75 static PyTypeObject witness_InterfaceType;
76
77 void initwitness(void);static PyTypeObject *Object_Type;
78 static PyTypeObject *policy_handle_Type;
79 static PyTypeObject *ClientConnection_Type;
80 static PyTypeObject *ndr_syntax_id_Type;
81
82 static PyObject *py_witness_interfaceInfo_get_group_name(PyObject *obj, void *closure)
83 {
84         struct witness_interfaceInfo *object = (struct witness_interfaceInfo *)pytalloc_get_ptr(obj);
85         PyObject *py_group_name;
86         if (object->group_name == NULL) {
87                 py_group_name = Py_None;
88                 Py_INCREF(py_group_name);
89         } else {
90                 py_group_name = PyUnicode_Decode(object->group_name, strlen(object->group_name), "utf-8", "ignore");
91         }
92         return py_group_name;
93 }
94
95 static int py_witness_interfaceInfo_set_group_name(PyObject *py_obj, PyObject *value, void *closure)
96 {
97         struct witness_interfaceInfo *object = (struct witness_interfaceInfo *)pytalloc_get_ptr(py_obj);
98         if (PyUnicode_Check(value)) {
99                 object->group_name = PyString_AS_STRING(PyUnicode_AsEncodedString(value, "utf-8", "ignore"));
100         } else if (PyString_Check(value)) {
101                 object->group_name = PyString_AS_STRING(value);
102         } else {
103                 PyErr_Format(PyExc_TypeError, "Expected string or unicode object, got %s", Py_TYPE(value)->tp_name);
104                 return -1;
105         }
106         return 0;
107 }
108
109 static PyObject *py_witness_interfaceInfo_get_version(PyObject *obj, void *closure)
110 {
111         struct witness_interfaceInfo *object = (struct witness_interfaceInfo *)pytalloc_get_ptr(obj);
112         PyObject *py_version;
113         py_version = ndr_PyLong_FromUnsignedLongLong((uint32_t)object->version);
114         return py_version;
115 }
116
117 static int py_witness_interfaceInfo_set_version(PyObject *py_obj, PyObject *value, void *closure)
118 {
119         struct witness_interfaceInfo *object = (struct witness_interfaceInfo *)pytalloc_get_ptr(py_obj);
120         {
121                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->version));
122                 if (PyLong_Check(value)) {
123                         unsigned long long test_var;
124                         test_var = PyLong_AsUnsignedLongLong(value);
125                         if (PyErr_Occurred() != NULL) {
126                                 return -1;
127                         }
128                         if (test_var > uint_max) {
129                                 PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %llu",\
130                                   PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
131                                 return -1;
132                         }
133                         object->version = test_var;
134                 } else if (PyInt_Check(value)) {
135                         long test_var;
136                         test_var = PyInt_AsLong(value);
137                         if (test_var < 0 || test_var > uint_max) {
138                                 PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %ld",\
139                                   PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
140                                 return -1;
141                         }
142                         object->version = test_var;
143                 } else {
144                         PyErr_Format(PyExc_TypeError, "Expected type %s or %s",\
145                           PyInt_Type.tp_name, PyLong_Type.tp_name);
146                         return -1;
147                 }
148         }
149         return 0;
150 }
151
152 static PyObject *py_witness_interfaceInfo_get_state(PyObject *obj, void *closure)
153 {
154         struct witness_interfaceInfo *object = (struct witness_interfaceInfo *)pytalloc_get_ptr(obj);
155         PyObject *py_state;
156         py_state = PyInt_FromLong((uint16_t)object->state);
157         return py_state;
158 }
159
160 static int py_witness_interfaceInfo_set_state(PyObject *py_obj, PyObject *value, void *closure)
161 {
162         struct witness_interfaceInfo *object = (struct witness_interfaceInfo *)pytalloc_get_ptr(py_obj);
163         {
164                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->state));
165                 if (PyLong_Check(value)) {
166                         unsigned long long test_var;
167                         test_var = PyLong_AsUnsignedLongLong(value);
168                         if (PyErr_Occurred() != NULL) {
169                                 return -1;
170                         }
171                         if (test_var > uint_max) {
172                                 PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %llu",\
173                                   PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
174                                 return -1;
175                         }
176                         object->state = test_var;
177                 } else if (PyInt_Check(value)) {
178                         long test_var;
179                         test_var = PyInt_AsLong(value);
180                         if (test_var < 0 || test_var > uint_max) {
181                                 PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %ld",\
182                                   PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
183                                 return -1;
184                         }
185                         object->state = test_var;
186                 } else {
187                         PyErr_Format(PyExc_TypeError, "Expected type %s or %s",\
188                           PyInt_Type.tp_name, PyLong_Type.tp_name);
189                         return -1;
190                 }
191         }
192         return 0;
193 }
194
195 static PyObject *py_witness_interfaceInfo_get_ipv4(PyObject *obj, void *closure)
196 {
197         struct witness_interfaceInfo *object = (struct witness_interfaceInfo *)pytalloc_get_ptr(obj);
198         PyObject *py_ipv4;
199         py_ipv4 = PyString_FromStringOrNULL(object->ipv4);
200         return py_ipv4;
201 }
202
203 static int py_witness_interfaceInfo_set_ipv4(PyObject *py_obj, PyObject *value, void *closure)
204 {
205         struct witness_interfaceInfo *object = (struct witness_interfaceInfo *)pytalloc_get_ptr(py_obj);
206         object->ipv4 = PyString_AS_STRING(value);
207         return 0;
208 }
209
210 static PyObject *py_witness_interfaceInfo_get_ipv6(PyObject *obj, void *closure)
211 {
212         struct witness_interfaceInfo *object = (struct witness_interfaceInfo *)pytalloc_get_ptr(obj);
213         PyObject *py_ipv6;
214         py_ipv6 = PyString_FromStringOrNULL(object->ipv6);
215         return py_ipv6;
216 }
217
218 static int py_witness_interfaceInfo_set_ipv6(PyObject *py_obj, PyObject *value, void *closure)
219 {
220         struct witness_interfaceInfo *object = (struct witness_interfaceInfo *)pytalloc_get_ptr(py_obj);
221         object->ipv6 = PyString_AsString(value);
222         return 0;
223 }
224
225 static PyObject *py_witness_interfaceInfo_get_flags(PyObject *obj, void *closure)
226 {
227         struct witness_interfaceInfo *object = (struct witness_interfaceInfo *)pytalloc_get_ptr(obj);
228         PyObject *py_flags;
229         py_flags = ndr_PyLong_FromUnsignedLongLong((uint32_t)object->flags);
230         return py_flags;
231 }
232
233 static int py_witness_interfaceInfo_set_flags(PyObject *py_obj, PyObject *value, void *closure)
234 {
235         struct witness_interfaceInfo *object = (struct witness_interfaceInfo *)pytalloc_get_ptr(py_obj);
236         {
237                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->flags));
238                 if (PyLong_Check(value)) {
239                         unsigned long long test_var;
240                         test_var = PyLong_AsUnsignedLongLong(value);
241                         if (PyErr_Occurred() != NULL) {
242                                 return -1;
243                         }
244                         if (test_var > uint_max) {
245                                 PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %llu",\
246                                   PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
247                                 return -1;
248                         }
249                         object->flags = test_var;
250                 } else if (PyInt_Check(value)) {
251                         long test_var;
252                         test_var = PyInt_AsLong(value);
253                         if (test_var < 0 || test_var > uint_max) {
254                                 PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %ld",\
255                                   PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
256                                 return -1;
257                         }
258                         object->flags = test_var;
259                 } else {
260                         PyErr_Format(PyExc_TypeError, "Expected type %s or %s",\
261                           PyInt_Type.tp_name, PyLong_Type.tp_name);
262                         return -1;
263                 }
264         }
265         return 0;
266 }
267
268 static PyGetSetDef py_witness_interfaceInfo_getsetters[] = {
269         { discard_const_p(char, "group_name"), py_witness_interfaceInfo_get_group_name, py_witness_interfaceInfo_set_group_name },
270         { discard_const_p(char, "version"), py_witness_interfaceInfo_get_version, py_witness_interfaceInfo_set_version },
271         { discard_const_p(char, "state"), py_witness_interfaceInfo_get_state, py_witness_interfaceInfo_set_state },
272         { discard_const_p(char, "ipv4"), py_witness_interfaceInfo_get_ipv4, py_witness_interfaceInfo_set_ipv4 },
273         { discard_const_p(char, "ipv6"), py_witness_interfaceInfo_get_ipv6, py_witness_interfaceInfo_set_ipv6 },
274         { discard_const_p(char, "flags"), py_witness_interfaceInfo_get_flags, py_witness_interfaceInfo_set_flags },
275         { NULL }
276 };
277
278 static PyObject *py_witness_interfaceInfo_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
279 {
280         return pytalloc_new(struct witness_interfaceInfo, type);
281 }
282
283
284 static PyTypeObject witness_interfaceInfo_Type = {
285         PyObject_HEAD_INIT(NULL) 0,
286         .tp_name = "witness.interfaceInfo",
287         .tp_getset = py_witness_interfaceInfo_getsetters,
288         .tp_methods = NULL,
289         .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
290         .tp_basicsize = sizeof(pytalloc_Object),
291         .tp_new = py_witness_interfaceInfo_new,
292 };
293
294
295 static PyObject *py_witness_interfaceList_get_num_interfaces(PyObject *obj, void *closure)
296 {
297         struct witness_interfaceList *object = (struct witness_interfaceList *)pytalloc_get_ptr(obj);
298         PyObject *py_num_interfaces;
299         py_num_interfaces = ndr_PyLong_FromUnsignedLongLong((uint32_t)object->num_interfaces);
300         return py_num_interfaces;
301 }
302
303 static int py_witness_interfaceList_set_num_interfaces(PyObject *py_obj, PyObject *value, void *closure)
304 {
305         struct witness_interfaceList *object = (struct witness_interfaceList *)pytalloc_get_ptr(py_obj);
306         {
307                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->num_interfaces));
308                 if (PyLong_Check(value)) {
309                         unsigned long long test_var;
310                         test_var = PyLong_AsUnsignedLongLong(value);
311                         if (PyErr_Occurred() != NULL) {
312                                 return -1;
313                         }
314                         if (test_var > uint_max) {
315                                 PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %llu",\
316                                   PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
317                                 return -1;
318                         }
319                         object->num_interfaces = test_var;
320                 } else if (PyInt_Check(value)) {
321                         long test_var;
322                         test_var = PyInt_AsLong(value);
323                         if (test_var < 0 || test_var > uint_max) {
324                                 PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %ld",\
325                                   PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
326                                 return -1;
327                         }
328                         object->num_interfaces = test_var;
329                 } else {
330                         PyErr_Format(PyExc_TypeError, "Expected type %s or %s",\
331                           PyInt_Type.tp_name, PyLong_Type.tp_name);
332                         return -1;
333                 }
334         }
335         return 0;
336 }
337
338 static PyObject *py_witness_interfaceList_get_interfaces(PyObject *obj, void *closure)
339 {
340         struct witness_interfaceList *object = (struct witness_interfaceList *)pytalloc_get_ptr(obj);
341         PyObject *py_interfaces;
342         if (object->interfaces == NULL) {
343                 py_interfaces = Py_None;
344                 Py_INCREF(py_interfaces);
345         } else {
346                 py_interfaces = PyList_New(object->num_interfaces);
347                 if (py_interfaces == NULL) {
348                         return NULL;
349                 }
350                 {
351                         int interfaces_cntr_1;
352                         for (interfaces_cntr_1 = 0; interfaces_cntr_1 < (object->num_interfaces); interfaces_cntr_1++) {
353                                 PyObject *py_interfaces_1;
354                                 py_interfaces_1 = pytalloc_reference_ex(&witness_interfaceInfo_Type, object->interfaces, &object->interfaces[interfaces_cntr_1]);
355                                 PyList_SetItem(py_interfaces, interfaces_cntr_1, py_interfaces_1);
356                         }
357                 }
358         }
359         return py_interfaces;
360 }
361
362 static int py_witness_interfaceList_set_interfaces(PyObject *py_obj, PyObject *value, void *closure)
363 {
364         struct witness_interfaceList *object = (struct witness_interfaceList *)pytalloc_get_ptr(py_obj);
365         talloc_unlink(pytalloc_get_mem_ctx(py_obj), discard_const(object->interfaces));
366         if (value == Py_None) {
367                 object->interfaces = NULL;
368         } else {
369                 object->interfaces = NULL;
370                 PY_CHECK_TYPE(&PyList_Type, value, return -1;);
371                 {
372                         int interfaces_cntr_1;
373                         object->interfaces = talloc_array_ptrtype(pytalloc_get_mem_ctx(py_obj), object->interfaces, PyList_GET_SIZE(value));
374                         if (!object->interfaces) { return -1;; }
375                         talloc_set_name_const(object->interfaces, "ARRAY: object->interfaces");
376                         for (interfaces_cntr_1 = 0; interfaces_cntr_1 < PyList_GET_SIZE(value); interfaces_cntr_1++) {
377                                 PY_CHECK_TYPE(&witness_interfaceInfo_Type, PyList_GET_ITEM(value, interfaces_cntr_1), return -1;);
378                                 if (talloc_reference(object->interfaces, pytalloc_get_mem_ctx(PyList_GET_ITEM(value, interfaces_cntr_1))) == NULL) {
379                                         PyErr_NoMemory();
380                                         return -1;
381                                 }
382                                 object->interfaces[interfaces_cntr_1] = *(struct witness_interfaceInfo *)pytalloc_get_ptr(PyList_GET_ITEM(value, interfaces_cntr_1));
383                         }
384                 }
385         }
386         return 0;
387 }
388
389 static PyGetSetDef py_witness_interfaceList_getsetters[] = {
390         { discard_const_p(char, "num_interfaces"), py_witness_interfaceList_get_num_interfaces, py_witness_interfaceList_set_num_interfaces },
391         { discard_const_p(char, "interfaces"), py_witness_interfaceList_get_interfaces, py_witness_interfaceList_set_interfaces },
392         { NULL }
393 };
394
395 static PyObject *py_witness_interfaceList_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
396 {
397         return pytalloc_new(struct witness_interfaceList, type);
398 }
399
400
401 static PyTypeObject witness_interfaceList_Type = {
402         PyObject_HEAD_INIT(NULL) 0,
403         .tp_name = "witness.interfaceList",
404         .tp_getset = py_witness_interfaceList_getsetters,
405         .tp_methods = NULL,
406         .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
407         .tp_basicsize = sizeof(pytalloc_Object),
408         .tp_new = py_witness_interfaceList_new,
409 };
410
411
412 static PyObject *py_witness_ResourceChange_get_length(PyObject *obj, void *closure)
413 {
414         struct witness_ResourceChange *object = (struct witness_ResourceChange *)pytalloc_get_ptr(obj);
415         PyObject *py_length;
416         py_length = ndr_PyLong_FromUnsignedLongLong((uint32_t)object->length);
417         return py_length;
418 }
419
420 static int py_witness_ResourceChange_set_length(PyObject *py_obj, PyObject *value, void *closure)
421 {
422         struct witness_ResourceChange *object = (struct witness_ResourceChange *)pytalloc_get_ptr(py_obj);
423         {
424                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->length));
425                 if (PyLong_Check(value)) {
426                         unsigned long long test_var;
427                         test_var = PyLong_AsUnsignedLongLong(value);
428                         if (PyErr_Occurred() != NULL) {
429                                 return -1;
430                         }
431                         if (test_var > uint_max) {
432                                 PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %llu",\
433                                   PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
434                                 return -1;
435                         }
436                         object->length = test_var;
437                 } else if (PyInt_Check(value)) {
438                         long test_var;
439                         test_var = PyInt_AsLong(value);
440                         if (test_var < 0 || test_var > uint_max) {
441                                 PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %ld",\
442                                   PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
443                                 return -1;
444                         }
445                         object->length = test_var;
446                 } else {
447                         PyErr_Format(PyExc_TypeError, "Expected type %s or %s",\
448                           PyInt_Type.tp_name, PyLong_Type.tp_name);
449                         return -1;
450                 }
451         }
452         return 0;
453 }
454
455 static PyObject *py_witness_ResourceChange_get_type(PyObject *obj, void *closure)
456 {
457         struct witness_ResourceChange *object = (struct witness_ResourceChange *)pytalloc_get_ptr(obj);
458         PyObject *py_type;
459         py_type = ndr_PyLong_FromUnsignedLongLong((uint32_t)object->type);
460         return py_type;
461 }
462
463 static int py_witness_ResourceChange_set_type(PyObject *py_obj, PyObject *value, void *closure)
464 {
465         struct witness_ResourceChange *object = (struct witness_ResourceChange *)pytalloc_get_ptr(py_obj);
466         {
467                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->type));
468                 if (PyLong_Check(value)) {
469                         unsigned long long test_var;
470                         test_var = PyLong_AsUnsignedLongLong(value);
471                         if (PyErr_Occurred() != NULL) {
472                                 return -1;
473                         }
474                         if (test_var > uint_max) {
475                                 PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %llu",\
476                                   PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
477                                 return -1;
478                         }
479                         object->type = test_var;
480                 } else if (PyInt_Check(value)) {
481                         long test_var;
482                         test_var = PyInt_AsLong(value);
483                         if (test_var < 0 || test_var > uint_max) {
484                                 PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %ld",\
485                                   PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
486                                 return -1;
487                         }
488                         object->type = test_var;
489                 } else {
490                         PyErr_Format(PyExc_TypeError, "Expected type %s or %s",\
491                           PyInt_Type.tp_name, PyLong_Type.tp_name);
492                         return -1;
493                 }
494         }
495         return 0;
496 }
497
498 static PyObject *py_witness_ResourceChange_get_name(PyObject *obj, void *closure)
499 {
500         struct witness_ResourceChange *object = (struct witness_ResourceChange *)pytalloc_get_ptr(obj);
501         PyObject *py_name;
502         py_name = PyString_FromStringOrNULL(object->name);
503         return py_name;
504 }
505
506 static int py_witness_ResourceChange_set_name(PyObject *py_obj, PyObject *value, void *closure)
507 {
508         struct witness_ResourceChange *object = (struct witness_ResourceChange *)pytalloc_get_ptr(py_obj);
509         object->name = talloc_strdup(pytalloc_get_mem_ctx(py_obj), PyString_AS_STRING(value));
510         return 0;
511 }
512
513 static PyGetSetDef py_witness_ResourceChange_getsetters[] = {
514         { discard_const_p(char, "length"), py_witness_ResourceChange_get_length, py_witness_ResourceChange_set_length },
515         { discard_const_p(char, "type"), py_witness_ResourceChange_get_type, py_witness_ResourceChange_set_type },
516         { discard_const_p(char, "name"), py_witness_ResourceChange_get_name, py_witness_ResourceChange_set_name },
517         { NULL }
518 };
519
520 static PyObject *py_witness_ResourceChange_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
521 {
522         return pytalloc_new(struct witness_ResourceChange, type);
523 }
524
525 static PyObject *py_witness_ResourceChange_ndr_pack(PyObject *py_obj)
526 {
527         struct witness_ResourceChange *object = (struct witness_ResourceChange *)pytalloc_get_ptr(py_obj);
528         DATA_BLOB blob;
529         enum ndr_err_code err;
530         err = ndr_push_struct_blob(&blob, pytalloc_get_mem_ctx(py_obj), object, (ndr_push_flags_fn_t)ndr_push_witness_ResourceChange);
531         if (err != NDR_ERR_SUCCESS) {
532                 PyErr_SetNdrError(err);
533                 return NULL;
534         }
535
536         return PyString_FromStringAndSize((char *)blob.data, blob.length);
537 }
538
539 static PyObject *py_witness_ResourceChange_ndr_unpack(PyObject *py_obj, PyObject *args, PyObject *kwargs)
540 {
541         struct witness_ResourceChange *object = (struct witness_ResourceChange *)pytalloc_get_ptr(py_obj);
542         DATA_BLOB blob;
543         int blob_length = 0;
544         enum ndr_err_code err;
545         const char * const kwnames[] = { "data_blob", "allow_remaining", NULL };
546         PyObject *allow_remaining_obj = NULL;
547         bool allow_remaining = false;
548
549         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s#|O:__ndr_unpack__",
550                 discard_const_p(char *, kwnames),
551                 &blob.data, &blob_length,
552                 &allow_remaining_obj)) {
553                 return NULL;
554         }
555         blob.length = blob_length;
556
557         if (allow_remaining_obj && PyObject_IsTrue(allow_remaining_obj)) {
558                 allow_remaining = true;
559         }
560
561         if (allow_remaining) {
562                 err = ndr_pull_struct_blob(&blob, pytalloc_get_mem_ctx(py_obj), object, (ndr_pull_flags_fn_t)ndr_pull_witness_ResourceChange);
563         } else {
564                 err = ndr_pull_struct_blob_all(&blob, pytalloc_get_mem_ctx(py_obj), object, (ndr_pull_flags_fn_t)ndr_pull_witness_ResourceChange);
565         }
566         if (err != NDR_ERR_SUCCESS) {
567                 PyErr_SetNdrError(err);
568                 return NULL;
569         }
570
571         Py_RETURN_NONE;
572 }
573
574 static PyObject *py_witness_ResourceChange_ndr_print(PyObject *py_obj)
575 {
576         struct witness_ResourceChange *object = (struct witness_ResourceChange *)pytalloc_get_ptr(py_obj);
577         PyObject *ret;
578         char *retstr;
579
580         retstr = ndr_print_struct_string(pytalloc_get_mem_ctx(py_obj), (ndr_print_fn_t)ndr_print_witness_ResourceChange, "witness_ResourceChange", object);
581         ret = PyString_FromString(retstr);
582         talloc_free(retstr);
583
584         return ret;
585 }
586
587 static PyMethodDef py_witness_ResourceChange_methods[] = {
588         { "__ndr_pack__", (PyCFunction)py_witness_ResourceChange_ndr_pack, METH_NOARGS, "S.ndr_pack(object) -> blob\nNDR pack" },
589         { "__ndr_unpack__", (PyCFunction)py_witness_ResourceChange_ndr_unpack, METH_VARARGS|METH_KEYWORDS, "S.ndr_unpack(class, blob, allow_remaining=False) -> None\nNDR unpack" },
590         { "__ndr_print__", (PyCFunction)py_witness_ResourceChange_ndr_print, METH_VARARGS, "S.ndr_print(object) -> None\nNDR print" },
591         { NULL, NULL, 0, NULL }
592 };
593
594
595 static PyTypeObject witness_ResourceChange_Type = {
596         PyObject_HEAD_INIT(NULL) 0,
597         .tp_name = "witness.ResourceChange",
598         .tp_getset = py_witness_ResourceChange_getsetters,
599         .tp_methods = py_witness_ResourceChange_methods,
600         .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
601         .tp_basicsize = sizeof(pytalloc_Object),
602         .tp_new = py_witness_ResourceChange_new,
603 };
604
605
606 static PyObject *py_witness_IPaddrInfo_get_flags(PyObject *obj, void *closure)
607 {
608         struct witness_IPaddrInfo *object = (struct witness_IPaddrInfo *)pytalloc_get_ptr(obj);
609         PyObject *py_flags;
610         py_flags = ndr_PyLong_FromUnsignedLongLong((uint32_t)object->flags);
611         return py_flags;
612 }
613
614 static int py_witness_IPaddrInfo_set_flags(PyObject *py_obj, PyObject *value, void *closure)
615 {
616         struct witness_IPaddrInfo *object = (struct witness_IPaddrInfo *)pytalloc_get_ptr(py_obj);
617         {
618                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->flags));
619                 if (PyLong_Check(value)) {
620                         unsigned long long test_var;
621                         test_var = PyLong_AsUnsignedLongLong(value);
622                         if (PyErr_Occurred() != NULL) {
623                                 return -1;
624                         }
625                         if (test_var > uint_max) {
626                                 PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %llu",\
627                                   PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
628                                 return -1;
629                         }
630                         object->flags = test_var;
631                 } else if (PyInt_Check(value)) {
632                         long test_var;
633                         test_var = PyInt_AsLong(value);
634                         if (test_var < 0 || test_var > uint_max) {
635                                 PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %ld",\
636                                   PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
637                                 return -1;
638                         }
639                         object->flags = test_var;
640                 } else {
641                         PyErr_Format(PyExc_TypeError, "Expected type %s or %s",\
642                           PyInt_Type.tp_name, PyLong_Type.tp_name);
643                         return -1;
644                 }
645         }
646         return 0;
647 }
648
649 static PyObject *py_witness_IPaddrInfo_get_ipv4(PyObject *obj, void *closure)
650 {
651         struct witness_IPaddrInfo *object = (struct witness_IPaddrInfo *)pytalloc_get_ptr(obj);
652         PyObject *py_ipv4;
653         py_ipv4 = PyString_FromStringOrNULL(object->ipv4);
654         return py_ipv4;
655 }
656
657 static int py_witness_IPaddrInfo_set_ipv4(PyObject *py_obj, PyObject *value, void *closure)
658 {
659         struct witness_IPaddrInfo *object = (struct witness_IPaddrInfo *)pytalloc_get_ptr(py_obj);
660         object->ipv4 = PyString_AS_STRING(value);
661         return 0;
662 }
663
664 static PyObject *py_witness_IPaddrInfo_get_ipv6(PyObject *obj, void *closure)
665 {
666         struct witness_IPaddrInfo *object = (struct witness_IPaddrInfo *)pytalloc_get_ptr(obj);
667         PyObject *py_ipv6;
668         py_ipv6 = PyString_FromStringOrNULL(object->ipv6);
669         return py_ipv6;
670 }
671
672 static int py_witness_IPaddrInfo_set_ipv6(PyObject *py_obj, PyObject *value, void *closure)
673 {
674         struct witness_IPaddrInfo *object = (struct witness_IPaddrInfo *)pytalloc_get_ptr(py_obj);
675         object->ipv6 = PyString_AsString(value);
676         return 0;
677 }
678
679 static PyGetSetDef py_witness_IPaddrInfo_getsetters[] = {
680         { discard_const_p(char, "flags"), py_witness_IPaddrInfo_get_flags, py_witness_IPaddrInfo_set_flags },
681         { discard_const_p(char, "ipv4"), py_witness_IPaddrInfo_get_ipv4, py_witness_IPaddrInfo_set_ipv4 },
682         { discard_const_p(char, "ipv6"), py_witness_IPaddrInfo_get_ipv6, py_witness_IPaddrInfo_set_ipv6 },
683         { NULL }
684 };
685
686 static PyObject *py_witness_IPaddrInfo_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
687 {
688         return pytalloc_new(struct witness_IPaddrInfo, type);
689 }
690
691
692 static PyTypeObject witness_IPaddrInfo_Type = {
693         PyObject_HEAD_INIT(NULL) 0,
694         .tp_name = "witness.IPaddrInfo",
695         .tp_getset = py_witness_IPaddrInfo_getsetters,
696         .tp_methods = NULL,
697         .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
698         .tp_basicsize = sizeof(pytalloc_Object),
699         .tp_new = py_witness_IPaddrInfo_new,
700 };
701
702
703 static PyObject *py_witness_IPaddrInfoList_get_length(PyObject *obj, void *closure)
704 {
705         struct witness_IPaddrInfoList *object = (struct witness_IPaddrInfoList *)pytalloc_get_ptr(obj);
706         PyObject *py_length;
707         py_length = ndr_PyLong_FromUnsignedLongLong((uint32_t)object->length);
708         return py_length;
709 }
710
711 static int py_witness_IPaddrInfoList_set_length(PyObject *py_obj, PyObject *value, void *closure)
712 {
713         struct witness_IPaddrInfoList *object = (struct witness_IPaddrInfoList *)pytalloc_get_ptr(py_obj);
714         {
715                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->length));
716                 if (PyLong_Check(value)) {
717                         unsigned long long test_var;
718                         test_var = PyLong_AsUnsignedLongLong(value);
719                         if (PyErr_Occurred() != NULL) {
720                                 return -1;
721                         }
722                         if (test_var > uint_max) {
723                                 PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %llu",\
724                                   PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
725                                 return -1;
726                         }
727                         object->length = test_var;
728                 } else if (PyInt_Check(value)) {
729                         long test_var;
730                         test_var = PyInt_AsLong(value);
731                         if (test_var < 0 || test_var > uint_max) {
732                                 PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %ld",\
733                                   PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
734                                 return -1;
735                         }
736                         object->length = test_var;
737                 } else {
738                         PyErr_Format(PyExc_TypeError, "Expected type %s or %s",\
739                           PyInt_Type.tp_name, PyLong_Type.tp_name);
740                         return -1;
741                 }
742         }
743         return 0;
744 }
745
746 static PyObject *py_witness_IPaddrInfoList_get_reserved(PyObject *obj, void *closure)
747 {
748         struct witness_IPaddrInfoList *object = (struct witness_IPaddrInfoList *)pytalloc_get_ptr(obj);
749         PyObject *py_reserved;
750         py_reserved = ndr_PyLong_FromUnsignedLongLong((uint32_t)object->reserved);
751         return py_reserved;
752 }
753
754 static int py_witness_IPaddrInfoList_set_reserved(PyObject *py_obj, PyObject *value, void *closure)
755 {
756         struct witness_IPaddrInfoList *object = (struct witness_IPaddrInfoList *)pytalloc_get_ptr(py_obj);
757         {
758                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->reserved));
759                 if (PyLong_Check(value)) {
760                         unsigned long long test_var;
761                         test_var = PyLong_AsUnsignedLongLong(value);
762                         if (PyErr_Occurred() != NULL) {
763                                 return -1;
764                         }
765                         if (test_var > uint_max) {
766                                 PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %llu",\
767                                   PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
768                                 return -1;
769                         }
770                         object->reserved = test_var;
771                 } else if (PyInt_Check(value)) {
772                         long test_var;
773                         test_var = PyInt_AsLong(value);
774                         if (test_var < 0 || test_var > uint_max) {
775                                 PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %ld",\
776                                   PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
777                                 return -1;
778                         }
779                         object->reserved = test_var;
780                 } else {
781                         PyErr_Format(PyExc_TypeError, "Expected type %s or %s",\
782                           PyInt_Type.tp_name, PyLong_Type.tp_name);
783                         return -1;
784                 }
785         }
786         return 0;
787 }
788
789 static PyObject *py_witness_IPaddrInfoList_get_num(PyObject *obj, void *closure)
790 {
791         struct witness_IPaddrInfoList *object = (struct witness_IPaddrInfoList *)pytalloc_get_ptr(obj);
792         PyObject *py_num;
793         py_num = ndr_PyLong_FromUnsignedLongLong((uint32_t)object->num);
794         return py_num;
795 }
796
797 static int py_witness_IPaddrInfoList_set_num(PyObject *py_obj, PyObject *value, void *closure)
798 {
799         struct witness_IPaddrInfoList *object = (struct witness_IPaddrInfoList *)pytalloc_get_ptr(py_obj);
800         {
801                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->num));
802                 if (PyLong_Check(value)) {
803                         unsigned long long test_var;
804                         test_var = PyLong_AsUnsignedLongLong(value);
805                         if (PyErr_Occurred() != NULL) {
806                                 return -1;
807                         }
808                         if (test_var > uint_max) {
809                                 PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %llu",\
810                                   PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
811                                 return -1;
812                         }
813                         object->num = test_var;
814                 } else if (PyInt_Check(value)) {
815                         long test_var;
816                         test_var = PyInt_AsLong(value);
817                         if (test_var < 0 || test_var > uint_max) {
818                                 PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %ld",\
819                                   PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
820                                 return -1;
821                         }
822                         object->num = test_var;
823                 } else {
824                         PyErr_Format(PyExc_TypeError, "Expected type %s or %s",\
825                           PyInt_Type.tp_name, PyLong_Type.tp_name);
826                         return -1;
827                 }
828         }
829         return 0;
830 }
831
832 static PyObject *py_witness_IPaddrInfoList_get_addr(PyObject *obj, void *closure)
833 {
834         struct witness_IPaddrInfoList *object = (struct witness_IPaddrInfoList *)pytalloc_get_ptr(obj);
835         PyObject *py_addr;
836         py_addr = PyList_New(object->num);
837         if (py_addr == NULL) {
838                 return NULL;
839         }
840         {
841                 int addr_cntr_0;
842                 for (addr_cntr_0 = 0; addr_cntr_0 < (object->num); addr_cntr_0++) {
843                         PyObject *py_addr_0;
844                         py_addr_0 = pytalloc_reference_ex(&witness_IPaddrInfo_Type, object->addr, &object->addr[addr_cntr_0]);
845                         PyList_SetItem(py_addr, addr_cntr_0, py_addr_0);
846                 }
847         }
848         return py_addr;
849 }
850
851 static int py_witness_IPaddrInfoList_set_addr(PyObject *py_obj, PyObject *value, void *closure)
852 {
853         struct witness_IPaddrInfoList *object = (struct witness_IPaddrInfoList *)pytalloc_get_ptr(py_obj);
854         PY_CHECK_TYPE(&PyList_Type, value, return -1;);
855         {
856                 int addr_cntr_0;
857                 object->addr = talloc_array_ptrtype(pytalloc_get_mem_ctx(py_obj), object->addr, PyList_GET_SIZE(value));
858                 if (!object->addr) { return -1;; }
859                 talloc_set_name_const(object->addr, "ARRAY: object->addr");
860                 for (addr_cntr_0 = 0; addr_cntr_0 < PyList_GET_SIZE(value); addr_cntr_0++) {
861                         PY_CHECK_TYPE(&witness_IPaddrInfo_Type, PyList_GET_ITEM(value, addr_cntr_0), return -1;);
862                         if (talloc_reference(object->addr, pytalloc_get_mem_ctx(PyList_GET_ITEM(value, addr_cntr_0))) == NULL) {
863                                 PyErr_NoMemory();
864                                 return -1;
865                         }
866                         object->addr[addr_cntr_0] = *(struct witness_IPaddrInfo *)pytalloc_get_ptr(PyList_GET_ITEM(value, addr_cntr_0));
867                 }
868         }
869         return 0;
870 }
871
872 static PyGetSetDef py_witness_IPaddrInfoList_getsetters[] = {
873         { discard_const_p(char, "length"), py_witness_IPaddrInfoList_get_length, py_witness_IPaddrInfoList_set_length },
874         { discard_const_p(char, "reserved"), py_witness_IPaddrInfoList_get_reserved, py_witness_IPaddrInfoList_set_reserved },
875         { discard_const_p(char, "num"), py_witness_IPaddrInfoList_get_num, py_witness_IPaddrInfoList_set_num },
876         { discard_const_p(char, "addr"), py_witness_IPaddrInfoList_get_addr, py_witness_IPaddrInfoList_set_addr },
877         { NULL }
878 };
879
880 static PyObject *py_witness_IPaddrInfoList_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
881 {
882         return pytalloc_new(struct witness_IPaddrInfoList, type);
883 }
884
885
886 static PyTypeObject witness_IPaddrInfoList_Type = {
887         PyObject_HEAD_INIT(NULL) 0,
888         .tp_name = "witness.IPaddrInfoList",
889         .tp_getset = py_witness_IPaddrInfoList_getsetters,
890         .tp_methods = NULL,
891         .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
892         .tp_basicsize = sizeof(pytalloc_Object),
893         .tp_new = py_witness_IPaddrInfoList_new,
894 };
895
896 PyObject *py_import_witness_notifyResponse_message(TALLOC_CTX *mem_ctx, int level, union witness_notifyResponse_message *in)
897 {
898         PyObject *ret;
899
900         switch (level) {
901                 case WITNESS_NOTIFY_RESOURCE_CHANGE:
902                         ret = pytalloc_reference_ex(&witness_ResourceChange_Type, mem_ctx, &in->resource_change);
903                         return ret;
904
905                 case WITNESS_NOTIFY_CLIENT_MOVE:
906                         ret = pytalloc_reference_ex(&witness_IPaddrInfoList_Type, mem_ctx, &in->client_move);
907                         return ret;
908
909                 case WITNESS_NOTIFY_SHARE_MOVE:
910                         ret = pytalloc_reference_ex(&witness_IPaddrInfoList_Type, mem_ctx, &in->share_move);
911                         return ret;
912
913                 case WITNESS_NOTIFY_IP_CHANGE:
914                         ret = pytalloc_reference_ex(&witness_IPaddrInfoList_Type, mem_ctx, &in->ip_change);
915                         return ret;
916
917                 default:
918                         ret = PyString_FromStringAndSize((char *)(in->data).data, (in->data).length);
919                         return ret;
920
921         }
922         PyErr_SetString(PyExc_TypeError, "unknown union level");
923         return NULL;
924 }
925
926 union witness_notifyResponse_message *py_export_witness_notifyResponse_message(TALLOC_CTX *mem_ctx, int level, PyObject *in)
927 {
928         union witness_notifyResponse_message *ret = talloc_zero(mem_ctx, union witness_notifyResponse_message);
929         switch (level) {
930                 case WITNESS_NOTIFY_RESOURCE_CHANGE:
931                         PY_CHECK_TYPE(&witness_ResourceChange_Type, in, talloc_free(ret); return NULL;);
932                         if (talloc_reference(mem_ctx, pytalloc_get_mem_ctx(in)) == NULL) {
933                                 PyErr_NoMemory();
934                                 talloc_free(ret); return NULL;
935                         }
936                         ret->resource_change = *(struct witness_ResourceChange *)pytalloc_get_ptr(in);
937                         break;
938
939                 case WITNESS_NOTIFY_CLIENT_MOVE:
940                         PY_CHECK_TYPE(&witness_IPaddrInfoList_Type, in, talloc_free(ret); return NULL;);
941                         if (talloc_reference(mem_ctx, pytalloc_get_mem_ctx(in)) == NULL) {
942                                 PyErr_NoMemory();
943                                 talloc_free(ret); return NULL;
944                         }
945                         ret->client_move = *(struct witness_IPaddrInfoList *)pytalloc_get_ptr(in);
946                         break;
947
948                 case WITNESS_NOTIFY_SHARE_MOVE:
949                         PY_CHECK_TYPE(&witness_IPaddrInfoList_Type, in, talloc_free(ret); return NULL;);
950                         if (talloc_reference(mem_ctx, pytalloc_get_mem_ctx(in)) == NULL) {
951                                 PyErr_NoMemory();
952                                 talloc_free(ret); return NULL;
953                         }
954                         ret->share_move = *(struct witness_IPaddrInfoList *)pytalloc_get_ptr(in);
955                         break;
956
957                 case WITNESS_NOTIFY_IP_CHANGE:
958                         PY_CHECK_TYPE(&witness_IPaddrInfoList_Type, in, talloc_free(ret); return NULL;);
959                         if (talloc_reference(mem_ctx, pytalloc_get_mem_ctx(in)) == NULL) {
960                                 PyErr_NoMemory();
961                                 talloc_free(ret); return NULL;
962                         }
963                         ret->ip_change = *(struct witness_IPaddrInfoList *)pytalloc_get_ptr(in);
964                         break;
965
966                 default:
967                         ret->data = data_blob_talloc(mem_ctx, PyString_AS_STRING(in), PyString_GET_SIZE(in));
968                         break;
969
970         }
971
972         return ret;
973 }
974
975
976 static PyObject *py_witness_notifyResponse_get_type(PyObject *obj, void *closure)
977 {
978         struct witness_notifyResponse *object = (struct witness_notifyResponse *)pytalloc_get_ptr(obj);
979         PyObject *py_type;
980         py_type = ndr_PyLong_FromUnsignedLongLong((uint32_t)object->type);
981         return py_type;
982 }
983
984 static int py_witness_notifyResponse_set_type(PyObject *py_obj, PyObject *value, void *closure)
985 {
986         struct witness_notifyResponse *object = (struct witness_notifyResponse *)pytalloc_get_ptr(py_obj);
987         {
988                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->type));
989                 if (PyLong_Check(value)) {
990                         unsigned long long test_var;
991                         test_var = PyLong_AsUnsignedLongLong(value);
992                         if (PyErr_Occurred() != NULL) {
993                                 return -1;
994                         }
995                         if (test_var > uint_max) {
996                                 PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %llu",\
997                                   PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
998                                 return -1;
999                         }
1000                         object->type = test_var;
1001                 } else if (PyInt_Check(value)) {
1002                         long test_var;
1003                         test_var = PyInt_AsLong(value);
1004                         if (test_var < 0 || test_var > uint_max) {
1005                                 PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %ld",\
1006                                   PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
1007                                 return -1;
1008                         }
1009                         object->type = test_var;
1010                 } else {
1011                         PyErr_Format(PyExc_TypeError, "Expected type %s or %s",\
1012                           PyInt_Type.tp_name, PyLong_Type.tp_name);
1013                         return -1;
1014                 }
1015         }
1016         return 0;
1017 }
1018
1019 static PyObject *py_witness_notifyResponse_get_length(PyObject *obj, void *closure)
1020 {
1021         struct witness_notifyResponse *object = (struct witness_notifyResponse *)pytalloc_get_ptr(obj);
1022         PyObject *py_length;
1023         py_length = ndr_PyLong_FromUnsignedLongLong((uint32_t)object->length);
1024         return py_length;
1025 }
1026
1027 static int py_witness_notifyResponse_set_length(PyObject *py_obj, PyObject *value, void *closure)
1028 {
1029         struct witness_notifyResponse *object = (struct witness_notifyResponse *)pytalloc_get_ptr(py_obj);
1030         {
1031                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->length));
1032                 if (PyLong_Check(value)) {
1033                         unsigned long long test_var;
1034                         test_var = PyLong_AsUnsignedLongLong(value);
1035                         if (PyErr_Occurred() != NULL) {
1036                                 return -1;
1037                         }
1038                         if (test_var > uint_max) {
1039                                 PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %llu",\
1040                                   PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
1041                                 return -1;
1042                         }
1043                         object->length = test_var;
1044                 } else if (PyInt_Check(value)) {
1045                         long test_var;
1046                         test_var = PyInt_AsLong(value);
1047                         if (test_var < 0 || test_var > uint_max) {
1048                                 PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %ld",\
1049                                   PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
1050                                 return -1;
1051                         }
1052                         object->length = test_var;
1053                 } else {
1054                         PyErr_Format(PyExc_TypeError, "Expected type %s or %s",\
1055                           PyInt_Type.tp_name, PyLong_Type.tp_name);
1056                         return -1;
1057                 }
1058         }
1059         return 0;
1060 }
1061
1062 static PyObject *py_witness_notifyResponse_get_num(PyObject *obj, void *closure)
1063 {
1064         struct witness_notifyResponse *object = (struct witness_notifyResponse *)pytalloc_get_ptr(obj);
1065         PyObject *py_num;
1066         py_num = ndr_PyLong_FromUnsignedLongLong((uint32_t)object->num);
1067         return py_num;
1068 }
1069
1070 static int py_witness_notifyResponse_set_num(PyObject *py_obj, PyObject *value, void *closure)
1071 {
1072         struct witness_notifyResponse *object = (struct witness_notifyResponse *)pytalloc_get_ptr(py_obj);
1073         {
1074                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->num));
1075                 if (PyLong_Check(value)) {
1076                         unsigned long long test_var;
1077                         test_var = PyLong_AsUnsignedLongLong(value);
1078                         if (PyErr_Occurred() != NULL) {
1079                                 return -1;
1080                         }
1081                         if (test_var > uint_max) {
1082                                 PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %llu",\
1083                                   PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
1084                                 return -1;
1085                         }
1086                         object->num = test_var;
1087                 } else if (PyInt_Check(value)) {
1088                         long test_var;
1089                         test_var = PyInt_AsLong(value);
1090                         if (test_var < 0 || test_var > uint_max) {
1091                                 PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %ld",\
1092                                   PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
1093                                 return -1;
1094                         }
1095                         object->num = test_var;
1096                 } else {
1097                         PyErr_Format(PyExc_TypeError, "Expected type %s or %s",\
1098                           PyInt_Type.tp_name, PyLong_Type.tp_name);
1099                         return -1;
1100                 }
1101         }
1102         return 0;
1103 }
1104
1105 static PyObject *py_witness_notifyResponse_get_messages(PyObject *obj, void *closure)
1106 {
1107         struct witness_notifyResponse *object = (struct witness_notifyResponse *)pytalloc_get_ptr(obj);
1108         PyObject *py_messages;
1109         py_messages = PyList_New(object->num);
1110         if (py_messages == NULL) {
1111                 return NULL;
1112         }
1113         {
1114                 int messages_cntr_0;
1115                 for (messages_cntr_0 = 0; messages_cntr_0 < (object->num); messages_cntr_0++) {
1116                         PyObject *py_messages_0;
1117                         py_messages_0 = py_import_witness_notifyResponse_message(object->messages, object->type, &object->messages[messages_cntr_0]);
1118                         if (py_messages_0 == NULL) {
1119                                 return NULL;
1120                         }
1121                         PyList_SetItem(py_messages, messages_cntr_0, py_messages_0);
1122                 }
1123         }
1124         return py_messages;
1125 }
1126
1127 static int py_witness_notifyResponse_set_messages(PyObject *py_obj, PyObject *value, void *closure)
1128 {
1129         struct witness_notifyResponse *object = (struct witness_notifyResponse *)pytalloc_get_ptr(py_obj);
1130         PY_CHECK_TYPE(&PyList_Type, value, return -1;);
1131         {
1132                 int messages_cntr_0;
1133                 object->messages = talloc_array_ptrtype(pytalloc_get_mem_ctx(py_obj), object->messages, PyList_GET_SIZE(value));
1134                 if (!object->messages) { return -1;; }
1135                 talloc_set_name_const(object->messages, "ARRAY: object->messages");
1136                 for (messages_cntr_0 = 0; messages_cntr_0 < PyList_GET_SIZE(value); messages_cntr_0++) {
1137                         {
1138                                 union witness_notifyResponse_message *messages_switch_2;
1139                                 messages_switch_2 = py_export_witness_notifyResponse_message(object->messages, object->type, PyList_GET_ITEM(value, messages_cntr_0));
1140                                 if (messages_switch_2 == NULL) {
1141                                         return -1;
1142                                 }
1143                                 object->messages[messages_cntr_0] = *messages_switch_2;
1144                         }
1145                 }
1146         }
1147         return 0;
1148 }
1149
1150 static PyGetSetDef py_witness_notifyResponse_getsetters[] = {
1151         { discard_const_p(char, "type"), py_witness_notifyResponse_get_type, py_witness_notifyResponse_set_type },
1152         { discard_const_p(char, "length"), py_witness_notifyResponse_get_length, py_witness_notifyResponse_set_length },
1153         { discard_const_p(char, "num"), py_witness_notifyResponse_get_num, py_witness_notifyResponse_set_num },
1154         { discard_const_p(char, "messages"), py_witness_notifyResponse_get_messages, py_witness_notifyResponse_set_messages },
1155         { NULL }
1156 };
1157
1158 static PyObject *py_witness_notifyResponse_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
1159 {
1160         return pytalloc_new(struct witness_notifyResponse, type);
1161 }
1162
1163 static PyObject *py_witness_notifyResponse_ndr_pack(PyObject *py_obj)
1164 {
1165         struct witness_notifyResponse *object = (struct witness_notifyResponse *)pytalloc_get_ptr(py_obj);
1166         DATA_BLOB blob;
1167         enum ndr_err_code err;
1168         err = ndr_push_struct_blob(&blob, pytalloc_get_mem_ctx(py_obj), object, (ndr_push_flags_fn_t)ndr_push_witness_notifyResponse);
1169         if (err != NDR_ERR_SUCCESS) {
1170                 PyErr_SetNdrError(err);
1171                 return NULL;
1172         }
1173
1174         return PyString_FromStringAndSize((char *)blob.data, blob.length);
1175 }
1176
1177 static PyObject *py_witness_notifyResponse_ndr_unpack(PyObject *py_obj, PyObject *args, PyObject *kwargs)
1178 {
1179         struct witness_notifyResponse *object = (struct witness_notifyResponse *)pytalloc_get_ptr(py_obj);
1180         DATA_BLOB blob;
1181         int blob_length = 0;
1182         enum ndr_err_code err;
1183         const char * const kwnames[] = { "data_blob", "allow_remaining", NULL };
1184         PyObject *allow_remaining_obj = NULL;
1185         bool allow_remaining = false;
1186
1187         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s#|O:__ndr_unpack__",
1188                 discard_const_p(char *, kwnames),
1189                 &blob.data, &blob_length,
1190                 &allow_remaining_obj)) {
1191                 return NULL;
1192         }
1193         blob.length = blob_length;
1194
1195         if (allow_remaining_obj && PyObject_IsTrue(allow_remaining_obj)) {
1196                 allow_remaining = true;
1197         }
1198
1199         if (allow_remaining) {
1200                 err = ndr_pull_struct_blob(&blob, pytalloc_get_mem_ctx(py_obj), object, (ndr_pull_flags_fn_t)ndr_pull_witness_notifyResponse);
1201         } else {
1202                 err = ndr_pull_struct_blob_all(&blob, pytalloc_get_mem_ctx(py_obj), object, (ndr_pull_flags_fn_t)ndr_pull_witness_notifyResponse);
1203         }
1204         if (err != NDR_ERR_SUCCESS) {
1205                 PyErr_SetNdrError(err);
1206                 return NULL;
1207         }
1208
1209         Py_RETURN_NONE;
1210 }
1211
1212 static PyObject *py_witness_notifyResponse_ndr_print(PyObject *py_obj)
1213 {
1214         struct witness_notifyResponse *object = (struct witness_notifyResponse *)pytalloc_get_ptr(py_obj);
1215         PyObject *ret;
1216         char *retstr;
1217
1218         retstr = ndr_print_struct_string(pytalloc_get_mem_ctx(py_obj), (ndr_print_fn_t)ndr_print_witness_notifyResponse, "witness_notifyResponse", object);
1219         ret = PyString_FromString(retstr);
1220         talloc_free(retstr);
1221
1222         return ret;
1223 }
1224
1225 static PyMethodDef py_witness_notifyResponse_methods[] = {
1226         { "__ndr_pack__", (PyCFunction)py_witness_notifyResponse_ndr_pack, METH_NOARGS, "S.ndr_pack(object) -> blob\nNDR pack" },
1227         { "__ndr_unpack__", (PyCFunction)py_witness_notifyResponse_ndr_unpack, METH_VARARGS|METH_KEYWORDS, "S.ndr_unpack(class, blob, allow_remaining=False) -> None\nNDR unpack" },
1228         { "__ndr_print__", (PyCFunction)py_witness_notifyResponse_ndr_print, METH_VARARGS, "S.ndr_print(object) -> None\nNDR print" },
1229         { NULL, NULL, 0, NULL }
1230 };
1231
1232
1233 static PyTypeObject witness_notifyResponse_Type = {
1234         PyObject_HEAD_INIT(NULL) 0,
1235         .tp_name = "witness.notifyResponse",
1236         .tp_getset = py_witness_notifyResponse_getsetters,
1237         .tp_methods = py_witness_notifyResponse_methods,
1238         .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
1239         .tp_basicsize = sizeof(pytalloc_Object),
1240         .tp_new = py_witness_notifyResponse_new,
1241 };
1242
1243
1244 static bool pack_py_witness_GetInterfaceList_args_in(PyObject *args, PyObject *kwargs, struct witness_GetInterfaceList *r)
1245 {
1246         const char *kwnames[] = {
1247                 NULL
1248         };
1249
1250         if (!PyArg_ParseTupleAndKeywords(args, kwargs, ":witness_GetInterfaceList", discard_const_p(char *, kwnames))) {
1251                 return false;
1252         }
1253
1254         return true;
1255 }
1256
1257 static PyObject *unpack_py_witness_GetInterfaceList_args_out(struct witness_GetInterfaceList *r)
1258 {
1259         PyObject *result;
1260         PyObject *py_interface_list;
1261         if (*r->out.interface_list == NULL) {
1262                 py_interface_list = Py_None;
1263                 Py_INCREF(py_interface_list);
1264         } else {
1265                 py_interface_list = pytalloc_reference_ex(&witness_interfaceList_Type, *r->out.interface_list, *r->out.interface_list);
1266         }
1267         result = py_interface_list;
1268         if (!W_ERROR_IS_OK(r->out.result)) {
1269                 PyErr_SetWERROR(r->out.result);
1270                 return NULL;
1271         }
1272
1273         return result;
1274 }
1275
1276 static bool pack_py_witness_Register_args_in(PyObject *args, PyObject *kwargs, struct witness_Register *r)
1277 {
1278         PyObject *py_version;
1279         PyObject *py_net_name;
1280         PyObject *py_ip_address;
1281         PyObject *py_client_computer_name;
1282         const char *kwnames[] = {
1283                 "version", "net_name", "ip_address", "client_computer_name", NULL
1284         };
1285
1286         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)) {
1287                 return false;
1288         }
1289
1290         {
1291                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(r->in.version));
1292                 if (PyLong_Check(py_version)) {
1293                         unsigned long long test_var;
1294                         test_var = PyLong_AsUnsignedLongLong(py_version);
1295                         if (PyErr_Occurred() != NULL) {
1296                                 return false;
1297                         }
1298                         if (test_var > uint_max) {
1299                                 PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %llu",\
1300                                   PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
1301                                 return false;
1302                         }
1303                         r->in.version = test_var;
1304                 } else if (PyInt_Check(py_version)) {
1305                         long test_var;
1306                         test_var = PyInt_AsLong(py_version);
1307                         if (test_var < 0 || test_var > uint_max) {
1308                                 PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %ld",\
1309                                   PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
1310                                 return false;
1311                         }
1312                         r->in.version = test_var;
1313                 } else {
1314                         PyErr_Format(PyExc_TypeError, "Expected type %s or %s",\
1315                           PyInt_Type.tp_name, PyLong_Type.tp_name);
1316                         return false;
1317                 }
1318         }
1319         if (py_net_name == Py_None) {
1320                 r->in.net_name = NULL;
1321         } else {
1322                 r->in.net_name = NULL;
1323                 if (PyUnicode_Check(py_net_name)) {
1324                         r->in.net_name = PyString_AS_STRING(PyUnicode_AsEncodedString(py_net_name, "utf-8", "ignore"));
1325                 } else if (PyString_Check(py_net_name)) {
1326                         r->in.net_name = PyString_AS_STRING(py_net_name);
1327                 } else {
1328                         PyErr_Format(PyExc_TypeError, "Expected string or unicode object, got %s", Py_TYPE(py_net_name)->tp_name);
1329                         return false;
1330                 }
1331         }
1332         if (py_ip_address == Py_None) {
1333                 r->in.ip_address = NULL;
1334         } else {
1335                 r->in.ip_address = NULL;
1336                 if (PyUnicode_Check(py_ip_address)) {
1337                         r->in.ip_address = PyString_AS_STRING(PyUnicode_AsEncodedString(py_ip_address, "utf-8", "ignore"));
1338                 } else if (PyString_Check(py_ip_address)) {
1339                         r->in.ip_address = PyString_AS_STRING(py_ip_address);
1340                 } else {
1341                         PyErr_Format(PyExc_TypeError, "Expected string or unicode object, got %s", Py_TYPE(py_ip_address)->tp_name);
1342                         return false;
1343                 }
1344         }
1345         if (py_client_computer_name == Py_None) {
1346                 r->in.client_computer_name = NULL;
1347         } else {
1348                 r->in.client_computer_name = NULL;
1349                 if (PyUnicode_Check(py_client_computer_name)) {
1350                         r->in.client_computer_name = PyString_AS_STRING(PyUnicode_AsEncodedString(py_client_computer_name, "utf-8", "ignore"));
1351                 } else if (PyString_Check(py_client_computer_name)) {
1352                         r->in.client_computer_name = PyString_AS_STRING(py_client_computer_name);
1353                 } else {
1354                         PyErr_Format(PyExc_TypeError, "Expected string or unicode object, got %s", Py_TYPE(py_client_computer_name)->tp_name);
1355                         return false;
1356                 }
1357         }
1358         return true;
1359 }
1360
1361 static PyObject *unpack_py_witness_Register_args_out(struct witness_Register *r)
1362 {
1363         PyObject *result;
1364         PyObject *py_context_handle;
1365         py_context_handle = pytalloc_reference_ex(policy_handle_Type, r->out.context_handle, r->out.context_handle);
1366         result = py_context_handle;
1367         if (!W_ERROR_IS_OK(r->out.result)) {
1368                 PyErr_SetWERROR(r->out.result);
1369                 return NULL;
1370         }
1371
1372         return result;
1373 }
1374
1375 static bool pack_py_witness_UnRegister_args_in(PyObject *args, PyObject *kwargs, struct witness_UnRegister *r)
1376 {
1377         PyObject *py_context_handle;
1378         const char *kwnames[] = {
1379                 "context_handle", NULL
1380         };
1381
1382         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:witness_UnRegister", discard_const_p(char *, kwnames), &py_context_handle)) {
1383                 return false;
1384         }
1385
1386         PY_CHECK_TYPE(policy_handle_Type, py_context_handle, return false;);
1387         if (talloc_reference(r, pytalloc_get_mem_ctx(py_context_handle)) == NULL) {
1388                 PyErr_NoMemory();
1389                 return false;
1390         }
1391         r->in.context_handle = *(struct policy_handle *)pytalloc_get_ptr(py_context_handle);
1392         return true;
1393 }
1394
1395 static PyObject *unpack_py_witness_UnRegister_args_out(struct witness_UnRegister *r)
1396 {
1397         PyObject *result;
1398         result = Py_None;
1399         Py_INCREF(result);
1400         if (!W_ERROR_IS_OK(r->out.result)) {
1401                 PyErr_SetWERROR(r->out.result);
1402                 return NULL;
1403         }
1404
1405         return result;
1406 }
1407
1408 static bool pack_py_witness_AsyncNotify_args_in(PyObject *args, PyObject *kwargs, struct witness_AsyncNotify *r)
1409 {
1410         PyObject *py_context_handle;
1411         const char *kwnames[] = {
1412                 "context_handle", NULL
1413         };
1414
1415         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:witness_AsyncNotify", discard_const_p(char *, kwnames), &py_context_handle)) {
1416                 return false;
1417         }
1418
1419         PY_CHECK_TYPE(policy_handle_Type, py_context_handle, return false;);
1420         if (talloc_reference(r, pytalloc_get_mem_ctx(py_context_handle)) == NULL) {
1421                 PyErr_NoMemory();
1422                 return false;
1423         }
1424         r->in.context_handle = *(struct policy_handle *)pytalloc_get_ptr(py_context_handle);
1425         return true;
1426 }
1427
1428 static PyObject *unpack_py_witness_AsyncNotify_args_out(struct witness_AsyncNotify *r)
1429 {
1430         PyObject *result;
1431         PyObject *py_response;
1432         if (*r->out.response == NULL) {
1433                 py_response = Py_None;
1434                 Py_INCREF(py_response);
1435         } else {
1436                 py_response = pytalloc_reference_ex(&witness_notifyResponse_Type, *r->out.response, *r->out.response);
1437         }
1438         result = py_response;
1439         if (!W_ERROR_IS_OK(r->out.result)) {
1440                 PyErr_SetWERROR(r->out.result);
1441                 return NULL;
1442         }
1443
1444         return result;
1445 }
1446
1447 static bool pack_py_witness_RegisterEx_args_in(PyObject *args, PyObject *kwargs, struct witness_RegisterEx *r)
1448 {
1449         PyObject *py_version;
1450         PyObject *py_net_name;
1451         PyObject *py_share_name;
1452         PyObject *py_ip_address;
1453         PyObject *py_client_computer_name;
1454         PyObject *py_flags;
1455         PyObject *py_timeout;
1456         const char *kwnames[] = {
1457                 "version", "net_name", "share_name", "ip_address", "client_computer_name", "flags", "timeout", NULL
1458         };
1459
1460         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)) {
1461                 return false;
1462         }
1463
1464         {
1465                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(r->in.version));
1466                 if (PyLong_Check(py_version)) {
1467                         unsigned long long test_var;
1468                         test_var = PyLong_AsUnsignedLongLong(py_version);
1469                         if (PyErr_Occurred() != NULL) {
1470                                 return false;
1471                         }
1472                         if (test_var > uint_max) {
1473                                 PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %llu",\
1474                                   PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
1475                                 return false;
1476                         }
1477                         r->in.version = test_var;
1478                 } else if (PyInt_Check(py_version)) {
1479                         long test_var;
1480                         test_var = PyInt_AsLong(py_version);
1481                         if (test_var < 0 || test_var > uint_max) {
1482                                 PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %ld",\
1483                                   PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
1484                                 return false;
1485                         }
1486                         r->in.version = test_var;
1487                 } else {
1488                         PyErr_Format(PyExc_TypeError, "Expected type %s or %s",\
1489                           PyInt_Type.tp_name, PyLong_Type.tp_name);
1490                         return false;
1491                 }
1492         }
1493         if (py_net_name == Py_None) {
1494                 r->in.net_name = NULL;
1495         } else {
1496                 r->in.net_name = NULL;
1497                 if (PyUnicode_Check(py_net_name)) {
1498                         r->in.net_name = PyString_AS_STRING(PyUnicode_AsEncodedString(py_net_name, "utf-8", "ignore"));
1499                 } else if (PyString_Check(py_net_name)) {
1500                         r->in.net_name = PyString_AS_STRING(py_net_name);
1501                 } else {
1502                         PyErr_Format(PyExc_TypeError, "Expected string or unicode object, got %s", Py_TYPE(py_net_name)->tp_name);
1503                         return false;
1504                 }
1505         }
1506         if (py_share_name == Py_None) {
1507                 r->in.share_name = NULL;
1508         } else {
1509                 r->in.share_name = NULL;
1510                 if (PyUnicode_Check(py_share_name)) {
1511                         r->in.share_name = PyString_AS_STRING(PyUnicode_AsEncodedString(py_share_name, "utf-8", "ignore"));
1512                 } else if (PyString_Check(py_share_name)) {
1513                         r->in.share_name = PyString_AS_STRING(py_share_name);
1514                 } else {
1515                         PyErr_Format(PyExc_TypeError, "Expected string or unicode object, got %s", Py_TYPE(py_share_name)->tp_name);
1516                         return false;
1517                 }
1518         }
1519         if (py_ip_address == Py_None) {
1520                 r->in.ip_address = NULL;
1521         } else {
1522                 r->in.ip_address = NULL;
1523                 if (PyUnicode_Check(py_ip_address)) {
1524                         r->in.ip_address = PyString_AS_STRING(PyUnicode_AsEncodedString(py_ip_address, "utf-8", "ignore"));
1525                 } else if (PyString_Check(py_ip_address)) {
1526                         r->in.ip_address = PyString_AS_STRING(py_ip_address);
1527                 } else {
1528                         PyErr_Format(PyExc_TypeError, "Expected string or unicode object, got %s", Py_TYPE(py_ip_address)->tp_name);
1529                         return false;
1530                 }
1531         }
1532         if (py_client_computer_name == Py_None) {
1533                 r->in.client_computer_name = NULL;
1534         } else {
1535                 r->in.client_computer_name = NULL;
1536                 if (PyUnicode_Check(py_client_computer_name)) {
1537                         r->in.client_computer_name = PyString_AS_STRING(PyUnicode_AsEncodedString(py_client_computer_name, "utf-8", "ignore"));
1538                 } else if (PyString_Check(py_client_computer_name)) {
1539                         r->in.client_computer_name = PyString_AS_STRING(py_client_computer_name);
1540                 } else {
1541                         PyErr_Format(PyExc_TypeError, "Expected string or unicode object, got %s", Py_TYPE(py_client_computer_name)->tp_name);
1542                         return false;
1543                 }
1544         }
1545         {
1546                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(r->in.flags));
1547                 if (PyLong_Check(py_flags)) {
1548                         unsigned long long test_var;
1549                         test_var = PyLong_AsUnsignedLongLong(py_flags);
1550                         if (PyErr_Occurred() != NULL) {
1551                                 return false;
1552                         }
1553                         if (test_var > uint_max) {
1554                                 PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %llu",\
1555                                   PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
1556                                 return false;
1557                         }
1558                         r->in.flags = test_var;
1559                 } else if (PyInt_Check(py_flags)) {
1560                         long test_var;
1561                         test_var = PyInt_AsLong(py_flags);
1562                         if (test_var < 0 || test_var > uint_max) {
1563                                 PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %ld",\
1564                                   PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
1565                                 return false;
1566                         }
1567                         r->in.flags = test_var;
1568                 } else {
1569                         PyErr_Format(PyExc_TypeError, "Expected type %s or %s",\
1570                           PyInt_Type.tp_name, PyLong_Type.tp_name);
1571                         return false;
1572                 }
1573         }
1574         {
1575                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(r->in.timeout));
1576                 if (PyLong_Check(py_timeout)) {
1577                         unsigned long long test_var;
1578                         test_var = PyLong_AsUnsignedLongLong(py_timeout);
1579                         if (PyErr_Occurred() != NULL) {
1580                                 return false;
1581                         }
1582                         if (test_var > uint_max) {
1583                                 PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %llu",\
1584                                   PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
1585                                 return false;
1586                         }
1587                         r->in.timeout = test_var;
1588                 } else if (PyInt_Check(py_timeout)) {
1589                         long test_var;
1590                         test_var = PyInt_AsLong(py_timeout);
1591                         if (test_var < 0 || test_var > uint_max) {
1592                                 PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %ld",\
1593                                   PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
1594                                 return false;
1595                         }
1596                         r->in.timeout = test_var;
1597                 } else {
1598                         PyErr_Format(PyExc_TypeError, "Expected type %s or %s",\
1599                           PyInt_Type.tp_name, PyLong_Type.tp_name);
1600                         return false;
1601                 }
1602         }
1603         return true;
1604 }
1605
1606 static PyObject *unpack_py_witness_RegisterEx_args_out(struct witness_RegisterEx *r)
1607 {
1608         PyObject *result;
1609         PyObject *py_context_handle;
1610         py_context_handle = pytalloc_reference_ex(policy_handle_Type, r->out.context_handle, r->out.context_handle);
1611         result = py_context_handle;
1612         if (!W_ERROR_IS_OK(r->out.result)) {
1613                 PyErr_SetWERROR(r->out.result);
1614                 return NULL;
1615         }
1616
1617         return result;
1618 }
1619
1620 const struct PyNdrRpcMethodDef py_ndr_witness_methods[] = {
1621         { "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 },
1622         { "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 },
1623         { "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 },
1624         { "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 },
1625         { "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 },
1626         { NULL }
1627 };
1628
1629 static PyObject *interface_witness_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
1630 {
1631         return py_dcerpc_interface_init_helper(type, args, kwargs, &ndr_table_witness);
1632 }
1633
1634 #define PY_DOC_WITNESS "SMB Witness Service"
1635 static PyTypeObject witness_InterfaceType = {
1636         PyObject_HEAD_INIT(NULL) 0,
1637         .tp_name = "witness.witness",
1638         .tp_basicsize = sizeof(dcerpc_InterfaceObject),
1639         .tp_doc = "witness(binding, lp_ctx=None, credentials=None) -> connection\n"
1640 "\n"
1641 "binding should be a DCE/RPC binding string (for example: ncacn_ip_tcp:127.0.0.1)\n"
1642 "lp_ctx should be a path to a smb.conf file or a param.LoadParm object\n"
1643 "credentials should be a credentials.Credentials object.\n\n"PY_DOC_WITNESS,
1644         .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
1645         .tp_new = interface_witness_new,
1646 };
1647
1648 static PyObject *syntax_witness_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
1649 {
1650         return py_dcerpc_syntax_init_helper(type, args, kwargs, &ndr_table_witness.syntax_id);
1651 }
1652
1653 #define PY_DOC_WITNESS_SYNTAX "SMB Witness Service"
1654 static PyTypeObject witness_SyntaxType = {
1655         PyObject_HEAD_INIT(NULL) 0,
1656         .tp_name = "witness.witness",
1657         .tp_basicsize = sizeof(pytalloc_Object),
1658         .tp_doc = "abstract_syntax()\n"PY_DOC_WITNESS_SYNTAX,
1659         .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
1660         .tp_new = syntax_witness_new,
1661 };
1662
1663 static PyMethodDef witness_methods[] = {
1664         { NULL, NULL, 0, NULL }
1665 };
1666
1667 void initwitness(void)
1668 {
1669         PyObject *m;
1670         PyObject *dep_samba_dcerpc_misc;
1671         PyObject *dep_talloc;
1672         PyObject *dep_samba_dcerpc_base;
1673
1674         dep_samba_dcerpc_misc = PyImport_ImportModule("samba.dcerpc.misc");
1675         if (dep_samba_dcerpc_misc == NULL)
1676                 return;
1677
1678         dep_talloc = PyImport_ImportModule("talloc");
1679         if (dep_talloc == NULL)
1680                 return;
1681
1682         dep_samba_dcerpc_base = PyImport_ImportModule("samba.dcerpc.base");
1683         if (dep_samba_dcerpc_base == NULL)
1684                 return;
1685
1686         Object_Type = (PyTypeObject *)PyObject_GetAttrString(dep_talloc, "Object");
1687         if (Object_Type == NULL)
1688                 return;
1689
1690         policy_handle_Type = (PyTypeObject *)PyObject_GetAttrString(dep_samba_dcerpc_misc, "policy_handle");
1691         if (policy_handle_Type == NULL)
1692                 return;
1693
1694         ClientConnection_Type = (PyTypeObject *)PyObject_GetAttrString(dep_samba_dcerpc_base, "ClientConnection");
1695         if (ClientConnection_Type == NULL)
1696                 return;
1697
1698         ndr_syntax_id_Type = (PyTypeObject *)PyObject_GetAttrString(dep_samba_dcerpc_misc, "ndr_syntax_id");
1699         if (ndr_syntax_id_Type == NULL)
1700                 return;
1701
1702         witness_interfaceInfo_Type.tp_base = Object_Type;
1703
1704         witness_interfaceList_Type.tp_base = Object_Type;
1705
1706         witness_ResourceChange_Type.tp_base = Object_Type;
1707
1708         witness_IPaddrInfo_Type.tp_base = Object_Type;
1709
1710         witness_IPaddrInfoList_Type.tp_base = Object_Type;
1711
1712         witness_notifyResponse_Type.tp_base = Object_Type;
1713
1714         witness_InterfaceType.tp_base = ClientConnection_Type;
1715
1716         witness_SyntaxType.tp_base = ndr_syntax_id_Type;
1717
1718         if (PyType_Ready(&witness_interfaceInfo_Type) < 0)
1719                 return;
1720         if (PyType_Ready(&witness_interfaceList_Type) < 0)
1721                 return;
1722         if (PyType_Ready(&witness_ResourceChange_Type) < 0)
1723                 return;
1724         if (PyType_Ready(&witness_IPaddrInfo_Type) < 0)
1725                 return;
1726         if (PyType_Ready(&witness_IPaddrInfoList_Type) < 0)
1727                 return;
1728         if (PyType_Ready(&witness_notifyResponse_Type) < 0)
1729                 return;
1730         if (PyType_Ready(&witness_InterfaceType) < 0)
1731                 return;
1732         if (PyType_Ready(&witness_SyntaxType) < 0)
1733                 return;
1734         if (!PyInterface_AddNdrRpcMethods(&witness_InterfaceType, py_ndr_witness_methods))
1735                 return;
1736
1737 #ifdef PY_INTERFACEINFO_PATCH
1738         PY_INTERFACEINFO_PATCH(&witness_interfaceInfo_Type);
1739 #endif
1740 #ifdef PY_INTERFACELIST_PATCH
1741         PY_INTERFACELIST_PATCH(&witness_interfaceList_Type);
1742 #endif
1743 #ifdef PY_RESOURCECHANGE_PATCH
1744         PY_RESOURCECHANGE_PATCH(&witness_ResourceChange_Type);
1745 #endif
1746 #ifdef PY_IPADDRINFO_PATCH
1747         PY_IPADDRINFO_PATCH(&witness_IPaddrInfo_Type);
1748 #endif
1749 #ifdef PY_IPADDRINFOLIST_PATCH
1750         PY_IPADDRINFOLIST_PATCH(&witness_IPaddrInfoList_Type);
1751 #endif
1752 #ifdef PY_NOTIFYRESPONSE_PATCH
1753         PY_NOTIFYRESPONSE_PATCH(&witness_notifyResponse_Type);
1754 #endif
1755 #ifdef PY_WITNESS_PATCH
1756         PY_WITNESS_PATCH(&witness_InterfaceType);
1757 #endif
1758 #ifdef PY_ABSTRACT_SYNTAX_PATCH
1759         PY_ABSTRACT_SYNTAX_PATCH(&witness_SyntaxType);
1760 #endif
1761
1762         m = Py_InitModule3("witness", witness_methods, "witness DCE/RPC");
1763         if (m == NULL)
1764                 return;
1765
1766         PyModule_AddObject(m, "WITNESS_V1", ndr_PyLong_FromUnsignedLongLong((uint32_t)WITNESS_V1));
1767         PyModule_AddObject(m, "WITNESS_V2", ndr_PyLong_FromUnsignedLongLong((uint32_t)WITNESS_V2));
1768         PyModule_AddObject(m, "WITNESS_UNSPECIFIED_VERSION", ndr_PyLong_FromUnsignedLongLong((uint32_t)WITNESS_UNSPECIFIED_VERSION));
1769         PyModule_AddObject(m, "WITNESS_STATE_UNKNOWN", PyInt_FromLong((uint16_t)WITNESS_STATE_UNKNOWN));
1770         PyModule_AddObject(m, "WITNESS_STATE_AVAILABLE", PyInt_FromLong((uint16_t)WITNESS_STATE_AVAILABLE));
1771         PyModule_AddObject(m, "WITNESS_STATE_UNAVAILABLE", PyInt_FromLong((uint16_t)WITNESS_STATE_UNAVAILABLE));
1772         PyModule_AddObject(m, "WITNESS_INFO_IPv4_VALID", ndr_PyLong_FromUnsignedLongLong((uint32_t)WITNESS_INFO_IPv4_VALID));
1773         PyModule_AddObject(m, "WITNESS_INFO_IPv6_VALID", ndr_PyLong_FromUnsignedLongLong((uint32_t)WITNESS_INFO_IPv6_VALID));
1774         PyModule_AddObject(m, "WITNESS_INFO_WITNESS_IF", ndr_PyLong_FromUnsignedLongLong((uint32_t)WITNESS_INFO_WITNESS_IF));
1775         PyModule_AddObject(m, "WITNESS_NOTIFY_RESOURCE_CHANGE", ndr_PyLong_FromUnsignedLongLong((uint32_t)WITNESS_NOTIFY_RESOURCE_CHANGE));
1776         PyModule_AddObject(m, "WITNESS_NOTIFY_CLIENT_MOVE", ndr_PyLong_FromUnsignedLongLong((uint32_t)WITNESS_NOTIFY_CLIENT_MOVE));
1777         PyModule_AddObject(m, "WITNESS_NOTIFY_SHARE_MOVE", ndr_PyLong_FromUnsignedLongLong((uint32_t)WITNESS_NOTIFY_SHARE_MOVE));
1778         PyModule_AddObject(m, "WITNESS_NOTIFY_IP_CHANGE", ndr_PyLong_FromUnsignedLongLong((uint32_t)WITNESS_NOTIFY_IP_CHANGE));
1779         PyModule_AddObject(m, "WITNESS_RESOURCE_STATE_UNKNOWN", ndr_PyLong_FromUnsignedLongLong((uint32_t)WITNESS_RESOURCE_STATE_UNKNOWN));
1780         PyModule_AddObject(m, "WITNESS_RESOURCE_STATE_AVAILABLE", ndr_PyLong_FromUnsignedLongLong((uint32_t)WITNESS_RESOURCE_STATE_AVAILABLE));
1781         PyModule_AddObject(m, "WITNESS_RESOURCE_STATE_UNAVAILABLE", ndr_PyLong_FromUnsignedLongLong((uint32_t)WITNESS_RESOURCE_STATE_UNAVAILABLE));
1782         PyModule_AddObject(m, "WITNESS_IPADDR_V4", ndr_PyLong_FromUnsignedLongLong((uint32_t)WITNESS_IPADDR_V4));
1783         PyModule_AddObject(m, "WITNESS_IPADDR_V6", ndr_PyLong_FromUnsignedLongLong((uint32_t)WITNESS_IPADDR_V6));
1784         PyModule_AddObject(m, "WITNESS_IPADDR_ONLINE", ndr_PyLong_FromUnsignedLongLong((uint32_t)WITNESS_IPADDR_ONLINE));
1785         PyModule_AddObject(m, "WITNESS_IPADDR_OFFLINE", ndr_PyLong_FromUnsignedLongLong((uint32_t)WITNESS_IPADDR_OFFLINE));
1786         PyModule_AddObject(m, "WITNESS_REGISTER_NONE", ndr_PyLong_FromUnsignedLongLong((uint32_t)WITNESS_REGISTER_NONE));
1787         PyModule_AddObject(m, "WITNESS_REGISTER_IP_NOTIFICATION", ndr_PyLong_FromUnsignedLongLong((uint32_t)WITNESS_REGISTER_IP_NOTIFICATION));
1788         Py_INCREF((PyObject *)(void *)&witness_interfaceInfo_Type);
1789         PyModule_AddObject(m, "interfaceInfo", (PyObject *)(void *)&witness_interfaceInfo_Type);
1790         Py_INCREF((PyObject *)(void *)&witness_interfaceList_Type);
1791         PyModule_AddObject(m, "interfaceList", (PyObject *)(void *)&witness_interfaceList_Type);
1792         Py_INCREF((PyObject *)(void *)&witness_ResourceChange_Type);
1793         PyModule_AddObject(m, "ResourceChange", (PyObject *)(void *)&witness_ResourceChange_Type);
1794         Py_INCREF((PyObject *)(void *)&witness_IPaddrInfo_Type);
1795         PyModule_AddObject(m, "IPaddrInfo", (PyObject *)(void *)&witness_IPaddrInfo_Type);
1796         Py_INCREF((PyObject *)(void *)&witness_IPaddrInfoList_Type);
1797         PyModule_AddObject(m, "IPaddrInfoList", (PyObject *)(void *)&witness_IPaddrInfoList_Type);
1798         Py_INCREF((PyObject *)(void *)&witness_notifyResponse_Type);
1799         PyModule_AddObject(m, "notifyResponse", (PyObject *)(void *)&witness_notifyResponse_Type);
1800         Py_INCREF((PyObject *)(void *)&witness_InterfaceType);
1801         PyModule_AddObject(m, "witness", (PyObject *)(void *)&witness_InterfaceType);
1802         Py_INCREF((PyObject *)(void *)&witness_SyntaxType);
1803         PyModule_AddObject(m, "abstract_syntax", (PyObject *)(void *)&witness_SyntaxType);
1804 #ifdef PY_MOD_WITNESS_PATCH
1805         PY_MOD_WITNESS_PATCH(m);
1806 #endif
1807
1808 }