|
Ripples 1.0
High Performant Software Architecture For Transaction Processing
|
Collection of utilities for working with DNS queries. These utilities were copied from glibc then modified.
Data Structures | |
| struct | rip_ns_header_s |
Macros | |
| #define | RIP_NS_PACKETSZ 512 |
| #define | RIP_NS_UDP_MAXMSG 4096 |
| #define | RIP_NS_MAXMSG 65535 |
| #define | RIP_NS_MAXCDNAME 255 |
| #define | RIP_NS_MAXLABEL 63 |
| #define | RIP_NS_QFIXEDSZ 4 |
| #define | RIP_NS_RRFIXEDSZ 10 |
| #define | RIP_NS_INT32SZ 4 |
| #define | RIP_NS_INT16SZ 2 |
| #define | RIP_NS_INT8SZ 1 |
| #define | RIP_NS_INADDRSZ 4 |
| #define | RIP_NS_IN6ADDRSZ 16 |
| #define | RIP_NS_CMPRSFLGS 0xc0 |
| #define | RIP_NS_RESP_MAX_ANSW 128 |
| #define | RIP_NS_RESP_MAX_NS 16 |
| #define | RIP_NS_RESP_MAX_ADDL 128 |
| #define | RIP_NS_CDNAME_COMP_BUF_LEN 256 |
| #define | RIP_NS_QUERY_SET_END_CODE_AND_RETURN(q, c) |
| #define | RIP_NS_GET16(s, cp) |
| #define | RIP_NS_PUT16(s, cp) |
| #define | RIP_NS_GET32(l, cp) |
| #define | RIP_NS_PUT32(l, cp) |
Typedefs | |
| typedef enum rip_ns_flag_e | rip_ns_flag_t |
| typedef enum rip_ns_opcode_e | rip_ns_opcode_t |
| typedef enum rip_ns_rcode_e | rip_ns_rcode_t |
| typedef enum rip_ns_type_e | rip_ns_type_t |
| typedef enum rip_ns_class_e | rip_ns_class_t |
| typedef enum rip_ns_ext_opt_code_e | rip_ns_ext_opt_code_t |
| typedef struct rip_ns_header_s | rip_ns_header_t |
Enumerations | |
| enum | rip_ns_flag_e { rip_ns_f_qr , rip_ns_f_opcode , rip_ns_f_aa , rip_ns_f_tc , rip_ns_f_rd , rip_ns_f_ra , rip_ns_f_z , rip_ns_f_ad , rip_ns_f_cd , rip_ns_f_rcode , rip_ns_f_max } |
| enum | rip_ns_opcode_e { rip_ns_o_query = 0 , rip_ns_o_iquery = 1 , rip_ns_o_status = 2 , rip_ns_o_notify = 4 , rip_ns_o_update = 5 , rip_ns_o_max = 6 } |
| enum | rip_ns_rcode_e { rip_ns_r_noerror = 0 , rip_ns_r_formerr = 1 , rip_ns_r_servfail = 2 , rip_ns_r_nxdomain = 3 , rip_ns_r_notimpl = 4 , rip_ns_r_refused = 5 , rip_ns_r_yxdomain = 6 , rip_ns_r_yxrrset = 7 , rip_ns_r_nxrrset = 8 , rip_ns_r_notauth = 9 , rip_ns_r_notzone = 10 , rip_ns_r_max = 11 , rip_ns_r_badvers = 16 , rip_ns_r_badsig = 16 , rip_ns_r_badkey = 17 , rip_ns_r_badtime = 18 , rip_ns_r_rip_unknown = -1 , rip_ns_r_rip_shortheader = -2 , rip_ns_r_rip_toolarge = -3 , rip_ns_r_rip_query_tc = -4 , rip_ns_r_rip_pack_rr_err = -5 , rip_ns_r_rip_tcp_write_err = -6 , rip_ns_r_rip_tcp_write_close = -7 } |
| enum | rip_ns_type_e { rip_ns_t_invalid = 0 , rip_ns_t_a = 1 , rip_ns_t_ns = 2 , rip_ns_t_md = 3 , rip_ns_t_mf = 4 , rip_ns_t_cname = 5 , rip_ns_t_soa = 6 , rip_ns_t_mb = 7 , rip_ns_t_mg = 8 , rip_ns_t_mr = 9 , rip_ns_t_null = 10 , rip_ns_t_wks = 11 , rip_ns_t_ptr = 12 , rip_ns_t_hinfo = 13 , rip_ns_t_minfo = 14 , rip_ns_t_mx = 15 , rip_ns_t_txt = 16 , rip_ns_t_rp = 17 , rip_ns_t_afsdb = 18 , rip_ns_t_x25 = 19 , rip_ns_t_isdn = 20 , rip_ns_t_rt = 21 , rip_ns_t_nsap = 22 , rip_ns_t_nsap_ptr = 23 , rip_ns_t_sig = 24 , rip_ns_t_key = 25 , rip_ns_t_px = 26 , rip_ns_t_gpos = 27 , rip_ns_t_aaaa = 28 , rip_ns_t_loc = 29 , rip_ns_t_nxt = 30 , rip_ns_t_eid = 31 , rip_ns_t_nimloc = 32 , rip_ns_t_srv = 33 , rip_ns_t_atma = 34 , rip_ns_t_naptr = 35 , rip_ns_t_kx = 36 , rip_ns_t_cert = 37 , rip_ns_t_a6 = 38 , rip_ns_t_dname = 39 , rip_ns_t_sink = 40 , rip_ns_t_opt = 41 , rip_ns_t_apl = 42 , rip_ns_t_ds = 43 , rip_ns_t_sshfp = 44 , rip_ns_t_ipseckey = 45 , rip_ns_t_rrsig = 46 , rip_ns_t_nsec = 47 , rip_ns_t_dnskey = 48 , rip_ns_t_dhcid = 49 , rip_ns_t_nsec3 = 50 , rip_ns_t_nsec3param = 51 , rip_ns_t_tlsa = 52 , rip_ns_t_smimea = 53 , rip_ns_t_hip = 55 , rip_ns_t_ninfo = 56 , rip_ns_t_rkey = 57 , rip_ns_t_talink = 58 , rip_ns_t_cds = 59 , rip_ns_t_cdnskey = 60 , rip_ns_t_openpgpkey = 61 , rip_ns_t_csync = 62 , rip_ns_t_spf = 99 , rip_ns_t_uinfo = 100 , rip_ns_t_uid = 101 , rip_ns_t_gid = 102 , rip_ns_t_unspec = 103 , rip_ns_t_nid = 104 , rip_ns_t_l32 = 105 , rip_ns_t_l64 = 106 , rip_ns_t_lp = 107 , rip_ns_t_eui48 = 108 , rip_ns_t_eui64 = 109 , rip_ns_t_tkey = 249 , rip_ns_t_tsig = 250 , rip_ns_t_ixfr = 251 , rip_ns_t_axfr = 252 , rip_ns_t_mailb = 253 , rip_ns_t_maila = 254 , rip_ns_t_any = 255 , rip_ns_t_uri = 256 , rip_ns_t_caa = 257 , rip_ns_t_avc = 258 , rip_ns_t_ta = 32768 , rip_ns_t_dlv = 32769 , rip_ns_t_max = 65536 } |
| enum | rip_ns_class_e { rip_ns_c_invalid = 0 , rip_ns_c_in = 1 , rip_ns_c_2 = 2 , rip_ns_c_chaos = 3 , rip_ns_c_hs = 4 , rip_ns_c_none = 254 , rip_ns_c_any = 255 , rip_ns_c_max = 65536 } |
| enum | rip_ns_ext_opt_code_e { rip_ns_ext_opt_c_cs = 8 } |
Functions | |
| const char * | rip_ns_class_to_str (rip_ns_class_t class) |
| const char * | rip_ns_rr_type_to_str (rip_ns_type_t type) |
| bool | rip_ns_rr_type_supported (uint16_t query_type) |
| bool | rip_ns_rr_class_supported (uint16_t query_class) |
| void | rip_ns_put16 (unsigned char *dst, uint16_t num) |
| int | rip_ns_name_unpack (const unsigned char *msg, const unsigned char *eom, const unsigned char *src, unsigned char *dst, size_t dstsiz) |
| int | rip_ns_name_pack (const unsigned char *src, unsigned char *dst, int dstsiz, const unsigned char **dnptrs, const unsigned char **lastdnptr) |
| int | rip_ns_name_pton (const unsigned char *src, unsigned char *dst, size_t dstsiz) |
| int | rip_ns_name_ntop (const unsigned char *src, char *dst, size_t dstsiz) |
| int | rip_rr_name_get (const unsigned char *msg, const unsigned char *eom, const unsigned char *src, unsigned char *dst, size_t dstsiz, uint16_t *query_label_len) |
| int | rip_ns_name_put (const unsigned char *src, unsigned char *dst, int dstsiz, const unsigned char **dnptrs, const unsigned char **lastdnptr) |
| #define RIP_NS_CDNAME_COMP_BUF_LEN 256 |
size of buffer used to compress CDNAME.
| #define RIP_NS_CMPRSFLGS 0xc0 |
Flag bits indicating name compression.
| #define RIP_NS_GET16 | ( | s, | |
| cp | |||
| ) |
Get a network order unsigned 16 bit integer from buffer "cp" and store it in "s" in host order. "cp" pointer is advanced by 2 bytes.
| #define RIP_NS_GET32 | ( | l, | |
| cp | |||
| ) |
Get a network order unsigned 32 bit integer from buffer "cp" and store it in "l" in host order. "cp" pointer is advanced by 4 bytes.
| #define RIP_NS_IN6ADDRSZ 16 |
IPv6 T_AAAA
| #define RIP_NS_INADDRSZ 4 |
IPv4 T_A
| #define RIP_NS_INT16SZ 2 |
#/bytes of data in a uint16_t
| #define RIP_NS_INT32SZ 4 |
#/bytes of data in a uint32_t
| #define RIP_NS_INT8SZ 1 |
#/bytes of data in a uint8_t
| #define RIP_NS_MAXCDNAME 255 |
maximum compressed domain name
| #define RIP_NS_MAXLABEL 63 |
maximum length of domain label
| #define RIP_NS_MAXMSG 65535 |
maximum message size
| #define RIP_NS_PACKETSZ 512 |
Define constants based on RFC 883, RFC 1034, RFC 1035 default UDP packet size
| #define RIP_NS_PUT16 | ( | s, | |
| cp | |||
| ) |
Pack an unsigned 16 bit integer "s" in host order into buffer "cp" in network order. "cp" pointer is advanced by 2 bytes.
| #define RIP_NS_PUT32 | ( | l, | |
| cp | |||
| ) |
Pack an unsigned 32 bit integer "l" in host order into buffer "cp" in network order. "cp" pointer is advanced by 4 bytes.
| #define RIP_NS_QFIXEDSZ 4 |
#/bytes of fixed data in query
| #define RIP_NS_QUERY_SET_END_CODE_AND_RETURN | ( | q, | |
| c | |||
| ) |
Macro to set a query code and return from function. This is useful when handling a query and we want to: set query end code and stop any further processing.
| #define RIP_NS_RESP_MAX_ADDL 128 |
Maximum number of additional record query response could have, excluding EDNS.
| #define RIP_NS_RESP_MAX_ANSW 128 |
Maximum number of answer record query response could have.
| #define RIP_NS_RESP_MAX_NS 16 |
Maximum number of authority record query response could have.
| #define RIP_NS_RRFIXEDSZ 10 |
#/bytes of fixed data in r record
| #define RIP_NS_UDP_MAXMSG 4096 |
maximum UDP response message size
| typedef enum rip_ns_class_e rip_ns_class_t |
Values for DNS resource record class field
| typedef enum rip_ns_ext_opt_code_e rip_ns_ext_opt_code_t |
EDNS extension option codes
| typedef enum rip_ns_flag_e rip_ns_flag_t |
DNS message header flags.
| typedef struct rip_ns_header_s rip_ns_header_t |
Structure for DNS query header. The order of the fields is machine- and compiler-dependent, depending on the byte/bit order and the layout of bit fields. We use bit fields only in int variables, as this is all ANSI requires.
| typedef enum rip_ns_opcode_e rip_ns_opcode_t |
DNS opcodes.
| typedef enum rip_ns_rcode_e rip_ns_rcode_t |
DNS response codes.
| typedef enum rip_ns_type_e rip_ns_type_t |
Currently defined type values for DNS resources and queries.
| enum rip_ns_class_e |
EDNS extension option codes
| enum rip_ns_flag_e |
DNS message header flags.
| enum rip_ns_opcode_e |
| enum rip_ns_rcode_e |
DNS response codes.
| enum rip_ns_type_e |
Currently defined type values for DNS resources and queries.
| const char * rip_ns_class_to_str | ( | rip_ns_class_t | class | ) |
Convert Resource Record enum class to string.
| class | RR class to get string representation for. |

