~ubuntu-branches/ubuntu/gutsy/openafs/gutsy

« back to all changes in this revision

Viewing changes to src/WINNT/afsd/cm_dns_private.h

  • Committer: Bazaar Package Importer
  • Author(s): Sam Hartman
  • Date: 2004-01-10 16:37:33 UTC
  • Revision ID: james.westby@ubuntu.com-20040110163733-jvr0n1uahshlb1uu
Tags: upstream-1.2.11
ImportĀ upstreamĀ versionĀ 1.2.11

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright 2000, International Business Machines Corporation and others.
 
2
 * All Rights Reserved.
 
3
 *
 
4
 * This software has been released under the terms of the IBM Public
 
5
 * License.  For details, see the LICENSE file in the top-level source
 
6
 * directory or online at http://www.openafs.org/dl/license10.html
 
7
 */
 
8
 
 
9
#ifndef __DNS_AFS_private_h_env_
 
10
#define __DNS_AFS_private_h_env_
 
11
 
 
12
#ifdef DJGPP
 
13
#include <sys/types.h>
 
14
#include <sys/socket.h>
 
15
#include <netinet/in.h>
 
16
#include <netdb.h>
 
17
/*#else
 
18
  #include <windows.h>*/
 
19
#endif
 
20
 
 
21
#ifdef KERNEL
 
22
#define SOCKET struct osi_socket *
 
23
#else
 
24
#define SOCKET int
 
25
#endif
 
26
 
 
27
#define SOCKADDR_IN struct sockaddr_in
 
28
 
 
29
#include <stdio.h>
 
30
#include <string.h>
 
31
 
 
32
 
 
33
#ifdef DJGPP
 
34
 
 
35
char *inet_ntoa(struct in_addr in)
 
36
{
 
37
  static char   out[256];
 
38
  char temp[20];
 
39
  unsigned long sVal,pVal;
 
40
 
 
41
  out[0] = '\0';
 
42
 
 
43
 
 
44
  pVal = ntohl(in.s_addr);
 
45
 
 
46
  sVal = pVal;
 
47
  sVal >>= 24;
 
48
  sprintf(out,"%ld",sVal);
 
49
 
 
50
  sVal = pVal;
 
51
  sVal <<= 8;
 
52
  sVal >>= 24;
 
53
  sprintf(out,"%s.%ld",out,sVal);
 
54
 
 
55
  sVal = pVal;
 
56
  sVal <<= 16;
 
57
  sVal >>= 24;
 
58
  sprintf(out,"%s.%ld",out,sVal);
 
59
 
 
60
  sVal = pVal;
 
61
  sVal <<= 24;
 
62
  sVal >>= 24;
 
63
  sprintf(out,"%s.%ld",out,sVal);
 
64
 
 
65
  return(&out[0]);
 
66
}
 
67
 
 
68
unsigned long inet_addr(const char *cp)
 
69
{
 
70
  
 
71
  unsigned long val=0;
 
72
  unsigned char sVal;
 
73
  
 
74
  char   cp2[256];
 
75
 
 
76
  char*  ptr = cp2;
 
77
  int    i;
 
78
  int    len;
 
79
 
 
80
  strcpy(cp2,cp);
 
81
 
 
82
  for (i=0; i<=strlen(cp); i++)
 
83
    {
 
84
      if (cp2[i] == '.')
 
85
        {
 
86
          cp2[i] = '\0';
 
87
          sVal = atoi(ptr);
 
88
          ptr = &cp2[i+1];
 
89
          val = val << 8;
 
90
          val &= 0xffffff00;
 
91
          val |= sVal;
 
92
          //printf("%x\t%lx\n",sVal,val);
 
93
        };
 
94
    };
 
95
  sVal = atoi(ptr);
 
96
  val = val << 8;
 
97
  val &= 0xffffff00;
 
98
  val |= sVal;
 
99
  //printf("%x\t%lx\n",sVal,val);
 
100
  
 
101
  return htonl(val);
 
102
}
 
103
 
 
104
#endif /* DJGPP */
 
105
 
 
106
#define BUFSIZE                 2048
 
107
 
 
108
/*
 
109
 * AFS Server List (a list of host names and their count)
 
110
 */
 
111
#define MAX_AFS_SRVS 20
 
112
typedef struct afs_srvlist
 
113
{
 
114
  unsigned short  count;           /* number of host names */
 
115
  char     host[MAX_AFS_SRVS][256];/* array of hosts*/
 
116
} AFS_SRV_LIST, *PAFS_SRV_LIST;
 
117
 
 
118
 
 
119
/*
 
120
 * DNS Message Header
 
121
 */
 
122
typedef struct dns_hdr
 
123
{
 
124
  unsigned short id;          /* client query ID number */
 
125
  unsigned short flags;       /* qualify contents <see below> */
 
126
  unsigned short q_count;     /* number of questions */
 
127
  unsigned short rr_count;    /* number of answer RRs */
 
128
  unsigned short auth_count;  /* number of authority RRs */
 
129
  unsigned short add_count;   /* number of additional RRs */
 
130
} DNS_HDR, *PDNS_HDR;
 
