Skip to content
Snippets Groups Projects
Commit 7d513d34 authored by Jan Kadlec's avatar Jan Kadlec
Browse files

Moved conversion functions from zcompile.c file to parser-util.c. Disabled zone file locking.

parent d754f06a
No related branches found
No related tags found
No related merge requests found
......@@ -339,6 +339,7 @@ static char *rdata_txt_data_to_string(const uint8_t *data)
char *rdata_text_to_string(knot_rdata_item_t item)
{
printf("Size of the whole item: %u\n", item.raw_data[0]);
uint16_t size = item.raw_data[0];
char *ret = malloc(sizeof(char) * size * 2) ;
if (ret == NULL) {
......
This diff is collapsed.
......@@ -61,6 +61,280 @@ uint32_t strtoserial(const char *nptr, const char **endptr);
void write_uint32(void *dst, uint32_t data);
uint32_t strtottl(const char *nptr, const char **endptr);
time_t mktime_from_utc(const struct tm *tm);
/*!< Conversions from text to wire. */
/*!
* \brief Converts hex text format to wireformat.
*
* \param hex String to be converted.
* \param len Length of string.
*
* \return Converted wireformat.
*/
uint16_t *zparser_conv_hex(const char *hex, size_t len);
/*!
* \brief Converts hex text format with length to wireformat.
*
* \param hex String to be converted/.
* \param len Length of string.
*
* \return Converted wireformat.
*/
uint16_t *zparser_conv_hex_length(const char *hex, size_t len);
/*!
* \brief Converts time string to wireformat.
*
* \param time Time string to be converted.
*
* \return Converted wireformat.
*/
uint16_t *zparser_conv_time(const char *time);
/*!
* \brief Converts a protocol and a list of service port numbers
* (separated by spaces) in the rdata to wireformat
*
* \param protostr Protocol string.
* \param servicestr Service string.
*
* \return Converted wireformat.
*/
uint16_t *zparser_conv_services(const char *protostr, char *servicestr);
/*!
* \brief Converts serial to wireformat.
*
* \param serialstr Serial string.
*
* \return Converted wireformat.
*/
uint16_t *zparser_conv_serial(const char *serialstr);
/*!
* \brief Converts period to wireformat.
*
* \param periodstr Period string.
*
* \return Converted wireformat.
*/
uint16_t *zparser_conv_period(const char *periodstr);
/*!
* \brief Converts short int to wireformat.
*
* \param text String containing short int.
*
* \return Converted wireformat.
*/
uint16_t *zparser_conv_short(const char *text);
/*!
* \brief Converts long int to wireformat.
*
* \param text String containing long int.
*
* \return Converted wireformat.
*/
uint16_t *zparser_conv_long(const char *text);
/*!
* \brief Converts byte to wireformat.
*
* \param text String containing byte.
*
* \return Converted wireformat.
*/
uint16_t *zparser_conv_byte(const char *text);
/*!
* \brief Converts A rdata string to wireformat.
*
* \param text String containing A rdata.
*
* \return Converted wireformat.
*/
uint16_t *zparser_conv_a(const char *text);
/*!
* \brief Converts AAAA rdata string to wireformat.
*
* \param text String containing AAAA rdata.
*
* \return Converted wireformat.
*/
uint16_t *zparser_conv_aaaa(const char *text);
/*!
* \brief Converts text string to wireformat.
*
* \param text Text string.
* \param len Length of string.
*
* \return Converted wireformat.
*/
uint16_t *zparser_conv_text(const char *text, size_t len);
/*!
* \brief Converts domain name string to wireformat.
*
* \param name Domain name string.
* \param len Length of string.
*
* \return Converted wireformat.
*/
uint16_t *zparser_conv_dns_name(const uint8_t* name, size_t len);
/*!
* \brief Converts base32 encoded string to wireformat.
* TODO consider replacing with our implementation.
*
* \param b32 Base32 encoded string.
*
* \return Converted wireformat.
*/
uint16_t *zparser_conv_b32(const char *b32);
/*!
* \brief Converts base64 encoded string to wireformat.
* TODO consider replacing with our implementation.
*
* \param b64 Base64 encoded string.
*
* \return Converted wireformat.
*/
uint16_t *zparser_conv_b64(const char *b64);
/*!
* \brief Converts RR type string to wireformat.
*
* \param rr RR type string.
*
* \return Converted wireformat.
*/
uint16_t *zparser_conv_rrtype(const char *rr);
/*!
* \brief Converts NXT string to wireformat.
*
* \param nxtbits NXT string.
*
* \return Converted wireformat.
*/
uint16_t *zparser_conv_nxt(uint8_t *nxtbits);
/*!
* \brief Converts NSEC bitmap to wireformat.
*
* \param nsecbits[][] NSEC bits.
*
* \return Converted wireformat.
*/
uint16_t *zparser_conv_nsec(uint8_t nsecbits[NSEC_WINDOW_COUNT]
[NSEC_WINDOW_BITS_SIZE]);
/*!
* \brief Converts LOC string to wireformat.
*
* \param str LOC string.
*
* \return Converted wireformat.
*/
uint16_t *zparser_conv_loc(char *str);
/*!
* \brief Converts algorithm string to wireformat.
*
* \param algstr Algorithm string.
*
* \return Converted wireformat.
*/
uint16_t *zparser_conv_algorithm(const char *algstr);
/*!
* \brief Converts certificate type string to wireformat.
*
* \param typestr Certificate type mnemonic string.
*
* \return Converted wireformat.
*/
uint16_t *zparser_conv_certificate_type(const char *typestr);
/*!
* \brief Converts APL data to wireformat.
*
* \param str APL data string.
*
* \return Converted wireformat.
*/
uint16_t *zparser_conv_apl_rdata(char *str);
/*!
* \brief Parses unknown rdata.
*
* \param type Type of data.
* \param wireformat Wireformat of data.
*
* \return Converted wireformat.
*/
void parse_unknown_rdata(uint16_t type, uint16_t *wireformat);
/*!
* \brief Converts TTL string to int.
*
* \param ttlstr String
* \param error Error code.
*
* \return Converted wireformat.
*/
uint32_t zparser_ttl2int(const char *ttlstr, int* error);
/*!
* \brief Adds wireformat to temporary list of rdata items.
*
* \param data Wireformat to be added.
*/
void zadd_rdata_wireformat(uint16_t *data);
/*!
* \brief Adds TXT wireformat to temporary list of rdata items.
*
* \param data Wireformat to be added.
* \param first This is first text to be added.
*/
void zadd_rdata_txt_wireformat(uint16_t *data, int first);
/*!
* \brief Cleans after using zadd_rdata_txt_wireformat().
*/
void zadd_rdata_txt_clean_wireformat();
/*!
* \brief Adds domain name to temporary list of rdata items.
*
* \param domain Domain name to be added.
*/
void zadd_rdata_domain(knot_dname_t *domain);
/*!
* \brief Sets bit in NSEC bitmap.
*
* \param bits[][] NSEC bitmaps.
* \param index Index on which bit is to be set.
*/
void set_bitnsec(uint8_t bits[NSEC_WINDOW_COUNT][NSEC_WINDOW_BITS_SIZE],
uint16_t index);
/*!
* \brief Allocate and init wireformat.
*
* \param data Data to be copied into newly created wireformat.
* \param size Size of data.
*
* \return Allocated wireformat.
*/
uint16_t *alloc_rdata_init(const void *data, size_t size);
uint16_t rrsig_type_covered(knot_rrset_t *rrset);
#endif /* _KNOTD_PARSER_UTIL_H_ */
/*! @} */
This diff is collapsed.
......@@ -143,276 +143,6 @@ void zc_warning_prev_line(const char *fmt, ...);
*/
int process_rr();
/*!
* \brief Converts hex text format to wireformat.
*
* \param hex String to be converted.
* \param len Length of string.
*
* \return Converted wireformat.
*/
uint16_t *zparser_conv_hex(const char *hex, size_t len);
/*!
* \brief Converts hex text format with length to wireformat.
*
* \param hex String to be converted/.
* \param len Length of string.
*
* \return Converted wireformat.
*/
uint16_t *zparser_conv_hex_length(const char *hex, size_t len);
/*!
* \brief Converts time string to wireformat.
*
* \param time Time string to be converted.
*
* \return Converted wireformat.
*/
uint16_t *zparser_conv_time(const char *time);
/*!
* \brief Converts a protocol and a list of service port numbers
* (separated by spaces) in the rdata to wireformat
*
* \param protostr Protocol string.
* \param servicestr Service string.
*
* \return Converted wireformat.
*/
uint16_t *zparser_conv_services(const char *protostr, char *servicestr);
/*!
* \brief Converts serial to wireformat.
*
* \param serialstr Serial string.
*
* \return Converted wireformat.
*/
uint16_t *zparser_conv_serial(const char *serialstr);
/*!
* \brief Converts period to wireformat.
*
* \param periodstr Period string.
*
* \return Converted wireformat.
*/
uint16_t *zparser_conv_period(const char *periodstr);
/*!
* \brief Converts short int to wireformat.
*
* \param text String containing short int.
*
* \return Converted wireformat.
*/
uint16_t *zparser_conv_short(const char *text);
/*!
* \brief Converts long int to wireformat.
*
* \param text String containing long int.
*
* \return Converted wireformat.
*/
uint16_t *zparser_conv_long(const char *text);
/*!
* \brief Converts byte to wireformat.
*
* \param text String containing byte.
*
* \return Converted wireformat.
*/
uint16_t *zparser_conv_byte(const char *text);
/*!
* \brief Converts A rdata string to wireformat.
*
* \param text String containing A rdata.
*
* \return Converted wireformat.
*/
uint16_t *zparser_conv_a(const char *text);
/*!
* \brief Converts AAAA rdata string to wireformat.
*
* \param text String containing AAAA rdata.
*
* \return Converted wireformat.
*/
uint16_t *zparser_conv_aaaa(const char *text);
/*!
* \brief Converts text string to wireformat.
*
* \param text Text string.
* \param len Length of string.
*
* \return Converted wireformat.
*/
uint16_t *zparser_conv_text(const char *text, size_t len);
/*!
* \brief Converts domain name string to wireformat.
*
* \param name Domain name string.
* \param len Length of string.
*
* \return Converted wireformat.
*/
uint16_t *zparser_conv_dns_name(const uint8_t* name, size_t len);
/*!
* \brief Converts base32 encoded string to wireformat.
* TODO consider replacing with our implementation.
*
* \param b32 Base32 encoded string.
*
* \return Converted wireformat.
*/
uint16_t *zparser_conv_b32(const char *b32);
/*!
* \brief Converts base64 encoded string to wireformat.
* TODO consider replacing with our implementation.
*
* \param b64 Base64 encoded string.
*
* \return Converted wireformat.
*/
uint16_t *zparser_conv_b64(const char *b64);
/*!
* \brief Converts RR type string to wireformat.
*
* \param rr RR type string.
*
* \return Converted wireformat.
*/
uint16_t *zparser_conv_rrtype(const char *rr);
/*!
* \brief Converts NXT string to wireformat.
*
* \param nxtbits NXT string.
*
* \return Converted wireformat.
*/
uint16_t *zparser_conv_nxt(uint8_t *nxtbits);
/*!
* \brief Converts NSEC bitmap to wireformat.
*
* \param nsecbits[][] NSEC bits.
*
* \return Converted wireformat.
*/
uint16_t *zparser_conv_nsec(uint8_t nsecbits[NSEC_WINDOW_COUNT]
[NSEC_WINDOW_BITS_SIZE]);
/*!
* \brief Converts LOC string to wireformat.
*
* \param str LOC string.
*
* \return Converted wireformat.
*/
uint16_t *zparser_conv_loc(char *str);
/*!
* \brief Converts algorithm string to wireformat.
*
* \param algstr Algorithm string.
*
* \return Converted wireformat.
*/
uint16_t *zparser_conv_algorithm(const char *algstr);
/*!
* \brief Converts certificate type string to wireformat.
*
* \param typestr Certificate type mnemonic string.
*
* \return Converted wireformat.
*/
uint16_t *zparser_conv_certificate_type(const char *typestr);
/*!
* \brief Converts APL data to wireformat.
*
* \param str APL data string.
*
* \return Converted wireformat.
*/
uint16_t *zparser_conv_apl_rdata(char *str);
/*!
* \brief Parses unknown rdata.
*
* \param type Type of data.
* \param wireformat Wireformat of data.
*
* \return Converted wireformat.
*/
void parse_unknown_rdata(uint16_t type, uint16_t *wireformat);
/*!
* \brief Converts TTL string to int.
*
* \param ttlstr String
* \param error Error code.
*
* \return Converted wireformat.
*/
uint32_t zparser_ttl2int(const char *ttlstr, int* error);
/*!
* \brief Adds wireformat to temporary list of rdata items.
*
* \param data Wireformat to be added.
*/
void zadd_rdata_wireformat(uint16_t *data);
/*!
* \brief Adds TXT wireformat to temporary list of rdata items.
*
* \param data Wireformat to be added.
* \param first This is first text to be added.
*/
void zadd_rdata_txt_wireformat(uint16_t *data, int first);
/*!
* \brief Cleans after using zadd_rdata_txt_wireformat().
*/
void zadd_rdata_txt_clean_wireformat();
/*!
* \brief Adds domain name to temporary list of rdata items.
*
* \param domain Domain name to be added.
*/
void zadd_rdata_domain(knot_dname_t *domain);
/*!
* \brief Sets bit in NSEC bitmap.
*
* \param bits[][] NSEC bitmaps.
* \param index Index on which bit is to be set.
*/
void set_bitnsec(uint8_t bits[NSEC_WINDOW_COUNT][NSEC_WINDOW_BITS_SIZE],
uint16_t index);
/*!
* \brief Allocate and init wireformat.
*
* \param data Data to be copied into newly created wireformat.
* \param size Size of data.
*
* \return Allocated wireformat.
*/
uint16_t *alloc_rdata_init(const void *data, size_t size);
/*!
* \brief Parses and creates zone from given file.
*
......
......@@ -3,6 +3,7 @@
* \file zparser.y
*
* \author modifications by Jan Kadlec <jan.kadlec@nic.cz>,
* notable changes: normal allocation, parser is reentrant.
* most of the code by NLnet Labs
* Copyright (c) 2001-2006, NLnet Labs. All rights reserved.
* See LICENSE for the license.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment