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

version» Context lines:

pike.git/lib/modules/Protocols.pmod/DNS.pmod:139:    return 0;   }      //! Low level DNS protocol   class protocol   {    string mklabel(string s)    {    if(sizeof(s)>63)    error("Too long component in domain name.\n"); -  return sprintf("%c%s",sizeof(s),s); +  return sprintf("%1H",s);    }       protected private string mkname(string|array(string) labels, int pos,    mapping(string:int) comp)    {    if(stringp(labels))    labels = labels/"."-({""});    if(!labels || !sizeof(labels))    return "\0";    string n = labels*".";
pike.git/lib/modules/Protocols.pmod/DNS.pmod:188:    return mkname(entry->mf, pos, c);    case T_MB:    return mkname(entry->mb, pos, c);    case T_MG:    return mkname(entry->mg, pos, c);    case T_MR:    return mkname(entry->mr, pos, c);    case T_MX:    return sprintf("%2c", entry->preference)+mkname(entry->mx, pos+2, c);    case T_HINFO: -  return sprintf("%1c%s%1c%s", sizeof(entry->cpu||""), entry->cpu||"", -  sizeof(entry->os||""), entry->os||""); +  return sprintf("%1H%1H", entry->cpu||"", entry->os||"");    case T_MINFO:    string rmailbx = mkname(entry->rmailbx, pos, c);    return rmailbx + mkname(entry->emailbx, pos+sizeof(rmailbx), c);    case T_SRV:    return sprintf("%2c%2c%2c", entry->priority, entry->weight, entry->port) +    mkname(entry->target||"", pos+6, c);    case T_A:    return sprintf("%@1c", (array(int))((entry->a||"0.0.0.0")/".")[0..3]);    case T_AAAA:    return make_raw_addr6(entry->aaaa);
pike.git/lib/modules/Protocols.pmod/DNS.pmod:214:    entry->a6->prefixlen,    make_raw_addr6(entry->a6->address)[entry->a6->prefixlen/8..],    entry->a6->prefixname||"");    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_NAPTR:    string rnaptr = sprintf("%2c%2c", entry->order, entry->preference); -  rnaptr += sprintf("%1c%s%1c%s%1c%s%s", -  sizeof(entry->flags || ""), entry->flags || "", -  sizeof(entry->service || ""), entry->service || "", -  sizeof(entry->regexp || ""), entry->regexp || "", +  rnaptr += sprintf("%1H%1H%1H%s", +  entry->flags || "", +  entry->service || "", +  entry->regexp || "",    mkname(entry->replacement, pos, c));    return rnaptr;       case T_TXT:    return Array.map(stringp(entry->txt)? ({entry->txt}):(entry->txt||({})),    lambda(string t) { -  return sprintf("%1c%s", sizeof(t), t); +  return sprintf("%1H", t);    })*"";    case T_SPF:    return Array.map(stringp(entry->spf)? ({entry->spf}):(entry->spf||({})),    lambda(string t) { -  return sprintf("%1c%s", sizeof(t), t); +  return sprintf("%1H", t);    })*"";    case T_LOC:    // FIXME: Not implemented yet.    default:    return "";    }    }       protected private string encode_entries(array(mapping) entries, int pos,    mapping(string:int) comp)    {    string res="";    foreach(entries, mapping entry) {    string e = mkname(entry->name, pos, comp)+    sprintf("%2c%2c%4c", entry->type, entry->cl, entry->ttl);    pos += sizeof(e)+2;    string rd = entry->rdata || mkrdata(entry, pos, comp); -  res += e + sprintf("%2c", sizeof(rd)) + rd; +  res += e + sprintf("%2H", rd);    pos += sizeof(rd);    }    return res;    }       string low_low_mkquery(mapping q)    {    array qd = q->qd && (arrayp(q->qd)? q->qd : ({q->qd}));    array an = q->an && (arrayp(q->an)? q->an : ({q->an}));    array ns = q->ns && (arrayp(q->ns)? q->ns : ({q->ns}));
pike.git/lib/modules/Protocols.pmod/DNS.pmod:1008:          rec_data(m, this);    }    }    }       void send(string s) {    if (sizeof(s) > 65535)    error("DNS: Cannot send packets > 65535 bytes (%d here).\n", sizeof(s)); -  out_buffer += sprintf("%2c%s", sizeof(s), s); +  out_buffer += sprintf("%2H", s);       if (write_ready) {    int written = con->write(out_buffer);    out_buffer = out_buffer[written..];    write_ready = 0;    }       remove_call_out(c_id);    c_id = call_out(destruct, 120, this);    }