131
 
 
132
#define DNS_HDR_LEN sizeof(DNS_HDR)
 
133
 
 
134
 
 
135
 
 
136
/* THESE WERE ALSO WRONG !!!! */
 
137
#define DNS_FLAG_RD 0x0100
 
138
 
 
139
/*
 
140
 * DNS query class and response type for the tail of the query packet
 
141
 */
 
142
typedef struct dns_qtail
 
143
{
 
144
        unsigned short qtype;                /* Query type (2bytes) - for responses */
 
145
        unsigned short qclass;               /* Query Class (2bytes) - for questions */
 
146
} DNS_QTAIL, *PDNS_QTAIL;
 
147
 
 
148
#define DNS_QTAIL_LEN sizeof(DNS_QTAIL)
 
149
 
 
150
/* DNS Generic Resource Record format (from RFC 1034 and 1035)
 
151
 *
 
152
 *  NOTE: The first field in the DNS RR Record header is always
 
153
 *   the domain name in QNAME format (see earlier description)
 
154
 */
 
155
typedef struct dns_rr_hdr
 
156
{
 
157
        unsigned short rr_type;        /* RR type code (e.g. A, MX, NS, etc.) */
 
158
        unsigned short rr_class;       /* RR class code (IN for Internet) */
 
159
        unsigned long  rr_ttl;         /* Time-to-live for resource */
 
160
        unsigned short rr_rdlength;    /* length of RDATA field (in octets) */
 
161
} DNS_RR_HDR, *PDNS_RR_HDR;
 
162
 
 
163
#define DNS_RR_HDR_LEN sizeof(DNS_RR_HDR)
 
164
 
 
165
#define DNS_RRTYPE_A     1
 
166
#define DNS_RRTYPE_NS    2
 
167
#define DNS_RRTYPE_CNAME 5
 
168
#define DNS_RRTYPE_SOA   6
 
169
#define DNS_RRTYPE_WKS   11
 
170
#define DNS_RRTYPE_PTR   12
 
171
#define DNS_RRTYPE_HINFO 13
 
172
#define DNS_RRTYPE_MX    15
 
173
#define DNS_RRTYPE_AFSDB 18
 
174
 
 
175
 
 
176
#define DNS_RRCLASS_IN    1    // Internet
 
177
#define DNS_RRCLASS_CS    2    // CSNET
 
178
#define DNS_RRCLASS_CH    3    // CHAOS Net
 
179
#define DNS_RRCLASS_HS    4    // Hesiod
 
180
#define DNS_RRCLASS_WILD  255  // WildCard - all classes
 
181
 
 
182
/* 
 
183
 * DNS AFSDB Resource Data Field
 
184
 */
 
185
typedef struct dns_afsdb_rr_hdr
 
186
{
 
187
  unsigned short rr_type;        /* RR type code (e.g. A, MX, NS, etc.) */
 
188
  unsigned short rr_class;       /* RR class code (IN for Internet) */
 
189
  unsigned long  rr_ttl;         /* Time-to-live for resource */
 
190
  unsigned short rr_rdlength;    /* length of RDATA field (in octets) */
 
191
  unsigned short rr_afsdb_class; /* 1-AFS , 2-DCE */
 
192
} DNS_AFSDB_RR_HDR, *PDNS_AFSDB_RR_HDR;
 
193
 
 
194
#define DNS_AFSDB_RR_HDR_LEN sizeof(DNS_AFSDB_RR_HDR)
 
195
 
 
196
/* 
 
197
 * DNS A Resource Data Field
 
198
 */
 
199
typedef struct dns_a_rr_hdr
 
200
{
 
201
  unsigned short rr_type;        /* RR type code (e.g. A, MX, NS, etc.) */
 
202
  unsigned short rr_class;       /* RR class code (IN for Internet) */
 
203
  unsigned long  rr_ttl;         /* Time-to-live for resource */
 
204
  unsigned short rr_rdlength;    /* length of RDATA field (in octets) */
 
205
  unsigned long  rr_addr;        /* Resolved host address */
 
206
} DNS_A_RR_HDR, *PDNS_A_RR_HDR;
 
207
 
 
208
#define DNS_A_RR_LEN      14 //sizeof(DNS_A_RR_HDR)
 
209
#define DNS_A_RR_HDR_LEN  10 //(DNS_A_RR_LEN - sizeof(unsigned long))
 
210
 
 
211
int  putQName( char *pszHostName, char *pQName );
 
212
unsigned char * printRRQName( unsigned char *pQName, PDNS_HDR buffer );
 
213
unsigned char * skipRRQName(unsigned char *pQName);
 
214
/* void printReplyBuffer_AFSDB(PDNS_HDR replyBuff); */
 
215
 
 
216
#endif //__DNS_AFS_private_h_env_
 
217