1#cython: embedsignature=True 2# Copyright (c) 2015-2019 by Farsight Security, Inc. 3# 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15 16cimport cython 17from libcpp cimport bool 18from cpython.string cimport * 19from libc.stddef cimport * 20from libc.stdint cimport * 21from libc.stdlib cimport * 22from libc.string cimport * 23 24cdef extern from "sys/time.h" nogil: 25 ctypedef int time_t 26 cdef struct timespec: 27 time_t tv_sec 28 long tv_nsec 29 30cdef extern from "dnstable.h" nogil: 31 ctypedef enum dnstable_res: 32 dnstable_res_failure 33 dnstable_res_success 34 dnstable_res_timeout 35 36 ctypedef enum dnstable_entry_type: 37 DNSTABLE_ENTRY_TYPE_RRSET 38 DNSTABLE_ENTRY_TYPE_RRSET_NAME_FWD 39 DNSTABLE_ENTRY_TYPE_RDATA 40 DNSTABLE_ENTRY_TYPE_RDATA_NAME_REV 41 42 ctypedef enum dnstable_query_type: 43 DNSTABLE_QUERY_TYPE_RRSET 44 DNSTABLE_QUERY_TYPE_RDATA_NAME 45 DNSTABLE_QUERY_TYPE_RDATA_IP 46 DNSTABLE_QUERY_TYPE_RDATA_RAW 47 48 ctypedef enum dnstable_filter_parameter_type: 49 DNSTABLE_FILTER_PARAMETER_TIME_FIRST_BEFORE 50 DNSTABLE_FILTER_PARAMETER_TIME_FIRST_AFTER 51 DNSTABLE_FILTER_PARAMETER_TIME_LAST_BEFORE 52 DNSTABLE_FILTER_PARAMETER_TIME_LAST_AFTER 53 54 ctypedef enum dnstable_output_format_type: 55 dnstable_output_format_json 56 dnstable_output_format_text 57 58 ctypedef enum dnstable_date_format_type: 59 dnstable_date_format_unix 60 dnstable_date_format_rfc3339 61 62 struct dnstable_entry: 63 pass 64 struct dnstable_iter: 65 pass 66 struct dnstable_query: 67 pass 68 struct dnstable_reader: 69 pass 70 struct dnstable_formatter: 71 pass 72 73 # entry 74 void dnstable_entry_destroy(dnstable_entry **) 75 void dnstable_entry_set_iszone(dnstable_entry *, bool) 76 dnstable_entry_type dnstable_entry_get_type(dnstable_entry *) 77 dnstable_res dnstable_entry_get_rrname(dnstable_entry *, uint8_t **, size_t *) 78 dnstable_res dnstable_entry_get_rrtype(dnstable_entry *, uint16_t *) 79 dnstable_res dnstable_entry_get_bailiwick(dnstable_entry *, uint8_t **, size_t *) 80 dnstable_res dnstable_entry_get_num_rdata(dnstable_entry *, size_t *) 81 dnstable_res dnstable_entry_get_rdata(dnstable_entry *, size_t, uint8_t **, size_t *) 82 dnstable_res dnstable_entry_get_time_first(dnstable_entry *, uint64_t *) 83 dnstable_res dnstable_entry_get_time_last(dnstable_entry *, uint64_t *) 84 dnstable_res dnstable_entry_get_count(dnstable_entry *, uint64_t *) 85 char * dnstable_entry_to_json(dnstable_entry *) 86 char * dnstable_entry_to_text(dnstable_entry *) 87 dnstable_formatter *dnstable_formatter_init() 88 void dnstable_formatter_destroy(dnstable_formatter **) 89 void dnstable_formatter_set_output_format(dnstable_formatter *, dnstable_output_format_type) 90 void dnstable_formatter_set_date_format(dnstable_formatter *, dnstable_date_format_type) 91 void dnstable_formatter_set_rdata_array(dnstable_formatter *, bool) 92 char *dnstable_entry_format(const dnstable_formatter *, const dnstable_entry *) 93 94 # iter 95 void dnstable_iter_destroy(dnstable_iter **) 96 dnstable_res dnstable_iter_next(dnstable_iter *, dnstable_entry **) 97 98 # query 99 dnstable_query * dnstable_query_init(dnstable_query_type) 100 void dnstable_query_destroy(dnstable_query **) 101 char * dnstable_query_get_error(dnstable_query *) 102 dnstable_res dnstable_query_set_data(dnstable_query *, char *) 103 dnstable_res dnstable_query_set_rrtype(dnstable_query *, char *) 104 dnstable_res dnstable_query_set_offset(dnstable_query *, uint64_t) 105 dnstable_res dnstable_query_set_aggregated(dnstable_query *, bool) 106 bool dnstable_query_is_aggregated(const dnstable_query *) 107 dnstable_res dnstable_query_set_bailiwick(dnstable_query *, char *) 108 dnstable_res dnstable_query_set_timeout(dnstable_query *, timespec *) 109 dnstable_res dnstable_query_set_filter_parameter(dnstable_query *, dnstable_filter_parameter_type, void *, size_t) 110 111 # reader 112 dnstable_reader * dnstable_reader_init_setfile(char *) 113 void dnstable_reader_reload_setfile(dnstable_reader *) 114 void dnstable_reader_destroy(dnstable_reader **) 115 dnstable_iter * dnstable_reader_iter(dnstable_reader *) 116 dnstable_iter * dnstable_reader_query(dnstable_reader *, dnstable_query *) 117