@@ -246,6 +246,48 @@ context_set_append_name(getdns_context *context, PyObject *py_value)
246246}
247247
248248
249+ int
250+ context_set_suffix (getdns_context * context , PyObject * py_value )
251+ {
252+ getdns_list * values ;
253+ getdns_return_t ret ;
254+ Py_ssize_t len ;
255+ PyObject * a_value ;
256+ int i ;
257+
258+ if (!PyList_Check (py_value )) {
259+ PyErr_SetString (getdns_error , GETDNS_RETURN_INVALID_PARAMETER_TEXT );
260+ return -1 ;
261+ }
262+ len = PyList_Size (py_value );
263+
264+ values = getdns_list_create ();
265+ for (i = 0 ; i < len ; i ++ ) {
266+ getdns_bindata value ;
267+
268+ if ((a_value = PyList_GetItem (py_value , (Py_ssize_t )i )) != NULL ) {
269+ if (!PyString_Check (a_value )) {
270+ PyErr_SetString (getdns_error , GETDNS_RETURN_INVALID_PARAMETER_TEXT );
271+ return -1 ;
272+ }
273+ value .data = (uint8_t * )strdup (PyString_AsString (a_value ));
274+ value .size = strlen ((char * )value .data );
275+ getdns_list_set_bindata (values , (size_t )i , & value );
276+ } else {
277+ PyErr_SetString (getdns_error , GETDNS_RETURN_INVALID_PARAMETER_TEXT );
278+ return -1 ;
279+ }
280+ }
281+ if ((ret = getdns_context_set_suffix (context , values )) != GETDNS_RETURN_GOOD ) {
282+ char err_buf [256 ];
283+ getdns_strerror (ret , err_buf , sizeof err_buf );
284+ PyErr_SetString (getdns_error , err_buf );
285+ return -1 ;
286+ }
287+ return 0 ;
288+ }
289+
290+
249291int
250292context_set_dnssec_allowed_skew (getdns_context * context , PyObject * py_value )
251293{
@@ -345,6 +387,35 @@ context_set_edns_version(getdns_context *context, PyObject *py_value)
345387}
346388
347389
390+ int
391+ context_set_edns_do_bit (getdns_context * context , PyObject * py_value )
392+ {
393+ getdns_return_t ret ;
394+ uint8_t value ;
395+
396+ if (!PyInt_Check (py_value )) {
397+ PyErr_SetString (PyExc_AttributeError , GETDNS_RETURN_INVALID_PARAMETER_TEXT );
398+ return -1 ;
399+ }
400+ if ((value = (uint8_t )PyInt_AsLong (py_value )) < 0 ) {
401+ PyErr_SetString (PyExc_AttributeError , GETDNS_RETURN_INVALID_PARAMETER_TEXT );
402+ return -1 ;
403+ }
404+ if (!((value == 0 ) || (value == 1 ))) {
405+ PyErr_SetString (PyExc_AttributeError , GETDNS_RETURN_INVALID_PARAMETER_TEXT );
406+ return -1 ;
407+ }
408+ if ((ret = getdns_context_set_edns_do_bit (context , (uint8_t )value ))
409+ != GETDNS_RETURN_GOOD ) {
410+ char err_buf [256 ];
411+ getdns_strerror (ret , err_buf , sizeof err_buf );
412+ PyErr_SetString (getdns_error , err_buf );
413+ return -1 ;
414+ }
415+ return 0 ;
416+ }
417+
418+
348419int
349420context_set_namespaces (getdns_context * context , PyObject * py_value )
350421{
@@ -580,6 +651,37 @@ context_getattro(PyObject *self, PyObject *nameobj)
580651 PyErr_SetString (getdns_error , err_buf );
581652 return NULL ;
582653 }
654+ if (!strncmp (attrname , "implementation_string" , strlen ("implementation_string" ))) {
655+ getdns_bindata * implementation_string ;
656+ if ((ret = getdns_dict_get_bindata (api_info , "implementation_string" , & implementation_string )) != GETDNS_RETURN_GOOD ) {
657+ char err_buf [256 ];
658+ getdns_strerror (ret , err_buf , sizeof err_buf );
659+ PyErr_SetString (getdns_error , err_buf );
660+ return NULL ;
661+ }
662+ return PyString_FromString ((char * )implementation_string -> data );
663+ }
664+ if (!strncmp (attrname , "version_string" , strlen ("version_string" ))) {
665+ getdns_bindata * version_string ;
666+ if ((ret = getdns_dict_get_bindata (api_info , "version_string" , & version_string )) != GETDNS_RETURN_GOOD ) {
667+ char err_buf [256 ];
668+ getdns_strerror (ret , err_buf , sizeof err_buf );
669+ PyErr_SetString (getdns_error , err_buf );
670+ return NULL ;
671+ }
672+ return PyString_FromString ((char * )version_string -> data );
673+ }
674+ if (!strncmp (attrname , "resolver_type" , strlen ("resolver_type" ))) {
675+ uint32_t resolver_type ;
676+ if ((ret = getdns_dict_get_int (api_info , "resolver_type" , & resolver_type )) != GETDNS_RETURN_GOOD ) {
677+ char err_buf [256 ];
678+ getdns_strerror (ret , err_buf , sizeof err_buf );
679+ PyErr_SetString (getdns_error , err_buf );
680+ return NULL ;
681+ }
682+ return PyInt_FromLong (resolver_type );
683+ }
684+
583685 if (!strncmp (attrname , "timeout" , strlen ("timeout" ))) {
584686 uint32_t timeout ;
585687 if ((ret = getdns_dict_get_int (all_context , "timeout" , & timeout )) != GETDNS_RETURN_GOOD ) {
@@ -599,6 +701,7 @@ context_getattro(PyObject *self, PyObject *nameobj)
599701 PyErr_SetString (getdns_error , err_buf );
600702 return NULL ;
601703 }
704+ return PyInt_FromLong ((long )dns_transport );
602705 }
603706 if (!strncmp (attrname , "limit_outstanding_queries" , strlen ("limit_outstanding_queries" ))) {
604707 uint32_t limit_outstanding_queries ;
@@ -683,6 +786,18 @@ context_getattro(PyObject *self, PyObject *nameobj)
683786 }
684787 return PyInt_FromLong ((long )edns_version );
685788 }
789+ if (!strncmp (attrname , "edns_do_bit" , strlen ("edns_do_bit" ))) {
790+ uint32_t edns_do_bit ;
791+ if ((ret = getdns_dict_get_int (all_context , "edns_do_bit" ,
792+ & edns_do_bit )) !=
793+ GETDNS_RETURN_GOOD ) {
794+ char err_buf [256 ];
795+ getdns_strerror (ret , err_buf , sizeof err_buf );
796+ PyErr_SetString (getdns_error , err_buf );
797+ return NULL ;
798+ }
799+ return PyInt_FromLong ((long )edns_do_bit );
800+ }
686801 if (!strncmp (attrname , "namespaces" , strlen ("namespaces" ))) {
687802 PyObject * py_namespaces ;
688803 getdns_list * namespaces ;
@@ -698,7 +813,20 @@ context_getattro(PyObject *self, PyObject *nameobj)
698813 PyErr_SetString (getdns_error , GETDNS_RETURN_GENERIC_ERROR_TEXT );
699814 return py_namespaces ;
700815 }
701- #if 0
816+ if (!strncmp (attrname , "suffix" , strlen ("suffix" ))) {
817+ PyObject * py_suffix ;
818+ getdns_list * suffix ;
819+ if ((ret = getdns_dict_get_list (all_context , "suffix" ,
820+ & suffix )) != GETDNS_RETURN_GOOD ) {
821+ char err_buf [256 ];
822+ getdns_strerror (ret , err_buf , sizeof err_buf );
823+ PyErr_SetString (getdns_error , err_buf );
824+ return NULL ;
825+ }
826+ if ((py_suffix = glist_to_plist (suffix )) == NULL )
827+ PyErr_SetString (getdns_error , GETDNS_RETURN_GENERIC_ERROR_TEXT );
828+ return py_suffix ;
829+ }
702830 if (!strncmp (attrname , "dns_root_servers" , strlen ("dns_root_servers" ))) {
703831 PyObject * py_rootservers ;
704832 getdns_list * dns_root_servers ;
@@ -715,7 +843,6 @@ context_getattro(PyObject *self, PyObject *nameobj)
715843 }
716844 return py_rootservers ;
717845 }
718- #endif
719846 if (!strncmp (attrname , "upstream_recursive_servers" , strlen ("upstream_recursive_servers" ))) {
720847 PyObject * py_upstream_servers ;
721848 getdns_list * upstream_list ;
@@ -770,6 +897,9 @@ context_setattro(PyObject *self, PyObject *attrname, PyObject *py_value)
770897 if (!strncmp (name , "append_name" , strlen ("append_name" ))) {
771898 return (context_set_append_name (context , py_value ));
772899 }
900+ if (!strncmp (name , "suffix" , strlen ("suffix" ))) {
901+ return (context_set_suffix (context , py_value ));
902+ }
773903 if (!strncmp (name , "dnssec_allowed_skew" , strlen ("dnssec_allowed_skew" ))) {
774904 return (context_set_dnssec_allowed_skew (context , py_value ));
775905 }
@@ -782,6 +912,9 @@ context_setattro(PyObject *self, PyObject *attrname, PyObject *py_value)
782912 if (!strncmp (name , "edns_version" , strlen ("edns_version" ))) {
783913 return (context_set_edns_version (context , py_value ));
784914 }
915+ if (!strncmp (name , "edns_do_bit" , strlen ("edns_do_bit" ))) {
916+ return (context_set_edns_do_bit (context , py_value ));
917+ }
785918 if (!strncmp (name , "namespaces" , strlen ("namespaces" ))) {
786919 return (context_set_namespaces (context , py_value ));
787920 }
@@ -791,6 +924,9 @@ context_setattro(PyObject *self, PyObject *attrname, PyObject *py_value)
791924 if (!strncmp (name , "upstream_recursive_servers" , strlen ("upstream_recursive_servers" ))) {
792925 return (context_set_upstream_recursive_servers (context , py_value ));
793926 }
927+ if (!strncmp (name , "dns_transport" , strlen ("dns_transport" ))) {
928+ return (context_set_dns_transport (context , py_value ));
929+ }
794930
795931 return 0 ;
796932}
0 commit comments