7#define TO_OUTPUT(A,B) do{if (NULL == A) {fprintf(stdout, B);}else{strcpy(A,B);}}while(0);
9#define UDP_PAYLOAD_SIZE 1232
10#define DNS_HEADER_LENGTH 12
13#define SDNS_ERROR_MEMORY_ALLOC_FAILED -1
14#define SDNS_ERROR_BUFFER_TOO_SHORT -2
15#define SDNS_ERROR_QNAME_IS_NULL -3
16#define SDNS_ERROR_HOSTNAME_TOO_LONG -4
17#define SDNS_ERROR_WRONG_LABEL_SPECIFIED -5
18#define SDNS_ERROR_BUFFER_IS_NULL -6
19#define SDNS_ERROR_BUFFER_IS_SMALL -7
20#define SDNS_ERROR_INVALID_DNS_PACKET -8
21#define SDNS_ERROR_MORE_THAN_ONE_QUESTION_FOUND -9
22#define SDNS_ERROR_RR_NULL -10
24#define SDNS_ERROR_ELSIMPLE -11
25#define SDNS_ERROR_ELCOMPRESSED -12
27#define SDNS_ERROR_LABEL_MAX_63 -13
30#define SDNS_ERROR_ILLEGAL_COMPRESSION -14
31#define SDNS_ERROR_RR_SECTION_MALFORMED -15
32#define SDNS_ERROR_INVALID_HEX_VALUE -16
33#define SDNS_ERROR_WRONG_INPUT_PARAMETER -17
34#define SDNS_ERROR_NSID_NOT_FOUND -18
35#define SDNS_ERROR_CLIENT_COOKIE_NOT_FOUND -19
36#define SDNS_ERROR_CHARACTER_STRING_TOO_LONG -20
37#define SDNS_ERROR_NO_ANSWER_FOUND -21
38#define SDNS_ERROR_CAN_NOT_READ_SECTION -22
39#define SDNS_ERROR_INVALID_IPv6_FOUND -23
40#define SDNS_ERROR_NO_AUTHORITY_FOUND -24
41#define SDNS_ERROR_NO_ADDITIONAL_FOUND -25
42#define SDNS_ERROR_ADDITIONAL_RR_OPT -26
44#define DNS_SECTION_ANSWER 1
45#define DNS_SECTION_AUTHORITY 2
46#define DNS_SECTION_ADDITIONAL 3
47#define DNS_SECTION_QUESTION 4
50#define SDNS_QR_MASK 0x8000
51#define SDNS_OPCODE_MASK 0x7800
52#define SDNS_AA_MASK 0x0400
53#define SDNS_TC_MASK 0x0200
54#define SDNS_RD_MASK 0x0100
55#define SDNS_RA_MASK 0x0080
56#define SDNS_Z_MASK 0x0040
57#define SDNS_AD_MASK 0x0020
58#define SDNS_CD_MASK 0x0010
59#define SDNS_RCODE_MASK 0x000F
970 uint16_t rdlength, uint8_t decoded,
void * rdata);
976int sdns_create_edns_option(uint16_t, uint16_t,
char *,
sdns_opt_rdata**);
980sdns_opt_rdata * sdns_create_edns0_nsid(
char * nsid, uint16_t nsid_len);
1192sdns_rr_SRV * sdns_init_SRV(uint16_t, uint16_t, uint16_t,
char *);
1193sdns_rr_URI * sdns_init_rr_URI(uint16_t, uint16_t,
char *, uint16_t);
1194sdns_rr_RRSIG * sdns_init_rr_RRSIG(uint16_t, uint8_t, uint8_t, uint32_t, uint32_t, uint32_t, uint8_t,
char *,
char *, uint16_t);
1195sdns_rr_HINFO * sdns_init_rr_HINFO(uint8_t cpu_len,
char * cpu, uint8_t os_len,
char * os);
1196sdns_rr_SOA * sdns_init_rr_SOA(
char * mname,
char * rname, uint32_t expire, uint32_t minimum,
1197 uint32_t refresh, uint32_t retry, uint32_t serial);
1333int sdns_create_edns_option(uint16_t, uint16_t,
char *,
sdns_opt_rdata**);
int check_if_rrtype_is_valid(uint16_t qtype)
This function checks if the given RR type is valid or not.
int sdns_to_wire(sdns_context *ctx)
Coverts a DNS context to binary format.
void sdns_free_rr_CNAME(sdns_rr_CNAME *cname)
Free the memory of the structure of type sdns_rr_CNAME.
void sdns_free_rr_URI(sdns_rr_URI *uri)
Free the memory of the structure of type sdns_rr_URI.
void sdns_free_section(sdns_rr *rr)
free a DNS resource record no matter of the type
void sdns_free_rr_SRV(sdns_rr_SRV *srv)
Free the memory of the structure of type sdns_rr_SRV.
sdns_rr_A * sdns_init_rr_A(uint32_t ipaddress)
Initialize a structure of sdns_rr_A.
sdns_q_class
Definition sdns.h:394
@ sdns_q_class_CS
RFC1035 - the CSNET.
Definition sdns.h:396
@ sdns_q_class_HS
RFC1035 - Hesiod.
Definition sdns.h:398
@ sdns_q_class_IN
RFC1035 - the Internet.
Definition sdns.h:395
@ sdns_q_class_STAR
RFC1035 - any class.
Definition sdns.h:399
@ sdns_q_class_CH
RFC1035 - the CHAOS class.
Definition sdns.h:397
int sdns_ends0_option_code_to_text(sdns_edns0_option_code oc, char *buffer)
Copies the text description of the EDNS0 option code to the buffer.
void sdns_free_rr_TXT(sdns_rr_TXT *txt)
Free the memory of the structure of type sdns_rr_TXT.
void sdns_free_context(sdns_context *ctx)
Frees the context allocated by sdns_init_context().
void sdns_free_rr_NS(sdns_rr_NS *ns)
Free the memory of the structure of type sdns_rr_NS.
sdns_rr_TXT * sdns_init_rr_TXT(char *data, uint16_t data_len)
Initialize a structure of sdns_rr_TXT.
int check_if_qclass_is_valid(uint16_t qclass)
This function checks if the given Question class is valid or not.
void sdns_free_rr_CAA(sdns_rr_CAA *caa)
Free the memory of the structure of type sdns_rr_CAA.
sdns_message * sdns_init_message(void)
Initialize a DNS message structure (sdns_message).
int sdns_convert_type_to_int(char *type)
Converts text type to its numerical value.
void sdns_free_rr_PTR(sdns_rr_PTR *ptr)
Free the memory of the structure of type sdns_rr_PTR.
void sdns_free_rr_SOA(sdns_rr_SOA *soa)
Free the memory of the structure of type sdns_rr_SOA.
sdns_rr_LP * sdns_init_rr_LP(uint16_t preference, char *fqdn)
Initialize a structure of sdns_rr_LP.
int sdns_add_answer_section(sdns_context *ctx, sdns_rr *rr)
Creates an answer section for the DNS packet.
void sdns_free_rr_A(sdns_rr_A *a)
Free the memory of the structure of type sdns_rr_A.
void sdns_free_rr_L32(sdns_rr_L32 *l32)
Free the memory of the structure of type sdns_rr_L32.
sdns_rr_L32 * sdns_init_rr_L32(uint16_t preference, uint32_t locator32)
Initialize a structure of sdns_rr_L32.
int sdns_make_query(sdns_context *ctx, sdns_rr_type qtype, sdns_q_class cls, char *qname, int enable_edns0)
Creates a DNS question query.
sdns_ede_code
Definition sdns.h:451
@ sdns_ede_code_Unsupported_NSEC3_Iterations_Value
Unsupported NSEC3 Iterations Value.
Definition sdns.h:479
@ sdns_ede_code_DNSSEC_Bogus
The resolver attempted to perform DNSSEC validation, but validation ended in the Bogus state.
Definition sdns.h:458
@ sdns_ede_code_Stale_Answer
Stale Answer.
Definition sdns.h:455
@ sdns_ede_code_Signature_Expired
Signature Expired.
Definition sdns.h:459
@ sdns_ede_code_Blocked
Blocked.
Definition sdns.h:467
@ sdns_ede_code_Filtered
Filtered.
Definition sdns.h:469
@ sdns_ede_code_Prohibited
Prohibited.
Definition sdns.h:470
@ sdns_ede_code_Signature_Not_Yet_Valid
Signature Not Yet Valid.
Definition sdns.h:460
@ sdns_ede_code_Not_Supported
Not Supported.
Definition sdns.h:473
@ sdns_ede_code_Too_Early
Too Early
Definition sdns.h:478
@ sdns_ede_code_Signature_Expired_before_Valid
Signature Expired before Valid.
Definition sdns.h:477
@ sdns_ede_code_RRSIGs_Missing
RRSIGs Missing.
Definition sdns.h:462
@ sdns_ede_code_Not_Ready
The server is unable to answer the query, as it was not fully functional when the query was received.
Definition sdns.h:466
@ sdns_ede_code_Unsupported_DS_Digest_Type
Unsupported DS Digest Type.
Definition sdns.h:454
@ sdns_ede_code_DNSSEC_Indeterminate
DNSSEC Indeterminate.
Definition sdns.h:457
@ sdns_ede_code_No_Reachable_Authority
No Reachable Authority.
Definition sdns.h:474
@ sdns_ede_code_NSEC_Missing
NSEC Missing.
Definition sdns.h:464
@ sdns_ede_code_Forged_Answer
For policy reasons (legal obligation or malware filtering, for instance), an answer was forged.
Definition sdns.h:456
@ sdns_ede_code_Censored
Censored.
Definition sdns.h:468
@ sdns_ede_code_Unable_to_conform_to_policy
Unable to conform to policy.
Definition sdns.h:480
@ sdns_ede_code_Unsupported_DNSKEY_Algorithm
Unsupported DNSKEY Algorithm.
Definition sdns.h:453
@ sdns_ede_code_No_Zone_Key_Bit_Set
The resolver attempted to perform DNSSEC validation, but no Zone Key Bit was set in a DNSKEY.
Definition sdns.h:463
@ sdns_ede_code_Network_Error
Network Error.
Definition sdns.h:475
@ sdns_ede_code_Not_Authoritative
Not Authoritative.
Definition sdns.h:472
@ sdns_ede_code_Other_Error
Other.
Definition sdns.h:452
@ sdns_ede_code_Synthesized
Synthesized.
Definition sdns.h:481
@ sdns_ede_code_Cached_Error
Cached Error.
Definition sdns.h:465
@ sdns_ede_code_Invalid_Data
Invalid Data.
Definition sdns.h:476
@ sdns_ede_code_Stale_NXDomain_Answer
Stale NXDOMAIN Answer.
Definition sdns.h:471
@ sdns_ede_code_DNSKEY_Missing
A DS record existed at a parent, but no supported matching DNSKEY record could be found for the child...
Definition sdns.h:461
void sdns_free_rr_LP(sdns_rr_LP *lp)
Free the memory of the structure of type sdns_rr_LP.
void sdns_free_rr_MX(sdns_rr_MX *mx)
Free the memory of the structure of type sdns_rr_MX.
sdns_rr_class
Definition sdns.h:383
@ sdns_rr_class_CS
RFC1035 - the CSNET.
Definition sdns.h:385
@ sdns_rr_class_CH
RFC1035 - the CHAOS class.
Definition sdns.h:386
@ sdns_rr_class_IN
RFC1035 - the Internet.
Definition sdns.h:384
@ sdns_rr_class_HS
RFC1035 - Hesiod.
Definition sdns.h:387
sdns_rr_NID * sdns_init_rr_NID(uint16_t preference, char *nodid)
Initialize a structure of sdns_rr_NID.
int check_if_qtype_is_valid(uint16_t qtype)
This function checks if the given qtype code is valid or not.
sdns_rr_CAA * sdns_init_rr_CAA(uint8_t flag, char *tag, uint8_t tag_len, char *value, uint16_t value_len)
Initialize a structure of sdns_rr_CAA.
sdns_context * sdns_init_context(void)
Initialize and create a new DNS context.
sdns_rr_MX * sdns_init_rr_MX(uint16_t preference, char *exchange)
Initialize a structure of sdns_rr_MX.
sdns_opcode
Definition sdns.h:66
@ sdns_opcode_Update
RFC2136.
Definition sdns.h:71
@ sdns_opcode_IQuery
RFC1035.
Definition sdns.h:68
@ sdns_opcode_Status
RFC1035.
Definition sdns.h:69
@ sdns_opcode_Query
RFC1035.
Definition sdns.h:67
@ sdns_opcode_DSO
RFC8490.
Definition sdns.h:72
@ sdns_opcode_Notify
RFC1996.
Definition sdns.h:70
int check_if_rrclass_is_valid(uint16_t qclass)
This function checks if the given RR class is valid or not.
sdns_rcode
Definition sdns.h:81
@ sdns_rcode_YXRRSet
RFC2136.
Definition sdns.h:89
@ sdns_rcode_BADVERS
Bad OPT Version RFC6891.
Definition sdns.h:94
@ sdns_rcode_Reserved
Reserved, can be allocated by Standards Action RFC6895.
Definition sdns.h:103
@ sdns_rcode_BADCOOKIE
Bad/missing Server Cookie RFC7873.
Definition sdns.h:102
@ sdns_rcode_NXRRSet
RFC2136.
Definition sdns.h:90
@ sdns_rcode_NotZone
RFC2136.
Definition sdns.h:92
@ sdns_rcode_BADALG
Algorithm not supported RFC2930.
Definition sdns.h:100
@ sdns_rcode_FormErr
RFC1035.
Definition sdns.h:83
@ sdns_rcode_BADTRUNC
Bad Truncation RFC8945.
Definition sdns.h:101
@ sdns_rcode_NoError
RFC1035.
Definition sdns.h:82
@ sdns_rcode_ServFail
RFC1035.
Definition sdns.h:84
@ sdns_rcode_BADSIG
TSIG Signature Failure RFC8945.
Definition sdns.h:95
@ sdns_rcode_BADKEY
Key not recognized RFC8945.
Definition sdns.h:96
@ sdns_rcode_NotAuth
RFC2136, RFC8945.
Definition sdns.h:91
@ sdns_rcode_BADTIME
Signature out of time window RFC8945.
Definition sdns.h:97
@ sdns_rcode_YXDomain
RFC2136.
Definition sdns.h:88
@ sdns_rcode_BADNAME
Duplicate key name RFC2930.
Definition sdns.h:99
@ sdns_rcode_NotImp
RFC1035.
Definition sdns.h:86
@ sdns_rcode_BADMODE
Bad TKEY Mode RFC2930.
Definition sdns.h:98
@ sdns_rcode_DSOTYPENI
RFC8490.
Definition sdns.h:93
@ sdns_rcode_NXDomain
RFC1035.
Definition sdns.h:85
@ sdns_rcode_Refused
RFC1035.
Definition sdns.h:87
void sdns_rr_type_to_string(uint16_t t, char *buff)
Gets the string representation of the TYPE tp in to buffer
sdns_rr_SRV * sdns_init_rr_SRV(uint16_t Priority, uint16_t Weight, uint16_t Port, char *target)
Initialize a structure of sdns_rr_SRV.
sdns_rr_CNAME * sdns_init_rr_CNAME(char *cname)
Initialize a structure of sdns_rr_CNAME.
sdns_rr_AAAA * sdns_init_rr_AAAA(char *aaaa)
Initialize a structure of sdns_rr_AAAA.
void sdns_free_rr_RRSIG(sdns_rr_RRSIG *rrsig)
Free the memory of the structure of type sdns_rr_RRSIG.
void sdns_free_rr_L64(sdns_rr_L64 *l64)
Free the memory of the structure of type sdns_rr_L64.
int sdns_convert_class_to_int(char *cls)
Converts text class to its numerical value.
sdns_rr_type
Definition sdns.h:257
@ sdns_rr_type_AAAA
RFC3596 - AAAA record.
Definition sdns.h:285
@ sdns_rr_type_NXT
Next Domain (OBSOLETE) RFC2535, RFC3755.
Definition sdns.h:287
@ sdns_rr_type_NULL
RFC1035 - a null RR.
Definition sdns.h:267
@ sdns_rr_type_SVCB
General-purpose service binding RFC9460.
Definition sdns.h:320
@ sdns_rr_type_SPF
RFC7208.
Definition sdns.h:322
@ sdns_rr_type_CDNSKEY
DNSKEY(s) the Child wants reflected in DS RFC7344.
Definition sdns.h:316
@ sdns_rr_type_AXFR
RFC1035 - request for transfer of entire zone.
Definition sdns.h:336
@ sdns_rr_type_HTTPS
SVCB-compatible type for use with HTTP RFC9460.
Definition sdns.h:321
@ sdns_rr_type_RT
for Route Through RFC1183
Definition sdns.h:278
@ sdns_rr_type_NINFO
NINFO.
Definition sdns.h:312
@ sdns_rr_type_NID
RFC6742.
Definition sdns.h:327
@ sdns_rr_type_UINFO
IANA-Reserved.
Definition sdns.h:323
@ sdns_rr_type_TXT
RFC1035 - text strings.
Definition sdns.h:273
@ sdns_rr_type_DHCID
DHCID RFC4701.
Definition sdns.h:306
@ sdns_rr_type_NSAP_PTR
for domain name pointer, NSAP style
Definition sdns.h:280
@ sdns_rr_type_MB
RFC1035 - mailbox domain name.
Definition sdns.h:264
@ sdns_rr_type_CERT
CERT.
Definition sdns.h:294
@ sdns_rr_type_APL
APL.
Definition sdns.h:299
@ sdns_rr_type_GPOS
Geographical Position RFC1712.
Definition sdns.h:284
@ sdns_rr_type_CSYNC
Child-To-Parent Synchronization RFC7477.
Definition sdns.h:318
@ sdns_rr_type_AVC
Application Visibility and Control.
Definition sdns.h:342
@ sdns_rr_type_NSAP
for NSAP address, NSAP style A record (deprecated)
Definition sdns.h:279
@ sdns_rr_type_SINK
SINK.
Definition sdns.h:297
@ sdns_rr_type_RP
for Responsible Person RFC1183
Definition sdns.h:274
@ sdns_rr_type_WKS
RFC1035 - a well known service description.
Definition sdns.h:268
@ sdns_rr_type_CNAME
RFC1035 - canonical name.
Definition sdns.h:262
@ sdns_rr_type_PX
X.400 mail mapping information FC2163.
Definition sdns.h:283
@ sdns_rr_type_CAA
Certification Authority Restriction [RFC8659].
Definition sdns.h:341
@ sdns_rr_type_OPENPGPKEY
OpenPGP Key RFC7929.
Definition sdns.h:317
@ sdns_rr_type_DLV
DNSSEC Lookaside Validation (OBSOLETE)
Definition sdns.h:348
@ sdns_rr_type_MX
RFC1035 - mail exchange.
Definition sdns.h:272
@ sdns_rr_type_TSIG
Transaction Signature RFC8945.
Definition sdns.h:334
@ sdns_rr_type_MAILA
RFC1035 - request for mail agent RRs.
Definition sdns.h:338
@ sdns_rr_type_SSHFP
SSH Key Fingerprint RFC4255.
Definition sdns.h:301
@ sdns_rr_type_TLSA
TLSA [RFC6698.
Definition sdns.h:309
@ sdns_rr_type_IXFR
incremental transfer RFC1995
Definition sdns.h:335
@ sdns_rr_type_AMTRELAY
Automatic Multicast Tunneling Relay [RFC8777].
Definition sdns.h:344
@ sdns_rr_type_EUI48
an EUI-48 address RFC7043
Definition sdns.h:331
@ sdns_rr_type_ISDN
for ISDN address RFC1183
Definition sdns.h:277
@ sdns_rr_type_MD
RFC1035 - mail destination record.
Definition sdns.h:260
@ sdns_rr_type_KEY
for security key RFC2536, RFC2539, RFC3110, RFC4034
Definition sdns.h:282
@ sdns_rr_type_DS
Delegation Signer RFC4034.
Definition sdns.h:300
@ sdns_rr_type_RKEY
RKEY.
Definition sdns.h:313
@ sdns_rr_type_NSEC3
NSEC3 RFC5155, RFC9077.
Definition sdns.h:307
@ sdns_rr_type_TA
DNSSEC Trust Authorities.
Definition sdns.h:347
@ sdns_rr_type_NSEC
NSEC RFC4034, RFC9077.
Definition sdns.h:304
@ sdns_rr_type_MG
RFC1035 - mail group member.
Definition sdns.h:265
@ sdns_rr_type_TKEY
Transaction Key RFC2930.
Definition sdns.h:333
@ sdns_rr_type_X25
for X.25 PSDN address RFC1183
Definition sdns.h:276
@ sdns_rr_type_GID
IANA-Reserved.
Definition sdns.h:325
@ sdns_rr_type_ZONEMD
Message Digest Over Zone Data RFC8976.
Definition sdns.h:319
@ sdns_rr_type_NS
RFC1035 - NS record.
Definition sdns.h:259
@ sdns_rr_type_SMIMEA
S/MIME cert association RFC8162.
Definition sdns.h:310
@ sdns_rr_type_SOA
RFC1035 - start of a zone of authority.
Definition sdns.h:263
@ sdns_rr_type_URI
URI RFC7553.
Definition sdns.h:340
@ sdns_rr_type_NSEC3PARAM
NSEC3PARAM [RFC5155.
Definition sdns.h:308
@ sdns_rr_type_RESINFO
Resolver Information as Key/Value Pairs.
Definition sdns.h:345
@ sdns_rr_type_MAILB
RFC1035 - request for mailbox related records.
Definition sdns.h:337
@ sdns_rr_type_HINFO
RFC1035 - host information.
Definition sdns.h:270
@ sdns_rr_type_PTR
RFC1035 - a domain name pointer.
Definition sdns.h:269
@ sdns_rr_type_EID
Endpoint Identifier.
Definition sdns.h:288
@ sdns_rr_type_WALLET
Public wallet address.
Definition sdns.h:346
@ sdns_rr_type_A
RFC1035 - A record.
Definition sdns.h:258
@ sdns_rr_type_HIP
Host Identity Protocol RFC8005.
Definition sdns.h:311
@ sdns_rr_type_TALINK
Trust Anchor LINK.
Definition sdns.h:314
@ sdns_rr_type_UNSPEC
IANA-Reserved.
Definition sdns.h:326
@ sdns_rr_type_DNSKEY
DNSKEY RFC4034.
Definition sdns.h:305
@ sdns_rr_type_NIMLOC
Nimrod Locator.
Definition sdns.h:289
@ sdns_rr_type_EUI64
an EUI-64 address RFC7043
Definition sdns.h:332
@ sdns_rr_type_DNAME
DNAME.
Definition sdns.h:296
@ sdns_rr_type_MR
RFC1035 - mail rename domain name.
Definition sdns.h:266
@ sdns_rr_type_MF
RFC1035 - mail forwarder record.
Definition sdns.h:261
@ sdns_rr_type_SIG
for security signature RFC2536, RFC2931, RFC3110, RFC4034
Definition sdns.h:281
@ sdns_rr_type_RRSIG
RRSIG RFC4034.
Definition sdns.h:303
@ sdns_rr_type_NAPTR
Naming Authority Pointer.
Definition sdns.h:292
@ sdns_rr_type_AFSDB
for AFS Data Base location RFC1183, RFC5864
Definition sdns.h:275
@ sdns_rr_type_DOA
Digital Object Architecture.
Definition sdns.h:343
@ sdns_rr_type_L64
RFC6742.
Definition sdns.h:329
@ sdns_rr_type_LOC
Location Information RFC1876.
Definition sdns.h:286
@ sdns_rr_type_SRV
Server Selection.
Definition sdns.h:290
@ sdns_rr_type_ATMA
ATM Address.
Definition sdns.h:291
@ sdns_rr_type_KX
Key Exchanger.
Definition sdns.h:293
@ sdns_rr_type_UID
IANA-Reserved.
Definition sdns.h:324
@ sdns_rr_type_LP
RFC6742.
Definition sdns.h:330
@ sdns_rr_type_IPSECKEY
IPSECKEY RFC4025.
Definition sdns.h:302
@ sdns_rr_type_L32
RFC6742.
Definition sdns.h:328
@ sdns_rr_type_CDS
Child DS.
Definition sdns.h:315
@ sdns_rr_type_A6
A6 (OBSOLETE - use AAAA)
Definition sdns.h:295
@ sdns_rr_type_OPT
RFC6891 - option RR for ends.
Definition sdns.h:298
@ sdns_rr_type_star
RFC1035 - request for all records.
Definition sdns.h:339
@ sdns_rr_type_MINFO
RFC1035 - mailbox or mail list information.
Definition sdns.h:271
void sdns_class_to_string(uint16_t cls, char *buff)
Gets the string representation of the CLASS cls in to buffer
sdns_rr_NS * sdns_init_rr_NS(char *nsdname)
Initialize a structure of sdns_rr_NS.
void sdns_free_rr_NID(sdns_rr_NID *nid)
Free the memory of the structure of type sdns_rr_NID.
sdns_rr_PTR * sdns_init_rr_PTR(char *ptrdname)
Initialize a structure of sdns_rr_PTR.
sdns_opt_rdata * sdns_create_edns0_cookie(char *client_cookie, char *server_cookie, uint8_t server_cookie_len)
Creates and adds a cookie in the DNS packet.
void sdns_free_rr_AAAA(sdns_rr_AAAA *aaaa)
Free the memory of the structure of type sdns_rr_AAAA.
int sdns_add_authority_section(sdns_context *ctx, sdns_rr *rr)
Adds a new RR to the authority section of the DNS packet.
sdns_edns0_option_code
Definition sdns.h:356
@ sdns_edns0_option_code_DeviceID
DeviceID.
Definition sdns.h:377
@ sdns_edns0_option_code_edns_tcp_keepalive
edns-tcp-keepalive RFC7828
Definition sdns.h:368
@ sdns_edns0_option_code_LLQ
LLQ RFC8764.
Definition sdns.h:358
@ sdns_edns0_option_code_N3U
N3U RFC6975.
Definition sdns.h:364
@ sdns_edns0_option_code_edns_key_tag
edns-key-tag RFC8145
Definition sdns.h:371
@ sdns_edns0_option_code_edns_client_subnet
edns-client-subnet RFC7871
Definition sdns.h:365
@ sdns_edns0_option_code_Update_Lease
Update Lease.
Definition sdns.h:359
@ sdns_edns0_option_code_EDNS_Server_Tag
EDNS-Server-Tag.
Definition sdns.h:374
@ sdns_edns0_option_code_Extended_DNS_Error
Extended DNS Error RFC8914.
Definition sdns.h:372
@ sdns_edns0_option_code_DAU
DAU RFC6975.
Definition sdns.h:362
@ sdns_edns0_option_code_COOKIE
COOKIE RFC7873.
Definition sdns.h:367
@ sdns_edns0_option_code_CHAIN
CHAIN RFC7901.
Definition sdns.h:370
@ sdns_edns0_option_code_NSID
NSID RFC5001.
Definition sdns.h:360
@ sdns_edns0_option_code_Umbrella_Ident
Umbrella Ident.
Definition sdns.h:376
@ sdns_edns0_option_code_EDNS_EXPIRE
EDNS EXPIRE RFC7314.
Definition sdns.h:366
@ sdns_edns0_option_code_Reserved0
Reserved RFC6891.
Definition sdns.h:357
@ sdns_edns0_option_code_Padding
Padding RFC7830.
Definition sdns.h:369
@ sdns_edns0_option_code_Reserved4
Reserved.
Definition sdns.h:361
@ sdns_edns0_option_code_Report_Channel
Report-Channel RFC9567.
Definition sdns.h:375
@ sdns_edns0_option_code_EDNS_Client_Tag
EDNS-Client-Tag.
Definition sdns.h:373
@ sdns_edns0_option_code_DHU
DHU RFC6975.
Definition sdns.h:363
sdns_opt_rdata * sdns_create_edns0_ede(uint16_t info_code, char *extra_text, uint16_t extra_text_len)
Creates EDNS0 extended DNS error option.
sdns_rr * sdns_init_rr(char *name, uint16_t type, uint16_t class, uint32_t ttl, uint16_t rdlength, uint8_t decoded, void *rdata)
Initialize an RR data structure.
int sdns_add_additional_section(sdns_context *ctx, sdns_rr *rr)
Adds a new RR to the additional section of the DNS packet.
void sdns_error_string(int err, char **err_buff)
Coverts error codes to a string.
void sdns_free_rr_HINFO(sdns_rr_HINFO *hinfo)
Free the memory of the structure of type sdns_rr_HINFO.
sdns_rr_L64 * sdns_init_rr_L64(uint16_t preference, char *locator64)
Initialize a structure of sdns_rr_L64.
int sdns_from_wire(sdns_context *ctx)
Converts the raw data received from socket (bytes) to a DNS packet.
uint16_t option_code
16bit option code
Definition sdns.h:150
struct _sdns_opt_rdata * next
non-rfc field. Just to keep the reference to the next option structure
Definition sdns.h:153
char * option_data
Pointer to the option data.
Definition sdns.h:152
uint16_t option_length
16bit option length specifies the length of the option data
Definition sdns.h:151
struct _sdns_rr_TXT * next
keep the reference to the next structure
Definition sdns.h:518
txt_data character_string
see :txt_data for more info
Definition sdns.h:517
uint16_t type
RFC1035 - RR type code.
Definition sdns.h:231
void * psdns_rr
this is not DNS-RFC. It's just a reference for our library
Definition sdns.h:244
uint16_t rdlength
RFC1035 - length of the RDATA field.
Definition sdns.h:240
uint16_t udp_size
size of the UDP packet
Definition sdns.h:234
sdns_opt_ttl opt_ttl
will expand to sdns_opt_ttl if type=OPT
Definition sdns.h:238
uint8_t decoded
this is not DNS-RFC. it's just a flag to know if the rdata is decoded or not
Definition sdns.h:246
uint32_t ttl
Time To Live.
Definition sdns.h:237
struct _sdns_rr * next
non-rfc field, just keep the reference to the next structure (linked-list)
Definition sdns.h:247
sdns_opt_rdata * opt_rdata
if type=OPT, this will refer to sdns_opt_rdata structure
Definition sdns.h:243
char * name
RFC1035 - domain name.
Definition sdns.h:230
char * rdata
resource record data (for all RRs except for OPT)
Definition sdns.h:242
sdns_message * msg
This is the DNS packet.
Definition sdns.h:689
char * cursor
This cursor keeps the position of the pointer in raw data.
Definition sdns.h:692
uint16_t raw_len
Length of the raw data we received from socket.
Definition sdns.h:691
int err
This shows the last error code after any operation on the context.
Definition sdns.h:693
char * raw
The raw bytes we received from socket.
Definition sdns.h:690
sdns_rr * authority
Authority section of a DNS packet.
Definition sdns.h:489
sdns_rr * answer
Answer section of a DNS packet.
Definition sdns.h:488
sdns_header header
See sdns_header for more info.
Definition sdns.h:486
sdns_rr * additional
Additional section of a DNS packet.
Definition sdns.h:490
sdns_question question
See sdns_question for more info.
Definition sdns.h:487
uint32_t Z
Reserved (must be zero always)
Definition sdns.h:176
uint32_t DO
DNSSEC OK bit.
Definition sdns.h:175
uint32_t version
version of the edns (it's zero)
Definition sdns.h:174
uint32_t extended_rcode
extended response code
Definition sdns.h:173
uint16_t qtype
RFC1035 - two octet, type of the query.
Definition sdns.h:123
uint16_t qclass
RFC1035 - two octet, class of the query.
Definition sdns.h:124
char * qname
RFC1035 - the domain name.
Definition sdns.h:122
char * address
IPv6 address but we keep it as a sequence of bytes (exactly 16 bytes)
Definition sdns.h:500
uint32_t address
IPv4 address (only one address)
Definition sdns.h:495
uint8_t tag_len
length of the tag field (non-RFC field). tag is not null-terminated necessarily
Definition sdns.h:676
uint8_t flag
8 bit flag
Definition sdns.h:674
char * tag
pointer to tag
Definition sdns.h:675
uint16_t value_len
length of the value filed (non-RFC field). value is not null-terminated necessarily
Definition sdns.h:677
char * value
pointer to value
Definition sdns.h:678
char * CNAME
A <domain-name> which specifies the canonical or primary name for the owner.
Definition sdns.h:556
char * cpu
CPU information.
Definition sdns.h:638
uint8_t cpu_len
non-rfc: just to have the length of the CPU field
Definition sdns.h:637
uint8_t os_len
non-rfc: just to have the length of the OS field
Definition sdns.h:639
char * os
OS information.
Definition sdns.h:640
uint32_t Locator32
locator32 is exactly 32 bit so we can have a uint32 type to cover it
Definition sdns.h:648
uint16_t Preference
a 16-bit preference field
Definition sdns.h:647
char * Locator64
Locator64 is exactly 64 bit (8bytes)
Definition sdns.h:657
uint16_t Preference
a 16-bit Preference field
Definition sdns.h:656
char * FQDN
FQDN is a variable length field contains the DNS target name that is used to reference L32 and/or L64...
Definition sdns.h:666
uint16_t Preference
a 16-bit Preference field
Definition sdns.h:665
char * exchange
A <domain-name> which specifies a host willing to act as a mail exchange for the owner name.
Definition sdns.h:540
uint16_t preference
A 16 bit integer which specifies the preference given to this RR among others at the same owner.
Definition sdns.h:539
uint16_t Preference
indicates the owner name's relative preference
Definition sdns.h:629
char * NodeId
NodeID field is an unsigned 64-bit value in network byte order (len=8bytes)
Definition sdns.h:630
char * NSDNAME
A <domain-name> which specifies a host which should be authoritative for the specified class and doma...
Definition sdns.h:545
uint16_t extra_text_len
Section 2, RFC8914: the length MUST be derived from the OPTION-LENGTH field.
Definition sdns.h:563
uint16_t inf_code
One of the values in sdns_ede_code.
Definition sdns.h:561
char * extra_text
Section 2, RFC8914 says this is null-terminated but MUST NOT be assumed to be.
Definition sdns.h:562
char * PTRDNAME
A <domain-name> which points to some location in the domain name space.
Definition sdns.h:551
uint32_t signature_expiration
validity period for the signature
Definition sdns.h:595
uint16_t signature_len
This is just a helper not an RFC standard field.
Definition sdns.h:600
char * signature
the cryptographic signature that covers the RRSIG RDATA and the RRset
Definition sdns.h:599
uint8_t labels
specifies the number of labels in the original RRSIG RR owner name
Definition sdns.h:593
uint8_t algorithm
identifies the cryptographic algorithm used to create the signature
Definition sdns.h:592
uint16_t key_tag
key tag value of the DNSKEY RR that validates this signature
Definition sdns.h:597
uint32_t original_ttl
specifies the TTL of the covered RRset as it appears in the authoritative zone
Definition sdns.h:594
uint16_t type_covered
identifies the type of the RRset that is covered by this RRSIG record
Definition sdns.h:591
char * signers_name
the owner name of the DNSKEY RR that a validator is supposed to use to validate this signature
Definition sdns.h:598
uint32_t signature_inception
validity period for the signature
Definition sdns.h:596
char * rname
mailbox of the responsible person
Definition sdns.h:528
uint32_t retry
elapse before a failed refresh should be retried
Definition sdns.h:531
char * mname
Primary name server.
Definition sdns.h:527
uint32_t expire
upper limit on the time interval that can elapse before the zone is no longer authoritative
Definition sdns.h:532
uint32_t minimum
minimum TTL field that should be exported with any RR from this zone
Definition sdns.h:533
uint32_t refresh
time interval before the zone should be refreshed
Definition sdns.h:530
uint32_t serial
version number of the original copy of the zone
Definition sdns.h:529
uint16_t Port
The port on this target host of this service.
Definition sdns.h:611
uint16_t Priority
The priority of this target host.
Definition sdns.h:609
char * Target
RFC2782: the name compression can not be applied to this name.
Definition sdns.h:612
uint16_t Weight
A server selection mechanism.
Definition sdns.h:610
char * Target
I didn't find any text in RFC saying this must be a human-readable string!
Definition sdns.h:621
uint16_t Weight
This field holds the server selection mechanism.
Definition sdns.h:620
uint16_t target_len
non-rfc filed. Just used as a helper to know the length of the Target filed
Definition sdns.h:622
uint16_t Priority
his field holds the priority of the target URI in this RR
Definition sdns.h:619
uint8_t len
length of the content filed
Definition sdns.h:511
char * content
content filed is not nul-terminated necessarily
Definition sdns.h:512