| int rip_ns_name_ntop | ( | const unsigned char * | src, |
| char * | dst, | ||
| size_t | dstsiz | ||
| ) |
Converts an uncompressed, encoded domain name to printable ASCII as per RFC1035. Returns the number of bytes written to buffer, or -1 (with errno set). The root is returned as "." All other domains are returned in non absolute form.
| src | Encoded domain name to convert to printable ASCII. |
| dst | Destination buffer where to store converted string. |
| dstsiz | Size of destination buffer. |


| int rip_ns_name_pack | ( | const unsigned char * | src, |
| unsigned char * | dst, | ||
| int | dstsiz, | ||
| const unsigned char ** | dnptrs, | ||
| const unsigned char ** | lastdnptr | ||
| ) |
Packs domain name SRC into DST. Domain name MUST be in "network" format. To convert C string to "network" format use rip_ns_name_pton().
DNPTRS is an array of pointers to previous compressed names. DNPTRS[0] is a pointer to the beginning of the message. The array ends with NULL. LASTDNPTR is a pointer to the end of the array pointed to by 'dnptrs'.
The list of pointers in DNPTRS is updated for labels inserted into the message as we compress the name. If DNPTRS is NULL, we don't try to compress names. If LASTDNPTR is NULL, we don't update the list.
| src | Domain name in "network" format to pack. |
| dst | Destination buffer where to pack the domain name. |
| dstsiz | Length of destination buffer. |
| dnptrs | |
| lastdnptr |


