Annotation of embedaddon/dnsmasq/src/dns-protocol.h, revision 1.1.1.3

1.1.1.3 ! misho       1: /* dnsmasq is Copyright (c) 2000-2016 Simon Kelley
1.1       misho       2: 
                      3:    This program is free software; you can redistribute it and/or modify
                      4:    it under the terms of the GNU General Public License as published by
                      5:    the Free Software Foundation; version 2 dated June, 1991, or
                      6:    (at your option) version 3 dated 29 June, 2007.
                      7:  
                      8:    This program is distributed in the hope that it will be useful,
                      9:    but WITHOUT ANY WARRANTY; without even the implied warranty of
                     10:    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                     11:    GNU General Public License for more details.
                     12:      
                     13:    You should have received a copy of the GNU General Public License
                     14:    along with this program.  If not, see <http://www.gnu.org/licenses/>.
                     15: */
                     16: 
                     17: #define NAMESERVER_PORT 53
                     18: #define TFTP_PORT       69
1.1.1.3 ! misho      19: #define MAX_PORT        65535u
1.1       misho      20: 
                     21: #define IN6ADDRSZ       16
                     22: #define INADDRSZ        4
                     23: 
                     24: #define PACKETSZ       512             /* maximum packet size */
                     25: #define MAXDNAME       1025            /* maximum presentation domain name */
                     26: #define RRFIXEDSZ      10              /* #/bytes of fixed data in r record */
                     27: #define MAXLABEL        63              /* maximum length of domain label */
                     28: 
                     29: #define NOERROR                0               /* no error */
                     30: #define FORMERR                1               /* format error */
                     31: #define SERVFAIL       2               /* server failure */
                     32: #define NXDOMAIN       3               /* non existent domain */
                     33: #define NOTIMP         4               /* not implemented */
                     34: #define REFUSED                5               /* query refused */
                     35: 
                     36: #define QUERY           0               /* opcode */
                     37: 
                     38: #define C_IN            1               /* the arpa internet */
                     39: #define C_CHAOS         3               /* for chaos net (MIT) */
1.1.1.2   misho      40: #define C_HESIOD        4               /* hesiod */
1.1       misho      41: #define C_ANY           255             /* wildcard match */
                     42: 
                     43: #define T_A            1
1.1.1.2   misho      44: #define T_NS            2
                     45: #define T_MD            3
                     46: #define T_MF            4             
1.1       misho      47: #define T_CNAME                5
                     48: #define T_SOA          6
1.1.1.2   misho      49: #define T_MB            7
                     50: #define T_MG            8
                     51: #define T_MR            9
1.1       misho      52: #define T_PTR          12
1.1.1.2   misho      53: #define T_MINFO         14
1.1       misho      54: #define T_MX           15
                     55: #define T_TXT          16
1.1.1.2   misho      56: #define T_RP            17
                     57: #define T_AFSDB         18
                     58: #define T_RT            21
1.1       misho      59: #define T_SIG          24
1.1.1.2   misho      60: #define T_PX            26
1.1       misho      61: #define T_AAAA         28
1.1.1.2   misho      62: #define T_NXT           30
1.1       misho      63: #define T_SRV          33
                     64: #define T_NAPTR                35
1.1.1.2   misho      65: #define T_KX            36
                     66: #define T_DNAME         39
1.1       misho      67: #define T_OPT          41
1.1.1.2   misho      68: #define T_DS            43
                     69: #define T_RRSIG         46
                     70: #define T_NSEC          47
                     71: #define T_DNSKEY        48
                     72: #define T_NSEC3         50
1.1       misho      73: #define        T_TKEY          249             
                     74: #define        T_TSIG          250
                     75: #define T_AXFR          252
                     76: #define T_MAILB                253     
                     77: #define T_ANY          255
                     78: 
1.1.1.2   misho      79: #define EDNS0_OPTION_MAC            65001 /* dyndns.org temporary assignment */
                     80: #define EDNS0_OPTION_CLIENT_SUBNET  8     /* IANA */
