git add -f bin/default/librpc/gen_ndr/*.{c,h,ndr,pidl} bin/default/source*/librpc...
[metze/samba/wip.git] / bin / default / source4 / librpc / gen_ndr / py_ntp_signd.c
index fb26567d951245dc7b65680dd85c55fa1415ed91..da8a616c80fadeb007073dee4c3d4e1d6537c62d 100644 (file)
@@ -1,5 +1,6 @@
 
 /* Python wrapper functions auto-generated by pidl */
+#define PY_SSIZE_T_CLEAN 1 /* We use Py_ssize_t for PyArg_ParseTupleAndKeywords */
 #include <Python.h>
 #include "includes.h"
 #include <pytalloc.h>
@@ -8,11 +9,66 @@
 #include "bin/default/source4/librpc/gen_ndr/ndr_ntp_signd.h"
 #include "bin/default/source4/librpc/gen_ndr/ndr_ntp_signd_c.h"
 
-staticforward PyTypeObject sign_request_Type;
-staticforward PyTypeObject signed_reply_Type;
-staticforward PyTypeObject ntp_signd_InterfaceType;
+/*
+ * These functions are here to ensure they can be optimized out by
+ * the compiler based on the constant input values
+ */
 
-void initntp_signd(void);static PyTypeObject *Object_Type;
+static inline unsigned long long ndr_sizeof2uintmax(size_t var_size)
+{
+       switch (var_size) {
+       case 8:
+               return UINT64_MAX;
+       case 4:
+               return UINT32_MAX;
+       case 2:
+               return UINT16_MAX;
+       case 1:
+               return UINT8_MAX;
+       }
+
+       return 0;
+}
+
+static inline long long ndr_sizeof2intmax(size_t var_size)
+{
+       switch (var_size) {
+       case 8:
+               return INT64_MAX;
+       case 4:
+               return INT32_MAX;
+       case 2:
+               return INT16_MAX;
+       case 1:
+               return INT8_MAX;
+       }
+
+       return 0;
+}
+
+static inline PyObject *ndr_PyLong_FromLongLong(long long v)
+{
+       if (v > LONG_MAX || v < LONG_MIN) {
+               return PyLong_FromLongLong(v);
+       } else {
+               return PyInt_FromLong(v);
+       }
+}
+
+static inline PyObject *ndr_PyLong_FromUnsignedLongLong(unsigned long long v)
+{
+       if (v > LONG_MAX) {
+               return PyLong_FromUnsignedLongLong(v);
+       } else {
+               return PyInt_FromLong(v);
+       }
+}
+
+static PyTypeObject sign_request_Type;
+static PyTypeObject signed_reply_Type;
+static PyTypeObject ntp_signd_InterfaceType;
+
+void initntp_signd(void);static PyTypeObject *BaseObject_Type;
 static PyTypeObject *ClientConnection_Type;
 static PyTypeObject *ndr_syntax_id_Type;
 
@@ -20,15 +76,46 @@ static PyObject *py_sign_request_get_version(PyObject *obj, void *closure)
 {
        struct sign_request *object = (struct sign_request *)pytalloc_get_ptr(obj);
        PyObject *py_version;
-       py_version = PyInt_FromLong(object->version);
+       py_version = ndr_PyLong_FromUnsignedLongLong((uint32_t)object->version);
        return py_version;
 }
 
 static int py_sign_request_set_version(PyObject *py_obj, PyObject *value, void *closure)
 {
        struct sign_request *object = (struct sign_request *)pytalloc_get_ptr(py_obj);
-       PY_CHECK_TYPE(&PyInt_Type, value, return -1;);
-       object->version = PyInt_AsLong(value);
+       if (value == NULL) {
+               PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->version");
+               return -1;
+       }
+       {
+               const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->version));
+               if (PyLong_Check(value)) {
+                       unsigned long long test_var;
+                       test_var = PyLong_AsUnsignedLongLong(value);
+                       if (PyErr_Occurred() != NULL) {
+                               return -1;
+                       }
+                       if (test_var > uint_max) {
+                               PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %llu",\
+                                 PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
+                               return -1;
+                       }
+                       object->version = test_var;
+               } else if (PyInt_Check(value)) {
+                       long test_var;
+                       test_var = PyInt_AsLong(value);
+                       if (test_var < 0 || test_var > uint_max) {
+                               PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %ld",\
+                                 PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
+                               return -1;
+                       }
+                       object->version = test_var;
+               } else {
+                       PyErr_Format(PyExc_TypeError, "Expected type %s or %s",\
+                         PyInt_Type.tp_name, PyLong_Type.tp_name);
+                       return -1;
+               }
+       }
        return 0;
 }
 
