Changeset 1204

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

unxsBind started support for AAAA RRs save commit not stable!

Location:
trunk/unxsBind
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/unxsBind/mysqlrad.h

    r1079 r1204  
    2525#include <mysql/mysql.h> 
    2626char *crypt(const char *key, const char *salt); 
     27 
     28//This creates a dependency on provided tRRType.txt table fie 
     29#define RRTYPE_A 1 
     30#define RRTYPE_NS 2 
     31#define RRTYPE_MX 3  
     32#define RRTYPE_HINFO 4 
     33#define RRTYPE_CNAME 5 
     34#define RRTYPE_TXT 6 
     35#define RRTYPE_PTR 7 
     36#define RRTYPE_SRV 8 
     37#define RRTYPE_AAAA 9 
    2738 
    2839 
  • 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 
  • trunk/unxsBind/trrtype.c

    r166 r1204  
    387387//cLabel 
    388388        OpenRow(LANG_FL_tRRType_cLabel,"black"); 
    389         printf("<input title='%s' type=text name=cLabel value=\"%s\" size=40 maxlength=32 " 
     389        printf("<input title='%s' type=text name=cLabel value=\"%s\" size=60 maxlength=32 " 
    390390,LANG_FT_tRRType_cLabel,EncodeDoubleQuotes(cLabel)); 
    391391        if(guPermLevel>=0 && uMode) 
     
    412412//cParam1Func 
    413413        OpenRow(LANG_FL_tRRType_cParam1Func,"black"); 
    414         printf("<input title='%s' type=text name=cParam1Func value=\"%s\" size=40 maxlength=32 " 
     414        printf("<input title='%s' type=text name=cParam1Func value=\"%s\" size=60 maxlength=32 " 
    415415,LANG_FT_tRRType_cParam1Func,EncodeDoubleQuotes(cParam1Func)); 
    416416        if(guPermLevel>=0 && uMode) 
     
    425425//cParam2Func 
    426426        OpenRow(LANG_FL_tRRType_cParam2Func,"black"); 
    427         printf("<input title='%s' type=text name=cParam2Func value=\"%s\" size=40 maxlength=32 " 
     427        printf("<input title='%s' type=text name=cParam2Func value=\"%s\" size=60 maxlength=32 " 
    428428,LANG_FT_tRRType_cParam2Func,EncodeDoubleQuotes(cParam2Func)); 
    429429        if(guPermLevel>=0 && uMode) 
     
    438438//cParam3Func 
    439439        OpenRow(LANG_FL_tRRType_cParam3Func,"black"); 
    440         printf("<input title='%s' type=text name=cParam3Func value=\"%s\" size=40 maxlength=32 " 
     440        printf("<input title='%s' type=text name=cParam3Func value=\"%s\" size=60 maxlength=32 " 
    441441,LANG_FT_tRRType_cParam3Func,EncodeDoubleQuotes(cParam3Func)); 
    442442        if(guPermLevel>=0 && uMode) 
     
    451451//cParam4Func 
    452452        OpenRow(LANG_FL_tRRType_cParam4Func,"black"); 
    453         printf("<input title='%s' type=text name=cParam4Func value=\"%s\" size=40 maxlength=32 " 
     453        printf("<input title='%s' type=text name=cParam4Func value=\"%s\" size=60 maxlength=32 " 
    454454,LANG_FT_tRRType_cParam4Func,EncodeDoubleQuotes(cParam4Func)); 
    455455        if(guPermLevel>=0 && uMode) 
     
    464464//cParam1Label 
    465465        OpenRow(LANG_FL_tRRType_cParam1Label,"black"); 
    466         printf("<input title='%s' type=text name=cParam1Label value=\"%s\" size=40 maxlength=32 " 
     466        printf("<input title='%s' type=text name=cParam1Label value=\"%s\" size=60 maxlength=32 " 
    467467,LANG_FT_tRRType_cParam1Label,EncodeDoubleQuotes(cParam1Label)); 
    468468        if(guPermLevel>=0 && uMode) 
     
    477477//cParam2Label 
    478478        OpenRow(LANG_FL_tRRType_cParam2Label,"black"); 
    479         printf("<input title='%s' type=text name=cParam2Label value=\"%s\" size=40 maxlength=32 " 
     479        printf("<input title='%s' type=text name=cParam2Label value=\"%s\" size=60 maxlength=32 " 
    480480,LANG_FT_tRRType_cParam2Label,EncodeDoubleQuotes(cParam2Label)); 
    481481        if(guPermLevel>=0 && uMode) 
     
    490490//cParam3Label 
    491491        OpenRow(LANG_FL_tRRType_cParam3Label,"black"); 
    492         printf("<input title='%s' type=text name=cParam3Label value=\"%s\" size=40 maxlength=32 " 
     492        printf("<input title='%s' type=text name=cParam3Label value=\"%s\" size=60 maxlength=32 " 
    493493,LANG_FT_tRRType_cParam3Label,EncodeDoubleQuotes(cParam3Label)); 
    494494        if(guPermLevel>=0 && uMode) 
     
    503503//cParam4Label 
    504504        OpenRow(LANG_FL_tRRType_cParam4Label,"black"); 
    505         printf("<input title='%s' type=text name=cParam4Label value=\"%s\" size=40 maxlength=32 " 
     505        printf("<input title='%s' type=text name=cParam4Label value=\"%s\" size=60 maxlength=32 " 
    506506,LANG_FT_tRRType_cParam4Label,EncodeDoubleQuotes(cParam4Label)); 
    507507        if(guPermLevel>=0 && uMode) 
     
    516516//cParam1Tip 
    517517        OpenRow(LANG_FL_tRRType_cParam1Tip,"black"); 
    518         printf("<input title='%s' type=text name=cParam1Tip value=\"%s\" size=40 maxlength=100 " 
     518        printf("<input title='%s' type=text name=cParam1Tip value=\"%s\" size=60 maxlength=100 " 
    519519,LANG_FT_tRRType_cParam1Tip,EncodeDoubleQuotes(cParam1Tip)); 
    520520        if(guPermLevel>=0 && uMode) 
     
    529529//cParam2Tip 
    530530        OpenRow(LANG_FL_tRRType_cParam2Tip,"black"); 
    531         printf("<input title='%s' type=text name=cParam2Tip value=\"%s\" size=40 maxlength=100 " 
     531        printf("<input title='%s' type=text name=cParam2Tip value=\"%s\" size=60 maxlength=100 " 
    532532,LANG_FT_tRRType_cParam2Tip,EncodeDoubleQuotes(cParam2Tip)); 
    533533        if(guPermLevel>=0 && uMode) 
     
    542542//cParam3Tip 
    543543        OpenRow(LANG_FL_tRRType_cParam3Tip,"black"); 
    544         printf("<input title='%s' type=text name=cParam3Tip value=\"%s\" size=40 maxlength=100 " 
     544        printf("<input title='%s' type=text name=cParam3Tip value=\"%s\" size=60 maxlength=100 " 
    545545,LANG_FT_tRRType_cParam3Tip,EncodeDoubleQuotes(cParam3Tip)); 
    546546        if(guPermLevel>=0 && uMode) 
     
    555555//cParam4Tip 
    556556        OpenRow(LANG_FL_tRRType_cParam4Tip,"black"); 
    557         printf("<input title='%s' type=text name=cParam4Tip value=\"%s\" size=40 maxlength=100 " 
     557        printf("<input title='%s' type=text name=cParam4Tip value=\"%s\" size=60 maxlength=100 " 
    558558,LANG_FT_tRRType_cParam4Tip,EncodeDoubleQuotes(cParam4Tip)); 
    559559        if(guPermLevel>=0 && uMode) 
     
    586586//cNameFunc 
    587587        OpenRow(LANG_FL_tRRType_cNameFunc,"black"); 
    588         printf("<input title='%s' type=text name=cNameFunc value=\"%s\" size=40 maxlength=32 " 
     588        printf("<input title='%s' type=text name=cNameFunc value=\"%s\" size=60 maxlength=32 " 
    589589,LANG_FT_tRRType_cNameFunc,EncodeDoubleQuotes(cNameFunc)); 
    590590        if(guPermLevel>=0 && uMode) 
     
    599599//cNameLabel 
    600600        OpenRow(LANG_FL_tRRType_cNameLabel,"black"); 
    601         printf("<input title='%s' type=text name=cNameLabel value=\"%s\" size=40 maxlength=32 " 
     601        printf("<input title='%s' type=text name=cNameLabel value=\"%s\" size=60 maxlength=32 " 
    602602,LANG_FT_tRRType_cNameLabel,EncodeDoubleQuotes(cNameLabel)); 
    603603        if(guPermLevel>=0 && uMode) 
     
    612612//cNameTip 
    613613        OpenRow(LANG_FL_tRRType_cNameTip,"black"); 
    614         printf("<input title='%s' type=text name=cNameTip value=\"%s\" size=40 maxlength=100 " 
     614        printf("<input title='%s' type=text name=cNameTip value=\"%s\" size=60 maxlength=100 " 
    615615,LANG_FT_tRRType_cNameTip,EncodeDoubleQuotes(cNameTip)); 
    616616        if(guPermLevel>=0 && uMode)