Show
Ignore:
Timestamp:
03/04/10 08:19:24 (2 years ago)
Author:
Gary
Message:

unxsBind started support for AAAA RRs save commit not stable!

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/unxsBind/tresourcefunc.h

    r1079 r1204  
    198198                } 
    199199        } 
     200        else if(!strcmp(cRRType,"AAAA")) 
     201        { 
     202                unsigned h1=0; 
     203                unsigned h2=0; 
     204                unsigned h3=0; 
     205                unsigned h4=0; 
     206                unsigned h5=0; 
     207                unsigned h6=0; 
     208                unsigned h7=0; 
     209                unsigned h8=0; 
     210 
     211                //Insure these are empty 
     212                cParam2[0]=0; 
     213 
     214                if(!strcmp(cZone+strlen(cZone)-5,".arpa")) 
     215                        tResource("Can not add AAAA records to arpa zones"); 
     216                sscanf(cParam1,"%x:%x:%x:%x:%x:%x:%x:%x",&h1,&h2,&h3,&h4,&h5,&h6,&h7,&h8); 
     217 
     218                //Leading 0's. Done via sprintf below. 
     219 
     220                //First checks 
     221                if(!h1) 
     222                { 
     223                        guMode=uMode; 
     224                        tResource("IPv6 number can not have a 0 in first 16 bit hex word."); 
     225                } 
     226 
     227                if(!h8) 
     228                { 
     229                        guMode=uMode; 
     230                        tResource("IPv6 number can not have a 0 in last 16 bit hex word."); 
     231                } 
     232 
     233                //Compress empty words: Double colon. Can only be used once. 
     234                //Trying KISS method here 
     235                //6 consecutive 0 case 
     236                if(!h2 && !h3 && !h4 && !h5 && !h6 && !h7) 
     237                        sprintf(cParam1,"%x::%x",h1,h8); 
     238                //5 consecutive 0 cases 
     239                else if(!h3 && !h4 && !h5 && !h6 && !h7) 
     240                        sprintf(cParam1,"%x:%x::%x",h1,h2,h8); 
     241                else if(!h2 && !h3 && !h4 && !h5 && !h6) 
     242                        sprintf(cParam1,"%x::%x:%x",h1,h7,h8); 
     243                //4 consecutive 0 cases 
     244                else if(!h4 && !h5 && !h6 && !h7) 
     245                        sprintf(cParam1,"%x:%x:%x::%x",h1,h2,h3, h8); 
     246                else if(!h3 && !h4 && !h5 && !h6) 
     247                        sprintf(cParam1,"%x:%x::%x:%x",h1,h2, h7,h8); 
     248                else if(!h2 && !h3 && !h4 && !h5) 
     249                        sprintf(cParam1,"%x::%x:%x:%x",h1, h6,h7,h8); 
     250                //3 consecutive 0 cases 
     251                else if(!h5 && !h6 && !h7) 
     252                        sprintf(cParam1,"%x:%x:%x:%x::%x",h1,h2,h3,h4, h8); 
     253                else if(!h4 && !h5 && !h6) 
     254                        sprintf(cParam1,"%x:%x:%x::%x:%x",h1,h2,h3, h7,h8); 
     255                else if(!h3 && !h4 && !h5) 
     256                        sprintf(cParam1,"%x:%x::%x:%x:%x",h1,h2, h6,h7,h8); 
     257                else if(!h2 && !h3 && !h4) 
     258                        sprintf(cParam1,"%x::%x:%x:%x:%x",h1, h5,h6,h7,h8); 
     259                //2 consecutive 0 cases 
     260                else if(!h6 && !h7) 
     261                        sprintf(cParam1,"%x:%x:%x:%x:%x::%x",h1,h2,h3,h4,h5, h8); 
     262                else if(!h5 && !h6) 
     263                        sprintf(cParam1,"%x:%x:%x:%x::%x:%x",h1,h2,h3,h4, h7,h8); 
     264                else if(!h4 && !h5) 
     265                        sprintf(cParam1,"%x:%x:%x::%x:%x:%x",h1,h2,h3, h6,h7,h8); 
     266                else if(!h3 && !h4) 
     267                        sprintf(cParam1,"%x:%x::%x:%x:%x:%x",h1,h2, h5,h6,h7,h8); 
     268                else if(!h2 && !h3) 
     269                        sprintf(cParam1,"%x::%x:%x:%x:%x:%x",h1, h4,h5,h6,h7,h8); 
     270                //0 consecutive 0 case, i.e. no double colon case 
     271                else if(1) 
     272                        sprintf(cParam1,"%x:%x:%x:%x:%x:%x:%x:%x",h1,h2,h3,h4,h5,h6,h7,h8); 
     273                 
     274 
     275        } 
    200276        else if(!strcmp(cRRType,"PTR")) 
    201277        { 
     
    429505                                //New PTR record in automated arpa zones 
    430506                                //exception allowed 
    431                                 if(!uZoneOwner && uRRType!=7) 
     507                                if(!uZoneOwner && uRRType!=RRTYPE_PTR) 
    432508                                { 
    433509                                        guMode=0; 
     
    440516                                uModBy=0;//Never modified 
    441517                                 
    442                                 if(uAddArpaPTR && uRRType==1) 
     518                                if(uAddArpaPTR && uRRType==RRTYPE_A) 
    443519                                { 
    444520                                        char cFQDN[512]; 
     
    508584                                UpdateSerialNum(uZone);                          
    509585                                sprintf(gcQuery,"INSERT INTO tDeletedResource SET uDeletedResource='%u',uZone='%u'," 
    510                                                 "cName='%s',uTTL='%u',uRRType='%u',cParam1='%s',cParam2='%s',cParam3='%s',cParam4='%s'," 
     586                                                "cName='%s',uTTL='%u',uRRType='%u',cParam1='%s',cParam2='%s'," 
     587                                                "cParam3='%s',cParam4='%s'," 
    511588                                                "cComment='%s',uOwner='%u',uCreatedBy=1,uCreatedDate=UNIX_TIMESTAMP(NOW())", 
    512589                                                uResource, 
     
    550627                                RRCheck(2002); 
    551628                                uModBy=guLoginClient; 
    552                                 if(uAddArpaPTR && uRRType==1) 
     629                                if(uAddArpaPTR && uRRType==RRTYPE_A) 
    553630                                { 
    554631                                        char cFQDN[512]; 
     
    656733                                        { 
    657734                                                sprintf(gcQuery,"INSERT INTO tResource SET uZone=%u,cName='%.99s'," 
    658                                                                 "uRRType=2,cParam1='%.99s.'," 
     735                                                                "uRRType=%u,cParam1='%.99s.'," 
    659736                                                                "cComment='DelegationWizard created',uOwner=%u," 
    660737                                                                "uCreatedDate=UNIX_TIMESTAMP(NOW())", 
    661738                                                                uZone 
    662739                                                                ,cZone 
     740                                                                ,RRTYPE_NS 
    663741                                                                ,cNSSet[i] 
    664742                                                                ,guLoginClient); 
     
    680758                                        sprintf(cParam1,"%u-%u",uStartBlock,uNumIPs-1); 
    681759                                        sprintf(gcQuery,"INSERT INTO tResource SET uZone=%u,cName='%.15s'," 
    682                                                         "uRRType=2,cParam1='%.99s.'" 
     760                                                        "uRRType=%u,cParam1='%.99s.'" 
    683761                                                        ",cComment='DelegationWizard created',uOwner=%u," 
    684762                                                        "uCreatedDate=UNIX_TIMESTAMP(NOW())", 
    685763                                                        uZone 
    686764                                                        ,cParam1 
     765                                                        ,RRTYPE_NS 
    687766                                                        ,cNSSet[i] 
    688767                                                        ,guLoginClient); 
     
    803882                        printf("<p><u>Enter required data</u><br>"); 
    804883                        printf(LANG_NBB_CONFIRMNEW); 
    805                         if(strcmp(cZone+strlen(cZone)-5,".arpa")) 
     884                        if(uRRType==RRTYPE_A && strcmp(cZone+strlen(cZone)-5,".arpa")) 
    806885                        { 
    807886                                printf("<br><input title='For some RR types this will add a PTR entry to" 
     
    829908                        printf("<p><u>Review record data</u><br>"); 
    830909                        printf(LANG_NBB_CONFIRMMOD); 
    831                         if(uRRType==1 && strcmp(cZone+strlen(cZone)-5,".arpa")) 
     910                        if(uRRType==RRTYPE_A && strcmp(cZone+strlen(cZone)-5,".arpa")) 
    832911                        { 
    833912                                printf("<br><input title='For some RR types this will add a PTR entry to" 
     
    11141193        //Only allow one PTR entry per FQDN for same uOwner 
    11151194 
    1116         sprintf(gcQuery,"DELETE FROM tResource WHERE uRRType=7 AND cParam1='%s' AND uOwner=%u", 
    1117                         cParam1,uSourceZoneOwner); 
     1195        sprintf(gcQuery,"DELETE FROM tResource WHERE uRRType=%u AND cParam1='%s' AND uOwner=%u", 
     1196                                RRTYPE_PTR,cParam1,uSourceZoneOwner); 
    11181197        mysql_query(&gMysql,gcQuery); 
    11191198        if(mysql_errno(&gMysql))  
     
    11251204 
    11261205        sprintf(cName,"%u",d); 
    1127         sprintf(gcQuery,"INSERT INTO tResource SET uZone=%u,cName='%.16s',uRRType=7,cParam1='%.511s',cComment='%.99s'," 
     1206        sprintf(gcQuery,"INSERT INTO tResource SET uZone=%u,cName='%.16s',uRRType=%u,cParam1='%.511s',cComment='%.99s'," 
    11281207                        "uOwner=%u,uCreatedBy=%u,uCreatedDate=UNIX_TIMESTAMP(NOW())", 
    11291208                                uInZone 
    11301209                                ,cName 
     1210                                ,RRTYPE_PTR 
    11311211                                ,cParam1 
    11321212                                ,cComment