chiark / gitweb /
reverse parsing: Pass dgram and labstart instead of label
[adns.git] / src / internal.h
index 0b39418433c859b464aa2c19606769e5dd728e0c..5312fe1ac1520f1ea3241c340e2ceca09750ff0e 100644 (file)
@@ -39,6 +39,7 @@ typedef unsigned char byte;
 #include <errno.h>
 #include <string.h>
 #include <stdlib.h>
+#include <stdbool.h>
 
 #include <sys/time.h>
 
@@ -198,7 +199,8 @@ typedef struct typeinfo {
 
   adns_status (*checklabel)(adns_state ads, adns_queryflags flags,
                            union checklabel_state *cls, qcontext *ctx,
-                           int labnum, const char *label, int lablen);
+                           int labnum, const char *dgram,
+                           int labstart, int lablen);
   /* Check a label from the query domain string.  The label is not
    * necessarily null-terminated.  The hook can refuse the query's submission
    * by returning a nonzero status.  State can be stored in *cls between
@@ -230,7 +232,7 @@ typedef struct typeinfo {
 adns_status adns__ckl_hostname(adns_state ads, adns_queryflags flags,
                               union checklabel_state *cls,
                               qcontext *ctx, int labnum,
-                              const char *label, int lablen);
+                              const char *dgram, int labstart, int lablen);
   /* implemented in query.c, used by types.c as default
    * and as part of implementation for some fancier types
    * doesn't require any state */
@@ -471,7 +473,8 @@ extern int adns__make_reverse_domain(const struct sockaddr *sa,
  */
 
 extern int adns__revparse_label(struct revparse_state *rps, int labnum,
-                               const char *label, int lablen);
+                               const char *dgram,
+                               int labstart, int lablen);
 /* Parse a label in a reverse-domain name, given its index labnum (starting
  * from zero), a pointer to its contents (which need not be null-terminated),
  * and its length.  The state in *rps is initialized implicitly when labnum
@@ -481,7 +484,8 @@ extern int adns__revparse_label(struct revparse_state *rps, int labnum,
  * definitely invalid and the parse must be abandoned.
  */
 
-extern int adns__revparse_done(struct revparse_state *rps, int nlabels,
+extern int adns__revparse_done(struct revparse_state *rps,
+                              const char *dgram, int nlabels,
                               adns_rrtype *rrtype_r, adns_sockaddr *addr_r);
 /* Finishes parsing a reverse-domain name, given the total number of
  * labels in the name.  On success, fills in the af and protocol
@@ -865,6 +869,8 @@ void adns__update_expires(adns_query qu, unsigned long ttl,
 
 int vbuf__append_quoted1035(vbuf *vb, const byte *buf, int len);
 
+bool adns__labels_equal(const byte *a, int al, const byte *b, int bl);
+
 /* From event.c: */
 
 void adns__tcp_broken(adns_state ads, const char *what, const char *why);
@@ -913,6 +919,9 @@ static inline int ctype_digit(int c) { return c>='0' && c<='9'; }
 static inline int ctype_alpha(int c) {
   return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z');
 }
+static inline int ctype_toupper(int c) {
+  return ctype_alpha(c) ? (c & ~32) : c;
+}
 static inline int ctype_822special(int c) {
   return strchr("()<>@,;:\\\".[]",c) != 0;
 }