@@ -36,22 +123,46 @@ static PyObject *py_sign_request_get_op(PyObject *obj, void *closure)
 {
        struct sign_request *object = (struct sign_request *)pytalloc_get_ptr(obj);
        PyObject *py_op;
-       py_op = PyInt_FromLong(object->op);
+       py_op = ndr_PyLong_FromUnsignedLongLong((uint32_t)object->op);
        return py_op;
 }
 
 static int py_sign_request_set_op(PyObject *py_obj, PyObject *value, void *closure)
 {
        struct sign_request *object = (struct sign_request *)pytalloc_get_ptr(py_obj);
-       if (PyLong_Check(value)) {
-               object->op = PyLong_AsLongLong(value);
-       } else if (PyInt_Check(value)) {
-               object->op = PyInt_AsLong(value);
-       } else {
-               PyErr_Format(PyExc_TypeError, "Expected type %s or %s",\
-                 PyInt_Type.tp_name, PyLong_Type.tp_name);
+       if (value == NULL) {
+               PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->op");
                return -1;
        }
+       {
+               const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->op));
+               if (PyLong_Check(value)) {
+                       unsigned long long test_var;
+                       test_var = PyLong_AsUnsignedLongLong(value);
+                       if (PyErr_Occurred() != NULL) {
+                               return -1;
+                       }
+                       if (test_var > uint_max) {
+                               PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %llu",\
+                                 PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
+                               return -1;
+                       }
+                       object->op = test_var;
+               } else if (PyInt_Check(value)) {
+                       long test_var;
+                       test_var = PyInt_AsLong(value);
+                       if (test_var < 0 || test_var > uint_max) {
+                               PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %ld",\
+                                 PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
+                               return -1;
+                       }
+                       object->op = test_var;
+               } else {
+                       PyErr_Format(PyExc_TypeError, "Expected type %s or %s",\
+                         PyInt_Type.tp_name, PyLong_Type.tp_name);
+                       return -1;
+               }
+       }
        return 0;
 }
 
@@ -59,15 +170,46 @@ static PyObject *py_sign_request_get_packet_id(PyObject *obj, void *closure)
 {
        struct sign_request *object = (struct sign_request *)pytalloc_get_ptr(obj);
        PyObject *py_packet_id;
-       py_packet_id = PyInt_FromLong(object->packet_id);
+       py_packet_id = PyInt_FromLong((uint16_t)object->packet_id);
        return py_packet_id;
 }
 
 static int py_sign_request_set_packet_id(PyObject *py_obj, PyObject *value, void *closure)
 {
        struct sign_request *object = (struct sign_request *)pytalloc_get_ptr(py_obj);
-       PY_CHECK_TYPE(&PyInt_Type, value, return -1;);
-       object->packet_id = PyInt_AsLong(value);
+       if (value == NULL) {
+               PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->packet_id");
+               return -1;
+       }
+       {
+               const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->packet_id));
+               if (PyLong_Check(value)) {
+                       unsigned long long test_var;
+                       test_var = PyLong_AsUnsignedLongLong(value);
+                       if (PyErr_Occurred() != NULL) {
+                               return -1;
+                       }
+                       if (test_var > uint_max) {
+                               PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %llu",\
+                                 PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
+                               return -1;
+                       }
+                       object->packet_id = test_var;
+               } else if (PyInt_Check(value)) {
+                       long test_var;
+                       test_var = PyInt_AsLong(value);
+                       if (test_var < 0 || test_var > uint_max) {
+                               PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %ld",\
+                                 PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
+                               return -1;
+                       }
+                       object->packet_id = test_var;
+               } else {
+                       PyErr_Format(PyExc_TypeError, "Expected type %s or %s",\
+                         PyInt_Type.tp_name, PyLong_Type.tp_name);
+                       return -1;
+               }
+       }
        return 0;
 }
 
@@ -75,15 +217,46 @@ static PyObject *py_sign_request_get_key_id(PyObject *obj, void *closure)
 {
        struct sign_request *object = (struct sign_request *)pytalloc_get_ptr(obj);
        PyObject *py_key_id;
-       py_key_id = PyInt_FromLong(object->key_id);
+       py_key_id = ndr_PyLong_FromUnsignedLongLong((uint32_t)object->key_id);
        return py_key_id;
 }
 
 static int py_sign_request_set_key_id(PyObject *py_obj, PyObject *value, void *closure)
 {
        struct sign_request *object = (struct sign_request *)pytalloc_get_ptr(py_obj);
-       PY_CHECK_TYPE(&PyInt_Type, value, return -1;);
-       object->key_id = PyInt_AsLong(value);
+       if (value == NULL) {
+               PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->key_id");
+               return -1;
+       }
+       {
+               const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->key_id));
+               if (PyLong_Check(value)) {
+                       unsigned long long test_var;
+                       test_var = PyLong_AsUnsignedLongLong(value);
+                       if (PyErr_Occurred() != NULL) {
+                               return -1;
+                       }
+                       if (test_var > uint_max) {
+                               PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %llu",\
+                                 PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
+                               return -1;
+                       }
+                       object->key_id = test_var;
+               } else if (PyInt_Check(value)) {
+                       long test_var;
+                       test_var = PyInt_AsLong(value);
+                       if (test_var < 0 || test_var > uint_max) {
+                               PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %ld",\
+                                 PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
+                               return -1;
+                       }
+                       object->key_id = test_var;
+               } else {
+                       PyErr_Format(PyExc_TypeError, "Expected type %s or %s",\
+                         PyInt_Type.tp_name, PyLong_Type.tp_name);
+                       return -1;
+               }
+       }
        return 0;
 }
 
@@ -98,17 +271,46 @@ static PyObject *py_sign_request_get_packet_to_sign(PyObject *obj, void *closure
 static int py_sign_request_set_packet_to_sign(PyObject *py_obj, PyObject *value, void *closure)
 {
        struct sign_request *object = (struct sign_request *)pytalloc_get_ptr(py_obj);
+       if (value == NULL) {
+               PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->packet_to_sign");
+               return -1;
+       }
        object->packet_to_sign = data_blob_talloc(pytalloc_get_mem_ctx(py_obj), PyString_AS_STRING(value), PyString_GET_SIZE(value));
        return 0;
 }
 
 static PyGetSetDef py_sign_request_getsetters[] = {
-       { discard_const_p(char, "version"), py_sign_request_get_version, py_sign_request_set_version },
-       { discard_const_p(char, "op"), py_sign_request_get_op, py_sign_request_set_op },
-       { discard_const_p(char, "packet_id"), py_sign_request_get_packet_id, py_sign_request_set_packet_id },
-       { discard_const_p(char, "key_id"), py_sign_request_get_key_id, py_sign_request_set_key_id },
-       { discard_const_p(char, "packet_to_sign"), py_sign_request_get_packet_to_sign, py_sign_request_set_packet_to_sign },
-       { NULL }
+       {
+               .name = discard_const_p(char, "version"),
+               .get = py_sign_request_get_version,
+               .set = py_sign_request_set_version,
+               .doc = discard_const_p(char, "PIDL-generated element version")
+       },
+       {
+               .name = discard_const_p(char, "op"),
+               .get = py_sign_request_get_op,
+               .set = py_sign_request_set_op,
+               .doc = discard_const_p(char, "PIDL-generated element op")
+       },
+       {
+               .name = discard_const_p(char, "packet_id"),
+               .get = py_sign_request_get_packet_id,
+               .set = py_sign_request_set_packet_id,
+               .doc = discard_const_p(char, "PIDL-generated element packet_id")
+       },
+       {
+               .name = discard_const_p(char, "key_id"),
+               .get = py_sign_request_get_key_id,
+               .set = py_sign_request_set_key_id,
+               .doc = discard_const_p(char, "PIDL-generated element key_id")
+       },
+       {
+               .name = discard_const_p(char, "packet_to_sign"),
+               .get = py_sign_request_get_packet_to_sign,
+               .set = py_sign_request_set_packet_to_sign,
+               .doc = discard_const_p(char, "PIDL-generated element packet_to_sign")
+       },
+       { .name = NULL }
 };
 
 static PyObject *py_sign_request_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
@@ -119,22 +321,31 @@ static PyObject *py_sign_request_new(PyTypeObject *type, PyObject *args, PyObjec
 static PyObject *py_sign_request_ndr_pack(PyObject *py_obj)
 {
        struct sign_request *object = (struct sign_request *)pytalloc_get_ptr(py_obj);
+       PyObject *ret = NULL;
        DATA_BLOB blob;
        enum ndr_err_code err;
-       err = ndr_push_struct_blob(&blob, pytalloc_get_mem_ctx(py_obj), object, (ndr_push_flags_fn_t)ndr_push_sign_request);
+       TALLOC_CTX *tmp_ctx = talloc_new(pytalloc_get_mem_ctx(py_obj));
+       if (tmp_ctx == NULL) {
+               PyErr_SetNdrError(NDR_ERR_ALLOC);
+               return NULL;
+       }
+       err = ndr_push_struct_blob(&blob, tmp_ctx, object, (ndr_push_flags_fn_t)ndr_push_sign_request);
        if (err != NDR_ERR_SUCCESS) {
+               TALLOC_FREE(tmp_ctx);
                PyErr_SetNdrError(err);
                return NULL;
        }
 
-       return PyString_FromStringAndSize((char *)blob.data, blob.length);
+       ret = PyString_FromStringAndSize((char *)blob.data, blob.length);
+       TALLOC_FREE(tmp_ctx);
+       return ret;
 }
 
 static PyObject *py_sign_request_ndr_unpack(PyObject *py_obj, PyObject *args, PyObject *kwargs)
 {
        struct sign_request *object = (struct sign_request *)pytalloc_get_ptr(py_obj);
        DATA_BLOB blob;
-       int blob_length = 0;
+       Py_ssize_t blob_length = 0;
        enum ndr_err_code err;
        const char * const kwnames[] = { "data_blob", "allow_remaining", NULL };
        PyObject *allow_remaining_obj = NULL;
@@ -192,7 +403,6 @@ static PyTypeObject sign_request_Type = {
        .tp_getset = py_sign_request_getsetters,
        .tp_methods = py_sign_request_methods,
        .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
-       .tp_basicsize = sizeof(pytalloc_Object),
        .tp_new = py_sign_request_new,
 };
 
@@ -201,15 +411,46 @@ static PyObject *py_signed_reply_get_version(PyObject *obj, void *closure)
 {
        struct signed_reply *object = (struct signed_reply *)pytalloc_get_ptr(obj);
        PyObject *py_version;
-       py_version = PyInt_FromLong(object->version);
+       py_version = ndr_PyLong_FromUnsignedLongLong((uint32_t)object->version);
        return py_version;
 }
 
 static int py_signed_reply_set_version(PyObject *py_obj, PyObject *value, void *closure)
 {
        struct signed_reply *object = (struct signed_reply *)pytalloc_get_ptr(py_obj);
-       PY_CHECK_TYPE(&PyInt_Type, value, return -1;);
-       object->version = PyInt_AsLong(value);
+       if (value == NULL) {
+               PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->version");
+               return -1;
+       }
+       {
+               const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->version));
+               if (PyLong_Check(value)) {
+                       unsigned long long test_var;
+                       test_var = PyLong_AsUnsignedLongLong(value);
+                       if (PyErr_Occurred() != NULL) {
+                               return -1;
+                       }
+                       if (test_var > uint_max) {
+                               PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %llu",\
+                                 PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
+                               return -1;
+                       }
+                       object->version = test_var;
+               } else if (PyInt_Check(value)) {
+                       long test_var;
+                       test_var = PyInt_AsLong(value);
+                       if (test_var < 0 || test_var > uint_max) {
+                               PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %ld",\
+                                 PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
+                               return -1;
+                       }
+                       object->version = test_var;
+               } else {
+                       PyErr_Format(PyExc_TypeError, "Expected type %s or %s",\
+                         PyInt_Type.tp_name, PyLong_Type.tp_name);
+                       return -1;
+               }
+       }
        return 0;
 }
 
@@ -217,22 +458,46 @@ static PyObject *py_signed_reply_get_op(PyObject *obj, void *closure)
 {
        struct signed_reply *object = (struct signed_reply *)pytalloc_get_ptr(obj);
        PyObject *py_op;
-       py_op = PyInt_FromLong(object->op);
+       py_op = ndr_PyLong_FromUnsignedLongLong((uint32_t)object->op);
        return py_op;
 }
 
 static int py_signed_reply_set_op(PyObject *py_obj, PyObject *value, void *closure)
 {
        struct signed_reply *object = (struct signed_reply *)pytalloc_get_ptr(py_obj);
-       if (PyLong_Check(value)) {
-               object->op = PyLong_AsLongLong(value);
-       } else if (PyInt_Check(value)) {
-               object->op = PyInt_AsLong(value);
-       } else {
-               PyErr_Format(PyExc_TypeError, "Expected type %s or %s",\
-                 PyInt_Type.tp_name, PyLong_Type.tp_name);
+       if (value == NULL) {
+               PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->op");
                return -1;
        }
+       {
+               const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->op));
+               if (PyLong_Check(value)) {
+                       unsigned long long test_var;
+                       test_var = PyLong_AsUnsignedLongLong(value);
+                       if (PyErr_Occurred() != NULL) {
+                               return -1;
+                       }
+                       if (test_var > uint_max) {
+                               PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %llu",\
+                                 PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
+                               return -1;
+                       }
+                       object->op = test_var;
+               } else if (PyInt_Check(value)) {
+                       long test_var;
+                       test_var = PyInt_AsLong(value);
+                       if (test_var < 0 || test_var > uint_max) {
+                               PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %ld",\
+                                 PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
+                               return -1;
+                       }
+                       object->op = test_var;
+               } else {
+                       PyErr_Format(PyExc_TypeError, "Expected type %s or %s",\
+                         PyInt_Type.tp_name, PyLong_Type.tp_name);
+                       return -1;
+               }
+       }
        return 0;
 }
 
@@ -240,15 +505,46 @@ static PyObject *py_signed_reply_get_packet_id(PyObject *obj, void *closure)
 {
        struct signed_reply *object = (struct signed_reply *)pytalloc_get_ptr(obj);
        PyObject *py_packet_id;
-       py_packet_id = PyInt_FromLong(object->packet_id);
+       py_packet_id = ndr_PyLong_FromUnsignedLongLong((uint32_t)object->packet_id);
        return py_packet_id;
 }
 
 static int py_signed_reply_set_packet_id(PyObject *py_obj, PyObject *value, void *closure)
 {
        struct signed_reply *object = (struct signed_reply *)pytalloc_get_ptr(py_obj);
-       PY_CHECK_TYPE(&PyInt_Type, value, return -1;);
-       object->packet_id = PyInt_AsLong(value);
+       if (value == NULL) {
+               PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->packet_id");
+               return -1;
+       }
+       {
+               const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->packet_id));
+               if (PyLong_Check(value)) {
+                       unsigned long long test_var;
+                       test_var = PyLong_AsUnsignedLongLong(value);
+                       if (PyErr_Occurred() != NULL) {
+                               return -1;
+                       }
+                       if (test_var > uint_max) {
+                               PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %llu",\
+                                 PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
+                               return -1;
+                       }
+                       object->packet_id = test_var;
+               } else if (PyInt_Check(value)) {
+                       long test_var;
+                       test_var = PyInt_AsLong(value);
+                       if (test_var < 0 || test_var > uint_max) {
+                               PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %ld",\
+                                 PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
+                               return -1;
+                       }
+                       object->packet_id = test_var;
+               } else {
+                       PyErr_Format(PyExc_TypeError, "Expected type %s or %s",\
+                         PyInt_Type.tp_name, PyLong_Type.tp_name);
+                       return -1;
+               }
+       }
        return 0;
 }
 
