Changeset 1204 for trunk/unxsBind/tresourcefunc.h
- Timestamp:
- 03/04/10 08:19:24 (2 years ago)
- Files:
-
- 1 modified
-
trunk/unxsBind/tresourcefunc.h (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/unxsBind/tresourcefunc.h
r1079 r1204 198 198 } 199 199 } 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 } 200 276 else if(!strcmp(cRRType,"PTR")) 201 277 { … … 429 505 //New PTR record in automated arpa zones 430 506 //exception allowed 431 if(!uZoneOwner && uRRType!= 7)507 if(!uZoneOwner && uRRType!=RRTYPE_PTR) 432 508 { 433 509 guMode=0; … … 440 516 uModBy=0;//Never modified 441 517 442 if(uAddArpaPTR && uRRType== 1)518 if(uAddArpaPTR && uRRType==RRTYPE_A) 443 519 { 444 520 char cFQDN[512]; … … 508 584 UpdateSerialNum(uZone); 509 585 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'," 511 588 "cComment='%s',uOwner='%u',uCreatedBy=1,uCreatedDate=UNIX_TIMESTAMP(NOW())", 512 589 uResource, … … 550 627 RRCheck(2002); 551 628 uModBy=guLoginClient; 552 if(uAddArpaPTR && uRRType== 1)629 if(uAddArpaPTR && uRRType==RRTYPE_A) 553 630 { 554 631 char cFQDN[512]; … … 656 733 { 657 734 sprintf(gcQuery,"INSERT INTO tResource SET uZone=%u,cName='%.99s'," 658 "uRRType= 2,cParam1='%.99s.',"735 "uRRType=%u,cParam1='%.99s.'," 659 736 "cComment='DelegationWizard created',uOwner=%u," 660 737 "uCreatedDate=UNIX_TIMESTAMP(NOW())", 661 738 uZone 662 739 ,cZone 740 ,RRTYPE_NS 663 741 ,cNSSet[i] 664 742 ,guLoginClient); … … 680 758 sprintf(cParam1,"%u-%u",uStartBlock,uNumIPs-1); 681 759 sprintf(gcQuery,"INSERT INTO tResource SET uZone=%u,cName='%.15s'," 682 "uRRType= 2,cParam1='%.99s.'"760 "uRRType=%u,cParam1='%.99s.'" 683 761 ",cComment='DelegationWizard created',uOwner=%u," 684 762 "uCreatedDate=UNIX_TIMESTAMP(NOW())", 685 763 uZone 686 764 ,cParam1 765 ,RRTYPE_NS 687 766 ,cNSSet[i] 688 767 ,guLoginClient); … … 803 882 printf("<p><u>Enter required data</u><br>"); 804 883 printf(LANG_NBB_CONFIRMNEW); 805 if( strcmp(cZone+strlen(cZone)-5,".arpa"))884 if(uRRType==RRTYPE_A && strcmp(cZone+strlen(cZone)-5,".arpa")) 806 885 { 807 886 printf("<br><input title='For some RR types this will add a PTR entry to" … … 829 908 printf("<p><u>Review record data</u><br>"); 830 909 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")) 832 911 { 833 912 printf("<br><input title='For some RR types this will add a PTR entry to" … … 1114 1193 //Only allow one PTR entry per FQDN for same uOwner 1115 1194 1116 sprintf(gcQuery,"DELETE FROM tResource WHERE uRRType= 7AND 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); 1118 1197 mysql_query(&gMysql,gcQuery); 1119 1198 if(mysql_errno(&gMysql)) … … 1125 1204 1126 1205 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'," 1128 1207 "uOwner=%u,uCreatedBy=%u,uCreatedDate=UNIX_TIMESTAMP(NOW())", 1129 1208 uInZone 1130 1209 ,cName 1210 ,RRTYPE_PTR 1131 1211 ,cParam1 1132 1212 ,cComment
