OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [net/] [common/] [v2_0/] [include/] [arpa/] [nameser.h] - Blame information for rev 174

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 unneback
//==========================================================================
2
//
3
//      include/arpa/nameser.h
4
//
5
//==========================================================================
6
//####BSDCOPYRIGHTBEGIN####
7
//
8
// -------------------------------------------
9
//
10
// Portions of this software may have been derived from OpenBSD, 
11
// FreeBSD or other sources, and are covered by the appropriate
12
// copyright disclaimers included herein.
13
//
14
// Portions created by Red Hat are
15
// Copyright (C) 2002 Red Hat, Inc. All Rights Reserved.
16
//
17
// -------------------------------------------
18
//
19
//####BSDCOPYRIGHTEND####
20
//==========================================================================
21
 
22
/*
23
 * Copyright (c) 1983, 1989 Regents of the University of California.
24
 * All rights reserved.
25
 *
26
 * Redistribution and use in source and binary forms, with or without
27
 * modification, are permitted provided that the following conditions
28
 * are met:
29
 * 1. Redistributions of source code must retain the above copyright
30
 *    notice, this list of conditions and the following disclaimer.
31
 * 2. Redistributions in binary form must reproduce the above copyright
32
 *    notice, this list of conditions and the following disclaimer in the
33
 *    documentation and/or other materials provided with the distribution.
34
 * 3. All advertising materials mentioning features or use of this software
35
 *    must display the following acknowledgement:
36
 *      This product includes software developed by the University of
37
 *      California, Berkeley and its contributors.
38
 * 4. Neither the name of the University nor the names of its contributors
39
 *    may be used to endorse or promote products derived from this software
40
 *    without specific prior written permission.
41
 *
42
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
43
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
44
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
45
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
46
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
47
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
48
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
49
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
50
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
51
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
52
 * SUCH DAMAGE.
53
 *
54
 *      @(#)nameser.h   5.25 (Berkeley) 4/3/91
55
 */
56
 
57
#ifndef _ARPA_NAMESER_H_
58
#define _ARPA_NAMESER_H_
59
 
60
/*
61
 * Define constants based on rfc883
62
 */
63
#define PACKETSZ        512             /* maximum packet size */
64
#define MAXDNAME        256             /* maximum domain name */
65
#define MAXCDNAME       255             /* maximum compressed domain name */
66
#define MAXLABEL        63              /* maximum length of domain label */
67
        /* Number of bytes of fixed size data in query structure */
68
#define QFIXEDSZ        4
69
        /* number of bytes of fixed size data in resource record */
70
#define RRFIXEDSZ       10
71
 
72
/*
73
 * Internet nameserver port number
74
 */
75
#define NAMESERVER_PORT 53
76
 
77
/*
78
 * Currently defined opcodes
79
 */
80
#define QUERY           0x0             /* standard query */
81
#define IQUERY          0x1             /* inverse query */
82
#define STATUS          0x2             /* nameserver status query */
83
// #define xxx          0x3             /* 0x3 reserved */
84
        /* non standard */
85
#define UPDATEA         0x9             /* add resource record */
86
#define UPDATED         0xa             /* delete a specific resource record */
87
#define UPDATEDA        0xb             /* delete all nemed resource record */
88
#define UPDATEM         0xc             /* modify a specific resource record */
89
#define UPDATEMA        0xd             /* modify all named resource record */
90
 
91
#define ZONEINIT        0xe             /* initial zone transfer */
92
#define ZONEREF         0xf             /* incremental zone referesh */
93
 
94
/*
95
 * Currently defined response codes
96
 */
97
#define NOERROR         0                /* no error */
98
#define FORMERR         1               /* format error */
99
#define SERVFAIL        2               /* server failure */
100
#define NXDOMAIN        3               /* non existent domain */
101
#define NOTIMP          4               /* not implemented */
102
#define REFUSED         5               /* query refused */
103
        /* non standard */
104
#define NOCHANGE        0xf             /* update failed to change db */
105
 
106
/*
107
 * Type values for resources and queries
108
 */
109
#define T_A             1               /* host address */
110
#define T_NS            2               /* authoritative server */
111
#define T_MD            3               /* mail destination */
112
#define T_MF            4               /* mail forwarder */
113
#define T_CNAME         5               /* connonical name */
114
#define T_SOA           6               /* start of authority zone */
115
#define T_MB            7               /* mailbox domain name */
116
#define T_MG            8               /* mail group member */
117
#define T_MR            9               /* mail rename name */
118
#define T_NULL          10              /* null resource record */
119
#define T_WKS           11              /* well known service */
120
#define T_PTR           12              /* domain name pointer */
121
#define T_HINFO         13              /* host information */
122
#define T_MINFO         14              /* mailbox information */
123
#define T_MX            15              /* mail routing information */
124
#define T_TXT           16              /* text strings */
125
        /* non standard */
