| 1 | /* | 
|---|
| 2 | Linux DNS client library implementation | 
|---|
| 3 |  | 
|---|
| 4 | Copyright (C) 2006 Krishna Ganugapati <krishnag@centeris.com> | 
|---|
| 5 | Copyright (C) 2006 Gerald Carter <jerry@samba.org> | 
|---|
| 6 |  | 
|---|
| 7 | ** NOTE! The following LGPL license applies to the libaddns | 
|---|
| 8 | ** library. This does NOT imply that all of Samba is released | 
|---|
| 9 | ** under the LGPL | 
|---|
| 10 |  | 
|---|
| 11 | This library is free software; you can redistribute it and/or | 
|---|
| 12 | modify it under the terms of the GNU Lesser General Public | 
|---|
| 13 | License as published by the Free Software Foundation; either | 
|---|
| 14 | version 2.1 of the License, or (at your option) any later version. | 
|---|
| 15 |  | 
|---|
| 16 | This library is distributed in the hope that it will be useful, | 
|---|
| 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|---|
| 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | 
|---|
| 19 | Lesser General Public License for more details. | 
|---|
| 20 |  | 
|---|
| 21 | You should have received a copy of the GNU Lesser General Public | 
|---|
| 22 | License along with this library; if not, see <http://www.gnu.org/licenses/>. | 
|---|
| 23 | */ | 
|---|
| 24 |  | 
|---|
| 25 | #ifndef _DNS_H | 
|---|
| 26 | #define _DNS_H | 
|---|
| 27 |  | 
|---|
| 28 | #include "../replace/replace.h" | 
|---|
| 29 | #include "system/network.h" | 
|---|
| 30 |  | 
|---|
| 31 | /* make sure we have included the correct config.h */ | 
|---|
| 32 | #ifndef NO_CONFIG_H /* for some tests */ | 
|---|
| 33 | #ifndef CONFIG_H_IS_FROM_SAMBA | 
|---|
| 34 | #error "make sure you have removed all config.h files from standalone builds!" | 
|---|
| 35 | #error "the included config.h isn't from samba!" | 
|---|
| 36 | #endif | 
|---|
| 37 | #endif /* NO_CONFIG_H */ | 
|---|
| 38 |  | 
|---|
| 39 | #include <stdio.h> | 
|---|
| 40 | #include <stdlib.h> | 
|---|
| 41 | #include <fcntl.h> | 
|---|
| 42 | #include <time.h> | 
|---|
| 43 | #ifndef __OS2__ | 
|---|
| 44 | #include <string.h> | 
|---|
| 45 | #endif | 
|---|
| 46 | #include <errno.h> | 
|---|
| 47 | #include <netdb.h> | 
|---|
| 48 | #include <sys/types.h> | 
|---|
| 49 | #include <sys/socket.h> | 
|---|
| 50 | #include <netinet/in.h> | 
|---|
| 51 | #include <arpa/inet.h> | 
|---|
| 52 | #include <stdarg.h> | 
|---|
| 53 |  | 
|---|
| 54 | #ifdef HAVE_UUID_UUID_H | 
|---|
| 55 | #include <uuid/uuid.h> | 
|---|
| 56 | #endif | 
|---|
| 57 |  | 
|---|
| 58 | #ifdef HAVE_KRB5_H | 
|---|
| 59 | #include <krb5.h> | 
|---|
| 60 | #endif | 
|---|
| 61 |  | 
|---|
| 62 | #ifdef HAVE_INTTYPES_H | 
|---|
| 63 | #include <inttypes.h> | 
|---|
| 64 |  | 
|---|
| 65 | #ifndef int16 | 
|---|
| 66 | #define int16 int16_t | 
|---|
| 67 | #endif | 
|---|
| 68 |  | 
|---|
| 69 | #ifndef uint16 | 
|---|
| 70 | #define uint16 uint16_t | 
|---|
| 71 | #endif | 
|---|
| 72 |  | 
|---|
| 73 | #ifndef int32 | 
|---|
| 74 | #define int32 int32_t | 
|---|
| 75 | #endif | 
|---|
| 76 |  | 
|---|
| 77 | #ifndef uint32 | 
|---|
| 78 | #define uint32 uint32_t | 
|---|
| 79 | #endif | 
|---|
| 80 | #endif | 
|---|
| 81 |  | 
|---|
| 82 | #ifdef HAVE_KRB5_H | 
|---|
| 83 | #include <krb5.h> | 
|---|
| 84 | #endif | 
|---|
| 85 |  | 
|---|
| 86 | #if HAVE_GSSAPI_GSSAPI_H | 
|---|
| 87 | #include <gssapi/gssapi.h> | 
|---|
| 88 | #elif HAVE_GSSAPI_GSSAPI_GENERIC_H | 
|---|
| 89 | #include <gssapi/gssapi_generic.h> | 
|---|
| 90 | #elif HAVE_GSSAPI_H | 
|---|
| 91 | #include <gssapi.h> | 
|---|
| 92 | #endif | 
|---|
| 93 |  | 
|---|
| 94 | #if defined(HAVE_GSSAPI_H) || defined(HAVE_GSSAPI_GSSAPI_H) || defined(HAVE_GSSAPI_GSSAPI_GENERIC_H) | 
|---|
| 95 | #define HAVE_GSSAPI_SUPPORT    1 | 
|---|
| 96 | #endif | 
|---|
| 97 |  | 
|---|
| 98 | #include <talloc.h> | 
|---|
| 99 |  | 
|---|
| 100 | #if 0 | 
|---|
| 101 |  | 
|---|
| 102 | Disable these now we have checked all code paths and ensured | 
|---|
| 103 | NULL returns on zero request. JRA. | 
|---|
| 104 |  | 
|---|
| 105 | void *_talloc_zero_zeronull(const void *ctx, size_t size, const char *name); | 
|---|
| 106 | void *_talloc_memdup_zeronull(const void *t, const void *p, size_t size, const char *name); | 
|---|
| 107 | void *_talloc_array_zeronull(const void *ctx, size_t el_size, unsigned count, const char *name); | 
|---|
| 108 | void *_talloc_zero_array_zeronull(const void *ctx, size_t el_size, unsigned count, const char *name); | 
|---|
| 109 | void *talloc_zeronull(const void *context, size_t size, const char *name); | 
|---|
| 110 |  | 
|---|
| 111 | #define TALLOC(ctx, size) talloc_zeronull(ctx, size, __location__) | 
|---|
| 112 | #define TALLOC_P(ctx, type) (type *)talloc_zeronull(ctx, sizeof(type), #type) | 
|---|
| 113 | #define TALLOC_ARRAY(ctx, type, count) (type *)_talloc_array_zeronull(ctx, sizeof(type), count, #type) | 
|---|
| 114 | #define TALLOC_MEMDUP(ctx, ptr, size) _talloc_memdup_zeronull(ctx, ptr, size, __location__) | 
|---|
| 115 | #define TALLOC_ZERO(ctx, size) _talloc_zero_zeronull(ctx, size, __location__) | 
|---|
| 116 | #define TALLOC_ZERO_P(ctx, type) (type *)_talloc_zero_zeronull(ctx, sizeof(type), #type) | 
|---|
| 117 | #define TALLOC_ZERO_ARRAY(ctx, type, count) (type *)_talloc_zero_array_zeronull(ctx, sizeof(type), count, #type) | 
|---|
| 118 | #define TALLOC_SIZE(ctx, size) talloc_zeronull(ctx, size, __location__) | 
|---|
| 119 | #define TALLOC_ZERO_SIZE(ctx, size) _talloc_zero_zeronull(ctx, size, __location__) | 
|---|
| 120 |  | 
|---|
| 121 | #else | 
|---|
| 122 |  | 
|---|
| 123 | #define TALLOC(ctx, size) talloc_named_const(ctx, size, __location__) | 
|---|
| 124 | #define TALLOC_P(ctx, type) (type *)talloc_named_const(ctx, sizeof(type), #type) | 
|---|
| 125 | #define TALLOC_ARRAY(ctx, type, count) (type *)_talloc_array(ctx, sizeof(type), count, #type) | 
|---|
| 126 | #define TALLOC_MEMDUP(ctx, ptr, size) _talloc_memdup(ctx, ptr, size, __location__) | 
|---|
| 127 | #define TALLOC_ZERO(ctx, size) _talloc_zero(ctx, size, __location__) | 
|---|
| 128 | #define TALLOC_ZERO_P(ctx, type) (type *)_talloc_zero(ctx, sizeof(type), #type) | 
|---|
| 129 | #define TALLOC_ZERO_ARRAY(ctx, type, count) (type *)_talloc_zero_array(ctx, sizeof(type), count, #type) | 
|---|
| 130 | #define TALLOC_SIZE(ctx, size) talloc_named_const(ctx, size, __location__) | 
|---|
| 131 | #define TALLOC_ZERO_SIZE(ctx, size) _talloc_zero(ctx, size, __location__) | 
|---|
| 132 |  | 
|---|
| 133 | #endif | 
|---|
| 134 |  | 
|---|
| 135 | #define TALLOC_REALLOC(ctx, ptr, count) _talloc_realloc(ctx, ptr, count, __location__) | 
|---|
| 136 | #define TALLOC_REALLOC_ARRAY(ctx, ptr, type, count) (type *)_talloc_realloc_array(ctx, ptr, sizeof(type), count, #type) | 
|---|
| 137 | #define talloc_destroy(ctx) talloc_free(ctx) | 
|---|
| 138 | #ifndef TALLOC_FREE | 
|---|
| 139 | #define TALLOC_FREE(ctx) do { talloc_free(ctx); ctx=NULL; } while(0) | 
|---|
| 140 | #endif | 
|---|
| 141 |  | 
|---|
| 142 | /******************************************************************* | 
|---|
| 143 | Type definitions for int16, int32, uint16 and uint32.  Needed | 
|---|
| 144 | for Samba coding style | 
|---|
| 145 | *******************************************************************/ | 
|---|
| 146 |  | 
|---|
| 147 | #ifndef uint8 | 
|---|
| 148 | #  define uint8 unsigned char | 
|---|
| 149 | #endif | 
|---|
| 150 |  | 
|---|
| 151 | #if !defined(int16) && !defined(HAVE_INT16_FROM_RPC_RPC_H) | 
|---|
| 152 | #  if (SIZEOF_SHORT == 4) | 
|---|
| 153 | #    define int16 __ERROR___CANNOT_DETERMINE_TYPE_FOR_INT16; | 
|---|
| 154 | #  else /* SIZEOF_SHORT != 4 */ | 
|---|
| 155 | #    define int16 short | 
|---|
| 156 | #  endif /* SIZEOF_SHORT != 4 */ | 
|---|
| 157 | /* needed to work around compile issue on HP-UX 11.x */ | 
|---|
| 158 | #  define _INT16        1 | 
|---|
| 159 | #endif | 
|---|
| 160 |  | 
|---|
| 161 | /* | 
|---|
| 162 | * Note we duplicate the size tests in the unsigned | 
|---|
| 163 | * case as int16 may be a typedef from rpc/rpc.h | 
|---|
| 164 | */ | 
|---|
| 165 |  | 
|---|
| 166 | #if !defined(uint16) && !defined(HAVE_UINT16_FROM_RPC_RPC_H) | 
|---|
| 167 | #  if (SIZEOF_SHORT == 4) | 
|---|
| 168 | #    define uint16 __ERROR___CANNOT_DETERMINE_TYPE_FOR_INT16; | 
|---|
| 169 | #  else /* SIZEOF_SHORT != 4 */ | 
|---|
| 170 | #    define uint16 unsigned short | 
|---|
| 171 | #  endif /* SIZEOF_SHORT != 4 */ | 
|---|
| 172 | #endif | 
|---|
| 173 |  | 
|---|
| 174 | #if !defined(int32) && !defined(HAVE_INT32_FROM_RPC_RPC_H) | 
|---|
| 175 | #  if (SIZEOF_INT == 4) | 
|---|
| 176 | #    define int32 int | 
|---|
| 177 | #  elif (SIZEOF_LONG == 4) | 
|---|
| 178 | #    define int32 long | 
|---|
| 179 | #  elif (SIZEOF_SHORT == 4) | 
|---|
| 180 | #    define int32 short | 
|---|
| 181 | #  else | 
|---|
| 182 | /* uggh - no 32 bit type?? probably a CRAY. just hope this works ... */ | 
|---|
| 183 | #    define int32 int | 
|---|
| 184 | #  endif | 
|---|
| 185 | #  ifndef _INT32 | 
|---|
| 186 | /* needed to work around compile issue on HP-UX 11.x */ | 
|---|
| 187 | #    define _INT32        1 | 
|---|
| 188 | #  endif | 
|---|
| 189 | #endif | 
|---|
| 190 |  | 
|---|
| 191 | /* | 
|---|
| 192 | * Note we duplicate the size tests in the unsigned | 
|---|
| 193 | * case as int32 may be a typedef from rpc/rpc.h | 
|---|
| 194 | */ | 
|---|
| 195 |  | 
|---|
| 196 | #if !defined(uint32) && !defined(HAVE_UINT32_FROM_RPC_RPC_H) | 
|---|
| 197 | #  if (SIZEOF_INT == 4) | 
|---|
| 198 | #    define uint32 unsigned int | 
|---|
| 199 | #  elif (SIZEOF_LONG == 4) | 
|---|
| 200 | #    define uint32 unsigned long | 
|---|
| 201 | #  elif (SIZEOF_SHORT == 4) | 
|---|
| 202 | #    define uint32 unsigned short | 
|---|
| 203 | #  else | 
|---|
| 204 | /* uggh - no 32 bit type?? probably a CRAY. just hope this works ... */ | 
|---|
| 205 | #    define uint32 unsigned | 
|---|
| 206 | #  endif | 
|---|
| 207 | #endif | 
|---|
| 208 |  | 
|---|
| 209 | /* | 
|---|
| 210 | * check for 8 byte long long | 
|---|
| 211 | */ | 
|---|
| 212 |  | 
|---|
| 213 | #if !defined(uint64) | 
|---|
| 214 | #  if (SIZEOF_LONG == 8) | 
|---|
| 215 | #    define uint64 unsigned long | 
|---|
| 216 | #  elif (SIZEOF_LONG_LONG == 8) | 
|---|
| 217 | #    define uint64 unsigned long long | 
|---|
| 218 | #  endif /* don't lie.  If we don't have it, then don't use it */ | 
|---|
| 219 | #endif | 
|---|
| 220 |  | 
|---|
| 221 | /* needed on Sun boxes */ | 
|---|
| 222 | #ifndef INADDR_NONE | 
|---|
| 223 | #define INADDR_NONE          0xFFFFFFFF | 
|---|
| 224 | #endif | 
|---|
| 225 |  | 
|---|
| 226 | #include "dnserr.h" | 
|---|
| 227 |  | 
|---|
| 228 |  | 
|---|
| 229 | #define DNS_TCP                 1 | 
|---|
| 230 | #define DNS_UDP                 2 | 
|---|
| 231 |  | 
|---|
| 232 | #define DNS_OPCODE_UPDATE       1 | 
|---|
| 233 |  | 
|---|
| 234 | /* DNS Class Types */ | 
|---|
| 235 |  | 
|---|
| 236 | #define DNS_CLASS_IN            1 | 
|---|
| 237 | #define DNS_CLASS_ANY           255 | 
|---|
| 238 | #define DNS_CLASS_NONE          254 | 
|---|
| 239 |  | 
|---|
| 240 | /* DNS RR Types */ | 
|---|
| 241 |  | 
|---|
| 242 | #define DNS_RR_A                1 | 
|---|
| 243 |  | 
|---|
| 244 | #define DNS_TCP_PORT            53 | 
|---|
| 245 | #define DNS_UDP_PORT            53 | 
|---|
| 246 |  | 
|---|
| 247 | #define QTYPE_A         1 | 
|---|
| 248 | #define QTYPE_NS        2 | 
|---|
| 249 | #define QTYPE_MD        3 | 
|---|
| 250 | #define QTYPE_CNAME     5 | 
|---|
| 251 | #define QTYPE_SOA       6 | 
|---|
| 252 | #define QTYPE_ANY       255 | 
|---|
| 253 | #define QTYPE_TKEY      249 | 
|---|
| 254 | #define QTYPE_TSIG      250 | 
|---|
| 255 |  | 
|---|
| 256 | /* | 
|---|
| 257 | MF              4 a mail forwarder (Obsolete - use MX) | 
|---|
| 258 | CNAME           5 the canonical name for an alias | 
|---|
| 259 | SOA             6 marks the start of a zone of authority | 
|---|
| 260 | MB              7 a mailbox domain name (EXPERIMENTAL) | 
|---|
| 261 | MG              8 a mail group member (EXPERIMENTAL) | 
|---|
| 262 | MR              9 a mail rename domain name (EXPERIMENTAL) | 
|---|
| 263 | NULL            10 a null RR (EXPERIMENTAL) | 
|---|
| 264 | WKS             11 a well known service description | 
|---|
| 265 | PTR             12 a domain name pointer | 
|---|
| 266 | HINFO           13 host information | 
|---|
| 267 | MINFO           14 mailbox or mail list information | 
|---|
| 268 | MX              15 mail exchange | 
|---|
| 269 | TXT             16 text strings | 
|---|
| 270 | */ | 
|---|
| 271 |  | 
|---|
| 272 | #define QR_QUERY         0x0000 | 
|---|
| 273 | #define QR_RESPONSE      0x0001 | 
|---|
| 274 |  | 
|---|
| 275 | #define OPCODE_QUERY 0x00 | 
|---|
| 276 | #define OPCODE_IQUERY   0x01 | 
|---|
| 277 | #define OPCODE_STATUS   0x02 | 
|---|
| 278 |  | 
|---|
| 279 | #define AA                      1 | 
|---|
| 280 |  | 
|---|
| 281 | #define RECURSION_DESIRED       0x01 | 
|---|
| 282 |  | 
|---|
| 283 | #define RCODE_NOERROR          0 | 
|---|
| 284 | #define RCODE_FORMATERROR      1 | 
|---|
| 285 | #define RCODE_SERVER_FAILURE   2 | 
|---|
| 286 | #define RCODE_NAME_ERROR       3 | 
|---|
| 287 | #define RCODE_NOTIMPLEMENTED   4 | 
|---|
| 288 | #define RCODE_REFUSED          5 | 
|---|
| 289 |  | 
|---|
| 290 | #define SENDBUFFER_SIZE         65536 | 
|---|
| 291 | #define RECVBUFFER_SIZE         65536 | 
|---|
| 292 |  | 
|---|
| 293 | /* | 
|---|
| 294 | * TKEY Modes from rfc2930 | 
|---|
| 295 | */ | 
|---|
| 296 |  | 
|---|
| 297 | #define DNS_TKEY_MODE_SERVER   1 | 
|---|
| 298 | #define DNS_TKEY_MODE_DH       2 | 
|---|
| 299 | #define DNS_TKEY_MODE_GSSAPI   3 | 
|---|
| 300 | #define DNS_TKEY_MODE_RESOLVER 4 | 
|---|
| 301 | #define DNS_TKEY_MODE_DELETE   5 | 
|---|
| 302 |  | 
|---|
| 303 |  | 
|---|
| 304 | #define DNS_ONE_DAY_IN_SECS     86400 | 
|---|
| 305 | #define DNS_TEN_HOURS_IN_SECS   36000 | 
|---|
| 306 |  | 
|---|
| 307 | #define SOCKET_ERROR            -1 | 
|---|
| 308 | #define INVALID_SOCKET          -1 | 
|---|
| 309 |  | 
|---|
| 310 | #define  DNS_NO_ERROR           0 | 
|---|
| 311 | #define  DNS_FORMAT_ERROR       1 | 
|---|
| 312 | #define  DNS_SERVER_FAILURE     2 | 
|---|
| 313 | #define  DNS_NAME_ERROR         3 | 
|---|
| 314 | #define  DNS_NOT_IMPLEMENTED    4 | 
|---|
| 315 | #define  DNS_REFUSED            5 | 
|---|
| 316 |  | 
|---|
| 317 | typedef long HANDLE; | 
|---|
| 318 |  | 
|---|
| 319 | enum dns_ServerType { DNS_SRV_ANY, DNS_SRV_WIN2000, DNS_SRV_WIN2003 }; | 
|---|
| 320 |  | 
|---|
| 321 | struct dns_domain_label { | 
|---|
| 322 | struct dns_domain_label *next; | 
|---|
| 323 | char *label; | 
|---|
| 324 | size_t len; | 
|---|
| 325 | }; | 
|---|
| 326 |  | 
|---|
| 327 | struct dns_domain_name { | 
|---|
| 328 | struct dns_domain_label *pLabelList; | 
|---|
| 329 | }; | 
|---|
| 330 |  | 
|---|
| 331 | struct dns_question { | 
|---|
| 332 | struct dns_domain_name *name; | 
|---|
| 333 | uint16 q_type; | 
|---|
| 334 | uint16 q_class; | 
|---|
| 335 | }; | 
|---|
| 336 |  | 
|---|
| 337 | /* | 
|---|
| 338 | * Before changing the definition of dns_zone, look | 
|---|
| 339 | * dns_marshall_update_request(), we rely on this being the same as | 
|---|
| 340 | * dns_question right now. | 
|---|
| 341 | */ | 
|---|
| 342 |  | 
|---|
| 343 | struct dns_zone { | 
|---|
| 344 | struct dns_domain_name *name; | 
|---|
| 345 | uint16 z_type; | 
|---|
| 346 | uint16 z_class; | 
|---|
| 347 | }; | 
|---|
| 348 |  | 
|---|
| 349 | struct dns_rrec { | 
|---|
| 350 | struct dns_domain_name *name; | 
|---|
| 351 | uint16 type; | 
|---|
| 352 | uint16 r_class; | 
|---|
| 353 | uint32 ttl; | 
|---|
| 354 | uint16 data_length; | 
|---|
| 355 | uint8 *data; | 
|---|
| 356 | }; | 
|---|
| 357 |  | 
|---|
| 358 | struct dns_tkey_record { | 
|---|
| 359 | struct dns_domain_name *algorithm; | 
|---|
| 360 | time_t inception; | 
|---|
| 361 | time_t expiration; | 
|---|
| 362 | uint16 mode; | 
|---|
| 363 | uint16 error; | 
|---|
| 364 | uint16 key_length; | 
|---|
| 365 | uint8 *key; | 
|---|
| 366 | }; | 
|---|
| 367 |  | 
|---|
| 368 | struct dns_request { | 
|---|
| 369 | uint16 id; | 
|---|
| 370 | uint16 flags; | 
|---|
| 371 | uint16 num_questions; | 
|---|
| 372 | uint16 num_answers; | 
|---|
| 373 | uint16 num_auths; | 
|---|
| 374 | uint16 num_additionals; | 
|---|
| 375 | struct dns_question **questions; | 
|---|
| 376 | struct dns_rrec **answers; | 
|---|
| 377 | struct dns_rrec **auths; | 
|---|
| 378 | struct dns_rrec **additionals; | 
|---|
| 379 | }; | 
|---|
| 380 |  | 
|---|
| 381 | /* | 
|---|
| 382 | * Before changing the definition of dns_update_request, look | 
|---|
| 383 | * dns_marshall_update_request(), we rely on this being the same as | 
|---|
| 384 | * dns_request right now. | 
|---|
| 385 | */ | 
|---|
| 386 |  | 
|---|
| 387 | struct dns_update_request { | 
|---|
| 388 | uint16 id; | 
|---|
| 389 | uint16 flags; | 
|---|
| 390 | uint16 num_zones; | 
|---|
| 391 | uint16 num_preqs; | 
|---|
| 392 | uint16 num_updates; | 
|---|
| 393 | uint16 num_additionals; | 
|---|
| 394 | struct dns_zone **zones; | 
|---|
| 395 | struct dns_rrec **preqs; | 
|---|
| 396 | struct dns_rrec **updates; | 
|---|
| 397 | struct dns_rrec **additionals; | 
|---|
| 398 | }; | 
|---|
| 399 |  | 
|---|
| 400 | struct dns_connection { | 
|---|
| 401 | int32 hType; | 
|---|
| 402 | int s; | 
|---|
| 403 | struct sockaddr RecvAddr; | 
|---|
| 404 | }; | 
|---|
| 405 |  | 
|---|
| 406 | struct dns_buffer { | 
|---|
| 407 | uint8 *data; | 
|---|
| 408 | size_t size; | 
|---|
| 409 | size_t offset; | 
|---|
| 410 | DNS_ERROR error; | 
|---|
| 411 | }; | 
|---|
| 412 |  | 
|---|
| 413 | /* from dnsutils.c */ | 
|---|
| 414 |  | 
|---|
| 415 | DNS_ERROR dns_domain_name_from_string( TALLOC_CTX *mem_ctx, | 
|---|
| 416 | const char *pszDomainName, | 
|---|
| 417 | struct dns_domain_name **presult ); | 
|---|
| 418 | char *dns_generate_keyname( TALLOC_CTX *mem_ctx ); | 
|---|
| 419 |  | 
|---|
| 420 | /* from dnsrecord.c */ | 
|---|
| 421 |  | 
|---|
| 422 | DNS_ERROR dns_create_query( TALLOC_CTX *mem_ctx, const char *name, | 
|---|
| 423 | uint16 q_type, uint16 q_class, | 
|---|
| 424 | struct dns_request **preq ); | 
|---|
| 425 | DNS_ERROR dns_create_update( TALLOC_CTX *mem_ctx, const char *name, | 
|---|
| 426 | struct dns_update_request **preq ); | 
|---|
| 427 | DNS_ERROR dns_create_probe(TALLOC_CTX *mem_ctx, const char *zone, | 
|---|
| 428 | const char *host, int num_ips, | 
|---|
| 429 | const struct sockaddr_storage *sslist, | 
|---|
| 430 | struct dns_update_request **preq); | 
|---|
| 431 | DNS_ERROR dns_create_rrec(TALLOC_CTX *mem_ctx, const char *name, | 
|---|
| 432 | uint16 type, uint16 r_class, uint32 ttl, | 
|---|
| 433 | uint16 data_length, uint8 *data, | 
|---|
| 434 | struct dns_rrec **prec); | 
|---|
| 435 | DNS_ERROR dns_add_rrec(TALLOC_CTX *mem_ctx, struct dns_rrec *rec, | 
|---|
| 436 | uint16 *num_records, struct dns_rrec ***records); | 
|---|
| 437 | DNS_ERROR dns_create_tkey_record(TALLOC_CTX *mem_ctx, const char *keyname, | 
|---|
| 438 | const char *algorithm_name, time_t inception, | 
|---|
| 439 | time_t expiration, uint16 mode, uint16 error, | 
|---|
| 440 | uint16 key_length, const uint8 *key, | 
|---|
| 441 | struct dns_rrec **prec); | 
|---|
| 442 | DNS_ERROR dns_create_name_in_use_record(TALLOC_CTX *mem_ctx, | 
|---|
| 443 | const char *name, | 
|---|
| 444 | const struct sockaddr_storage *ip, | 
|---|
| 445 | struct dns_rrec **prec); | 
|---|
| 446 | DNS_ERROR dns_create_delete_record(TALLOC_CTX *mem_ctx, const char *name, | 
|---|
| 447 | uint16 type, uint16 r_class, | 
|---|
| 448 | struct dns_rrec **prec); | 
|---|
| 449 | DNS_ERROR dns_create_name_not_in_use_record(TALLOC_CTX *mem_ctx, | 
|---|
| 450 | const char *name, uint32 type, | 
|---|
| 451 | struct dns_rrec **prec); | 
|---|
| 452 | DNS_ERROR dns_create_a_record(TALLOC_CTX *mem_ctx, const char *host, | 
|---|
| 453 | uint32 ttl, const struct sockaddr_storage *pss, | 
|---|
| 454 | struct dns_rrec **prec); | 
|---|
| 455 | DNS_ERROR dns_unmarshall_tkey_record(TALLOC_CTX *mem_ctx, struct dns_rrec *rec, | 
|---|
| 456 | struct dns_tkey_record **ptkey); | 
|---|
| 457 | DNS_ERROR dns_create_tsig_record(TALLOC_CTX *mem_ctx, const char *keyname, | 
|---|
| 458 | const char *algorithm_name, | 
|---|
| 459 | time_t time_signed, uint16 fudge, | 
|---|
| 460 | uint16 mac_length, const uint8 *mac, | 
|---|
| 461 | uint16 original_id, uint16 error, | 
|---|
| 462 | struct dns_rrec **prec); | 
|---|
| 463 | DNS_ERROR dns_add_rrec(TALLOC_CTX *mem_ctx, struct dns_rrec *rec, | 
|---|
| 464 | uint16 *num_records, struct dns_rrec ***records); | 
|---|
| 465 | DNS_ERROR dns_create_update_request(TALLOC_CTX *mem_ctx, | 
|---|
| 466 | const char *domainname, | 
|---|
| 467 | const char *hostname, | 
|---|
| 468 | const struct sockaddr_storage *ip_addr, | 
|---|
| 469 | size_t num_adds, | 
|---|
| 470 | struct dns_update_request **preq); | 
|---|
| 471 |  | 
|---|
| 472 | /* from dnssock.c */ | 
|---|
| 473 |  | 
|---|
| 474 | DNS_ERROR dns_open_connection( const char *nameserver, int32 dwType, | 
|---|
| 475 | TALLOC_CTX *mem_ctx, | 
|---|
| 476 | struct dns_connection **conn ); | 
|---|
| 477 | DNS_ERROR dns_send(struct dns_connection *conn, const struct dns_buffer *buf); | 
|---|
| 478 | DNS_ERROR dns_receive(TALLOC_CTX *mem_ctx, struct dns_connection *conn, | 
|---|
| 479 | struct dns_buffer **presult); | 
|---|
| 480 | DNS_ERROR dns_transaction(TALLOC_CTX *mem_ctx, struct dns_connection *conn, | 
|---|
| 481 | const struct dns_request *req, | 
|---|
| 482 | struct dns_request **resp); | 
|---|
| 483 | DNS_ERROR dns_update_transaction(TALLOC_CTX *mem_ctx, | 
|---|
| 484 | struct dns_connection *conn, | 
|---|
| 485 | struct dns_update_request *up_req, | 
|---|
| 486 | struct dns_update_request **up_resp); | 
|---|
| 487 |  | 
|---|
| 488 | /* from dnsmarshall.c */ | 
|---|
| 489 |  | 
|---|
| 490 | struct dns_buffer *dns_create_buffer(TALLOC_CTX *mem_ctx); | 
|---|
| 491 | void dns_marshall_buffer(struct dns_buffer *buf, const uint8 *data, | 
|---|
| 492 | size_t len); | 
|---|
| 493 | void dns_marshall_uint16(struct dns_buffer *buf, uint16 val); | 
|---|
| 494 | void dns_marshall_uint32(struct dns_buffer *buf, uint32 val); | 
|---|
| 495 | void dns_unmarshall_buffer(struct dns_buffer *buf, uint8 *data, | 
|---|
| 496 | size_t len); | 
|---|
| 497 | void dns_unmarshall_uint16(struct dns_buffer *buf, uint16 *val); | 
|---|
| 498 | void dns_unmarshall_uint32(struct dns_buffer *buf, uint32 *val); | 
|---|
| 499 | void dns_unmarshall_domain_name(TALLOC_CTX *mem_ctx, | 
|---|
| 500 | struct dns_buffer *buf, | 
|---|
| 501 | struct dns_domain_name **pname); | 
|---|
| 502 | void dns_marshall_domain_name(struct dns_buffer *buf, | 
|---|
| 503 | const struct dns_domain_name *name); | 
|---|
| 504 | void dns_unmarshall_domain_name(TALLOC_CTX *mem_ctx, | 
|---|
| 505 | struct dns_buffer *buf, | 
|---|
| 506 | struct dns_domain_name **pname); | 
|---|
| 507 | DNS_ERROR dns_marshall_request(TALLOC_CTX *mem_ctx, | 
|---|
| 508 | const struct dns_request *req, | 
|---|
| 509 | struct dns_buffer **pbuf); | 
|---|
| 510 | DNS_ERROR dns_unmarshall_request(TALLOC_CTX *mem_ctx, | 
|---|
| 511 | struct dns_buffer *buf, | 
|---|
| 512 | struct dns_request **preq); | 
|---|
| 513 | DNS_ERROR dns_marshall_update_request(TALLOC_CTX *mem_ctx, | 
|---|
| 514 | struct dns_update_request *update, | 
|---|
| 515 | struct dns_buffer **pbuf); | 
|---|
| 516 | DNS_ERROR dns_unmarshall_update_request(TALLOC_CTX *mem_ctx, | 
|---|
| 517 | struct dns_buffer *buf, | 
|---|
| 518 | struct dns_update_request **pupreq); | 
|---|
| 519 | struct dns_request *dns_update2request(struct dns_update_request *update); | 
|---|
| 520 | struct dns_update_request *dns_request2update(struct dns_request *request); | 
|---|
| 521 | uint16 dns_response_code(uint16 flags); | 
|---|
| 522 |  | 
|---|
| 523 | /* from dnsgss.c */ | 
|---|
| 524 |  | 
|---|
| 525 | #ifdef HAVE_GSSAPI_SUPPORT | 
|---|
| 526 |  | 
|---|
| 527 | void display_status( const char *msg, OM_uint32 maj_stat, OM_uint32 min_stat ); | 
|---|
| 528 | DNS_ERROR dns_negotiate_sec_ctx( const char *target_realm, | 
|---|
| 529 | const char *servername, | 
|---|
| 530 | const char *keyname, | 
|---|
| 531 | gss_ctx_id_t *gss_ctx, | 
|---|
| 532 | enum dns_ServerType srv_type ); | 
|---|
| 533 | DNS_ERROR dns_sign_update(struct dns_update_request *req, | 
|---|
| 534 | gss_ctx_id_t gss_ctx, | 
|---|
| 535 | const char *keyname, | 
|---|
| 536 | const char *algorithmname, | 
|---|
| 537 | time_t time_signed, uint16 fudge); | 
|---|
| 538 |  | 
|---|
| 539 | #endif  /* HAVE_GSSAPI_SUPPORT */ | 
|---|
| 540 |  | 
|---|
| 541 | #endif  /* _DNS_H */ | 
|---|