#INSTALL = $(srcdir)/install-sh -c
#INSTALL_PROGRAM = $(INSTALL)
-LIBDNS_SOURCES=rdata.c util.c
+LIBDNS_SOURCES=rdata.c util.c rr.c
LIBDNS_HEADERS=rdata.h prototype.h rr.h packet.h
LIBDNS_OBJECTS=$(LIBDNS_SOURCES:.c=.o)
#define _PROTOTYPE_H
/* util.c */
-void *xmalloc(size_t);
-void xprintf_rd_field(t_rdata_field *);
+void *xmalloc(size_t);
+void *xrealloc(void *, size_t);
+void xprintf_rd_field(t_rdata_field *);
#endif /* _PROTOTYPE_H */
t_rd_type rd_field_type(t_rdata_field *);
t_rdata_field *rd_field_new(uint16_t, t_rd_type, uint8_t *);
uint8_t *rd_field_data(t_rdata_field *);
-void rd_field__destroy(t_rdata_field *);
+void rd_field_destroy(t_rdata_field *);
#endif /* _RDATA_H */
-
#include "rdata.h"
#include "rr.h"
-
+#include "prototype.h"
/*
* create a new rr structure.
if (NULL == new)
return NULL;
+ rr_set_rd_count(new, 0);
return(new);
}
-
-/* do we need access functions for all these members? */
-
/*
* set the owner in the rr structure
*/
void
-rr_set_owner(t_rr *rr, uint8_t owner)
+rr_set_owner(t_rr *rr, uint8_t *owner)
{
rr->_owner = owner;
}
rr->_ttl = ttl;
}
+/*
+ * set the rd_count in the rr
+ */
void
rr_set_rd_count(t_rr *rr, uint16_t count)
{
rr->_rd_count = count;
}
+/*
+ * set the class in the rr
+ */
void
rr_set_class(t_rr *rr, t_class klass)
{
rr->_klass = klass;
}
+/*
+ * set rd_field member in the rr, it will be
+ * placed in the next available spot
+ */
+void
+rr_set_rd_field(t_rr *rr, t_rdata_field f)
+{
+ uint16_t rd_count;
+
+ rd_count = rr_rd_count(rr);
+ /* grow the array */
+ rr->rdata_fields = xrealloc(rr->rdata_fields, ++rd_count);
+
+ /* add the new member */
+ rr->rdata_fields[rd_count] = f;
+
+ rr_set_rd_count(rr, rd_count);
+}
/*
* return the owner name of an rr structure
*/
-uint8_t
+uint8_t *
rr_owner(t_rr *rr)
{
return (rr->_owner);
{
return (rr->_ttl);
}
+
+/*
+ * return the rd_count of an rr structure
+ */
+uint16_t
+rr_rd_count(t_rr *rr)
+{
+ return (rr->_rd_count);
+}
};
typedef struct type_struct_rrset t_rrset;
+/* prototypes */
+t_rr * rr_new(void);
+void rr_set_owner(t_rr *, uint8_t *);
+void rr_set_ttl(t_rr *, uint16_t);
+void rr_set_rd_count(t_rr *, uint16_t);
+void rr_set_class(t_rr *, t_class);
+void rr_set_rd_field(t_rr *, t_rdata_field);;
+uint8_t * rr_owner(t_rr *);
+uint8_t rr_ttl(t_rr *);
+uint16_t rr_rd_count(t_rr *);
+
#endif /* _RR_H */
xmalloc(size_t s)
{
void *p;
-
p = (void*)malloc(s);
+ return p;
+}
+void *
+xrealloc(void *p, size_t s)
+{
+ p = (void*)realloc(p, s);
return p;
}