pike.git / lib / modules / Protocols.pmod / LDAP.pmod / protocol.pike

version» Context lines:

pike.git/lib/modules/Protocols.pmod/LDAP.pmod/protocol.pike:31:       /*private*/ string readbuf=""; // read buffer    private int ok; // read buffer status    /*private*/ string writebuf=""; // write buffer   // private written; // count of written chars    private function con_ok; // async callback functions    object conthread; // thread connection    array extra_args; // not used, yet   // /*private*/ int errno;    int connected = 0; -  Stdio.File ldapfd; // helper fd +     -  + #if constant(SSL.Cipher) +  Stdio.Stream|SSL.File ldapfd; // helper fd + #else +  Stdio.Stream ldapfd; // helper fd + #endif +    protected int last_io_time; // Timestamp when I/O on the fd was made last.       int seterr(int errno, void|string errstr) {    // Sets ldap_err* variables and returns errno       ldap_rem_errstr = errstr;    ldap_errno = errno;    return errno;    }   
pike.git/lib/modules/Protocols.pmod/LDAP.pmod/protocol.pike:100:    readbuf = ldapfd->read(2); // 1. byte = 0x0C, 2. byte = msglen    if (intp(readbuf) || (sizeof(readbuf) < 2)) {    seterr (LDAP_SERVER_DOWN,    !readbuf ? strerror (ldapfd->errno()) : "Connection closed");    ERROR ("LDAP read error: %s\n", ldap_rem_errstr);    //return -ldap_errno;    return;    }    if (readbuf[0] != '0') {    seterr (LDAP_PROTOCOL_ERROR); -  DWRITE_HI("protocol.read_answer: ERROR: retv=<"+sprintf("%O",readbuf)+">\n"); +  DWRITE_HI("protocol.read_answer: ERROR: retv=<%O>\n", readbuf);    THROW(({"LDAP: Protocol mismatch.\n",backtrace()}));    //return -ldap_errno;    return;    } -  DWRITE(sprintf("protocol.read_answer: sizeof = %d\n", sizeof(readbuf))); +  DWRITE("protocol.read_answer: sizeof = %d\n", sizeof(readbuf));       msglen = readbuf[1];    ofs = 2;    if (msglen & 0x80) { // > 0x7f    if (msglen == 0x80) { // RFC not allows unexplicitly defined length    seterr (LDAP_PROTOCOL_ERROR);    THROW(({"LDAP: Protocol mismatch.\n",backtrace()}));    //return -ldap_errno;    return;    }
pike.git/lib/modules/Protocols.pmod/LDAP.pmod/protocol.pike:145:    if(ix > 0)    s = ldapfd->read(ix);    if (!s || (sizeof(s) < ix)) {    seterr (LDAP_CONNECT_ERROR,    !s ? strerror (ldapfd->errno()) : "Connection closed");    ERROR ("LDAP read error: %s\n", ldap_rem_errstr);    //return -ldap_errno;    return;    }    readbuf += s; -  //DWRITE(sprintf("protocol.read_answer: %O\n", .ldap_privates.ldap_der_decode(readbuf))); +  //DWRITE("protocol.read_answer: %O\n", .ldap_privates.ldap_der_decode(readbuf));    DWRITE("protocol.read_answer: ok=1.\n");    ok = 1;       last_io_time = time();       if(con_ok)    con_ok(this, @extra_args);    }       protected int is_whole_pdu() {
pike.git/lib/modules/Protocols.pmod/LDAP.pmod/protocol.pike:207:    // ---------------------------    // Make LDAP PDU envelope for 'msgop', send it and read answer ...       object msgval;    object msgid;    int rv = 0, msgnum;       //THREAD_LOCK    msgnum = next_id++;    //THREAD_UNLOCK -  msgid = Standards.ASN1.Types.asn1_integer(msgnum); +  msgid = Standards.ASN1.Types.Integer(msgnum);    if (controls) { -  msgval = Standards.ASN1.Types.asn1_sequence(({msgid, msgop, controls})); +  msgval = Standards.ASN1.Types.Sequence(({msgid, msgop, controls}));    } else { -  msgval = Standards.ASN1.Types.asn1_sequence(({msgid, msgop})); +  msgval = Standards.ASN1.Types.Sequence(({msgid, msgop}));    }       if (objectp(msgval)) { -  DWRITE(sprintf("protocol.do_op: msg = [%d]\n",sizeof(msgval->get_der()))); +  DWRITE("protocol.do_op: msg = [%d]\n",sizeof(msgval->get_der()));    } else    DWRITE("protocol.do_op: msg is null!\n");       // call_out    writebuf = msgval->get_der();    rv = ldapfd->write(writebuf); // !!!!! - jak rozlisit async a sync ????    // call_out    if (rv < 2) {    seterr (LDAP_SERVER_DOWN, strerror (ldapfd->errno()));    ERROR ("LDAP write error: %s\n", ldap_rem_errstr);    return -ldap_errno;    } -  DWRITE(sprintf("protocol.do_op: write OK [%d bytes].\n",rv)); +  DWRITE("protocol.do_op: write OK [%d bytes].\n",rv);    msgval = 0; msgid = 0;    writebuf= "";    readbuf= ""; // !!! NEni to pozde ?       last_io_time = time();       //`()();       read_answer();    // now is all in 'readbuf'
pike.git/lib/modules/Protocols.pmod/LDAP.pmod/protocol.pike:260:    string|int retv;    string s, shlp;       retv = ldapfd->read(2); // 1. byte = 0x0C, 2. byte = msglen    if (!retv || (sizeof(retv) != 2) || (retv[0] != '0')) {    seterr (LDAP_SERVER_DOWN,    !retv ? strerror (ldapfd->errno()) : "Connection closed");    ERROR ("LDAP read error: %s\n", ldap_rem_errstr);    return -ldap_errno;    } -  DWRITE(sprintf("protocol.readmsg: sizeof = %d\n", sizeof(retv))); +  DWRITE("protocol.readmsg: sizeof = %d\n", sizeof(retv));       msglen = retv[1];    if (msglen & 0x80) { // > 0x7f    if (msglen == 0x80) { // RFC does not allow implicitly defined length    seterr (LDAP_PROTOCOL_ERROR);    THROW(({"LDAP: Protocol mismatch.\n",backtrace()}));    return -ldap_errno;    }    s = ldapfd->read(msglen & 0x7f);    if (!s) {
pike.git/lib/modules/Protocols.pmod/LDAP.pmod/protocol.pike:282:    ERROR ("LDAP read error: %s\n", ldap_rem_errstr);    return -ldap_errno;    }    retv += s;    msglen = 0; // !!! RESTRICTION: 2^32 !!!    shlp = reverse(s);    for (ix=0; ix<sizeof(shlp); ix++) {    msglen += shlp[ix]*(1<<(ix*8));    }    } -  DWRITE(sprintf("protocol.readmsg: reading %d bytes.\n", msglen)); +  DWRITE("protocol.readmsg: reading %d bytes.\n", msglen);    s = ldapfd->read(msglen);    if (!s | (sizeof(s) < msglen)) {    seterr (LDAP_SERVER_DOWN,    !s ? strerror (ldapfd->errno()) : "Connection closed");    ERROR ("LDAP read error: %s\n", ldap_rem_errstr);    return -ldap_errno;    }    retv += s;    last_io_time = time(); -  DWRITE(sprintf("protocol.readmsg: %O\n", .ldap_privates.ldap_der_decode(retv))); +  DWRITE("protocol.readmsg: %O\n", .ldap_privates.ldap_der_decode(retv));    return retv;    }       int writemsg(object msgop) {    // Make LDAP PDU envelope for 'msgop' and send it       object msgval;    object msgid;    int rv = 0, msgnum;       //THREAD_LOCK    msgnum = next_id++;    //THREAD_UNLOCK -  msgid = Standards.ASN1.Types.asn1_integer(msgnum); -  msgval = Standards.ASN1.Types.asn1_sequence(({msgid, msgop})); +  msgid = Standards.ASN1.Types.Integer(msgnum); +  msgval = Standards.ASN1.Types.Sequence(({msgid, msgop}));       if (objectp(msgval)) { -  DWRITE(sprintf("protocol.writemsg: msg = [%d]\n",sizeof(msgval->get_der()))); +  DWRITE("protocol.writemsg: msg = [%d]\n",sizeof(msgval->get_der()));    } else    DWRITE("protocol.writemsg: msg is null!\n");       // call_out    rv = ldapfd->write(msgval->get_der());    // call_out    if (rv < 2) {    seterr (LDAP_SERVER_DOWN, strerror (ldapfd->errno()));    ERROR ("LDAP write error: %s\n", ldap_rem_errstr);    return -ldap_errno;    } -  DWRITE(sprintf("protocol.writemsg: write OK [%d bytes].\n",rv)); +  DWRITE("protocol.writemsg: write OK [%d bytes].\n",rv);    msgval = 0; msgid = 0;    last_io_time = time();    return msgnum;    }