@@ -263,16 +559,40 @@ static PyObject *py_signed_reply_get_signed_packet(PyObject *obj, void *closure)
 static int py_signed_reply_set_signed_packet(PyObject *py_obj, PyObject *value, void *closure)
 {
        struct signed_reply *object = (struct signed_reply *)pytalloc_get_ptr(py_obj);
+       if (value == NULL) {
+               PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->signed_packet");
+               return -1;
+       }
        object->signed_packet = data_blob_talloc(pytalloc_get_mem_ctx(py_obj), PyString_AS_STRING(value), PyString_GET_SIZE(value));
        return 0;
 }
 
 static PyGetSetDef py_signed_reply_getsetters[] = {
-       { discard_const_p(char, "version"), py_signed_reply_get_version, py_signed_reply_set_version },
-       { discard_const_p(char, "op"), py_signed_reply_get_op, py_signed_reply_set_op },
-       { discard_const_p(char, "packet_id"), py_signed_reply_get_packet_id, py_signed_reply_set_packet_id },
-       { discard_const_p(char, "signed_packet"), py_signed_reply_get_signed_packet, py_signed_reply_set_signed_packet },
-       { NULL }
+       {
+               .name = discard_const_p(char, "version"),
+               .get = py_signed_reply_get_version,
+               .set = py_signed_reply_set_version,
+               .doc = discard_const_p(char, "PIDL-generated element version")
+       },
+       {
+               .name = discard_const_p(char, "op"),
+               .get = py_signed_reply_get_op,
+               .set = py_signed_reply_set_op,
+               .doc = discard_const_p(char, "PIDL-generated element op")
+       },
+       {
+               .name = discard_const_p(char, "packet_id"),
+               .get = py_signed_reply_get_packet_id,
+               .set = py_signed_reply_set_packet_id,
+               .doc = discard_const_p(char, "PIDL-generated element packet_id")
+       },
+       {
+               .name = discard_const_p(char, "signed_packet"),
+               .get = py_signed_reply_get_signed_packet,
+               .set = py_signed_reply_set_signed_packet,
+               .doc = discard_const_p(char, "PIDL-generated element signed_packet")
+       },
+       { .name = NULL }
 };
 
 static PyObject *py_signed_reply_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
