Logo Search packages:      
Sourcecode: ldns version File versions  Download package

ldns_rr_type ldns_get_rr_type_by_name ( const char *  name  ) 

retrieves a rrtype by looking up its name.

Parameters:
[in] name a string with the name
Returns:
the type which corresponds with the name

Definition at line 2037 of file rr.c.

References ldns_struct_rr_descriptor::_name, ldns_get_rr_type_by_name(), and ldns_rr_descript().

Referenced by ldns_get_rr_type_by_name(), ldns_rr_new_frm_str(), ldns_str2rdf_nsec(), and ldns_str2rdf_type().

{
      unsigned int i;
      const char *desc_name;
      const ldns_rr_descriptor *desc;
      
      /* TYPEXX representation */
      if (strlen(name) > 4 && strncasecmp(name, "TYPE", 4) == 0) {
            return atoi(name + 4);
      }

      /* Normal types */
      for (i = 0; i < (unsigned int) LDNS_RDATA_FIELD_DESCRIPTORS_COUNT; i++) {
            desc = ldns_rr_descript(i);
            desc_name = desc->_name;
            if(desc_name &&
               strlen(name) == strlen(desc_name) &&
               strncasecmp(name, desc_name, strlen(desc_name)) == 0) {
                  return i;
            }
      }
      
      /* special cases for query types */
      if (strlen(name) == 4 && strncasecmp(name, "IXFR", 4) == 0) {
            return 251;
      } else if (strlen(name) == 4 && strncasecmp(name, "AXFR", 4) == 0) {
            return 252;
      } else if (strlen(name) == 5 && strncasecmp(name, "MAILB", 5) == 0) {
            return 253;
      } else if (strlen(name) == 5 && strncasecmp(name, "MAILA", 5) == 0) {
            return 254;
      } else if (strlen(name) == 3 && strncasecmp(name, "ANY", 3) == 0) {
            return 255;
      }
      
      return 0;
}


Generated by  Doxygen 1.6.0   Back to index