pike.git / lib / modules / Protocols.pmod / DNS.pmod

version» Context lines:

pike.git/lib/modules/Protocols.pmod/DNS.pmod:1: - // $Id: DNS.pmod,v 1.81 2003/10/21 03:10:39 nilsson Exp $ + // $Id: DNS.pmod,v 1.82 2004/04/13 13:14:19 grubba Exp $   // Not yet finished -- Fredrik Hubinette      //! Domain Name System   //! RFC 1035      #pike __REAL_VERSION__      constant NOERROR=0;   constant FORMERR=1;   constant SERVFAIL=2;
pike.git/lib/modules/Protocols.pmod/DNS.pmod:81:       //! Type - mail exchange    T_MX=15,       //! Type - text strings    T_TXT=16,       //! Type - IPv6 address record (RFC 1886, deprecated)    T_AAAA=28,    +  //! Type - Location Record (RFC 1876) +  T_LOC=29, +     //! Type - Service location record (RFC 2782)    T_SRV=33,       //! Type - IPv6 address record (RFC 2874, incomplete support)    T_A6=38,   };      //! Low level DNS protocol   class protocol   {
pike.git/lib/modules/Protocols.pmod/DNS.pmod:177:    case T_SOA:    string mname = mkname(entry->mname, pos, c);    return mname + mkname(entry->rname, pos+sizeof(mname), c) +    sprintf("%4c%4c%4c%4c%4c", entry->serial, entry->refresh,    entry->retry, entry->expire, entry->minimum);    case T_TXT:    return Array.map(stringp(entry->txt)? ({entry->txt}):(entry->txt||({})),    lambda(string t) {    return sprintf("%1c%s", sizeof(t), t);    })*""; +  case T_LOC: +  // FIXME: Not implemented yet.    default:    return "";    }    }       static private string encode_entries(array(mapping) entries, int pos,    mapping(string:int) comp)    {    string res="";    foreach(entries, mapping entry) {
pike.git/lib/modules/Protocols.pmod/DNS.pmod:295:    }    }       string decode_string(string s, array(int) next)    {    int len=s[next[0]];    next[0]+=len+1;    return s[next[0]-len..next[0]-1];    }    +  int decode_byte(string s, array(int) next) +  { +  return s[next[0]++]; +  } +     int decode_short(string s, array(int) next)    {    sscanf(s[next[0]..next[0]+1],"%2c",int ret);    next[0]+=2;    return ret;    }       int decode_int(string s, array(int) next)    {    sscanf(s[next[0]..next[0]+3],"%4c",int ret);
pike.git/lib/modules/Protocols.pmod/DNS.pmod:377:       m->ttl=decode_int(s,next);    break;    case T_A:    m->a=sprintf("%{.%d%}",values(s[next[0]..next[0]+m->len-1]))[1..];    break;    case T_AAAA:    m->aaaa=sprintf("%{:%02X%02X%}",    values(s[next[0]..next[0]+m->len-1])/2)[1..];    break; +  case T_LOC: +  m->version = decode_byte(s,next); +  if (m->version == 0) +  { +  int aByte; +  aByte = decode_byte(s,next); +  m->size = pow((aByte>>4)&0xf , aByte&0xf)/100.0; +  aByte = decode_byte(s,next); +  m->h_perc = pow((aByte>>4)&0xf , aByte&0xf)/100.0; +  aByte = decode_byte(s,next); +  m->v_perc = pow((aByte>>4)&0xf , aByte&0xf)/100.0; +  m->lat = ((decode_int(s,next)-(2<<30))/3600000.0); +  m->long = ((decode_int(s,next)-(2<<30))/3600000.0); +  m->alt = ((decode_int(s,next)/100.0)-100000.0); +  } +  break;    case T_SOA:    m->mname=decode_domain(s,next);    m->rname=decode_domain(s,next);    m->serial=decode_int(s,next);    m->refresh=decode_int(s,next);    m->retry=decode_int(s,next);    m->expire=decode_int(s,next);    m->minimum=decode_int(s,next);    break;    }