diff options
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/smtpd/dnsdefs.h | 166 | ||||
-rw-r--r-- | usr.sbin/smtpd/dnsutil.h | 191 |
2 files changed, 0 insertions, 357 deletions
diff --git a/usr.sbin/smtpd/dnsdefs.h b/usr.sbin/smtpd/dnsdefs.h deleted file mode 100644 index 88b65a7a4eb..00000000000 --- a/usr.sbin/smtpd/dnsdefs.h +++ /dev/null @@ -1,166 +0,0 @@ -/* $OpenBSD: dnsdefs.h,v 1.2 2011/03/27 17:39:17 eric Exp $ */ -/* - * Copyright (c) 2009 Eric Faurot <eric@faurot.net> - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#define PACKET_MAXLEN 512 - -#define HEADER_LEN 12 -#define DOMAIN_MAXLEN 255 -#define LABEL_MAXLEN 63 - -#define OPCODE_SHIFT 11 -#define Z_SHIFT 4 - -#define QR_MASK (0x1 << 15) -#define OPCODE_MASK (0xf << 11) -#define AA_MASK (0x1 << 10) -#define TC_MASK (0x1 << 9) -#define RD_MASK (0x1 << 8) -#define RA_MASK (0x1 << 7) -#define Z_MASK (0x7 << 4) -#define RCODE_MASK (0xf) - -#define OPCODE(v) ((v) & OPCODE_MASK) -#define RCODE(v) ((v) & RCODE_MASK) - -#define OP_QUERY (0) -#define OP_IQUERY (0x1 << 11) /* obsolete rfc3425*/ -#define OP_STATUS (0x2 << 11) -#define OP_NOTIFY (0x4 << 11) /* rfc1996 */ -#define OP_UPDATE (0x5 << 11) /* rfc2136 */ - - -#define NOERR 0 -#define ERR_FORMAT 1 -#define ERR_SERVER 2 -#define ERR_NAME 3 -#define ERR_NOFUNC 4 -#define ERR_REFUSED 5 - -#define ERR_YXDOMAIN 6 /* rfc2136 */ -#define ERR_YXRRSET 7 /* rfc2136 */ -#define ERR_NXRRSET 8 /* rfc2136 */ -#define ERR_NOEAUTH 9 /* rfc2136 */ -#define ERR_NOTZONE 10 /* rfc2136 */ - -#define ERR_BADVERS 16 /* rfc2671 */ -#define ERR_BADSIG 16 /* rfc2845 */ -#define ERR_BADKEY 17 /* rfc2845 */ -#define ERR_BADTIME 18 /* rfc2845 */ -#define ERR_BADMODE 19 /* rfc2930 */ -#define ERR_BADNAME 20 /* rfc2930 */ -#define ERR_BADALG 21 /* rfc2930 */ -#define ERR_BADTRUNC 22 /* rfc4635 */ - - - -/* TYPE */ - - /* rfc1035 */ -#define T_A 1 /* host address */ -#define T_NS 2 /* authoritative name server */ -#define T_MD 3 /* mail destination (Obsolete - use MX) */ -#define T_MF 4 /* mail forwarder (Obsolete - use MX) */ -#define T_CNAME 5 /* canonical name for an alias */ -#define T_SOA 6 /* marks the start of a zone of authority */ -#define T_MB 7 /* mailbox domain name (EXPERIMENTAL) */ -#define T_MG 8 /* mail group member (EXPERIMENTAL) */ -#define T_MR 9 /* mail rename domain name (EXPERIMENTAL) */ -#define T_NULL 10 /* null RR (EXPERIMENTAL) */ -#define T_WKS 11 /* well known service description */ -#define T_PTR 12 /* domain name pointer */ -#define T_HINFO 13 /* host information */ -#define T_MINFO 14 /* mailbox or mail list information */ -#define T_MX 15 /* mail exchange */ -#define T_TXT 16 /* text strings */ - - /* rfc1183 */ -#define T_RP 17 /* responsible person */ -#define T_AFSDB 18 /* AFS Database location */ -#define T_X25 19 /* X25 PSDN address */ -#define T_ISDN 20 /* ISDN address */ -#define T_RT 21 /* route through */ - -#define T_NSAP 22 /* NSAP address rfc1706 */ -#define T_NSAPPTR 23 /* rfc1348 */ -#define T_SIG 24 /* security signature rfc2931, rfc4034 */ -#define T_KEY 25 /* security key rfc3445, rfc4034 */ -#define T_PX 26 /* X.400 mail mapping info rfc2163 */ -#define T_GPOS 27 /* geographical position rfc1712 */ -#define T_AAAA 28 /* IPv6 address rfc3596 */ -#define T_LOC 29 /* location information rfc1876 */ -#define T_NXT 30 /* next domain (obsolete) rfc2535 */ -#define T_EID 31 /* endpoint identifier */ -#define T_NIMLOC 32 /* nimrod locator */ -#define T_NB 32 /* NetBIOS general name service rfc1002 */ -#define T_SRV 33 /* server selection rfc2052, rfc2782, */ -#define T_NBSTAT 33 /* NetBIOS node status rfc1002 */ -#define T_ATMA 34 /* atm address */ -#define T_NAPTR 35 /* naming authority pointer rfc3403 */ -#define T_KX 36 /* key exchange rfc2230 */ -#define T_CERT 37 /* rfc2538, rfc4398 */ -#define T_A6 38 /* rfc2874, rfc3226 */ -#define T_DNAME 39 /* rfc2672 */ -#define T_SINK 40 /* */ -#define T_OPT 41 /* rfc2671 */ -#define T_APL 42 /* rfc3123 */ -#define T_DS 43 /* delegation signer rfc3658 */ -#define T_SSHFP 44 /* ssh key fingerprint rfc4255 */ -#define T_IPSECKEY 45 /* rfc4025 */ -#define T_RRSIG 46 /* rfc3755 */ -#define T_NSEC 47 /* NextSECure rfc3755, rfc3845 */ -#define T_DNSKEY 48 /* rfc3755 */ -#define T_DHCID 49 /* DHCP identifier rfc4701 */ -#define T_NSEC3 50 /* rfc5155 */ -#define T_NSEC3PARAM 51 /* rfc5155 */ - -#define T_HIP 55 /* Host Identity protocol rfc5205 */ -#define T_NINFO 56 -#define T_RKEY 57 - -#define T_SPF 99 /* sender policy framework rfc4408 */ -#define T_UINFO 100 -#define T_UID 101 -#define T_GID 102 -#define T_UNSPEC 103 - -#define T_TKEY 249 /* rfc2930 */ -#define T_TSIG 250 /* transaction signature rfc2845, rfc3645 */ -#define T_IXFR 251 /* incremental transfer rfc1995 */ - - /* request only */ -#define T_AXFR 252 /* transfer of an entire zone rfc1035 */ -#define T_MAILB 253 /* mailbox-related records (MB, MG or MR) rfc1035 */ -#define T_MAILA 254 /* mail agent RRs (Obsolete - see MX) rfc1035 */ -#define T_ALL 255 /* all records rfc1035 */ - -#define T_DNSSECTA 32768 /* DNSSEC trust authorities */ -#define T_DNSSECLV 32769 /* lookaside validation rfc4431, rfc5074 */ - - -/* CLASS */ - /* 0 reserved rfc5395 */ -#define C_IN 1 /* Internet */ -#define C_CS 2 /* CSNET (obsolete) */ -#define C_CH 3 /* Chaos */ -#define C_HS 4 /* Hesiod */ - -#define C_NONE 254 /* rfc2136 */ -#define C_ANY 255 /* */ - -#define C_PRIV0 65280 /* rfc5395 */ -#define C_PRIV1 65534 /* rfc5395 */ - /* 65535 reserved rfc5395 */ diff --git a/usr.sbin/smtpd/dnsutil.h b/usr.sbin/smtpd/dnsutil.h deleted file mode 100644 index 1e0e02649eb..00000000000 --- a/usr.sbin/smtpd/dnsutil.h +++ /dev/null @@ -1,191 +0,0 @@ -/* $OpenBSD: dnsutil.h,v 1.3 2011/03/27 17:39:17 eric Exp $ */ -/* - * Copyright (c) 2009,2010 Eric Faurot <eric@faurot.net> - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include <sys/types.h> -#include <sys/socket.h> - -#include <netinet/in.h> - -#include "dnsdefs.h" - -struct packed { - char *data; - size_t len; - size_t offset; - const char *err; -}; - -struct header { - uint16_t id; - uint16_t flags; - uint16_t qdcount; - uint16_t ancount; - uint16_t nscount; - uint16_t arcount; -}; - -struct query { - char q_dname[DOMAIN_MAXLEN]; - uint16_t q_type; - uint16_t q_class; -}; - -struct rr { - char rr_dname[DOMAIN_MAXLEN]; - uint16_t rr_type; - uint16_t rr_class; - uint32_t rr_ttl; - union { - struct { - char cname[DOMAIN_MAXLEN]; - } cname; - struct { - uint16_t preference; - char exchange[DOMAIN_MAXLEN]; - } mx; - struct { - char nsname[DOMAIN_MAXLEN]; - } ns; - struct { - char ptrname[DOMAIN_MAXLEN]; - } ptr; - struct { - char mname[DOMAIN_MAXLEN]; - char rname[DOMAIN_MAXLEN]; - uint32_t serial; - uint32_t refresh; - uint32_t retry; - uint32_t expire; - uint32_t minimum; - } soa; - struct { - struct in_addr addr; - } in_a; - struct { - struct in6_addr addr6; - } in_aaaa; - struct { - uint16_t rdlen; - const void *rdata; - } other; - } rr; -}; - -struct rr_dynamic { - const char *rd_dname; - uint16_t rd_type; - uint16_t rd_class; - uint32_t rd_ttl; - union rr_subtype { - struct rr_cname { - char *cname; - } cname; - struct rr_mx { - uint16_t preference; - char *exchange; - } mx; - struct rr_ns { - char *nsname; - } ns; - struct rr_ptr { - char *ptrname; - } ptr; - struct rr_soa { - char *mname; - char *rname; - uint32_t serial; - uint32_t refresh; - uint32_t retry; - uint32_t expire; - uint32_t minimum; - } soa; - struct rr_in_a { - struct in_addr addr; - } in_a; - struct rr_in_aaaa { - struct in6_addr addr6; - } in_aaaa; - struct rr_other { - uint16_t rdlen; - void *rdata; - } other; - } rd; -}; - - - -/* pack.c */ -void packed_init(struct packed*, char*, size_t); - -int unpack_data(struct packed*, void*, size_t); -int unpack_u16(struct packed*, uint16_t*); -int unpack_u32(struct packed*, uint32_t*); -int unpack_inaddr(struct packed*, struct in_addr*); -int unpack_in6addr(struct packed*, struct in6_addr*); -int unpack_dname(struct packed*, char*, size_t); -int unpack_header(struct packed*, struct header*); -int unpack_query(struct packed*, struct query*); -int unpack_rr(struct packed*, struct rr*); - -int pack_data(struct packed*, const void*, size_t); -int pack_u16(struct packed*, uint16_t); -int pack_u32(struct packed*, uint32_t); -int pack_inaddr(struct packed*, struct in_addr); -int pack_in6addr(struct packed*, struct in6_addr); -int pack_header(struct packed*, const struct header*); -int pack_dname(struct packed*, const char*); -int pack_query(struct packed*, uint16_t, uint16_t, const char*); -int pack_rrdynamic(struct packed*, const struct rr_dynamic *rr); - -/* sockaddr.c */ -int sockaddr_from_rr(struct sockaddr *, struct rr *); -int sockaddr_from_str(struct sockaddr *, int, const char *); -ssize_t sockaddr_as_fqdn(const struct sockaddr *, char *, size_t); -void sockaddr_set_port(struct sockaddr *, int); -int sockaddr_connect(const struct sockaddr *, int); -int sockaddr_listen(const struct sockaddr *, int); - -/* print.c */ -const char *print_host(struct sockaddr*, char*, size_t); -const char *print_addr(struct sockaddr*, char*, size_t); -const char *print_dname(const char*, char*, size_t); -const char *print_header(struct header*, char*, size_t); -const char *print_query(struct query*, char*, size_t); -const char *print_rr(struct rr*, char*, size_t); -const char *print_rrdynamic(struct rr_dynamic*, char*, size_t); - -const char *typetostr(uint16_t); -const char *classtostr(uint16_t); -const char *rcodetostr(uint16_t); - -uint16_t strtotype(const char*); -uint16_t strtoclass(const char*); -const char *inet6_ntoa(struct in6_addr); - -/* dname.c */ -size_t dname_len(const char *); -size_t dname_depth(const char *); -ssize_t dname_from_fqdn(const char*, char*, size_t); -ssize_t dname_from_sockaddr(const struct sockaddr *, char*, size_t); -int dname_is_in(const char*, const char*); -int dname_is_wildcard(const char *); -int dname_is_reverse(const char *); -int dname_check_label(const char*, size_t); -const char* dname_up(const char*, unsigned int); - -/* res_random.c */ -unsigned int res_randomid(void); |