126
#define T_UINFO         100             /* user (finger) information */
127
#define T_UID           101             /* user ID */
128
#define T_GID           102             /* group ID */
129
#define T_UNSPEC        103             /* Unspecified format (binary data) */
130
        /* Query type values which do not appear in resource records */
131
#define T_AXFR          252             /* transfer zone of authority */
132
#define T_MAILB         253             /* transfer mailbox records */
133
#define T_MAILA         254             /* transfer mail agent records */
134
#define T_ANY           255             /* wildcard match */
135
 
136
/*
137
 * Values for class field
138
 */
139
 
140
#define C_IN            1               /* the arpa internet */
141
#define C_CHAOS         3               /* for chaos net at MIT */
142
#define C_HS            4               /* for Hesiod name server at MIT */
143
        /* Query class values which do not appear in resource records */
144
#define C_ANY           255             /* wildcard match */
145
 
146
/*
147
 * Status return codes for T_UNSPEC conversion routines
148
 */
149
#define CONV_SUCCESS 0
150
#define CONV_OVERFLOW -1
151
#define CONV_BADFMT -2
152
#define CONV_BADCKSUM -3
153
#define CONV_BADBUFLEN -4
154
 
155
#include <machine/endian.h>
156
 
157
/*
158
 * Structure for query header, the order of the fields is machine and
159
 * compiler dependent, in our case, the bits within a byte are assignd
160
 * least significant first, while the order of transmition is most
161
 * significant first.  This requires a somewhat confusing rearrangement.
162
 */
163
 
164
typedef struct {
165
        u_short id;             /* query identification number */
166
#if BYTE_ORDER == BIG_ENDIAN
167
                        /* fields in third byte */
168
        u_char  qr:1;           /* response flag */
169
        u_char  opcode:4;       /* purpose of message */
170
        u_char  aa:1;           /* authoritive answer */
171
        u_char  tc:1;           /* truncated message */
172
        u_char  rd:1;           /* recursion desired */
173
                        /* fields in fourth byte */
174
        u_char  ra:1;           /* recursion available */
175
        u_char  pr:1;           /* primary server required (non standard) */
176
        u_char  unused:2;       /* unused bits */
177
        u_char  rcode:4;        /* response code */
178
#endif
179
#if BYTE_ORDER == LITTLE_ENDIAN || BYTE_ORDER == PDP_ENDIAN
180
                        /* fields in third byte */
181
        u_char  rd:1;           /* recursion desired */
182
        u_char  tc:1;           /* truncated message */
183
        u_char  aa:1;           /* authoritive answer */
184
        u_char  opcode:4;       /* purpose of message */
185
        u_char  qr:1;           /* response flag */
186
                        /* fields in fourth byte */
187
        u_char  rcode:4;        /* response code */
188
        u_char  unused:2;       /* unused bits */
189
        u_char  pr:1;           /* primary server required (non standard) */
190
        u_char  ra:1;           /* recursion available */
191
#endif
192
                        /* remaining bytes */
193
        u_short qdcount;        /* number of question entries */
194
        u_short ancount;        /* number of answer entries */
195
        u_short nscount;        /* number of authority entries */
196
        u_short arcount;        /* number of resource entries */
197
} HEADER;
198
 
199
/*
200
 * Defines for handling compressed domain names
201
 */
202
#define INDIR_MASK      0xc0
203
 
204
/*
205
 * Structure for passing resource records around.
206
 */
207
struct rrec {
208
        short   r_zone;                 /* zone number */
209
        short   r_class;                /* class number */
210
        short   r_type;                 /* type number */
211
        u_long  r_ttl;                  /* time to live */
212
        int     r_size;                 /* size of data area */
213
        char    *r_data;                /* pointer to data */
214
};
215
 
216
/*
217
 * Inline versions of get/put short/long.
218
 * Pointer is advanced; we assume that both arguments
219
 * are lvalues and will already be in registers.
220
 * cp MUST be u_char *.
221
 */
222
#define GETSHORT(s, cp) { \
223
        (s) = *(cp)++ << 8; \
224
        (s) |= *(cp)++; \
225
}
226
 
227
#define GETLONG(l, cp) { \
228
        (l) = *(cp)++ << 8; \
229
        (l) |= *(cp)++; (l) <<= 8; \
230
        (l) |= *(cp)++; (l) <<= 8; \
231
        (l) |= *(cp)++; \
232
}
233
 
234
 
235
#define PUTSHORT(s, cp) { \
236
        *(cp)++ = (s) >> 8; \
237
        *(cp)++ = (s); \
238
}
239
 
240
/*
241
 * Warning: PUTLONG destroys its first argument.
242
 */
243
#define PUTLONG(l, cp) { \
244
        (cp)[3] = l; \
245
        (cp)[2] = (l >>= 8); \
246
        (cp)[1] = (l >>= 8); \
247
        (cp)[0] = l >> 8; \
248
        (cp) += sizeof(u_long); \
249
}
250
 
251
#endif /* !_ARPA_NAMESER_H_ */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.