git add -f bin/default/librpc/gen_ndr/*.[ch] bin/default/source*/librpc/gen_ndr/...
[metze/samba/wip.git] / bin.gen_ndr / default / librpc / gen_ndr / py_named_pipe_auth.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_named_pipe_auth.h"
9 #include "bin/default/librpc/gen_ndr/ndr_named_pipe_auth_c.h"
10
11 #include "librpc/gen_ndr/netlogon.h"
12 #include "librpc/gen_ndr/security.h"
13 #include "librpc/gen_ndr/auth.h"
14 staticforward PyTypeObject named_pipe_auth_req_info4_Type;
15 staticforward PyTypeObject named_pipe_auth_req_Type;
16 staticforward PyTypeObject named_pipe_auth_rep_info4_Type;
17 staticforward PyTypeObject named_pipe_auth_rep_Type;
18
19 void initnamed_pipe_auth(void);static PyTypeObject *auth_session_info_transport_Type;
20 static PyTypeObject *Object_Type;
21
22 static PyObject *py_named_pipe_auth_req_info4_get_client_name(PyObject *obj, void *closure)
23 {
24         struct named_pipe_auth_req_info4 *object = (struct named_pipe_auth_req_info4 *)pytalloc_get_ptr(obj);
25         PyObject *py_client_name;
26         if (object->client_name == NULL) {
27                 py_client_name = Py_None;
28                 Py_INCREF(py_client_name);
29         } else {
30                 if (object->client_name == NULL) {
31                         py_client_name = Py_None;
32                         Py_INCREF(py_client_name);
33                 } else {
34                         py_client_name = PyUnicode_Decode(object->client_name, strlen(object->client_name), "utf-8", "ignore");
35                 }
36         }
37         return py_client_name;
38 }
39
40 static int py_named_pipe_auth_req_info4_set_client_name(PyObject *py_obj, PyObject *value, void *closure)
41 {
42         struct named_pipe_auth_req_info4 *object = (struct named_pipe_auth_req_info4 *)pytalloc_get_ptr(py_obj);
43         if (value == Py_None) {
44                 object->client_name = NULL;
45         } else {
46                 object->client_name = NULL;
47                 if (PyUnicode_Check(value)) {
48                         object->client_name = PyString_AS_STRING(PyUnicode_AsEncodedString(value, "utf-8", "ignore"));
49                 } else if (PyString_Check(value)) {
50                         object->client_name = PyString_AS_STRING(value);
51                 } else {
52                         PyErr_Format(PyExc_TypeError, "Expected string or unicode object, got %s", Py_TYPE(value)->tp_name);
53                         return -1;
54                 }
55         }
56         return 0;
57 }
58
59 static PyObject *py_named_pipe_auth_req_info4_get_client_addr(PyObject *obj, void *closure)
60 {
61         struct named_pipe_auth_req_info4 *object = (struct named_pipe_auth_req_info4 *)pytalloc_get_ptr(obj);
62         PyObject *py_client_addr;
63         if (object->client_addr == NULL) {
64                 py_client_addr = Py_None;
65                 Py_INCREF(py_client_addr);
66         } else {
67                 if (object->client_addr == NULL) {
68                         py_client_addr = Py_None;
69                         Py_INCREF(py_client_addr);
70                 } else {
71                         py_client_addr = PyUnicode_Decode(object->client_addr, strlen(object->client_addr), "utf-8", "ignore");
72                 }
73         }
74         return py_client_addr;
75 }
76
77 static int py_named_pipe_auth_req_info4_set_client_addr(PyObject *py_obj, PyObject *value, void *closure)
78 {
79         struct named_pipe_auth_req_info4 *object = (struct named_pipe_auth_req_info4 *)pytalloc_get_ptr(py_obj);
80         if (value == Py_None) {
81                 object->client_addr = NULL;
82         } else {
83                 object->client_addr = NULL;
84                 if (PyUnicode_Check(value)) {
85                         object->client_addr = PyString_AS_STRING(PyUnicode_AsEncodedString(value, "utf-8", "ignore"));
86                 } else if (PyString_Check(value)) {
87                         object->client_addr = PyString_AS_STRING(value);
88                 } else {
89                         PyErr_Format(PyExc_TypeError, "Expected string or unicode object, got %s", Py_TYPE(value)->tp_name);
90                         return -1;
91                 }
92         }
93         return 0;
94 }
95
96 static PyObject *py_named_pipe_auth_req_info4_get_client_port(PyObject *obj, void *closure)
97 {
98         struct named_pipe_auth_req_info4 *object = (struct named_pipe_auth_req_info4 *)pytalloc_get_ptr(obj);
99         PyObject *py_client_port;
100         py_client_port = PyInt_FromLong(object->client_port);
101         return py_client_port;
102 }
103
104 static int py_named_pipe_auth_req_info4_set_client_port(PyObject *py_obj, PyObject *value, void *closure)
105 {
106         struct named_pipe_auth_req_info4 *object = (struct named_pipe_auth_req_info4 *)pytalloc_get_ptr(py_obj);
107         PY_CHECK_TYPE(&PyInt_Type, value, return -1;);
108         object->client_port = PyInt_AsLong(value);
109         return 0;
110 }
111
112 static PyObject *py_named_pipe_auth_req_info4_get_server_name(PyObject *obj, void *closure)
113 {
114         struct named_pipe_auth_req_info4 *object = (struct named_pipe_auth_req_info4 *)pytalloc_get_ptr(obj);
115         PyObject *py_server_name;
116         if (object->server_name == NULL) {
117                 py_server_name = Py_None;
118                 Py_INCREF(py_server_name);
119         } else {
120                 if (object->server_name == NULL) {
121                         py_server_name = Py_None;
122                         Py_INCREF(py_server_name);
123                 } else {
124                         py_server_name = PyUnicode_Decode(object->server_name, strlen(object->server_name), "utf-8", "ignore");
125                 }
126         }
127         return py_server_name;
128 }
129
130 static int py_named_pipe_auth_req_info4_set_server_name(PyObject *py_obj, PyObject *value, void *closure)
131 {
132         struct named_pipe_auth_req_info4 *object = (struct named_pipe_auth_req_info4 *)pytalloc_get_ptr(py_obj);
133         if (value == Py_None) {
134                 object->server_name = NULL;
135         } else {
136                 object->server_name = NULL;
137                 if (PyUnicode_Check(value)) {
138                         object->server_name = PyString_AS_STRING(PyUnicode_AsEncodedString(value, "utf-8", "ignore"));
139                 } else if (PyString_Check(value)) {
140                         object->server_name = PyString_AS_STRING(value);
141                 } else {
142                         PyErr_Format(PyExc_TypeError, "Expected string or unicode object, got %s", Py_TYPE(value)->tp_name);
143                         return -1;
144                 }
145         }
146         return 0;
147 }
148
149 static PyObject *py_named_pipe_auth_req_info4_get_server_addr(PyObject *obj, void *closure)
150 {
151         struct named_pipe_auth_req_info4 *object = (struct named_pipe_auth_req_info4 *)pytalloc_get_ptr(obj);
152         PyObject *py_server_addr;
153         if (object->server_addr == NULL) {
154                 py_server_addr = Py_None;
155                 Py_INCREF(py_server_addr);
156         } else {
157                 if (object->server_addr == NULL) {
158                         py_server_addr = Py_None;
159                         Py_INCREF(py_server_addr);
160                 } else {
161                         py_server_addr = PyUnicode_Decode(object->server_addr, strlen(object->server_addr), "utf-8", "ignore");
162                 }
163         }
164         return py_server_addr;
165 }
166
167 static int py_named_pipe_auth_req_info4_set_server_addr(PyObject *py_obj, PyObject *value, void *closure)
168 {
169         struct named_pipe_auth_req_info4 *object = (struct named_pipe_auth_req_info4 *)pytalloc_get_ptr(py_obj);
170         if (value == Py_None) {
171                 object->server_addr = NULL;
172         } else {
173                 object->server_addr = NULL;
174                 if (PyUnicode_Check(value)) {
175                         object->server_addr = PyString_AS_STRING(PyUnicode_AsEncodedString(value, "utf-8", "ignore"));
176                 } else if (PyString_Check(value)) {
177                         object->server_addr = PyString_AS_STRING(value);
178                 } else {
179                         PyErr_Format(PyExc_TypeError, "Expected string or unicode object, got %s", Py_TYPE(value)->tp_name);
180                         return -1;
181                 }
182         }
183         return 0;
184 }
185
186 static PyObject *py_named_pipe_auth_req_info4_get_server_port(PyObject *obj, void *closure)
187 {
188         struct named_pipe_auth_req_info4 *object = (struct named_pipe_auth_req_info4 *)pytalloc_get_ptr(obj);
189         PyObject *py_server_port;
190         py_server_port = PyInt_FromLong(object->server_port);
191         return py_server_port;
192 }
193
194 static int py_named_pipe_auth_req_info4_set_server_port(PyObject *py_obj, PyObject *value, void *closure)
195 {
196         struct named_pipe_auth_req_info4 *object = (struct named_pipe_auth_req_info4 *)pytalloc_get_ptr(py_obj);
197         PY_CHECK_TYPE(&PyInt_Type, value, return -1;);
198         object->server_port = PyInt_AsLong(value);
199         return 0;
200 }
201
202 static PyObject *py_named_pipe_auth_req_info4_get_session_info(PyObject *obj, void *closure)
203 {
204         struct named_pipe_auth_req_info4 *object = (struct named_pipe_auth_req_info4 *)pytalloc_get_ptr(obj);
205         PyObject *py_session_info;
206         if (object->session_info == NULL) {
207                 py_session_info = Py_None;
208                 Py_INCREF(py_session_info);
209         } else {
210                 py_session_info = pytalloc_reference_ex(auth_session_info_transport_Type, object->session_info, object->session_info);
211         }
212         return py_session_info;
213 }
214
215 static int py_named_pipe_auth_req_info4_set_session_info(PyObject *py_obj, PyObject *value, void *closure)
216 {
217         struct named_pipe_auth_req_info4 *object = (struct named_pipe_auth_req_info4 *)pytalloc_get_ptr(py_obj);
218         talloc_unlink(pytalloc_get_mem_ctx(py_obj), object->session_info);
219         if (value == Py_None) {
220                 object->session_info = NULL;
221         } else {
222                 object->session_info = NULL;
223                 PY_CHECK_TYPE(auth_session_info_transport_Type, value, return -1;);
224                 if (talloc_reference(pytalloc_get_mem_ctx(py_obj), pytalloc_get_mem_ctx(value)) == NULL) {
225                         PyErr_NoMemory();
226                         return -1;
227                 }
228                 object->session_info = (struct auth_session_info_transport *)pytalloc_get_ptr(value);
229         }
230         return 0;
231 }
232
233 static PyGetSetDef py_named_pipe_auth_req_info4_getsetters[] = {
234         { discard_const_p(char, "client_name"), py_named_pipe_auth_req_info4_get_client_name, py_named_pipe_auth_req_info4_set_client_name },
235         { discard_const_p(char, "client_addr"), py_named_pipe_auth_req_info4_get_client_addr, py_named_pipe_auth_req_info4_set_client_addr },
236         { discard_const_p(char, "client_port"), py_named_pipe_auth_req_info4_get_client_port, py_named_pipe_auth_req_info4_set_client_port },
237         { discard_const_p(char, "server_name"), py_named_pipe_auth_req_info4_get_server_name, py_named_pipe_auth_req_info4_set_server_name },
238         { discard_const_p(char, "server_addr"), py_named_pipe_auth_req_info4_get_server_addr, py_named_pipe_auth_req_info4_set_server_addr },
239         { discard_const_p(char, "server_port"), py_named_pipe_auth_req_info4_get_server_port, py_named_pipe_auth_req_info4_set_server_port },
240         { discard_const_p(char, "session_info"), py_named_pipe_auth_req_info4_get_session_info, py_named_pipe_auth_req_info4_set_session_info },
241         { NULL }
242 };
243
244 static PyObject *py_named_pipe_auth_req_info4_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
245 {
246         return pytalloc_new(struct named_pipe_auth_req_info4, type);
247 }
248
249
250 static PyTypeObject named_pipe_auth_req_info4_Type = {
251         PyObject_HEAD_INIT(NULL) 0,
252         .tp_name = "named_pipe_auth.req_info4",
253         .tp_getset = py_named_pipe_auth_req_info4_getsetters,
254         .tp_methods = NULL,
255         .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
256         .tp_basicsize = sizeof(pytalloc_Object),
257         .tp_new = py_named_pipe_auth_req_info4_new,
258 };
259
260 PyObject *py_import_named_pipe_auth_req_info(TALLOC_CTX *mem_ctx, int level, union named_pipe_auth_req_info *in)
261 {
262         PyObject *ret;
263
264         switch (level) {
265                 case 4:
266                         ret = pytalloc_reference_ex(&named_pipe_auth_req_info4_Type, mem_ctx, &in->info4);
267                         return ret;
268
269         }
270         PyErr_SetString(PyExc_TypeError, "unknown union level");
271         return NULL;
272 }
273
274 union named_pipe_auth_req_info *py_export_named_pipe_auth_req_info(TALLOC_CTX *mem_ctx, int level, PyObject *in)
275 {
276         union named_pipe_auth_req_info *ret = talloc_zero(mem_ctx, union named_pipe_auth_req_info);
277         switch (level) {
278                 case 4:
279                         PY_CHECK_TYPE(&named_pipe_auth_req_info4_Type, in, talloc_free(ret); return NULL;);
280                         if (talloc_reference(mem_ctx, pytalloc_get_mem_ctx(in)) == NULL) {
281                                 PyErr_NoMemory();
282                                 talloc_free(ret); return NULL;
283                         }
284                         ret->info4 = *(struct named_pipe_auth_req_info4 *)pytalloc_get_ptr(in);
285                         break;
286
287                 default:
288                         PyErr_SetString(PyExc_TypeError, "invalid union level value");
289                         talloc_free(ret);
290                         ret = NULL;
291         }
292
293         return ret;
294 }
295
296
297 static PyObject *py_named_pipe_auth_req_get_length(PyObject *obj, void *closure)
298 {
299         struct named_pipe_auth_req *object = (struct named_pipe_auth_req *)pytalloc_get_ptr(obj);
300         PyObject *py_length;
301         py_length = PyInt_FromLong(object->length);
302         return py_length;
303 }
304
305 static int py_named_pipe_auth_req_set_length(PyObject *py_obj, PyObject *value, void *closure)
306 {
307         struct named_pipe_auth_req *object = (struct named_pipe_auth_req *)pytalloc_get_ptr(py_obj);
308         PY_CHECK_TYPE(&PyInt_Type, value, return -1;);
309         object->length = PyInt_AsLong(value);
310         return 0;
311 }
312
313 static PyObject *py_named_pipe_auth_req_get_magic(PyObject *obj, void *closure)
314 {
315         struct named_pipe_auth_req *object = (struct named_pipe_auth_req *)pytalloc_get_ptr(obj);
316         PyObject *py_magic;
317         if (object->magic == NULL) {
318                 py_magic = Py_None;
319                 Py_INCREF(py_magic);
320         } else {
321                 py_magic = PyUnicode_Decode(object->magic, strlen(object->magic), "utf-8", "ignore");
322         }
323         return py_magic;
324 }
325
326 static int py_named_pipe_auth_req_set_magic(PyObject *py_obj, PyObject *value, void *closure)
327 {
328         struct named_pipe_auth_req *object = (struct named_pipe_auth_req *)pytalloc_get_ptr(py_obj);
329         if (PyUnicode_Check(value)) {
330                 object->magic = PyString_AS_STRING(PyUnicode_AsEncodedString(value, "utf-8", "ignore"));
331         } else if (PyString_Check(value)) {
332                 object->magic = PyString_AS_STRING(value);
333         } else {
334                 PyErr_Format(PyExc_TypeError, "Expected string or unicode object, got %s", Py_TYPE(value)->tp_name);
335                 return -1;
336         }
337         return 0;
338 }
339
340 static PyObject *py_named_pipe_auth_req_get_level(PyObject *obj, void *closure)
341 {
342         struct named_pipe_auth_req *object = (struct named_pipe_auth_req *)pytalloc_get_ptr(obj);
343         PyObject *py_level;
344         py_level = PyInt_FromLong(object->level);
345         return py_level;
346 }
347
348 static int py_named_pipe_auth_req_set_level(PyObject *py_obj, PyObject *value, void *closure)
349 {
350         struct named_pipe_auth_req *object = (struct named_pipe_auth_req *)pytalloc_get_ptr(py_obj);
351         PY_CHECK_TYPE(&PyInt_Type, value, return -1;);
352         object->level = PyInt_AsLong(value);
353         return 0;
354 }
355
356 static PyObject *py_named_pipe_auth_req_get_info(PyObject *obj, void *closure)
357 {
358         struct named_pipe_auth_req *object = (struct named_pipe_auth_req *)pytalloc_get_ptr(obj);
359         PyObject *py_info;
360         py_info = py_import_named_pipe_auth_req_info(pytalloc_get_mem_ctx(obj), object->level, &object->info);
361         if (py_info == NULL) {
362                 return NULL;
363         }
364         return py_info;
365 }
366
367 static int py_named_pipe_auth_req_set_info(PyObject *py_obj, PyObject *value, void *closure)
368 {
369         struct named_pipe_auth_req *object = (struct named_pipe_auth_req *)pytalloc_get_ptr(py_obj);
370         {
371                 union named_pipe_auth_req_info *info_switch_0;
372                 info_switch_0 = py_export_named_pipe_auth_req_info(pytalloc_get_mem_ctx(py_obj), object->level, value);
373                 if (info_switch_0 == NULL) {
374                         return -1;
375                 }
376                 object->info = *info_switch_0;
377         }
378         return 0;
379 }
380
381 static PyGetSetDef py_named_pipe_auth_req_getsetters[] = {
382         { discard_const_p(char, "length"), py_named_pipe_auth_req_get_length, py_named_pipe_auth_req_set_length },
383         { discard_const_p(char, "magic"), py_named_pipe_auth_req_get_magic, py_named_pipe_auth_req_set_magic },
384         { discard_const_p(char, "level"), py_named_pipe_auth_req_get_level, py_named_pipe_auth_req_set_level },
385         { discard_const_p(char, "info"), py_named_pipe_auth_req_get_info, py_named_pipe_auth_req_set_info },
386         { NULL }
387 };
388
389 static PyObject *py_named_pipe_auth_req_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
390 {
391         return pytalloc_new(struct named_pipe_auth_req, type);
392 }
393
394 static PyObject *py_named_pipe_auth_req_ndr_pack(PyObject *py_obj)
395 {
396         struct named_pipe_auth_req *object = (struct named_pipe_auth_req *)pytalloc_get_ptr(py_obj);
397         DATA_BLOB blob;
398         enum ndr_err_code err;
399         err = ndr_push_struct_blob(&blob, pytalloc_get_mem_ctx(py_obj), object, (ndr_push_flags_fn_t)ndr_push_named_pipe_auth_req);
400         if (err != NDR_ERR_SUCCESS) {
401                 PyErr_SetNdrError(err);
402                 return NULL;
403         }
404
405         return PyString_FromStringAndSize((char *)blob.data, blob.length);
406 }
407
408 static PyObject *py_named_pipe_auth_req_ndr_unpack(PyObject *py_obj, PyObject *args, PyObject *kwargs)
409 {
410         struct named_pipe_auth_req *object = (struct named_pipe_auth_req *)pytalloc_get_ptr(py_obj);
411         DATA_BLOB blob;
412         int blob_length = 0;
413         enum ndr_err_code err;
414         const char * const kwnames[] = { "data_blob", "allow_remaining", NULL };
415         PyObject *allow_remaining_obj = NULL;
416         bool allow_remaining = false;
417
418         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s#|O:__ndr_unpack__",
419                 discard_const_p(char *, kwnames),
420                 &blob.data, &blob_length,
421                 &allow_remaining_obj)) {
422                 return NULL;
423         }
424         blob.length = blob_length;
425
426         if (allow_remaining_obj && PyObject_IsTrue(allow_remaining_obj)) {
427                 allow_remaining = true;
428         }
429
430         if (allow_remaining) {
431                 err = ndr_pull_struct_blob(&blob, pytalloc_get_mem_ctx(py_obj), object, (ndr_pull_flags_fn_t)ndr_pull_named_pipe_auth_req);
432         } else {
433                 err = ndr_pull_struct_blob_all(&blob, pytalloc_get_mem_ctx(py_obj), object, (ndr_pull_flags_fn_t)ndr_pull_named_pipe_auth_req);
434         }
435         if (err != NDR_ERR_SUCCESS) {
436                 PyErr_SetNdrError(err);
437                 return NULL;
438         }
439
440         Py_RETURN_NONE;
441 }
442
443 static PyObject *py_named_pipe_auth_req_ndr_print(PyObject *py_obj)
444 {
445         struct named_pipe_auth_req *object = (struct named_pipe_auth_req *)pytalloc_get_ptr(py_obj);
446         PyObject *ret;
447         char *retstr;
448
449         retstr = ndr_print_struct_string(pytalloc_get_mem_ctx(py_obj), (ndr_print_fn_t)ndr_print_named_pipe_auth_req, "named_pipe_auth_req", object);
450         ret = PyString_FromString(retstr);
451         talloc_free(retstr);
452
453         return ret;
454 }
455
456 static PyMethodDef py_named_pipe_auth_req_methods[] = {
457         { "__ndr_pack__", (PyCFunction)py_named_pipe_auth_req_ndr_pack, METH_NOARGS, "S.ndr_pack(object) -> blob\nNDR pack" },
458         { "__ndr_unpack__", (PyCFunction)py_named_pipe_auth_req_ndr_unpack, METH_VARARGS|METH_KEYWORDS, "S.ndr_unpack(class, blob, allow_remaining=False) -> None\nNDR unpack" },
459         { "__ndr_print__", (PyCFunction)py_named_pipe_auth_req_ndr_print, METH_VARARGS, "S.ndr_print(object) -> None\nNDR print" },
460         { NULL, NULL, 0, NULL }
461 };
462
463
464 static PyTypeObject named_pipe_auth_req_Type = {
465         PyObject_HEAD_INIT(NULL) 0,
466         .tp_name = "named_pipe_auth.req",
467         .tp_getset = py_named_pipe_auth_req_getsetters,
468         .tp_methods = py_named_pipe_auth_req_methods,
469         .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
470         .tp_basicsize = sizeof(pytalloc_Object),
471         .tp_new = py_named_pipe_auth_req_new,
472 };
473
474
475 static PyObject *py_named_pipe_auth_rep_info4_get_file_type(PyObject *obj, void *closure)
476 {
477         struct named_pipe_auth_rep_info4 *object = (struct named_pipe_auth_rep_info4 *)pytalloc_get_ptr(obj);
478         PyObject *py_file_type;
479         py_file_type = PyInt_FromLong(object->file_type);
480         return py_file_type;
481 }
482
483 static int py_named_pipe_auth_rep_info4_set_file_type(PyObject *py_obj, PyObject *value, void *closure)
484 {
485         struct named_pipe_auth_rep_info4 *object = (struct named_pipe_auth_rep_info4 *)pytalloc_get_ptr(py_obj);
486         PY_CHECK_TYPE(&PyInt_Type, value, return -1;);
487         object->file_type = PyInt_AsLong(value);
488         return 0;
489 }
490
491 static PyObject *py_named_pipe_auth_rep_info4_get_device_state(PyObject *obj, void *closure)
492 {
493         struct named_pipe_auth_rep_info4 *object = (struct named_pipe_auth_rep_info4 *)pytalloc_get_ptr(obj);
494         PyObject *py_device_state;
495         py_device_state = PyInt_FromLong(object->device_state);
496         return py_device_state;
497 }
498
499 static int py_named_pipe_auth_rep_info4_set_device_state(PyObject *py_obj, PyObject *value, void *closure)
500 {
501         struct named_pipe_auth_rep_info4 *object = (struct named_pipe_auth_rep_info4 *)pytalloc_get_ptr(py_obj);
502         PY_CHECK_TYPE(&PyInt_Type, value, return -1;);
503         object->device_state = PyInt_AsLong(value);
504         return 0;
505 }
506
507 static PyObject *py_named_pipe_auth_rep_info4_get_allocation_size(PyObject *obj, void *closure)
508 {
509         struct named_pipe_auth_rep_info4 *object = (struct named_pipe_auth_rep_info4 *)pytalloc_get_ptr(obj);
510         PyObject *py_allocation_size;
511         py_allocation_size = PyLong_FromLongLong(object->allocation_size);
512         return py_allocation_size;
513 }
514
515 static int py_named_pipe_auth_rep_info4_set_allocation_size(PyObject *py_obj, PyObject *value, void *closure)
516 {
517         struct named_pipe_auth_rep_info4 *object = (struct named_pipe_auth_rep_info4 *)pytalloc_get_ptr(py_obj);
518         if (PyLong_Check(value)) {
519                 object->allocation_size = PyLong_AsLongLong(value);
520         } else if (PyInt_Check(value)) {
521                 object->allocation_size = PyInt_AsLong(value);
522         } else {
523                 PyErr_Format(PyExc_TypeError, "Expected type %s or %s",\
524                   PyInt_Type.tp_name, PyLong_Type.tp_name);
525                 return -1;
526         }
527         return 0;
528 }
529
530 static PyGetSetDef py_named_pipe_auth_rep_info4_getsetters[] = {
531         { discard_const_p(char, "file_type"), py_named_pipe_auth_rep_info4_get_file_type, py_named_pipe_auth_rep_info4_set_file_type },
532         { discard_const_p(char, "device_state"), py_named_pipe_auth_rep_info4_get_device_state, py_named_pipe_auth_rep_info4_set_device_state },
533         { discard_const_p(char, "allocation_size"), py_named_pipe_auth_rep_info4_get_allocation_size, py_named_pipe_auth_rep_info4_set_allocation_size },
534         { NULL }
535 };
536
537 static PyObject *py_named_pipe_auth_rep_info4_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
538 {
539         return pytalloc_new(struct named_pipe_auth_rep_info4, type);
540 }
541
542
543 static PyTypeObject named_pipe_auth_rep_info4_Type = {
544         PyObject_HEAD_INIT(NULL) 0,
545         .tp_name = "named_pipe_auth.rep_info4",
546         .tp_getset = py_named_pipe_auth_rep_info4_getsetters,
547         .tp_methods = NULL,
548         .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
549         .tp_basicsize = sizeof(pytalloc_Object),
550         .tp_new = py_named_pipe_auth_rep_info4_new,
551 };
552
553 PyObject *py_import_named_pipe_auth_rep_info(TALLOC_CTX *mem_ctx, int level, union named_pipe_auth_rep_info *in)
554 {
555         PyObject *ret;
556
557         switch (level) {
558                 case 4:
559                         ret = pytalloc_reference_ex(&named_pipe_auth_rep_info4_Type, mem_ctx, &in->info4);
560                         return ret;
561
562         }
563         PyErr_SetString(PyExc_TypeError, "unknown union level");
564         return NULL;
565 }
566
567 union named_pipe_auth_rep_info *py_export_named_pipe_auth_rep_info(TALLOC_CTX *mem_ctx, int level, PyObject *in)
568 {
569         union named_pipe_auth_rep_info *ret = talloc_zero(mem_ctx, union named_pipe_auth_rep_info);
570         switch (level) {
571                 case 4:
572                         PY_CHECK_TYPE(&named_pipe_auth_rep_info4_Type, in, talloc_free(ret); return NULL;);
573                         if (talloc_reference(mem_ctx, pytalloc_get_mem_ctx(in)) == NULL) {
574                                 PyErr_NoMemory();
575                                 talloc_free(ret); return NULL;
576                         }
577                         ret->info4 = *(struct named_pipe_auth_rep_info4 *)pytalloc_get_ptr(in);
578                         break;
579
580                 default:
581                         PyErr_SetString(PyExc_TypeError, "invalid union level value");
582                         talloc_free(ret);
583                         ret = NULL;
584         }
585
586         return ret;
587 }
588
589
590 static PyObject *py_named_pipe_auth_rep_get_length(PyObject *obj, void *closure)
591 {
592         struct named_pipe_auth_rep *object = (struct named_pipe_auth_rep *)pytalloc_get_ptr(obj);
593         PyObject *py_length;
594         py_length = PyInt_FromLong(object->length);
595         return py_length;
596 }
597
598 static int py_named_pipe_auth_rep_set_length(PyObject *py_obj, PyObject *value, void *closure)
599 {
600         struct named_pipe_auth_rep *object = (struct named_pipe_auth_rep *)pytalloc_get_ptr(py_obj);
601         PY_CHECK_TYPE(&PyInt_Type, value, return -1;);
602         object->length = PyInt_AsLong(value);
603         return 0;
604 }
605
606 static PyObject *py_named_pipe_auth_rep_get_magic(PyObject *obj, void *closure)
607 {
608         struct named_pipe_auth_rep *object = (struct named_pipe_auth_rep *)pytalloc_get_ptr(obj);
609         PyObject *py_magic;
610         if (object->magic == NULL) {
611                 py_magic = Py_None;
612                 Py_INCREF(py_magic);
613         } else {
614                 py_magic = PyUnicode_Decode(object->magic, strlen(object->magic), "utf-8", "ignore");
615         }
616         return py_magic;
617 }
618
619 static int py_named_pipe_auth_rep_set_magic(PyObject *py_obj, PyObject *value, void *closure)
620 {
621         struct named_pipe_auth_rep *object = (struct named_pipe_auth_rep *)pytalloc_get_ptr(py_obj);
622         if (PyUnicode_Check(value)) {
623                 object->magic = PyString_AS_STRING(PyUnicode_AsEncodedString(value, "utf-8", "ignore"));
624         } else if (PyString_Check(value)) {
625                 object->magic = PyString_AS_STRING(value);
626         } else {
627                 PyErr_Format(PyExc_TypeError, "Expected string or unicode object, got %s", Py_TYPE(value)->tp_name);
628                 return -1;
629         }
630         return 0;
631 }
632
633 static PyObject *py_named_pipe_auth_rep_get_level(PyObject *obj, void *closure)
634 {
635         struct named_pipe_auth_rep *object = (struct named_pipe_auth_rep *)pytalloc_get_ptr(obj);
636         PyObject *py_level;
637         py_level = PyInt_FromLong(object->level);
638         return py_level;
639 }
640
641 static int py_named_pipe_auth_rep_set_level(PyObject *py_obj, PyObject *value, void *closure)
642 {
643         struct named_pipe_auth_rep *object = (struct named_pipe_auth_rep *)pytalloc_get_ptr(py_obj);
644         PY_CHECK_TYPE(&PyInt_Type, value, return -1;);
645         object->level = PyInt_AsLong(value);
646         return 0;
647 }
648
649 static PyObject *py_named_pipe_auth_rep_get_info(PyObject *obj, void *closure)
650 {
651         struct named_pipe_auth_rep *object = (struct named_pipe_auth_rep *)pytalloc_get_ptr(obj);
652         PyObject *py_info;
653         py_info = py_import_named_pipe_auth_rep_info(pytalloc_get_mem_ctx(obj), object->level, &object->info);
654         if (py_info == NULL) {
655                 return NULL;
656         }
657         return py_info;
658 }
659
660 static int py_named_pipe_auth_rep_set_info(PyObject *py_obj, PyObject *value, void *closure)
661 {
662         struct named_pipe_auth_rep *object = (struct named_pipe_auth_rep *)pytalloc_get_ptr(py_obj);
663         {
664                 union named_pipe_auth_rep_info *info_switch_0;
665                 info_switch_0 = py_export_named_pipe_auth_rep_info(pytalloc_get_mem_ctx(py_obj), object->level, value);
666                 if (info_switch_0 == NULL) {
667                         return -1;
668                 }
669                 object->info = *info_switch_0;
670         }
671         return 0;
672 }
673
674 static PyObject *py_named_pipe_auth_rep_get_status(PyObject *obj, void *closure)
675 {
676         struct named_pipe_auth_rep *object = (struct named_pipe_auth_rep *)pytalloc_get_ptr(obj);
677         PyObject *py_status;
678         py_status = PyErr_FromNTSTATUS(object->status);
679         return py_status;
680 }
681
682 static int py_named_pipe_auth_rep_set_status(PyObject *py_obj, PyObject *value, void *closure)
683 {
684         struct named_pipe_auth_rep *object = (struct named_pipe_auth_rep *)pytalloc_get_ptr(py_obj);
685         object->status = NT_STATUS(PyInt_AsLong(value));
686         return 0;
687 }
688
689 static PyGetSetDef py_named_pipe_auth_rep_getsetters[] = {
690         { discard_const_p(char, "length"), py_named_pipe_auth_rep_get_length, py_named_pipe_auth_rep_set_length },
691         { discard_const_p(char, "magic"), py_named_pipe_auth_rep_get_magic, py_named_pipe_auth_rep_set_magic },
692         { discard_const_p(char, "level"), py_named_pipe_auth_rep_get_level, py_named_pipe_auth_rep_set_level },
693         { discard_const_p(char, "info"), py_named_pipe_auth_rep_get_info, py_named_pipe_auth_rep_set_info },
694         { discard_const_p(char, "status"), py_named_pipe_auth_rep_get_status, py_named_pipe_auth_rep_set_status },
695         { NULL }
696 };
697
698 static PyObject *py_named_pipe_auth_rep_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
699 {
700         return pytalloc_new(struct named_pipe_auth_rep, type);
701 }
702
703 static PyObject *py_named_pipe_auth_rep_ndr_pack(PyObject *py_obj)
704 {
705         struct named_pipe_auth_rep *object = (struct named_pipe_auth_rep *)pytalloc_get_ptr(py_obj);
706         DATA_BLOB blob;
707         enum ndr_err_code err;
708         err = ndr_push_struct_blob(&blob, pytalloc_get_mem_ctx(py_obj), object, (ndr_push_flags_fn_t)ndr_push_named_pipe_auth_rep);
709         if (err != NDR_ERR_SUCCESS) {
710                 PyErr_SetNdrError(err);
711                 return NULL;
712         }
713
714         return PyString_FromStringAndSize((char *)blob.data, blob.length);
715 }
716
717 static PyObject *py_named_pipe_auth_rep_ndr_unpack(PyObject *py_obj, PyObject *args, PyObject *kwargs)
718 {
719         struct named_pipe_auth_rep *object = (struct named_pipe_auth_rep *)pytalloc_get_ptr(py_obj);
720         DATA_BLOB blob;
721         int blob_length = 0;
722         enum ndr_err_code err;
723         const char * const kwnames[] = { "data_blob", "allow_remaining", NULL };
724         PyObject *allow_remaining_obj = NULL;
725         bool allow_remaining = false;
726
727         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s#|O:__ndr_unpack__",
728                 discard_const_p(char *, kwnames),
729                 &blob.data, &blob_length,
730                 &allow_remaining_obj)) {
731                 return NULL;
732         }
733         blob.length = blob_length;
734
735         if (allow_remaining_obj && PyObject_IsTrue(allow_remaining_obj)) {
736                 allow_remaining = true;
737         }
738
739         if (allow_remaining) {
740                 err = ndr_pull_struct_blob(&blob, pytalloc_get_mem_ctx(py_obj), object, (ndr_pull_flags_fn_t)ndr_pull_named_pipe_auth_rep);
741         } else {
742                 err = ndr_pull_struct_blob_all(&blob, pytalloc_get_mem_ctx(py_obj), object, (ndr_pull_flags_fn_t)ndr_pull_named_pipe_auth_rep);
743         }
744         if (err != NDR_ERR_SUCCESS) {
745                 PyErr_SetNdrError(err);
746                 return NULL;
747         }
748
749         Py_RETURN_NONE;
750 }
751
752 static PyObject *py_named_pipe_auth_rep_ndr_print(PyObject *py_obj)
753 {
754         struct named_pipe_auth_rep *object = (struct named_pipe_auth_rep *)pytalloc_get_ptr(py_obj);
755         PyObject *ret;
756         char *retstr;
757
758         retstr = ndr_print_struct_string(pytalloc_get_mem_ctx(py_obj), (ndr_print_fn_t)ndr_print_named_pipe_auth_rep, "named_pipe_auth_rep", object);
759         ret = PyString_FromString(retstr);
760         talloc_free(retstr);
761
762         return ret;
763 }
764
765 static PyMethodDef py_named_pipe_auth_rep_methods[] = {
766         { "__ndr_pack__", (PyCFunction)py_named_pipe_auth_rep_ndr_pack, METH_NOARGS, "S.ndr_pack(object) -> blob\nNDR pack" },
767         { "__ndr_unpack__", (PyCFunction)py_named_pipe_auth_rep_ndr_unpack, METH_VARARGS|METH_KEYWORDS, "S.ndr_unpack(class, blob, allow_remaining=False) -> None\nNDR unpack" },
768         { "__ndr_print__", (PyCFunction)py_named_pipe_auth_rep_ndr_print, METH_VARARGS, "S.ndr_print(object) -> None\nNDR print" },
769         { NULL, NULL, 0, NULL }
770 };
771
772
773 static PyTypeObject named_pipe_auth_rep_Type = {
774         PyObject_HEAD_INIT(NULL) 0,
775         .tp_name = "named_pipe_auth.rep",
776         .tp_getset = py_named_pipe_auth_rep_getsetters,
777         .tp_methods = py_named_pipe_auth_rep_methods,
778         .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
779         .tp_basicsize = sizeof(pytalloc_Object),
780         .tp_new = py_named_pipe_auth_rep_new,
781 };
782
783 static PyMethodDef named_pipe_auth_methods[] = {
784         { NULL, NULL, 0, NULL }
785 };
786
787 void initnamed_pipe_auth(void)
788 {
789         PyObject *m;
790         PyObject *dep_samba_dcerpc_security;
791         PyObject *dep_talloc;
792         PyObject *dep_samba_dcerpc_netlogon;
793         PyObject *dep_samba_dcerpc_auth;
794
795         dep_samba_dcerpc_security = PyImport_ImportModule("samba.dcerpc.security");
796         if (dep_samba_dcerpc_security == NULL)
797                 return;
798
799         dep_talloc = PyImport_ImportModule("talloc");
800         if (dep_talloc == NULL)
801                 return;
802
803         dep_samba_dcerpc_netlogon = PyImport_ImportModule("samba.dcerpc.netlogon");
804         if (dep_samba_dcerpc_netlogon == NULL)
805                 return;
806
807         dep_samba_dcerpc_auth = PyImport_ImportModule("samba.dcerpc.auth");
808         if (dep_samba_dcerpc_auth == NULL)
809                 return;
810
811         auth_session_info_transport_Type = (PyTypeObject *)PyObject_GetAttrString(dep_samba_dcerpc_auth, "session_info_transport");
812         if (auth_session_info_transport_Type == NULL)
813                 return;
814
815         Object_Type = (PyTypeObject *)PyObject_GetAttrString(dep_talloc, "Object");
816         if (Object_Type == NULL)
817                 return;
818
819         named_pipe_auth_req_info4_Type.tp_base = Object_Type;
820
821         named_pipe_auth_req_Type.tp_base = Object_Type;
822
823         named_pipe_auth_rep_info4_Type.tp_base = Object_Type;
824
825         named_pipe_auth_rep_Type.tp_base = Object_Type;
826
827         if (PyType_Ready(&named_pipe_auth_req_info4_Type) < 0)
828                 return;
829         if (PyType_Ready(&named_pipe_auth_req_Type) < 0)
830                 return;
831         if (PyType_Ready(&named_pipe_auth_rep_info4_Type) < 0)
832                 return;
833         if (PyType_Ready(&named_pipe_auth_rep_Type) < 0)
834                 return;
835 #ifdef PY_REQ_INFO4_PATCH
836         PY_REQ_INFO4_PATCH(&named_pipe_auth_req_info4_Type);
837 #endif
838 #ifdef PY_REQ_PATCH
839         PY_REQ_PATCH(&named_pipe_auth_req_Type);
840 #endif
841 #ifdef PY_REP_INFO4_PATCH
842         PY_REP_INFO4_PATCH(&named_pipe_auth_rep_info4_Type);
843 #endif
844 #ifdef PY_REP_PATCH
845         PY_REP_PATCH(&named_pipe_auth_rep_Type);
846 #endif
847
848         m = Py_InitModule3("named_pipe_auth", named_pipe_auth_methods, "named_pipe_auth DCE/RPC");
849         if (m == NULL)
850                 return;
851
852         PyModule_AddObject(m, "NAMED_PIPE_AUTH_MAGIC", PyString_FromString("NPAM"));
853         Py_INCREF((PyObject *)(void *)&named_pipe_auth_req_info4_Type);
854         PyModule_AddObject(m, "req_info4", (PyObject *)(void *)&named_pipe_auth_req_info4_Type);
855         Py_INCREF((PyObject *)(void *)&named_pipe_auth_req_Type);
856         PyModule_AddObject(m, "req", (PyObject *)(void *)&named_pipe_auth_req_Type);
857         Py_INCREF((PyObject *)(void *)&named_pipe_auth_rep_info4_Type);
858         PyModule_AddObject(m, "rep_info4", (PyObject *)(void *)&named_pipe_auth_rep_info4_Type);
859         Py_INCREF((PyObject *)(void *)&named_pipe_auth_rep_Type);
860         PyModule_AddObject(m, "rep", (PyObject *)(void *)&named_pipe_auth_rep_Type);
861 #ifdef PY_MOD_NAMED_PIPE_AUTH_PATCH
862         PY_MOD_NAMED_PIPE_AUTH_PATCH(m);
863 #endif
864
865 }