query is now an enum for compile-time checks

This commit is contained in:
Bjorn Andersson 2007-01-28 12:31:04 +00:00
parent 1a46808b8a
commit ef43ef6293
2 changed files with 9 additions and 7 deletions

View File

@ -201,7 +201,7 @@ dns_send_version(int dns_fd, int version)
} }
int int
dns_encode(char *buf, size_t buflen, struct query *q, int qr, char *data, size_t datalen) dns_encode(char *buf, size_t buflen, struct query *q, qr_t qr, char *data, size_t datalen)
{ {
HEADER *header; HEADER *header;
short name; short name;
@ -273,7 +273,7 @@ dns_encode(char *buf, size_t buflen, struct query *q, int qr, char *data, size_t
} }
int int
dns_decode(char *buf, size_t buflen, struct query *q, int qr, char *packet, size_t packetlen) dns_decode(char *buf, size_t buflen, struct query *q, qr_t qr, char *packet, size_t packetlen)
{ {
char rdata[4*1024]; char rdata[4*1024];
HEADER *header; HEADER *header;

View File

@ -17,6 +17,11 @@
#ifndef _DNS_H_ #ifndef _DNS_H_
#define _DNS_H_ #define _DNS_H_
typedef enum {
QR_QUERY = 0,
QR_ANSWER = 1
} qr_t;
int open_dns(int, in_addr_t); int open_dns(int, in_addr_t);
int dns_settarget(const char*); int dns_settarget(const char*);
void dns_set_topdomain(const char*); void dns_set_topdomain(const char*);
@ -29,8 +34,8 @@ void dns_send_version(int, int);
void dns_login(int, char *, int); void dns_login(int, char *, int);
int dns_read(int, char *, int); int dns_read(int, char *, int);
int dns_encode_hostname(const char *, char *, int); int dns_encode_hostname(const char *, char *, int);
int dns_encode(char *, size_t, struct query *, int, char *, size_t); int dns_encode(char *, size_t, struct query *, qr_t, char *, size_t);
int dns_decode(char *, size_t, struct query *, int, char *, size_t); int dns_decode(char *, size_t, struct query *, qr_t, char *, size_t);
extern struct sockaddr_in peer; extern struct sockaddr_in peer;
@ -44,7 +49,4 @@ void dnsd_queuepacket(const char *, const int);
int dns_parse_reply(char *, int, char *, int); int dns_parse_reply(char *, int, char *, int);
#define QR_QUERY 0
#define QR_ANSWER 1
#endif /* _DNS_H_ */ #endif /* _DNS_H_ */