chiark / gitweb /
Fix typo in changelog entry for 1.6.1
[adns.git] / src / addrfam.c
index 4d2fe060c75c046400a5fe506958884031c02578..dece6e3d1ce1efeb578d314ed520cd7219e509da 100644 (file)
@@ -3,15 +3,12 @@
  * - address-family specific code
  */
 /*
- *  This file is part of adns, which is
- *    Copyright (C) 1997-2000,2003,2006  Ian Jackson
- *    Copyright (C) 1999-2000,2003,2006  Tony Finch
- *    Copyright (C) 1991 Massachusetts Institute of Technology
- *  (See the file INSTALL for full details.)
+ *  This file is part of adns, which is Copyright Ian Jackson
+ *  and contributors (see the file INSTALL for full details).
  *  
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2, or (at your option)
+ *  the Free Software Foundation; either version 3, or (at your option)
  *  any later version.
  *  
  *  This program is distributed in the hope that it will be useful,
@@ -20,8 +17,7 @@
  *  GNU General Public License for more details.
  *  
  *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software Foundation,
- *  Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 
+ *  along with this program; if not, write to the Free Software Foundation.
  */
 
 #include <stdlib.h>
@@ -256,9 +252,18 @@ static bool addrtext_scope_use_ifname(const struct sockaddr *sa) {
     IN6_IS_ADDR_MC_LINKLOCAL(in6);
 }
 
+static int textaddr_check_qf(adns_queryflags flags) {
+  if (flags & ~(adns_queryflags)(adns_qf_addrlit_scope_forbid|
+                                adns_qf_addrlit_scope_numeric|
+                                adns_qf_addrlit_ipv4_quadonly|
+                                0x40000000))
+    return ENOSYS;
+  return 0;
+}
+
 int adns_text2addr(const char *text, uint16_t port, adns_queryflags flags,
                   struct sockaddr *sa, socklen_t *salen_io) {
-  int af;
+  int r, af;
   char copybuf[INET6_ADDRSTRLEN];
   const char *parse=text;
   const char *scopestr=0;
@@ -266,6 +271,8 @@ int adns_text2addr(const char *text, uint16_t port, adns_queryflags flags,
   void *dst;
   uint16_t *portp;
 
+  r= textaddr_check_qf(flags);  if (r) return r;
+
 #define INVAL(how) do{                         \
   af_debug("invalid: %s: `%s'", how, text);    \
   return EINVAL;                               \
@@ -389,7 +396,9 @@ int adns_text2addr(const char *text, uint16_t port, adns_queryflags flags,
 int adns_addr2text(const struct sockaddr *sa, adns_queryflags flags,
                   char *buffer, int *buflen_io, int *port_r) {
   const void *src;
-  int port;
+  int r, port;
+
+  r= textaddr_check_qf(flags);  if (r) return r;
 
   if (*buflen_io < ADNS_ADDR2TEXT_BUFLEN) {
     *buflen_io = ADNS_ADDR2TEXT_BUFLEN;