OSDN Git Service

2013.10.24
[uclinux-h8/uClinux-dist.git] / freeswan / pluto / adns.h
1 /* Pluto Asynchronous DNS Helper Program's Header
2  * Copyright (C) 2002  D. Hugh Redelmeier.
3  *
4  * This program is free software; you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License as published by the
6  * Free Software Foundation; either version 2 of the License, or (at your
7  * option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12  * for more details.
13  *
14  * RCSID $Id: adns.h,v 1.2 2002/03/09 01:26:19 dhr Exp $
15  */
16
17 /* The interface in RHL6.x and BIND distribution 8.2.2 are different,
18  * so we build some of our own :-(
19  */
20
21 # ifndef NS_MAXDNAME
22 #   define NS_MAXDNAME MAXDNAME /* I hope this is long enough for IPv6 */
23 # endif
24
25 # ifndef NS_PACKETSZ
26 #   define NS_PACKETSZ PACKETSZ
27 # endif
28
29 /* protocol version */
30
31 #define ADNS_Q_MAGIC (((((('d' << 8) + 'n') << 8) + 's') << 8) + 1)
32 #define ADNS_A_MAGIC (((((('d' << 8) + 'n') << 8) + 's') << 8) + 128 + 1)
33
34 /* note: both struct adns_query and struct adns_answer must start with
35  * size_t len;
36  */
37
38 struct adns_query {
39     size_t len;
40     unsigned int qmagic;
41     struct adns_continuation *continuation;
42     u_char name_buf[NS_MAXDNAME + 2];
43     int type;   /* T_KEY or T_TXT */
44 };
45
46 struct adns_answer {
47     size_t len;
48     unsigned int amagic;
49     struct adns_continuation *continuation;
50     int result;
51     int h_errno_val;
52     u_char ans[NS_PACKETSZ * 10];   /* very probably bigger than necessary */
53 };
54
55 enum helper_exit_status {
56     HES_CONTINUE = -1,  /* not an exit */
57     HES_OK = 0, /* all's well that ends well (perhaps EOF) */
58     HES_INVOCATION,     /* improper invocation */
59     HES_IO_ERROR_SELECT,        /* IO error in select() */
60     HES_MALLOC, /* malloc failed */
61     HES_IO_ERROR_IN,    /* error reading pipe */
62     HES_IO_ERROR_OUT,   /* error reading pipe */
63     HES_PIPE,   /* pipe(2) failed */
64     HES_SYNC,   /* answer from worker doesn't match query */
65     HES_FORK,   /* fork(2) failed */
66     HES_RES_INIT,       /* resolver initialization failed */
67     HES_BAD_LEN,        /* implausible .len field */
68     HES_BAD_MAGIC,      /* .magic field wrong */
69 };