2 /* Python wrapper functions auto-generated by pidl */
6 #include "librpc/rpc/pyrpc.h"
7 #include "librpc/rpc/pyrpc_util.h"
8 #include "bin/default/librpc/gen_ndr/ndr_named_pipe_auth.h"
9 #include "bin/default/librpc/gen_ndr/ndr_named_pipe_auth_c.h"
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;
19 void initnamed_pipe_auth(void);static PyTypeObject *auth_session_info_transport_Type;
20 static PyTypeObject *Object_Type;
22 static PyObject *py_named_pipe_auth_req_info4_get_client_name(PyObject *obj, void *closure)
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);
30 if (object->client_name == NULL) {
31 py_client_name = Py_None;
32 Py_INCREF(py_client_name);
34 py_client_name = PyUnicode_Decode(object->client_name, strlen(object->client_name), "utf-8", "ignore");
37 return py_client_name;
40 static int py_named_pipe_auth_req_info4_set_client_name(PyObject *py_obj, PyObject *value, void *closure)
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;
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);
52 PyErr_Format(PyExc_TypeError, "Expected string or unicode object, got %s", Py_TYPE(value)->tp_name);
59 static PyObject *py_named_pipe_auth_req_info4_get_client_addr(PyObject *obj, void *closure)
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);
67 if (object->client_addr == NULL) {
68 py_client_addr = Py_None;
69 Py_INCREF(py_client_addr);
71 py_client_addr = PyUnicode_Decode(object->client_addr, strlen(object->client_addr), "utf-8", "ignore");
74 return py_client_addr;
77 static int py_named_pipe_auth_req_info4_set_client_addr(PyObject *py_obj, PyObject *value, void *closure)
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;
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);
89 PyErr_Format(PyExc_TypeError, "Expected string or unicode object, got %s", Py_TYPE(value)->tp_name);
96 static PyObject *py_named_pipe_auth_req_info4_get_client_port(PyObject *obj, void *closure)
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;
104 static int py_named_pipe_auth_req_info4_set_client_port(PyObject *py_obj, PyObject *value, void *closure)
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);
112 static PyObject *py_named_pipe_auth_req_info4_get_server_name(PyObject *obj, void *closure)
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);
120 if (object->server_name == NULL) {
121 py_server_name = Py_None;
122 Py_INCREF(py_server_name);
124 py_server_name = PyUnicode_Decode(object->server_name, strlen(object->server_name), "utf-8", "ignore");
127 return py_server_name;
130 static int py_named_pipe_auth_req_info4_set_server_name(PyObject *py_obj, PyObject *value, void *closure)
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;
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);
142 PyErr_Format(PyExc_TypeError, "Expected string or unicode object, got %s", Py_TYPE(value)->tp_name);
149 static PyObject *py_named_pipe_auth_req_info4_get_server_addr(PyObject *obj, void *closure)
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);
157 if (object->server_addr == NULL) {
158 py_server_addr = Py_None;
159 Py_INCREF(py_server_addr);
161 py_server_addr = PyUnicode_Decode(object->server_addr, strlen(object->server_addr), "utf-8", "ignore");
164 return py_server_addr;
167 static int py_named_pipe_auth_req_info4_set_server_addr(PyObject *py_obj, PyObject *value, void *closure)
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;
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);
179 PyErr_Format(PyExc_TypeError, "Expected string or unicode object, got %s", Py_TYPE(value)->tp_name);
186 static PyObject *py_named_pipe_auth_req_info4_get_server_port(PyObject *obj, void *closure)
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;
194 static int py_named_pipe_auth_req_info4_set_server_port(PyObject *py_obj, PyObject *value, void *closure)
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);
202 static PyObject *py_named_pipe_auth_req_info4_get_session_info(PyObject *obj, void *closure)
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);
210 py_session_info = pytalloc_reference_ex(auth_session_info_transport_Type, object->session_info, object->session_info);
212 return py_session_info;
215 static int py_named_pipe_auth_req_info4_set_session_info(PyObject *py_obj, PyObject *value, void *closure)
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;
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) {
228 object->session_info = (struct auth_session_info_transport *)pytalloc_get_ptr(value);
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 },
244 static PyObject *py_named_pipe_auth_req_info4_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
246 return pytalloc_new(struct named_pipe_auth_req_info4, type);
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,
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,
260 PyObject *py_import_named_pipe_auth_req_info(TALLOC_CTX *mem_ctx, int level, union named_pipe_auth_req_info *in)
266 ret = pytalloc_reference_ex(&named_pipe_auth_req_info4_Type, mem_ctx, &in->info4);
270 PyErr_SetString(PyExc_TypeError, "unknown union level");
274 union named_pipe_auth_req_info *py_export_named_pipe_auth_req_info(TALLOC_CTX *mem_ctx, int level, PyObject *in)
276 union named_pipe_auth_req_info *ret = talloc_zero(mem_ctx, union named_pipe_auth_req_info);
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) {
282 talloc_free(ret); return NULL;
284 ret->info4 = *(struct named_pipe_auth_req_info4 *)pytalloc_get_ptr(in);
288 PyErr_SetString(PyExc_TypeError, "invalid union level value");
297 static PyObject *py_named_pipe_auth_req_get_length(PyObject *obj, void *closure)
299 struct named_pipe_auth_req *object = (struct named_pipe_auth_req *)pytalloc_get_ptr(obj);
301 py_length = PyInt_FromLong(object->length);
305 static int py_named_pipe_auth_req_set_length(PyObject *py_obj, PyObject *value, void *closure)
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);
313 static PyObject *py_named_pipe_auth_req_get_magic(PyObject *obj, void *closure)
315 struct named_pipe_auth_req *object = (struct named_pipe_auth_req *)pytalloc_get_ptr(obj);
317 if (object->magic == NULL) {
321 py_magic = PyUnicode_Decode(object->magic, strlen(object->magic), "utf-8", "ignore");
326 static int py_named_pipe_auth_req_set_magic(PyObject *py_obj, PyObject *value, void *closure)
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);
334 PyErr_Format(PyExc_TypeError, "Expected string or unicode object, got %s", Py_TYPE(value)->tp_name);
340 static PyObject *py_named_pipe_auth_req_get_level(PyObject *obj, void *closure)
342 struct named_pipe_auth_req *object = (struct named_pipe_auth_req *)pytalloc_get_ptr(obj);
344 py_level = PyInt_FromLong(object->level);
348 static int py_named_pipe_auth_req_set_level(PyObject *py_obj, PyObject *value, void *closure)
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);
356 static PyObject *py_named_pipe_auth_req_get_info(PyObject *obj, void *closure)
358 struct named_pipe_auth_req *object = (struct named_pipe_auth_req *)pytalloc_get_ptr(obj);
360 py_info = py_import_named_pipe_auth_req_info(pytalloc_get_mem_ctx(obj), object->level, &object->info);
361 if (py_info == NULL) {
367 static int py_named_pipe_auth_req_set_info(PyObject *py_obj, PyObject *value, void *closure)
369 struct named_pipe_auth_req *object = (struct named_pipe_auth_req *)pytalloc_get_ptr(py_obj);
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) {
376 object->info = *info_switch_0;
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 },
389 static PyObject *py_named_pipe_auth_req_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
391 return pytalloc_new(struct named_pipe_auth_req, type);
394 static PyObject *py_named_pipe_auth_req_ndr_pack(PyObject *py_obj)
396 struct named_pipe_auth_req *object = (struct named_pipe_auth_req *)pytalloc_get_ptr(py_obj);
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);
405 return PyString_FromStringAndSize((char *)blob.data, blob.length);
408 static PyObject *py_named_pipe_auth_req_ndr_unpack(PyObject *py_obj, PyObject *args, PyObject *kwargs)
410 struct named_pipe_auth_req *object = (struct named_pipe_auth_req *)pytalloc_get_ptr(py_obj);
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;
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)) {
424 blob.length = blob_length;
426 if (allow_remaining_obj && PyObject_IsTrue(allow_remaining_obj)) {
427 allow_remaining = true;
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);
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);
435 if (err != NDR_ERR_SUCCESS) {
436 PyErr_SetNdrError(err);
443 static PyObject *py_named_pipe_auth_req_ndr_print(PyObject *py_obj)
445 struct named_pipe_auth_req *object = (struct named_pipe_auth_req *)pytalloc_get_ptr(py_obj);
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);
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 }
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,
475 static PyObject *py_named_pipe_auth_rep_info4_get_file_type(PyObject *obj, void *closure)
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);
483 static int py_named_pipe_auth_rep_info4_set_file_type(PyObject *py_obj, PyObject *value, void *closure)
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);
491 static PyObject *py_named_pipe_auth_rep_info4_get_device_state(PyObject *obj, void *closure)
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;
499 static int py_named_pipe_auth_rep_info4_set_device_state(PyObject *py_obj, PyObject *value, void *closure)
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);
507 static PyObject *py_named_pipe_auth_rep_info4_get_allocation_size(PyObject *obj, void *closure)
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;
515 static int py_named_pipe_auth_rep_info4_set_allocation_size(PyObject *py_obj, PyObject *value, void *closure)
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);
523 PyErr_Format(PyExc_TypeError, "Expected type %s or %s",\
524 PyInt_Type.tp_name, PyLong_Type.tp_name);
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 },
537 static PyObject *py_named_pipe_auth_rep_info4_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
539 return pytalloc_new(struct named_pipe_auth_rep_info4, type);
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,
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,
553 PyObject *py_import_named_pipe_auth_rep_info(TALLOC_CTX *mem_ctx, int level, union named_pipe_auth_rep_info *in)
559 ret = pytalloc_reference_ex(&named_pipe_auth_rep_info4_Type, mem_ctx, &in->info4);
563 PyErr_SetString(PyExc_TypeError, "unknown union level");
567 union named_pipe_auth_rep_info *py_export_named_pipe_auth_rep_info(TALLOC_CTX *mem_ctx, int level, PyObject *in)
569 union named_pipe_auth_rep_info *ret = talloc_zero(mem_ctx, union named_pipe_auth_rep_info);
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) {
575 talloc_free(ret); return NULL;
577 ret->info4 = *(struct named_pipe_auth_rep_info4 *)pytalloc_get_ptr(in);
581 PyErr_SetString(PyExc_TypeError, "invalid union level value");
590 static PyObject *py_named_pipe_auth_rep_get_length(PyObject *obj, void *closure)
592 struct named_pipe_auth_rep *object = (struct named_pipe_auth_rep *)pytalloc_get_ptr(obj);
594 py_length = PyInt_FromLong(object->length);
598 static int py_named_pipe_auth_rep_set_length(PyObject *py_obj, PyObject *value, void *closure)
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);
606 static PyObject *py_named_pipe_auth_rep_get_magic(PyObject *obj, void *closure)
608 struct named_pipe_auth_rep *object = (struct named_pipe_auth_rep *)pytalloc_get_ptr(obj);
610 if (object->magic == NULL) {
614 py_magic = PyUnicode_Decode(object->magic, strlen(object->magic), "utf-8", "ignore");
619 static int py_named_pipe_auth_rep_set_magic(PyObject *py_obj, PyObject *value, void *closure)
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);
627 PyErr_Format(PyExc_TypeError, "Expected string or unicode object, got %s", Py_TYPE(value)->tp_name);
633 static PyObject *py_named_pipe_auth_rep_get_level(PyObject *obj, void *closure)
635 struct named_pipe_auth_rep *object = (struct named_pipe_auth_rep *)pytalloc_get_ptr(obj);
637 py_level = PyInt_FromLong(object->level);
641 static int py_named_pipe_auth_rep_set_level(PyObject *py_obj, PyObject *value, void *closure)
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);
649 static PyObject *py_named_pipe_auth_rep_get_info(PyObject *obj, void *closure)
651 struct named_pipe_auth_rep *object = (struct named_pipe_auth_rep *)pytalloc_get_ptr(obj);
653 py_info = py_import_named_pipe_auth_rep_info(pytalloc_get_mem_ctx(obj), object->level, &object->info);
654 if (py_info == NULL) {
660 static int py_named_pipe_auth_rep_set_info(PyObject *py_obj, PyObject *value, void *closure)
662 struct named_pipe_auth_rep *object = (struct named_pipe_auth_rep *)pytalloc_get_ptr(py_obj);
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) {
669 object->info = *info_switch_0;
674 static PyObject *py_named_pipe_auth_rep_get_status(PyObject *obj, void *closure)
676 struct named_pipe_auth_rep *object = (struct named_pipe_auth_rep *)pytalloc_get_ptr(obj);
678 py_status = PyErr_FromNTSTATUS(object->status);
682 static int py_named_pipe_auth_rep_set_status(PyObject *py_obj, PyObject *value, void *closure)
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));
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 },
698 static PyObject *py_named_pipe_auth_rep_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
700 return pytalloc_new(struct named_pipe_auth_rep, type);
703 static PyObject *py_named_pipe_auth_rep_ndr_pack(PyObject *py_obj)
705 struct named_pipe_auth_rep *object = (struct named_pipe_auth_rep *)pytalloc_get_ptr(py_obj);
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);
714 return PyString_FromStringAndSize((char *)blob.data, blob.length);
717 static PyObject *py_named_pipe_auth_rep_ndr_unpack(PyObject *py_obj, PyObject *args, PyObject *kwargs)
719 struct named_pipe_auth_rep *object = (struct named_pipe_auth_rep *)pytalloc_get_ptr(py_obj);
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;
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)) {
733 blob.length = blob_length;
735 if (allow_remaining_obj && PyObject_IsTrue(allow_remaining_obj)) {
736 allow_remaining = true;
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);
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);
744 if (err != NDR_ERR_SUCCESS) {
745 PyErr_SetNdrError(err);
752 static PyObject *py_named_pipe_auth_rep_ndr_print(PyObject *py_obj)
754 struct named_pipe_auth_rep *object = (struct named_pipe_auth_rep *)pytalloc_get_ptr(py_obj);
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);
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 }
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,
783 static PyMethodDef named_pipe_auth_methods[] = {
784 { NULL, NULL, 0, NULL }
787 void initnamed_pipe_auth(void)
790 PyObject *dep_samba_dcerpc_security;
791 PyObject *dep_talloc;
792 PyObject *dep_samba_dcerpc_netlogon;
793 PyObject *dep_samba_dcerpc_auth;
795 dep_samba_dcerpc_security = PyImport_ImportModule("samba.dcerpc.security");
796 if (dep_samba_dcerpc_security == NULL)
799 dep_talloc = PyImport_ImportModule("talloc");
800 if (dep_talloc == NULL)
803 dep_samba_dcerpc_netlogon = PyImport_ImportModule("samba.dcerpc.netlogon");
804 if (dep_samba_dcerpc_netlogon == NULL)
807 dep_samba_dcerpc_auth = PyImport_ImportModule("samba.dcerpc.auth");
808 if (dep_samba_dcerpc_auth == NULL)
811 auth_session_info_transport_Type = (PyTypeObject *)PyObject_GetAttrString(dep_samba_dcerpc_auth, "session_info_transport");
812 if (auth_session_info_transport_Type == NULL)
815 Object_Type = (PyTypeObject *)PyObject_GetAttrString(dep_talloc, "Object");
816 if (Object_Type == NULL)
819 named_pipe_auth_req_info4_Type.tp_base = Object_Type;
821 named_pipe_auth_req_Type.tp_base = Object_Type;
823 named_pipe_auth_rep_info4_Type.tp_base = Object_Type;
825 named_pipe_auth_rep_Type.tp_base = Object_Type;
827 if (PyType_Ready(&named_pipe_auth_req_info4_Type) < 0)
829 if (PyType_Ready(&named_pipe_auth_req_Type) < 0)
831 if (PyType_Ready(&named_pipe_auth_rep_info4_Type) < 0)
833 if (PyType_Ready(&named_pipe_auth_rep_Type) < 0)
835 #ifdef PY_REQ_INFO4_PATCH
836 PY_REQ_INFO4_PATCH(&named_pipe_auth_req_info4_Type);
839 PY_REQ_PATCH(&named_pipe_auth_req_Type);
841 #ifdef PY_REP_INFO4_PATCH
842 PY_REP_INFO4_PATCH(&named_pipe_auth_rep_info4_Type);
845 PY_REP_PATCH(&named_pipe_auth_rep_Type);
848 m = Py_InitModule3("named_pipe_auth", named_pipe_auth_methods, "named_pipe_auth DCE/RPC");
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);