| int rip_ns_name_pton | ( | const unsigned char * | src, |
| unsigned char * | dst, | ||
| size_t | dstsiz | ||
| ) |
Converts an ASCII string into an encoded domain name as per RFC1035. Enforces label and domain length limits.
| src | String to encode. |
| dst | Destination buffer to store encoded string. |
| dstsiz | Size of destination buffer. |

| int rip_ns_name_put | ( | const unsigned char * | src, |
| unsigned char * | dst, | ||
| int | dstsiz, | ||
| const unsigned char ** | dnptrs, | ||
| const unsigned char ** | lastdnptr | ||
| ) |
Packs domain name SRC into DST. Domain name MUST be a C string. This function converts the C string into "network" format, then packs it into destination buffer.
DNPTRS is an array of pointers to previous compressed names. DNPTRS[0] is a pointer to the beginning of the message. The array ends with NULL. LASTDNPTR is a pointer to the end of the array pointed to by 'dnptrs'.
The list of pointers in DNPTRS is updated for labels inserted into the message as we compress the name. If DNPTRS is NULL, we don't try to compress names. If LASTDNPTR is NULL, we don't update the list.
DNPTRS should be initialized when ready to populate DNS response. It should then be used for all rip_ns_name_put() and rip_ns_name_pack() calls while adding RRs to DNS response.
| src | Domain name in "network" format to pack. |
| dst | Destination buffer where to pack the domain name. |
| dstsiz | Length of destination buffer. |
| dnptrs | |
| lastdnptr |


