1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
/* resolv.h: DNS Resolver
*
* Copyright (C) 1998 Kenneth Albanowski <kjahds@kjahds.com>,
* The Silver Hammer Group, Ltd.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*/
#ifndef _RESOLV_H_
#define _RESOLV_H_
#include <features.h>
#include <sys/param.h>
#if (!defined(BSD)) || (BSD < 199306)
# include <sys/bitypes.h>
#else
# include <sys/types.h>
#endif
#include <stdio.h>
#include <netinet/in.h>
__BEGIN_DECLS
struct resolv_header {
int id;
int qr,opcode,aa,tc,rd,ra,rcode;
int qdcount;
int ancount;
int nscount;
int arcount;
};
struct resolv_question {
char * dotted;
int qtype;
int qclass;
};
struct resolv_answer {
char * dotted;
int atype;
int aclass;
int ttl;
int rdlength;
unsigned char * rdata;
int rdoffset;
};
int encode_header(struct resolv_header * h, unsigned char * dest, int maxlen);
int decode_header(unsigned char * data, struct resolv_header * h);
int encode_dotted(const char * dotted, unsigned char * dest, int maxlen);
int decode_dotted(const unsigned char * message, int offset,
char * dest, int maxlen);
int length_dotted(const unsigned char * message, int offset);
int encode_question(struct resolv_question * q,
unsigned char * dest, int maxlen);
int decode_question(unsigned char * message, int offset,
struct resolv_question * q);
int length_question(unsigned char * message, int offset);
int encode_answer(struct resolv_answer * a,
unsigned char * dest, int maxlen);
int decode_answer(unsigned char * message, int offset,
struct resolv_answer * a);
const char * resolve_name(const char * name, int mailbox);
int encode_packet(struct resolv_header * h,
struct resolv_question ** q,
struct resolv_answer ** an,
struct resolv_answer ** ns,
struct resolv_answer ** ar,
unsigned char * dest, int maxlen);
int decode_packet(unsigned char * data, struct resolv_header * h);
extern int open_nameservers(void);
extern void close_nameservers(void);
extern struct hostent * gethostbyname(const char * name);
extern struct hostent * gethostbyaddr(const char * addr, int len, int type);
extern int res_init(void);
extern int res_query(const char *dname, int class, int type,
unsigned char *answer, int anslen);
__END_DECLS
#endif /*_RESOLV_H_*/
|