], [AC_INCLUDES_DEFAULT]
)
-AC_CHECK_LIB(pcap, pcap_open_offline,, [
- AC_MSG_ERROR([Can't find pcap library (needed for dpa)])
- ]
-)
-
-AC_CHECK_HEADER(pcap.h,, [
- AC_MSG_ERROR([Can't find pcap library headers (needed for dpa)])
- ], [AC_INCLUDES_DEFAULT]
-)
+#AC_CHECK_LIB(pcap, pcap_open_offline,, [
+# AC_MSG_ERROR([Can't find pcap library (needed for dpa)])
+# ]
+#)
AC_CHECK_FUNCS(isblank)
int line_nr;
size_t split;
size_t i;
- bool splitting;
+ int splitting;
size_t file_counter;
char filename[255];
progname = strdup(argv[0]);
split = 0;
- splitting = false; /* when true we are about to split */
+ splitting = 0; /* when true we are about to split */
file_counter = 1;
+ lastname = NULL;
while ((c = getopt(argc, argv, "n:")) != -1) {
switch(c) {
ldns_rr_print(stdout,
ldns_rr_list_rr(zrrs, i));
- lastname = ldns_rr_owner(ldns_rr_list_rr(zrrs, i));
+ if (i > 0 && (i % split) == 0) {
+ printf("%d %d\n", i, (i & split));
+ splitting = 1;
+ }
+
+ if (splitting == 1 &&
+ ldns_dname_compare(ldns_rr_owner(ldns_rr_list_rr(zrrs, i)), lastname) == 0) {
+ /* equal names, don't split yet */
+ } else {
+ /* now we are ready to split */
+ splitting = 2;
+ }
+ if (splitting == 2) {
+ /* SPLIT */
+ printf("LDNS INTENT TO SPLIT !!!! \n");
+ lastname = NULL;
+ continue;
+ }
+
+ lastname = ldns_rr_owner(ldns_rr_list_rr(zrrs, i));
}
/* fclose(fp); */
} else {
snprintf(rr_str, LDNS_MAX_LINELEN, "%s IN A %s", word, addr);
}
- rr = ldns_rr_new_frm_str(rr_str, 0, NULL);
+ rr = ldns_rr_new_frm_str(rr_str, 0, NULL, NULL);
if (rr) {
ldns_rr_list_push_rr(list, ldns_rr_clone(rr));
}
snprintf(rrstr, rrstrlen, "%s IN %s %s", fqdn,
strchr(ipaddr, ':') ? "AAAA" : "A", ipaddr);
- up_rr = ldns_rr_new_frm_str(rrstr, ttl, NULL);
+ up_rr = ldns_rr_new_frm_str(rrstr, ttl, NULL, NULL);
if (!up_rr) {
ldns_rr_list_deep_free(up_rrlist);
free(rrstr);
*/
ldns_rdf *ldns_rdf_clone(const ldns_rdf *rd);
-/**
- * concatenate two rdfs (of the same type!) together. Left
- * is modified in this operation.
- * \param[in] left the left part of the new rdf
- * \param[in] right the right part of the new rdf
- * \return true when it succeeds otherwise false
- */
-bool ldns_rdf_cat(ldns_rdf *left, ldns_rdf *right);
-
-
/**
* compares two rdf's on their wire formats.
* (To order dnames according to rfc4034, use ldns_dname_compare)
* \param[in] str the string to convert
* \param[in] default_ttl pointer to a default ttl for the rr. If 0 DEF_TTL will be used
* \param[in] origin when the owner is relative add this
+ * \param prev the previous ownername. the function overwrite this with
+ * the current found ownername.
* \return the new rr
*/
-ldns_rr* ldns_rr_new_frm_str(const char *str, uint16_t default_ttl, ldns_rdf *origin);
+ldns_rr* ldns_rr_new_frm_str(const char *str, uint16_t default_ttl, ldns_rdf *origin, ldns_rdf **prev);
/**
* creates a new rr from a file containing a string.
* the pointer will be updated if the file contains a $TTL directive
* \param[in] origin when the owner is relative add this
* the pointer will be updated if the file contains a $ORIGIN directive
+ * \param[in] prev when the owner is whitespaces use this as the * ownername
+ * the pointer will be updated after the call
* \return ldns_rr*
*/
-ldns_rr* ldns_rr_new_frm_fp(FILE *fp, uint16_t *default_ttl, ldns_rdf **origin);
+ldns_rr* ldns_rr_new_frm_fp(FILE *fp, uint16_t *default_ttl, ldns_rdf **origin, ldns_rdf **prev);
/**
* creates a new rr from a file containing a string.
* \param[in] origin when the owner is relative add this
* the pointer will be updated if the file contains a $ORIGIN directive
* \param[in] line_nr pointer to an integer containing the current line number (for debugging purposes)
+ * \param[in] prev when the owner is whitespaces use this as the * ownername
+ * the pointer will be updated after the call
* \return ldns_rr*
*/
-ldns_rr* ldns_rr_new_frm_fp_l(FILE *fp, uint16_t *default_ttl, ldns_rdf **origin, int *line_nr);
+ldns_rr* ldns_rr_new_frm_fp_l(FILE *fp, uint16_t *default_ttl, ldns_rdf **origin, ldns_rdf **prev, int *line_nr);
/**
* sets the owner in the rr structure.
ldns_rdf_data(r)));
}
-/* we modify left! */
-bool
-ldns_rdf_cat(ldns_rdf *left, ldns_rdf *right)
-{
- uint8_t *d;
- size_t new;
-
- if (ldns_rdf_get_type(left) != ldns_rdf_get_type(right)) {
- return false;
- }
-
- d = ldns_rdf_data(left);
- new =ldns_rdf_size(left) + ldns_rdf_size(right);
-
- d = LDNS_XREALLOC(d, uint8_t, new);
- if (!d) {
- return false;
- }
-
- /* this -1 is ONLY TEST WITH LDNS_RDF_TYPE_DNAME XXX */
- memcpy(d + ldns_rdf_size(left) - 1, ldns_rdf_data(right), ldns_rdf_size(right));
- ldns_rdf_set_size(left, new);
- ldns_rdf_set_data(left, d);
- return true;
-}
-
void
ldns_rdf_deep_free(ldns_rdf *rd)
{
* miek.nl. IN MX 10 elektron.atoom.net
*/
ldns_rr *
-ldns_rr_new_frm_str(const char *str, uint16_t default_ttl, ldns_rdf *origin)
+ldns_rr_new_frm_str(const char *str, uint16_t default_ttl, ldns_rdf *origin, ldns_rdf **prev)
{
ldns_rr *new;
const ldns_rr_descriptor *desc;
ldns_rr_free(new);
return NULL;
}
+
if (ldns_bget_token(rr_buf, ttl, "\t\n ", 21) == -1) {
LDNS_FREE(owner);
LDNS_FREE(ttl);
}
} else {
if (strlen(owner) == 0) {
- if (origin) {
+ /* no ownername was given, try prev, if that fails
+ * origin, else default to root */
+ if (prev) {
+ ldns_rr_set_owner(new, ldns_rdf_clone(*prev));
+ } else if (origin) {
ldns_rr_set_owner(new, ldns_rdf_clone(origin));
} else {
ldns_rr_set_owner(new, ldns_dname_new_frm_str("."));
ldns_buffer_free(rr_buf);
ldns_rr_free(new);
return NULL;
- }
+ }
+ }
+ if (prev) {
+ *prev = ldns_rr_owner(new);
}
}
}
/* check if the origin should be concatenated */
if (ldns_rr_descriptor_field_type(desc, r_cnt) == LDNS_RDF_TYPE_DNAME &&
rd_strlen > 1 &&
- rd[rd_strlen - 1] != '.' &&
- origin) {
- if (!ldns_rdf_cat(r, origin)) {
+ !ldns_dname_str_absolute(rd) && origin) {
+ if (!ldns_dname_cat(r, origin)) {
/* don't know if to quit */
/* return NULL;*/
}
}
ldns_rr *
-ldns_rr_new_frm_fp(FILE *fp, uint16_t *ttl, ldns_rdf **origin)
+ldns_rr_new_frm_fp(FILE *fp, uint16_t *ttl, ldns_rdf **origin, ldns_rdf **prev)
{
- return ldns_rr_new_frm_fp_l(fp, ttl, origin, NULL);
+ return ldns_rr_new_frm_fp_l(fp, ttl, origin, prev, NULL);
}
ldns_rr *
-ldns_rr_new_frm_fp_l(FILE *fp, uint16_t *default_ttl, ldns_rdf **origin, int *line_nr)
+ldns_rr_new_frm_fp_l(FILE *fp, uint16_t *default_ttl, ldns_rdf **origin, ldns_rdf **prev, int *line_nr)
{
char *line;
ldns_rr *rr;
*default_ttl = (uint16_t) atoi(keyword + 5);
}
} else {
-
if (origin) {
- rr = ldns_rr_new_frm_str((const char*) line, ttl, *origin);
+ rr = ldns_rr_new_frm_str((const char*) line, ttl, *origin, prev);
} else {
- rr = ldns_rr_new_frm_str((const char*) line, ttl, NULL);
+ rr = ldns_rr_new_frm_str((const char*) line, ttl, NULL, prev);
}
}
uint16_t my_ttl = ttl;
ldns_rr_class my_class = c;
ldns_rr *last_rr = NULL;
-
+ ldns_rdf *my_prev = NULL;
uint8_t i;
newzone = ldns_zone_new();
i = 0;
do {
- rr = ldns_rr_new_frm_fp_l(fp, &my_ttl, &my_origin, line_nr);
+ rr = ldns_rr_new_frm_fp_l(fp, &my_ttl, &my_origin, &my_prev, line_nr);
i++;
} while (!rr && i <= 9);
}
while(!feof(fp)) {
- rr = ldns_rr_new_frm_fp_l(fp, &my_ttl, &my_origin, line_nr);
+ rr = ldns_rr_new_frm_fp_l(fp, &my_ttl, &my_origin, &my_prev, line_nr);
if (rr) {
last_rr = rr;
if (!ldns_zone_push_rr(newzone, rr)) {