"Fossies" - the Fresh Open Source Software Archive

Member "libspf2-1.2.10/src/libspf2/spf_dns_test.c" (28 Jan 2012, 19830 Bytes) of package /linux/privat/libspf2-1.2.10.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "spf_dns_test.c" see the Fossies "Dox" file reference documentation.

    1 /* 
    2  * This program is free software; you can redistribute it and/or modify
    3  * it under the terms of either:
    4  * 
    5  *   a) The GNU Lesser General Public License as published by the Free
    6  *      Software Foundation; either version 2.1, or (at your option) any
    7  *      later version, 
    8  * 
    9  *   OR
   10  * 
   11  *   b) The two-clause BSD license.
   12  *
   13  * These licenses can be found with the distribution in the file LICENSES
   14  */
   15 
   16 #include "spf_sys_config.h"
   17 
   18 #ifdef STDC_HEADERS
   19 # include <stdlib.h>       /* malloc / free */
   20 #endif
   21 
   22 #ifdef HAVE_STRING_H
   23 # include <string.h>       /* strstr / strdup */
   24 #else
   25 # ifdef HAVE_STRINGS_H
   26 #  include <strings.h>       /* strstr / strdup */
   27 # endif
   28 #endif
   29 
   30 #ifdef HAVE_NETDB_H
   31 #include <netdb.h>
   32 #endif
   33 
   34 #include "spf.h"
   35 #include "spf_dns.h"
   36 #include "spf_internal.h"
   37 #include "spf_dns_internal.h"
   38 #include "spf_dns_test.h"
   39 #include "spf_dns_zone.h"
   40 
   41 
   42     
   43 #define USE_SPF_SPEC_ZONE
   44 #define USE_MAILZONE_ZONE
   45 #define USE_EXT_MAILZONE_ZONE
   46 
   47 
   48 typedef struct
   49 {
   50     const char      *domain;
   51     int              rr_type;
   52     SPF_dns_stat_t   herrno;
   53     const char      *data;
   54 } SPF_dns_test_data_t;
   55     
   56 
   57 
   58 
   59 static const SPF_dns_test_data_t SPF_dns_db[] = {
   60     { "localhost",
   61       ns_t_a,   NETDB_SUCCESS, "127.0.0.1" },
   62 
   63 #ifdef USE_SPF_SPEC_ZONE
   64     { "example.com",
   65       ns_t_a,   NETDB_SUCCESS, "192.0.2.3" },
   66     { "example.com",
   67       ns_t_mx,  NETDB_SUCCESS, "mx.example.org" },
   68     { "example.com",
   69       ns_t_txt, NETDB_SUCCESS, "v=spf1 mx -all" },
   70     { "3.2.0.192.in-addr.arpa",
   71       ns_t_ptr, NETDB_SUCCESS, "mx.example.org" },
   72     { "1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.5.d.a.0.8.0.0.0.2.5.0.f.5.in6.arpa",
   73       ns_t_ptr, NETDB_SUCCESS, "mx.example.org" },
   74 
   75     { "noexist.example.com",
   76       ns_t_a,   HOST_NOT_FOUND, NULL },
   77     { "mx.example.org",
   78       ns_t_a,   NETDB_SUCCESS, "192.0.2.3" },
   79     { "mx.example.org",
   80       ns_t_aaaa, NETDB_SUCCESS, "5f05:2000:80ad:5800::1" },
   81     { "email.example.com",
   82       ns_t_txt, NETDB_SUCCESS, "v=spf1 -all" },
   83     { "*.example.com",
   84       ns_t_any, HOST_NOT_FOUND, NULL },
   85     { "*.example.org",
   86       ns_t_any, HOST_NOT_FOUND, NULL },
   87     { "*.example.net",
   88       ns_t_any, HOST_NOT_FOUND, NULL },
   89 #endif
   90 
   91 #ifdef USE_MAILZONE_ZONE
   92     { "01.spf1-test.mailzone.com",
   93       ns_t_txt, NETDB_SUCCESS, "v=spf1                                                             " },
   94     { "02.spf1-test.mailzone.com",
   95       ns_t_txt, NETDB_SUCCESS, "v=spf1                                             -all       " },
   96     { "03.spf1-test.mailzone.com",
   97       ns_t_txt, NETDB_SUCCESS, "v=spf1                                             ~all" },
   98     { "05.spf1-test.mailzone.com",
   99       ns_t_txt, NETDB_SUCCESS, "v=spf1                                             default=deny   " },
  100     { "06.spf1-test.mailzone.com",
  101       ns_t_txt, NETDB_SUCCESS, "v=spf1                                             ?all " },
  102     { "07.spf1-test.mailzone.com",
  103       ns_t_txt, NETDB_SUCCESS, "v=spf2                                             default=bogus   " },
  104     { "08.spf1-test.mailzone.com",
  105       ns_t_txt, NETDB_SUCCESS, "v=spf1                       -all      ?all  " },
  106     { "09.spf1-test.mailzone.com",
  107       ns_t_txt, NETDB_SUCCESS, "v=spf1    scope=header-from scope=envelope         -all  " },
  108     { "10.spf1-test.mailzone.com",
  109       ns_t_txt, NETDB_SUCCESS, "v=spf1 mx                                          -all" },
  110     { "10.spf1-test.mailzone.com",
  111       ns_t_mx,  NETDB_SUCCESS, "mx02.spf1-test.mailzone.com" },
  112     { "10.spf1-test.mailzone.com",
  113       ns_t_mx,  NETDB_SUCCESS, "mx03.spf1-test.mailzone.com" },
  114     { "10.spf1-test.mailzone.com",
  115       ns_t_mx,  NETDB_SUCCESS, "mx01.spf1-test.mailzone.com" },
  116     { "11.spf1-test.mailzone.com",
  117       ns_t_txt, NETDB_SUCCESS, "v=spf1    mx:spf1-test.mailzone.com                          -all" },
  118     { "12.spf1-test.mailzone.com",
  119       ns_t_txt, NETDB_SUCCESS, "v=spf1 mx mx:spf1-test.mailzone.com                          -all" },
  120     { "12.spf1-test.mailzone.com",
  121       ns_t_mx,  NETDB_SUCCESS, "mx02.spf1-test.mailzone.com" },
  122     { "12.spf1-test.mailzone.com",
  123       ns_t_mx,  NETDB_SUCCESS, "mx03.spf1-test.mailzone.com" },
  124     { "12.spf1-test.mailzone.com",
  125       ns_t_mx,  NETDB_SUCCESS, "mx01.spf1-test.mailzone.com" },
  126     { "13.spf1-test.mailzone.com",
  127       ns_t_txt, NETDB_SUCCESS, "v=spf1    mx:spf1-test.mailzone.com mx:fallback-relay.spf1-test.mailzone.com -all" },
  128     { "14.spf1-test.mailzone.com",
  129       ns_t_txt, NETDB_SUCCESS, "v=spf1 mx mx:spf1-test.mailzone.com mx:fallback-relay.spf1-test.mailzone.com -all" },
  130     { "14.spf1-test.mailzone.com",
  131       ns_t_mx,  NETDB_SUCCESS, "mx03.spf1-test.mailzone.com" },
  132     { "14.spf1-test.mailzone.com",
  133       ns_t_mx,  NETDB_SUCCESS, "mx01.spf1-test.mailzone.com" },
  134     { "14.spf1-test.mailzone.com",
  135       ns_t_mx,  NETDB_SUCCESS, "mx02.spf1-test.mailzone.com" },
  136     { "20.spf1-test.mailzone.com",
  137       ns_t_a,   NETDB_SUCCESS, "192.0.2.120" },
  138     { "20.spf1-test.mailzone.com",
  139       ns_t_txt, NETDB_SUCCESS, "v=spf1 a                                           -all" },
  140     { "21.spf1-test.mailzone.com",
  141       ns_t_txt, NETDB_SUCCESS, "v=spf1   a:spf1-test.mailzone.com                            -all" },
  142     { "21.spf1-test.mailzone.com",
  143       ns_t_a,   NETDB_SUCCESS, "192.0.2.121" },
  144     { "22.spf1-test.mailzone.com",
  145       ns_t_txt, NETDB_SUCCESS, "v=spf1 a a:spf1-test.mailzone.com                            -all" },
  146     { "22.spf1-test.mailzone.com",
  147       ns_t_a,   NETDB_SUCCESS, "192.0.2.122" },
  148     { "30.spf1-test.mailzone.com",
  149       ns_t_txt, NETDB_SUCCESS, "v=spf1 ptr                                         -all" },
  150     { "30.spf1-test.mailzone.com",
  151       ns_t_a,   NETDB_SUCCESS, "208.210.124.130" },
  152     { "31.spf1-test.mailzone.com",
  153       ns_t_txt, NETDB_SUCCESS, "v=spf1     ptr:spf1-test.mailzone.com                        -all" },
  154     { "31.spf1-test.mailzone.com",
  155       ns_t_a,   NETDB_SUCCESS, "208.210.124.131" },
  156     { "32.spf1-test.mailzone.com",
  157       ns_t_txt, NETDB_SUCCESS, "v=spf1 ptr ptr:spf1-test.mailzone.com                        -all" },
  158     { "32.spf1-test.mailzone.com",
  159       ns_t_a,   NETDB_SUCCESS, "208.210.124.132" },
  160     { "40.spf1-test.mailzone.com",
  161       ns_t_txt, NETDB_SUCCESS, "v=spf1 exists:%{ir}.%{v}._spf.%{d}                    -all" },
  162     { "41.spf1-test.mailzone.com",
  163       ns_t_txt, NETDB_SUCCESS, "v=spf1 exists:%{ir}.%{v}._spf.spf1-test.mailzone.com            -all" },
  164     { "42.spf1-test.mailzone.com",
  165       ns_t_txt, NETDB_SUCCESS, "v=spf1 exists:%{ir}.%{v}._spf.%{d} exists:%{ir}.%{v}._spf.%{d3} -all" },
  166     { "45.spf1-test.mailzone.com",
  167       ns_t_txt, NETDB_SUCCESS, "v=spf1 -a a:spf1-test.mailzone.com                           -all" },
  168     { "45.spf1-test.mailzone.com",
  169       ns_t_a,   NETDB_SUCCESS, "192.0.2.147" },
  170     { "45.spf1-test.mailzone.com",
  171       ns_t_a,   NETDB_SUCCESS, "192.0.2.145" },
  172     { "45.spf1-test.mailzone.com",
  173       ns_t_a,   NETDB_SUCCESS, "192.0.2.146" },
  174     { "50.spf1-test.mailzone.com",
  175       ns_t_txt, NETDB_SUCCESS, "v=spf1 include                                     -all" },
  176     { "51.spf1-test.mailzone.com",
  177       ns_t_txt, NETDB_SUCCESS, "v=spf1 include:42.spf1-test.mailzone.com                  -all" },
  178     { "52.spf1-test.mailzone.com",
  179       ns_t_txt, NETDB_SUCCESS, "v=spf1 include:53.spf1-test.mailzone.com                  -all" },
  180     { "53.spf1-test.mailzone.com",
  181       ns_t_txt, NETDB_SUCCESS, "v=spf1 include:42.spf1-test.mailzone.com                  -all" },
  182     { "54.spf1-test.mailzone.com",
  183       ns_t_txt, NETDB_SUCCESS, "v=spf1 include:42.spf1-test.mailzone.com                  -all" },
  184     { "55.spf1-test.mailzone.com",
  185       ns_t_txt, NETDB_SUCCESS, "v=spf1 include:56.spf1-test.mailzone.com                  -all" },
  186     { "57.spf1-test.mailzone.com",
  187       ns_t_txt, NETDB_SUCCESS, "v=spf1 include:spf1-test.mailzone.com         -all" },
  188     { "58.spf1-test.mailzone.com",
  189       ns_t_txt, NETDB_SUCCESS, "v=spf1 include:59.spf1-test.mailzone.com                  -all" },
  190     { "59.spf1-test.mailzone.com",
  191       ns_t_txt, NETDB_SUCCESS, "v=spf1 include:58.spf1-test.mailzone.com                  -all" },
  192     { "70.spf1-test.mailzone.com",
  193       ns_t_txt, NETDB_SUCCESS, "v=spf1 exists:%{lr+=}.lp._spf.spf1-test.mailzone.com -all" },
  194     { "80.spf1-test.mailzone.com",
  195       ns_t_txt, NETDB_SUCCESS, "v=spf1 a mx exists:%{ir}.%{v}._spf.80.spf1-test.mailzone.com ptr -all" },
  196     { "80.spf1-test.mailzone.com",
  197       ns_t_a,   NETDB_SUCCESS, "208.210.124.180" },
  198     { "90.spf1-test.mailzone.com",
  199       ns_t_txt, NETDB_SUCCESS, "v=spf1  ip4:192.0.2.128/25 -all" },
  200     { "91.spf1-test.mailzone.com",
  201       ns_t_txt, NETDB_SUCCESS, "v=spf1 -ip4:192.0.2.128/25 ip4:192.0.2.0/24 -all" },
  202     { "92.spf1-test.mailzone.com",
  203       ns_t_txt, NETDB_SUCCESS, "v=spf1 ?ip4:192.0.2.192/26 ip4:192.0.2.128/25 -ip4:192.0.2.0/24 -all" },
  204     { "95.spf1-test.mailzone.com",
  205       ns_t_txt, NETDB_SUCCESS, "v=spf1 exists:%{p}.whitelist.spf1-test.mailzone.com -all" },
  206     { "96.spf1-test.mailzone.com",
  207       ns_t_txt, NETDB_SUCCESS, "v=spf1 -exists:%{d}.blacklist.spf1-test.mailzone.com -all" },
  208     { "97.spf1-test.mailzone.com",
  209       ns_t_txt, NETDB_SUCCESS, "v=spf1 exists:%{p}.whitelist.spf1-test.mailzone.com -exists:%{d}.blacklist.spf1-test.mailzone.com -all" },
  210     { "98.spf1-test.mailzone.com",
  211       ns_t_txt, NETDB_SUCCESS, "v=spf1 a/26 mx/26 -all" },
  212     { "98.spf1-test.mailzone.com",
  213       ns_t_mx,  NETDB_SUCCESS, "80.spf1-test.mailzone.com" },
  214     { "98.spf1-test.mailzone.com",
  215       ns_t_a,   NETDB_SUCCESS, "192.0.2.98" },
  216     { "99.spf1-test.mailzone.com",
  217       ns_t_txt, NETDB_SUCCESS, "v=spf1 -all exp=99txt.spf1-test.mailzone.com moo" },
  218     { "99txt.spf1-test.mailzone.com",
  219       ns_t_txt, NETDB_SUCCESS, "u=%{u} s=%{s} d=%{d} t=%{t} h=%{h} i=%{i} %% U=%{U} S=%{S} D=%{D} T=%{T} H=%{H} I=%{I} %% moo" },
  220     { "100.spf1-test.mailzone.com",
  221       ns_t_txt, NETDB_SUCCESS, "v=spf1      redirect=98.spf1-test.mailzone.com" },
  222     { "101.spf1-test.mailzone.com",
  223       ns_t_txt, NETDB_SUCCESS, "v=spf1 -all redirect=98.spf1-test.mailzone.com" },
  224     { "102.spf1-test.mailzone.com",
  225       ns_t_txt, NETDB_SUCCESS, "v=spf1 ?all redirect=98.spf1-test.mailzone.com" },
  226     { "103.spf1-test.mailzone.com",
  227       ns_t_txt, NETDB_SUCCESS, "v=spf1      redirect=98.%{d3}" },
  228     { "104.spf1-test.mailzone.com",
  229       ns_t_txt, NETDB_SUCCESS, "v=spf1      redirect=105.%{d3}" },
  230     { "105.spf1-test.mailzone.com",
  231       ns_t_txt, NETDB_SUCCESS, "v=spf1      redirect=106.%{d3}" },
  232     { "106.spf1-test.mailzone.com",
  233       ns_t_txt, NETDB_SUCCESS, "v=spf1      redirect=107.%{d3}" },
  234     { "107.spf1-test.mailzone.com",
  235       ns_t_txt, NETDB_SUCCESS, "v=spf1       include:104.%{d3}" },
  236     { "110.spf1-test.mailzone.com",
  237       ns_t_txt, NETDB_SUCCESS, "v=spf1 some:unrecognized=mechanism some=unrecognized:modifier -all" },
  238     { "111.spf1-test.mailzone.com",
  239       ns_t_txt, NETDB_SUCCESS, "v=spf1 mx -a gpg ~all exp=111txt.spf1-test.mailzone.com" },
  240     { "111.spf1-test.mailzone.com",
  241       ns_t_mx,  NETDB_SUCCESS, "mx01.spf1-test.mailzone.com" },
  242     { "111.spf1-test.mailzone.com",
  243       ns_t_a,   NETDB_SUCCESS, "192.0.2.200" },
  244     { "111txt.2.0.192.in-addr._spf.spf1-test.mailzone.com",
  245       ns_t_txt,   NETDB_SUCCESS, "explanation text" },
  246     { "112.spf1-test.mailzone.com",
  247       ns_t_txt, NETDB_SUCCESS, "v=spf1 a mp3 ~all" },
  248     { "112.spf1-test.mailzone.com",
  249       ns_t_a,   NETDB_SUCCESS, "192.0.2.200" },
  250     { "113.spf1-test.mailzone.com",
  251       ns_t_txt, NETDB_SUCCESS, "v=spf1 a mp3: ~all" },
  252     { "113.spf1-test.mailzone.com",
  253       ns_t_a,   NETDB_SUCCESS, "192.0.2.200" },
  254     { "114.spf1-test.mailzone.com",
  255       ns_t_txt, NETDB_SUCCESS, "v=spf1 mx -a gpg=test ~all exp=114txt.spf1-test.mailzone.com" },
  256     { "114.spf1-test.mailzone.com",
  257       ns_t_mx,  NETDB_SUCCESS, "mx01.spf1-test.mailzone.com" },
  258     { "114.spf1-test.mailzone.com",
  259       ns_t_a,   NETDB_SUCCESS, "192.0.2.200" },
  260     { "114txt.spf1-test.mailzone.com",
  261       ns_t_txt, NETDB_SUCCESS, "explanation text" },
  262     { "115.spf1-test.mailzone.com",
  263       ns_t_txt, NETDB_SUCCESS, "v=spf1 a mp3=yes -all" },
  264     { "115.spf1-test.mailzone.com",
  265       ns_t_a,   NETDB_SUCCESS, "192.0.2.200" },
  266     { "116.spf1-test.mailzone.com",
  267       ns_t_txt, NETDB_SUCCESS, "v=spf1 redirect=116rdr.spf1-test.mailzone.com a" },
  268     { "116.spf1-test.mailzone.com",
  269       ns_t_a,   NETDB_SUCCESS, "192.0.2.200" },
  270     { "116rdr.spf1-test.mailzone.com",
  271       ns_t_txt, NETDB_SUCCESS, "v=spf1 -all" },
  272     { "117.spf1-test.mailzone.com",
  273       ns_t_txt, NETDB_SUCCESS, " v=spf1 +all" },
  274     { "118.spf1-test.mailzone.com",
  275       ns_t_txt, NETDB_SUCCESS, "v=spf1 -all exp=" },
  276 
  277     { "mx01.spf1-test.mailzone.com",
  278       ns_t_a,   NETDB_SUCCESS, "192.0.2.10" },
  279     { "mx01.spf1-test.mailzone.com",
  280       ns_t_a,   NETDB_SUCCESS, "192.0.2.11" },
  281     { "mx01.spf1-test.mailzone.com",
  282       ns_t_a,   NETDB_SUCCESS, "192.0.2.12" },
  283     { "mx01.spf1-test.mailzone.com",
  284       ns_t_a,   NETDB_SUCCESS, "192.0.2.13" },
  285     { "mx02.spf1-test.mailzone.com",
  286       ns_t_a,   NETDB_SUCCESS, "192.0.2.20" },
  287     { "mx02.spf1-test.mailzone.com",
  288       ns_t_a,   NETDB_SUCCESS, "192.0.2.21" },
  289     { "mx02.spf1-test.mailzone.com",
  290       ns_t_a,   NETDB_SUCCESS, "192.0.2.22" },
  291     { "mx02.spf1-test.mailzone.com",
  292       ns_t_a,   NETDB_SUCCESS, "192.0.2.23" },
  293     { "mx03.spf1-test.mailzone.com",
  294       ns_t_a,   NETDB_SUCCESS, "192.0.2.30" },
  295     { "mx03.spf1-test.mailzone.com",
  296       ns_t_a,   NETDB_SUCCESS, "192.0.2.31" },
  297     { "mx03.spf1-test.mailzone.com",
  298       ns_t_a,   NETDB_SUCCESS, "192.0.2.32" },
  299     { "mx03.spf1-test.mailzone.com",
  300       ns_t_a,   NETDB_SUCCESS, "192.0.2.33" },
  301     { "mx04.spf1-test.mailzone.com",
  302       ns_t_a,   NETDB_SUCCESS, "192.0.2.40" },
  303     { "mx04.spf1-test.mailzone.com",
  304       ns_t_a,   NETDB_SUCCESS, "192.0.2.41" },
  305     { "mx04.spf1-test.mailzone.com",
  306       ns_t_a,   NETDB_SUCCESS, "192.0.2.42" },
  307     { "mx04.spf1-test.mailzone.com",
  308       ns_t_a,   NETDB_SUCCESS, "192.0.2.43" },
  309 
  310     { "56.spf1-test.mailzone.com",
  311       ns_t_txt, NO_DATA, NULL },
  312     { "80.spf1-test.mailzone.com",
  313       ns_t_mx,  NO_DATA, NULL },
  314     { "servfail.spf1-test.mailzone.com",
  315       ns_t_txt, TRY_AGAIN, NULL },
  316     { "spf1-test.mailzone.com",
  317       ns_t_mx,  NETDB_SUCCESS, "mx02.spf1-test.mailzone.com" },
  318     { "spf1-test.mailzone.com",
  319       ns_t_mx,  NETDB_SUCCESS, "mx03.spf1-test.mailzone.com" },
  320     { "spf1-test.mailzone.com",
  321       ns_t_mx,  NETDB_SUCCESS, "mx01.spf1-test.mailzone.com" },
  322     { "spf1-test.mailzone.com",
  323       ns_t_a,   NETDB_SUCCESS, "208.210.124.192" },
  324     { "spf1-test.mailzone.com",
  325       ns_t_a,   NETDB_SUCCESS, "192.0.2.200" },
  326     { "fallback-relay.spf1-test.mailzone.com",
  327       ns_t_mx,  NETDB_SUCCESS, "mx04.spf1-test.mailzone.com" },
  328     
  329     { "www1.cnn.com",
  330       ns_t_a,   NETDB_SUCCESS, "64.236.24.4" },
  331     { "4.24.236.64.in-addr.arpa",
  332       ns_t_ptr, NETDB_SUCCESS, "www1.cnn.com" },
  333     { "130.124.210.208.in-addr.arpa",
  334       ns_t_ptr, NETDB_SUCCESS, "30.spf1-test.mailzone.com" },
  335     { "131.124.210.208.in-addr.arpa",
  336       ns_t_ptr, NETDB_SUCCESS, "31.spf1-test.mailzone.com" },
  337     { "192.124.210.208.in-addr.arpa",
  338       ns_t_ptr, NETDB_SUCCESS, "spf1-test.mailzone.com" },
  339     { "100.2.0.192.in-addr._spf.40.spf1-test.mailzone.com",
  340       ns_t_a,   NETDB_SUCCESS, "127.0.0.2" },
  341 
  342     { "110.2.0.192.in-addr._spf.spf1-test.mailzone.com",
  343       ns_t_a,   NETDB_SUCCESS, "127.0.0.2" },
  344     { "111.2.0.192.in-addr._spf.spf1-test.mailzone.com",
  345       ns_t_a,   NETDB_SUCCESS, "127.0.0.2" },
  346     { "101.2.0.192.in-addr._spf.40.spf1-test.mailzone.com",
  347       ns_t_a,   NETDB_SUCCESS, "127.0.0.2" },
  348     { "130.2.0.192.in-addr._spf.42.spf1-test.mailzone.com",
  349       ns_t_a,   NETDB_SUCCESS, "127.0.0.2" },
  350     { "131.2.0.192.in-addr._spf.42.spf1-test.mailzone.com",
  351       ns_t_a,   NETDB_SUCCESS, "127.0.0.2" },
  352     { "80.2.0.192.in-addr._spf.80.spf1-test.mailzone.com",
  353       ns_t_a,   NETDB_SUCCESS, "127.0.0.2" },
  354     { "96.spf1-test.mailzone.com.blacklist.spf1-test.mailzone.com",
  355       ns_t_a,   NETDB_SUCCESS, "127.0.0.2" },
  356     { "97.spf1-test.mailzone.com.blacklist.spf1-test.mailzone.com",
  357       ns_t_a,   NETDB_SUCCESS, "127.0.0.2" },
  358     { "bob.lp._spf.spf1-test.mailzone.com",
  359       ns_t_a,   NETDB_SUCCESS, "127.0.0.2" },
  360     { "postmaster.lp._spf.spf1-test.mailzone.com",
  361       ns_t_a,   NETDB_SUCCESS, "127.0.0.2" },
  362     { "1.bob.lp._spf.spf1-test.mailzone.com",
  363       ns_t_a,   NETDB_SUCCESS, "127.0.0.2" },
  364     { "2.bob.lp._spf.spf1-test.mailzone.com",
  365       ns_t_a,   NETDB_SUCCESS, "127.0.0.2" },
  366     { "1.joe.lp._spf.spf1-test.mailzone.com",
  367       ns_t_a,   HOST_NOT_FOUND, NULL },
  368     { "100.2.0.192.in-addr._spf.42.spf1-test.mailzone.com",
  369       ns_t_a,   HOST_NOT_FOUND, NULL },
  370     { "100.2.0.192.in-addr._spf.spf1-test.mailzone.com",
  371       ns_t_a,   HOST_NOT_FOUND, NULL },
  372     { "102.2.0.192.in-addr._spf.40.spf1-test.mailzone.com",
  373       ns_t_a,   HOST_NOT_FOUND, NULL },
  374     { "110.2.0.192.in-addr._spf.42.spf1-test.mailzone.com",
  375       ns_t_a,   HOST_NOT_FOUND, NULL },
  376     { "130.2.0.192.in-addr._spf.spf1-test.mailzone.com",
  377       ns_t_a,   HOST_NOT_FOUND, NULL },
  378     { "131.2.0.192.in-addr._spf.spf1-test.mailzone.com",
  379       ns_t_a,   HOST_NOT_FOUND, NULL },
  380     { "4.24.236.64.in-addr._spf.80.spf1-test.mailzone.com",
  381       ns_t_a,   HOST_NOT_FOUND, NULL },
  382     { "droid.lp._spf.spf1-test.mailzone.com",
  383       ns_t_a,   HOST_NOT_FOUND, NULL },
  384     { "joe-2.lp._spf.spf1-test.mailzone.com",
  385       ns_t_a,   HOST_NOT_FOUND, NULL },
  386     { "moe-1.lp._spf.spf1-test.mailzone.com",
  387       ns_t_a,   HOST_NOT_FOUND, NULL },
  388     { "unknown.whitelist.spf1-test.mailzone.com",
  389       ns_t_a,   HOST_NOT_FOUND, NULL },
  390 
  391     { "180.124.210.208.in-addr.arpa",
  392       ns_t_ptr, NETDB_SUCCESS, "80.spf1-test.mailzone.com" },
  393 
  394     { "80.spf1-test.mailzone.com.whitelist.spf1-test.mailzone.com",
  395       ns_t_a,   NETDB_SUCCESS, "127.0.0.2" },
  396     { "1.124.210.208.in-addr.arpa",
  397       ns_t_ptr, NETDB_SUCCESS, "pobox-gw.icgroup.com" },
  398 
  399     { "pobox-gw.icgroup.com",
  400       ns_t_a,   NETDB_SUCCESS, "208.210.124.1" },
  401     { "pobox-gw.icgroup.com.whitelist.spf1-test.mailzone.com",
  402       ns_t_a,   HOST_NOT_FOUND, NULL },
  403 
  404     { "200.2.0.192.in-addr._spf.51.spf1-test.mailzone.com",
  405       ns_t_a,   HOST_NOT_FOUND, NULL },
  406     { "200.2.0.192.in-addr._spf.spf1-test.mailzone.com",
  407       ns_t_a,   HOST_NOT_FOUND, NULL },
  408     { "130.2.0.192.in-addr._spf.51.spf1-test.mailzone.com",
  409       ns_t_a,   HOST_NOT_FOUND, NULL },
  410     { "200.2.0.192.in-addr._spf.42.spf1-test.mailzone.com",
  411       ns_t_a,   HOST_NOT_FOUND, NULL },
  412     { "spf1-test.mailzone.com",
  413       ns_t_txt, HOST_NOT_FOUND, NULL },
  414     { "spf.trusted-forwarder.org",
  415       ns_t_txt, NETDB_SUCCESS, "v=spf1 exists:%{ir}.wl.trusted-forwarder.org exists:%{p}.wl.trusted-forwarder.org" },
  416     { "*.spf1-text.mailzone.com",
  417       ns_t_any, HOST_NOT_FOUND, NULL },
  418 
  419     { "cat.com",
  420       ns_t_txt, NO_DATA, NULL },
  421     { "bar.com",
  422       ns_t_txt, NO_DATA, NULL },
  423     
  424 
  425 #endif
  426 
  427 #ifdef USE_EXT_MAILZONE_ZONE
  428     { "1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.5.d.a.0.8.0.0.0.2.5.0.f.5.in6.arpa",
  429       ns_t_ptr, NETDB_SUCCESS, "mx.example.org" },
  430 
  431 #endif
  432 };
  433 
  434 
  435 
  436 SPF_dns_server_t *
  437 SPF_dns_test_new(SPF_dns_server_t *layer_below,
  438                 const char *name, int debug)
  439 {
  440     SPF_dns_server_t    *spf_dns_server;
  441     int                  i;
  442     
  443     if (name == NULL)
  444         name = "test";
  445     spf_dns_server = SPF_dns_zone_new(layer_below, name, debug);
  446     if (spf_dns_server == NULL)
  447         return NULL;
  448 
  449     for( i = 0; i < array_elem( SPF_dns_db ); i++ ) {
  450         if (SPF_dns_zone_add_str(spf_dns_server,
  451                           SPF_dns_db[i].domain,
  452                           SPF_dns_db[i].rr_type, 
  453                           SPF_dns_db[i].herrno, 
  454                           SPF_dns_db[i].data) != SPF_E_SUCCESS)
  455             SPF_error( "Could not create test zone" );
  456     }
  457 
  458     return spf_dns_server;
  459 }