@@ -283,22 +603,31 @@ static PyObject *py_signed_reply_new(PyTypeObject *type, PyObject *args, PyObjec
 static PyObject *py_signed_reply_ndr_pack(PyObject *py_obj)
 {
        struct signed_reply *object = (struct signed_reply *)pytalloc_get_ptr(py_obj);
+       PyObject *ret = NULL;
        DATA_BLOB blob;
        enum ndr_err_code err;
-       err = ndr_push_struct_blob(&blob, pytalloc_get_mem_ctx(py_obj), object, (ndr_push_flags_fn_t)ndr_push_signed_reply);
+       TALLOC_CTX *tmp_ctx = talloc_new(pytalloc_get_mem_ctx(py_obj));
+       if (tmp_ctx == NULL) {
+               PyErr_SetNdrError(NDR_ERR_ALLOC);
+               return NULL;
+       }
+       err = ndr_push_struct_blob(&blob, tmp_ctx, object, (ndr_push_flags_fn_t)ndr_push_signed_reply);
        if (err != NDR_ERR_SUCCESS) {
+               TALLOC_FREE(tmp_ctx);
                PyErr_SetNdrError(err);
                return NULL;
        }
 
-       return PyString_FromStringAndSize((char *)blob.data, blob.length);
+       ret = PyString_FromStringAndSize((char *)blob.data, blob.length);
+       TALLOC_FREE(tmp_ctx);
+       return ret;
 }
 
 static PyObject *py_signed_reply_ndr_unpack(PyObject *py_obj, PyObject *args, PyObject *kwargs)
 {
        struct signed_reply *object = (struct signed_reply *)pytalloc_get_ptr(py_obj);
        DATA_BLOB blob;
-       int blob_length = 0;
+       Py_ssize_t blob_length = 0;
        enum ndr_err_code err;
        const char * const kwnames[] = { "data_blob", "allow_remaining", NULL };
        PyObject *allow_remaining_obj = NULL;
@@ -356,7 +685,6 @@ static PyTypeObject signed_reply_Type = {
        .tp_getset = py_signed_reply_getsetters,
        .tp_methods = py_signed_reply_methods,
        .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
-       .tp_basicsize = sizeof(pytalloc_Object),
        .tp_new = py_signed_reply_new,
 };
 
@@ -372,6 +700,10 @@ static bool pack_py_decode_sign_requst_args_in(PyObject *args, PyObject *kwargs,
                return false;
        }
 
+       if (py_request == NULL) {
+               PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct r->in.request");
+               return false;
+       }
        PY_CHECK_TYPE(&sign_request_Type, py_request, return false;);
        if (talloc_reference(r, pytalloc_get_mem_ctx(py_request)) == NULL) {
                PyErr_NoMemory();
@@ -420,7 +752,6 @@ static PyObject *syntax_ntp_signd_new(PyTypeObject *type, PyObject *args, PyObje
 static PyTypeObject ntp_signd_SyntaxType = {
        PyObject_HEAD_INIT(NULL) 0,
        .tp_name = "ntp_signd.ntp_signd",
-       .tp_basicsize = sizeof(pytalloc_Object),
        .tp_doc = "abstract_syntax()\n",
        .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
        .tp_new = syntax_ntp_signd_new,
@@ -449,8 +780,8 @@ void initntp_signd(void)
        if (dep_samba_dcerpc_misc == NULL)
                return;
 
-       Object_Type = (PyTypeObject *)PyObject_GetAttrString(dep_talloc, "Object");
-       if (Object_Type == NULL)
+       BaseObject_Type = (PyTypeObject *)PyObject_GetAttrString(dep_talloc, "BaseObject");
+       if (BaseObject_Type == NULL)
                return;
 
        ClientConnection_Type = (PyTypeObject *)PyObject_GetAttrString(dep_samba_dcerpc_base, "ClientConnection");
@@ -461,13 +792,16 @@ void initntp_signd(void)
        if (ndr_syntax_id_Type == NULL)
                return;
 
-       sign_request_Type.tp_base = Object_Type;
+       sign_request_Type.tp_base = BaseObject_Type;
+       sign_request_Type.tp_basicsize = pytalloc_BaseObject_size();
 
-       signed_reply_Type.tp_base = Object_Type;
+       signed_reply_Type.tp_base = BaseObject_Type;
+       signed_reply_Type.tp_basicsize = pytalloc_BaseObject_size();
 
        ntp_signd_InterfaceType.tp_base = ClientConnection_Type;
 
        ntp_signd_SyntaxType.tp_base = ndr_syntax_id_Type;
+       ntp_signd_SyntaxType.tp_basicsize = pytalloc_BaseObject_size();
 
        if (PyType_Ready(&sign_request_Type) < 0)
                return;
@@ -497,12 +831,12 @@ void initntp_signd(void)
        if (m == NULL)
                return;
 
-       PyModule_AddObject(m, "NTP_SIGND_PROTOCOL_VERSION_0", PyInt_FromLong(0));
-       PyModule_AddObject(m, "SIGN_TO_CLIENT", PyInt_FromLong(SIGN_TO_CLIENT));
-       PyModule_AddObject(m, "ASK_SERVER_TO_SIGN", PyInt_FromLong(ASK_SERVER_TO_SIGN));
-       PyModule_AddObject(m, "CHECK_SERVER_SIGNATURE", PyInt_FromLong(CHECK_SERVER_SIGNATURE));
-       PyModule_AddObject(m, "SIGNING_SUCCESS", PyInt_FromLong(SIGNING_SUCCESS));
-       PyModule_AddObject(m, "SIGNING_FAILURE", PyInt_FromLong(SIGNING_FAILURE));
+       PyModule_AddObject(m, "NTP_SIGND_PROTOCOL_VERSION_0", ndr_PyLong_FromUnsignedLongLong(0));
+       PyModule_AddObject(m, "SIGN_TO_CLIENT", ndr_PyLong_FromUnsignedLongLong((uint32_t)SIGN_TO_CLIENT));
+       PyModule_AddObject(m, "ASK_SERVER_TO_SIGN", ndr_PyLong_FromUnsignedLongLong((uint32_t)ASK_SERVER_TO_SIGN));
+       PyModule_AddObject(m, "CHECK_SERVER_SIGNATURE", ndr_PyLong_FromUnsignedLongLong((uint32_t)CHECK_SERVER_SIGNATURE));
+       PyModule_AddObject(m, "SIGNING_SUCCESS", ndr_PyLong_FromUnsignedLongLong((uint32_t)SIGNING_SUCCESS));
+       PyModule_AddObject(m, "SIGNING_FAILURE", ndr_PyLong_FromUnsignedLongLong((uint32_t)SIGNING_FAILURE));
        Py_INCREF((PyObject *)(void *)&sign_request_Type);
        PyModule_AddObject(m, "sign_request", (PyObject *)(void *)&sign_request_Type);
        Py_INCREF((PyObject *)(void *)&signed_reply_Type);