| int rip_ns_name_unpack | ( | const unsigned char * | msg, |
| const unsigned char * | eom, | ||
| const unsigned char * | src, | ||
| unsigned char * | dst, | ||
| size_t | dstsiz | ||
| ) |
Unpack a domain name from a message Resource Record (RR), source may be compressed. Unpacked name will be in "network" format. Use rip_ns_name_ntop() function to convert from "network" to regular C string.
| msg | Pointer to first byte of DNS message. |
| eom | Pointer to last byte DNS in message. |
| src | Pointer to first byte of RR name. |
| dst | Pointer to buffer where to store the unpacked RR name. |
| dstsiz | Size of destination buffer. |

|
inline |
Pack an unsigned 16 bit integer "num" in host order into buffer "dst" in network order.
| dst | Destination where to store packed unsigned 16 bit integer. |
| num | Number to pack. |

| bool rip_ns_rr_class_supported | ( | uint16_t | query_class | ) |
Check if DNS resource record class is one of supported types.
| query_class | DNS resource record type to check. |

| bool rip_ns_rr_type_supported | ( | uint16_t | query_type | ) |
Check if DNS resource record type is one of supported types.
| query_type | DNS resource record type to check. |

| const char * rip_ns_rr_type_to_str | ( | rip_ns_type_t | type | ) |
Convert Resource Record enum type to string.
| type | RR type to get string representation for. |

| int rip_rr_name_get | ( | const unsigned char * | msg, |
| const unsigned char * | eom, | ||
| const unsigned char * | src, | ||
| unsigned char * | dst, | ||
| size_t | dstsiz, | ||
| uint16_t * | query_label_len | ||
| ) |
Get a domain name from a message Resource Record (RR), source may be compressed. Unpacked name will be in stored in "dst" as to regular C string.
| msg | Pointer to first byte of DNS message. |
| eom | Pointer to last byte DNS in message. |
| src | Pointer to first byte of RR name. |
| dst | Pointer to buffer where to store the unpacked RR name. |
| dstsiz | Size of destination buffer. |
| query_label_len | Pointer where to store length of label extracted and stored in dst. |