1.1.1.3 ! misho      81: #define EDNS0_OPTION_NOMDEVICEID    65073 /* Nominum temporary assignment */
        !            82: #define EDNS0_OPTION_NOMCPEID       65074 /* Nominum temporary assignment */
1.1.1.2   misho      83: 
1.1       misho      84: struct dns_header {
                     85:   u16 id;
                     86:   u8  hb3,hb4;
                     87:   u16 qdcount,ancount,nscount,arcount;
                     88: };
                     89: 
1.1.1.3 ! misho      90: #define HB3_QR       0x80 /* Query */
1.1       misho      91: #define HB3_OPCODE   0x78
1.1.1.3 ! misho      92: #define HB3_AA       0x04 /* Authoritative Answer */
        !            93: #define HB3_TC       0x02 /* TrunCated */
        !            94: #define HB3_RD       0x01 /* Recursion Desired */
        !            95: 
        !            96: #define HB4_RA       0x80 /* Recursion Available */
        !            97: #define HB4_AD       0x20 /* Authenticated Data */
        !            98: #define HB4_CD       0x10 /* Checking Disabled */
1.1       misho      99: #define HB4_RCODE    0x0f
                    100: 
                    101: #define OPCODE(x)          (((x)->hb3 & HB3_OPCODE) >> 3)
1.1.1.2   misho     102: #define SET_OPCODE(x, code) (x)->hb3 = ((x)->hb3 & ~HB3_OPCODE) | code
                    103: 
1.1       misho     104: #define RCODE(x)           ((x)->hb4 & HB4_RCODE)
                    105: #define SET_RCODE(x, code) (x)->hb4 = ((x)->hb4 & ~HB4_RCODE) | code
                    106:   
                    107: #define GETSHORT(s, cp) { \
                    108:        unsigned char *t_cp = (unsigned char *)(cp); \
                    109:        (s) = ((u16)t_cp[0] << 8) \
                    110:            | ((u16)t_cp[1]) \
                    111:            ; \
                    112:        (cp) += 2; \
                    113: }
                    114: 
                    115: #define GETLONG(l, cp) { \
                    116:        unsigned char *t_cp = (unsigned char *)(cp); \
                    117:        (l) = ((u32)t_cp[0] << 24) \
                    118:            | ((u32)t_cp[1] << 16) \
                    119:            | ((u32)t_cp[2] << 8) \
                    120:            | ((u32)t_cp[3]) \
                    121:            ; \
                    122:        (cp) += 4; \
                    123: }
                    124: 
                    125: #define PUTSHORT(s, cp) { \
                    126:        u16 t_s = (u16)(s); \
                    127:        unsigned char *t_cp = (unsigned char *)(cp); \
                    128:        *t_cp++ = t_s >> 8; \
                    129:        *t_cp   = t_s; \
                    130:        (cp) += 2; \
                    131: }
                    132: 
                    133: #define PUTLONG(l, cp) { \
                    134:        u32 t_l = (u32)(l); \
                    135:        unsigned char *t_cp = (unsigned char *)(cp); \
                    136:        *t_cp++ = t_l >> 24; \
                    137:        *t_cp++ = t_l >> 16; \
                    138:        *t_cp++ = t_l >> 8; \
                    139:        *t_cp   = t_l; \
                    140:        (cp) += 4; \
                    141: }
                    142: 
1.1.1.2   misho     143: #define CHECK_LEN(header, pp, plen, len) \
                    144:     ((size_t)((pp) - (unsigned char *)(header) + (len)) <= (plen))
                    145: 
                    146: #define ADD_RDLEN(header, pp, plen, len) \
                    147:   (!CHECK_LEN(header, pp, plen, len) ? 0 : (((pp) += (len)), 1))
1.1.1.3 ! misho     148: 
        !           149: /* Escape character in our presentation format for names.
        !           150:    Cannot be '.' or /000 and must be !isprint().
        !           151:    Note that escaped chars are stored as
        !           152:    <NAME_ESCAPE> <orig-char+1>
        !           153:    to ensure that the escaped form of /000 doesn't include /000
        !           154: */
        !           155: #define NAME_ESCAPE 1

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>