123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156 |
- #include <dns/tsig.h>
- using namespace isc::dns;
- namespace {
- class s_TSIGContext : public PyObject {
- public:
- TSIGContext* tsig_ctx;
- };
- int TSIGContext_init(s_TSIGContext* self, PyObject* args);
- void TSIGContext_destroy(s_TSIGContext* self);
- PyMethodDef TSIGContext_methods[] = {
- { NULL, NULL, 0, NULL }
- };
- PyTypeObject tsig_context_type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "libdns_python.TSIGContext",
- sizeof(s_TSIGContext),
- 0,
- (destructor)TSIGContext_destroy,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- Py_TPFLAGS_DEFAULT,
- "The TSIGContext class maintains a context of a signed session of "
- "DNS transactions by TSIG.",
- NULL,
- NULL,
- NULL,
- 0,
- NULL,
- NULL,
- TSIGContext_methods,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- 0,
- (initproc)TSIGContext_init,
- NULL,
- PyType_GenericNew,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- 0
- };
- int
- TSIGContext_init(s_TSIGContext* self, PyObject* args) {
- const s_TSIGKey* tsigkey_obj;
- try {
- if (PyArg_ParseTuple(args, "O!", &tsigkey_type, &tsigkey_obj)) {
- self->tsig_ctx = new TSIGContext(*tsigkey_obj->tsigkey);
- return (0);
- }
- } catch (...) {
- PyErr_SetString(po_IscException, "Unexpected exception");
- return (-1);
- }
- PyErr_Clear();
- PyErr_SetString(PyExc_TypeError,
- "Invalid arguments to TSIGContext constructor");
- return (-1);
- }
- void
- TSIGContext_destroy(s_TSIGContext* const self) {
- delete self->tsig_ctx;
- self->tsig_ctx = NULL;
- Py_TYPE(self)->tp_free(self);
- }
- bool
- initModulePart_TSIGContext(PyObject* mod) {
-
-
-
- if (PyType_Ready(&tsig_context_type) < 0) {
- return (false);
- }
- Py_INCREF(&tsig_context_type);
- void* p = &tsig_context_type;
- PyModule_AddObject(mod, "TSIGContext", static_cast<PyObject*>(p));
- addClassVariable(tsig_context_type, "DEFAULT_FUDGE",
- Py_BuildValue("H", TSIGContext::DEFAULT_FUDGE));
- return (true);
- }
- }
|