diff options
Diffstat (limited to 'contrib/unbound/util/data/msgparse.h')
| -rw-r--r-- | contrib/unbound/util/data/msgparse.h | 54 |
1 files changed, 49 insertions, 5 deletions
diff --git a/contrib/unbound/util/data/msgparse.h b/contrib/unbound/util/data/msgparse.h index 4c0559a739a4..7de4e394f2ae 100644 --- a/contrib/unbound/util/data/msgparse.h +++ b/contrib/unbound/util/data/msgparse.h @@ -72,6 +72,8 @@ struct regional; struct edns_option; struct config_file; struct comm_point; +struct comm_reply; +struct cookie_secrets; /** number of buckets in parse rrset hash table. Must be power of 2. */ #define PARSE_TABLE_SIZE 32 @@ -81,10 +83,14 @@ extern time_t MAX_TTL; extern time_t MIN_TTL; /** Maximum Negative TTL that is allowed */ extern time_t MAX_NEG_TTL; +/** Minimum Negative TTL that is allowed */ +extern time_t MIN_NEG_TTL; /** If we serve expired entries and prefetch them */ extern int SERVE_EXPIRED; /** Time to serve records after expiration */ extern time_t SERVE_EXPIRED_TTL; +/** Reset serve expired TTL after failed update attempt */ +extern time_t SERVE_EXPIRED_TTL_RESET; /** TTL to use for expired records */ extern time_t SERVE_EXPIRED_REPLY_TTL; /** Negative cache time (for entries without any RRs.) */ @@ -217,8 +223,6 @@ struct rr_parse { * region. */ struct edns_data { - /** if EDNS OPT record was present */ - int edns_present; /** Extended RCODE */ uint8_t ext_rcode; /** The EDNS version number */ @@ -238,7 +242,15 @@ struct edns_data { struct edns_option* opt_list_inplace_cb_out; /** block size to pad */ uint16_t padding_block_size; -}; + /** if EDNS OPT record was present */ + unsigned int edns_present : 1; + /** if a cookie was present */ + unsigned int cookie_present : 1; + /** if the cookie validated */ + unsigned int cookie_valid : 1; + /** if the cookie holds only the client part */ + unsigned int cookie_client : 1; +}; /** * EDNS option @@ -294,19 +306,33 @@ int parse_extract_edns_from_response_msg(struct msg_parse* msg, struct edns_data* edns, struct regional* region); /** + * Skip RRs from packet + * @param pkt: the packet. position at start must be right after the query + * section. At end, right after EDNS data or partial movement if failed. + * @param num: Limit of the number of records we want to parse. + * @return: 1 on success, 0 on failure. + */ +int skip_pkt_rrs(struct sldns_buffer* pkt, int num); + +/** * If EDNS data follows a query section, extract it and initialize edns struct. * @param pkt: the packet. position at start must be right after the query - * section. At end, right after EDNS data or no movement if failed. + * section. At end, right after EDNS data or partial movement if failed. * @param edns: the edns data allocated by the caller. Does not have to be * initialised. * @param cfg: the configuration (with nsid value etc.) * @param c: commpoint to determine transport (if needed) + * @param repinfo: commreply to determine the client address + * @param now: current time * @param region: region to alloc results in (edns option contents) + * @param cookie_secrets: the cookie secrets for EDNS COOKIE validation. * @return: 0 on success, or an RCODE on error. * RCODE formerr if OPT is badly formatted and so on. */ int parse_edns_from_query_pkt(struct sldns_buffer* pkt, struct edns_data* edns, - struct config_file* cfg, struct comm_point* c, struct regional* region); + struct config_file* cfg, struct comm_point* c, + struct comm_reply* repinfo, time_t now, struct regional* region, + struct cookie_secrets* cookie_secrets); /** * Calculate hash value for rrset in packet. @@ -352,4 +378,22 @@ void msgparse_bucket_remove(struct msg_parse* msg, struct rrset_parse* rrset); void log_edns_opt_list(enum verbosity_value level, const char* info_str, struct edns_option* list); +/** + * Remove RR from msgparse RRset. + * @param str: this string is used for logging if verbose. If NULL, there is + * no logging of the remove. + * @param pkt: packet in buffer that is removed from. Used to log the name + * of the item removed. + * @param rrset: RRset that the RR is removed from. + * @param prev: previous RR in list, or NULL. + * @param rr: RR that is removed. + * @param addr: address used for logging, if verbose, or NULL then it is not + * used. + * @param addrlen: length of addr, if that is not NULL. + * @return true if rrset is entirely bad, it would then need to be removed. + */ +int msgparse_rrset_remove_rr(const char* str, struct sldns_buffer* pkt, + struct rrset_parse* rrset, struct rr_parse* prev, struct rr_parse* rr, + struct sockaddr_storage* addr, socklen_t addrlen); + #endif /* UTIL_DATA_MSGPARSE_H */ |
