Added DNS SRV record support in TinyDNS "unknown record" format

git-svn-id: https://svn.alkaloid.net/gpl/ldap2dns/trunk@8 06cd67b6-e706-0410-b29e-9de616bca6e9
This commit is contained in:
Ben Klang
2005-12-02 04:28:28 +00:00
parent 24f0ba9a9c
commit 14e06302a8
3 changed files with 77 additions and 3 deletions

View File

@@ -105,6 +105,24 @@ attributetype ( 1.3.6.1.4.1.7222.1.4.23
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{2} SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{2}
SINGLE-VALUE ) SINGLE-VALUE )
attributetype ( 1.3.6.1.4.1.7222.1.4.23
NAME 'dnssrvpriority'
EQUALITY integerMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.27
SINGLE-VALUE )
attributetype ( 1.3.6.1.4.1.7222.1.4.24
NAME 'dnssrvweight'
EQUALITY integerMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.27
SINGLE-VALUE )
attributetype ( 1.3.6.1.4.1.7222.1.4.25
NAME 'dnssrvport'
EQUALITY integerMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.27
SINGLE-VALUE )
objectclass ( 1.3.6.1.4.1.7222.1.4.19 objectclass ( 1.3.6.1.4.1.7222.1.4.19
NAME 'dnszone' NAME 'dnszone'
MUST ( objectclass $ cn ) MUST ( objectclass $ cn )
@@ -117,7 +135,8 @@ objectclass ( 1.3.6.1.4.1.7222.1.4.20
SUP dnszone SUP dnszone
MUST ( objectclass $ cn ) MUST ( objectclass $ cn )
MAY ( dnsdomainname $ dnsrr $ dnsclass $ dnstype $ dnsipaddr $ dnscipaddr MAY ( dnsdomainname $ dnsrr $ dnsclass $ dnstype $ dnsipaddr $ dnscipaddr
$ dnscname $ dnspreference $ dnsttl $ dnstimestamp $ owner ) ) $ dnscname $ dnspreference $ dnsttl $ dnstimestamp $ owner
$ dnssrvpriority $ dnssrvweight $ dnssrvport ) )
objectclass ( 1.3.6.1.4.1.7222.1.4.24 objectclass ( 1.3.6.1.4.1.7222.1.4.24
NAME 'dnsloccodes' NAME 'dnsloccodes'

View File

@@ -108,6 +108,24 @@ attributetype ( 1.3.6.1.4.1.7222.1.4.22
SUBSTR caseIgnoreSubstringsMatch SUBSTR caseIgnoreSubstringsMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{16} ) SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{16} )
attributetype ( 1.3.6.1.4.1.7222.1.4.23
NAME 'dnssrvpriority'
EQUALITY integerMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.27
SINGLE-VALUE )
attributetype ( 1.3.6.1.4.1.7222.1.4.24
NAME 'dnssrvweight'
EQUALITY integerMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.27
SINGLE-VALUE )
attributetype ( 1.3.6.1.4.1.7222.1.4.25
NAME 'dnssrvport'
EQUALITY integerMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.27
SINGLE-VALUE )
objectclass ( 1.3.6.1.4.1.7222.1.4.19 objectclass ( 1.3.6.1.4.1.7222.1.4.19
NAME 'dnszone' NAME 'dnszone'
MUST ( objectclass $ cn ) MUST ( objectclass $ cn )
@@ -120,7 +138,8 @@ objectclass ( 1.3.6.1.4.1.7222.1.4.20
SUP dnszone SUP dnszone
MUST ( objectclass $ cn ) MUST ( objectclass $ cn )
MAY ( dnsdomainname $ dnsrr $ dnsclass $ dnstype $ dnsipaddr $ dnscipaddr MAY ( dnsdomainname $ dnsrr $ dnsclass $ dnstype $ dnsipaddr $ dnscipaddr
$ dnscname $ dnspreference $ dnsttl $ dnstimestamp $ owner ) ) $ dnscname $ dnspreference $ dnsttl $ dnstimestamp $ owner
$ dnssrvpriority $ dnssrvweight $ dnssrvport ) )

View File

@@ -85,6 +85,9 @@ struct resourcerecord
char aliasedobjectname[256]; char aliasedobjectname[256];
char macaddress[32]; char macaddress[32];
#endif #endif
int dnssrvpriority;
int dnssrvweight;
int dnssrvport;
}; };
@@ -361,6 +364,9 @@ static void write_rr(struct resourcerecord* rr, int ipdx, int znix)
{ {
char ip[4]; char ip[4];
char buf[4]; char buf[4];
char *tmp;
char *p;
int i;
if (strcasecmp(rr->class, "IN")) if (strcasecmp(rr->class, "IN"))
return; return;
@@ -452,10 +458,21 @@ static void write_rr(struct resourcerecord* rr, int ipdx, int znix)
fprintf(tinyfile, "'%s:%s:%s:%s:%s\n", rr->dnsdomainname, rr->cname, rr->ttl, rr->timestamp, rr->location); fprintf(tinyfile, "'%s:%s:%s:%s:%s\n", rr->dnsdomainname, rr->cname, rr->ttl, rr->timestamp, rr->location);
if (namedzone) if (namedzone)
fprintf(namedzone, "%s.\tIN TXT\t%s.\n", rr->dnsdomainname, rr->cname); fprintf(namedzone, "%s.\tIN TXT\t%s.\n", rr->dnsdomainname, rr->cname);
} else if (strcasecmp(rr->type, "SRV")==0) {
if (tinyfile)
fprintf(tinyfile, ":%s:33:\\%03o\\%03o\\%03o\\%03o\\%03o\\%03o", rr->dnsdomainname, rr->dnssrvpriority >> 8, rr->dnssrvpriority & 0xff, rr->dnssrvweight >> 8, rr->dnssrvweight & 0xff, rr->dnssrvport >> 8, rr->dnssrvport & 0xff);
tmp = strdup(rr->cname);
while (p = strchr(tmp, '.')) {
*p = '\0';
p++;
fprintf(tinyfile, "\\%03o%s", strlen(tmp), tmp);
tmp = p;
}
fprintf(tinyfile, "\\%03o%s", strlen(tmp), tmp);
fprintf(tinyfile, "\\000:%s:%s:%s\n", rr->ttl, rr->timestamp, rr->location);
} }
} }
#if defined DRAFT_RFC #if defined DRAFT_RFC
static void parse_rr(struct resourcerecord* rr) static void parse_rr(struct resourcerecord* rr)
{ {
@@ -528,6 +545,9 @@ static void read_resourcerecords(char* dn, int znix)
rr.aliasedobjectname[0] = '\0'; rr.aliasedobjectname[0] = '\0';
rr.rr[0] = '\0'; rr.rr[0] = '\0';
#endif #endif
rr.dnssrvpriority = 0;
rr.dnssrvweight = 0;
rr.dnssrvport = 0;
for (attr = ldap_first_attribute(ldap_con, m, &ber); attr; attr = ldap_next_attribute(ldap_con, m, ber)) { for (attr = ldap_first_attribute(ldap_con, m, &ber); attr; attr = ldap_next_attribute(ldap_con, m, ber)) {
int len = strlen(attr); int len = strlen(attr);
struct berval** bvals; struct berval** bvals;
@@ -613,6 +633,22 @@ static void read_resourcerecords(char* dn, int znix)
} else if (strcasecmp(attr, "DNSmacaddress")==0) { } else if (strcasecmp(attr, "DNSmacaddress")==0) {
} }
#endif #endif
else if (strcasecmp(attr, "DNSsrvpriority")==0) {
if (!(rr.dnssrvpriority = atoi(bvals[0]->bv_val)))
rr.dnssrvpriority = 0;
else if (options.ldifname[0])
fprintf(ldifout, "%s: %d\n", attr, rr.dnssrvpriority);
} else if (strcasecmp(attr, "DNSsrvweight")==0) {
if (!(rr.dnssrvweight = atoi(bvals[0]->bv_val)))
rr.dnssrvweight = 0;
else if (options.ldifname[0])
fprintf(ldifout, "%s: %d\n", attr, rr.dnssrvweight);
} else if (strcasecmp(attr, "DNSsrvport")==0) {
if (!(rr.dnssrvport = atoi(bvals[0]->bv_val)))
rr.dnssrvport = 0;
else if (options.ldifname[0])
fprintf(ldifout, "%s: %d\n", attr, rr.dnssrvport);
}
} }
ldap_value_free_len(bvals); ldap_value_free_len(bvals);
} }