1: // $Id: dnsutil.cc,v 1.9 2001/11/05 03:26:18 jdw Exp $
   2: 
   3: 
   4: /**********************
   5: *                     *
   6: *  COMPILER INCLUDES  *
   7: *                     *
   8: **********************/
   9: 
  10: 
  11: #include <cassert> 
  12: #include <cstring> 
  13: 
  14: 
  15: /*********************
  16: *                    *
  17: *  PROJECT INCLUDES  *
  18: *                    *
  19: *********************/
  20: 
  21: 
  22: #include "dnsutil.h" 
  23: #include "wwwi/string.h" 
  24: 
  25: 
  26: /**************************
  27: *                         *
  28: *  FUNCTION GETCLASSNAME  *
  29: *                         *
  30: **************************/
  31: 
  32: 
  33: const char *GetClassName(RRClass i_rrClass) {
  34:   switch(i_rrClass) {
  35:   case CL_IN: return "IN";
  36:   case CL_CS: return "CS";
  37:   case CL_CH: return "CH"; 
  38:   case CL_HS: return "HS";
  39:   case CL_QANY: return "(ANY)";
  40:   }
  41:   assert(0);
  42:   return "(Unknown Class)"; 
  43: }
  44: 
  45: 
  46: /***************************
  47: *                          *
  48: *  FUNCTION GETOPCODENAME  *
  49: *                          *
  50: ***************************/
  51: 
  52: 
  53: const char *GetOpcodeName(Opcode i_op) {
  54:   switch(i_op) {
  55:   case OPCODE_QUERY: return "QUERY";
  56:   case OPCODE_IQUERY: return "IQUERY";
  57:   case OPCODE_STATUS: return "STATUS";
  58:   case OPCODE_NOTIFY: return "NOTIFY";
  59:   case OPCODE_UPDATE: return "UPDATE";
  60:   }
  61:   assert(0);
  62:   return "(Unknown Opcode)";
  63: }
  64: 
  65: 
  66: /**************************
  67: *                         *
  68: *  FUNCTION GETRCODENAME  *
  69: *                         *
  70: **************************/
  71: 
  72: 
  73: const char *GetRCodeName(RCode i_rc) {
  74:   switch(i_rc) {
  75:   case RCODE_NOERROR: return "NOERROR";
  76:   case RCODE_FORMERR: return "FORMERR";
  77:   case RCODE_SERVFAIL: return "SERVFAIL";
  78:   case RCODE_NXDOMAIN: return "NXDOMAIN";
  79:   case RCODE_NOTIMP: return "NOTIMP";
  80:   case RCODE_REFUSED: return "REFUSED"; 
  81:   case RCODE_YXDOMAIN: return "YXDOMAIN";
  82:   case RCODE_YXRRSET: return "YXRRSET";
  83:   case RCODE_NXRRSET: return "NXRRSET";
  84:   case RCODE_NOTAUTH: return "NOTAUTH";
  85:   case RCODE_NOTZONE: return "NOTZONE";
  86:   default: return "RCODE_UNKNOWN";
  87:   }
  88: }
  89: 
  90: 
  91: /*************************
  92: *                        *
  93: *  FUNCTION GETTYPENAME  *
  94: *                        *
  95: *************************/
  96: 
  97: 
  98: #define RRTX(XXX) case TY_##XXX: return #XXX; 
  99: 
 100: const char *GetTypeName(RRType i_ty) {
 101:   switch(i_ty) {
 102:   RRTX(A);
 103:   RRTX(NS);
 104:   RRTX(MD);
 105:   RRTX(MF);
 106:   RRTX(CNAME);
 107:   RRTX(SOA);
 108:   RRTX(MB);
 109:   RRTX(MG);
 110:   RRTX(MR);
 111:   RRTX(NULL);
 112:   RRTX(OPT);
 113:   RRTX(WKS);
 114:   RRTX(PTR);
 115:   RRTX(HINFO);
 116:   RRTX(MINFO);
 117:   RRTX(MX);
 118:   RRTX(TXT);
 119:   RRTX(AAAA);
 120:   case TY_QIXFR: return "(IXFR)"; 
 121:   case TY_QAXFR: return "(AXFR)"; 
 122:   case TY_QMAILB: return "(MAILB)";
 123:   case TY_QMAILA: return "(MAILA)";
 124:   case TY_QANY: return "(ANY)";
 125:   }
 126:   assert(0);
 127:   return "(Unknown Type)";
 128: }
 129: 
 130: 
 131: