NSIS-ka
A free C++ implementation of NSIS protocols

Changeset 4228


Ignore:
Timestamp:
Aug 11, 2009, 1:53:39 PM (8 years ago)
Author:
bless
Message:
  • implemented get_errorsubcode_str(), improved print output, inactivated serialize debugging messages
File:
1 edited

Legend:

Unmodified
Added
Removed
  • ntlp/trunk/src/pdu/ntlp_errorobject.cpp

    r4210 r4228  
    407407// special serialization function with the ability to omit the TLV header
    408408void errorobject::serializeEXT(NetMsg& msg, coding_t cod, uint32& wbytes, bool header) const {
    409   uint32 save_pos= msg.get_pos();
     409        //uint32 save_pos= msg.get_pos();
    410410
    411411    // calculate length of object body
     
    414414      ielen-= header_length;
    415415
    416     DLog("errorobject::serialize()","SHOULD be of length: " << ielen << " bytes" << (header ? "(incl. object header)" : "(no object header)"));
     416    //DLog("errorobject::serialize()","SHOULD be of length: " << ielen << " bytes" << (header ? "(incl. object header)" : "(no object header)"));
    417417    // check arguments and IE state
    418418    check_ser_args(cod,wbytes);
    419     DLog("errorobject::serialize()", "Bytes left in NetMsg: " << msg.get_bytes_left());
     419    //DLog("errorobject::serialize()", "Bytes left in NetMsg: " << msg.get_bytes_left());
    420420    // Encode object TLV header
    421421    if (header)
    422422    {
    423423      encode_header_ntlpv1(msg, ielen - header_length);
    424       DLog("errorobject::serialize()", "NTLP Object Header encoded (4 byte) bytes left in NetMsg: " << msg.get_bytes_left());
    425     }
    426     DLog("errorobject::serialize()", "Begin of serialization");
     424      //DLog("errorobject::serialize()", "NTLP Object Header encoded (4 byte) bytes left in NetMsg: " << msg.get_bytes_left());
     425    }
     426    //DLog("errorobject::serialize()", "Begin of serialization");
    427427
    428428    // encode errorclass
     
    442442    if (flags & MRI) {
    443443      msg.encode8((embedded_mri->get_serialized_size(cod)-header_length) / 4);
    444       DLog("errorobject::serialize()", "Expected MRI length (#bytes w/o TLV header):" << embedded_mri->get_serialized_size(cod)-header_length);
     444      //DLog("errorobject::serialize()", "Expected MRI length (#bytes w/o TLV header):" << embedded_mri->get_serialized_size(cod)-header_length);
    445445    }
    446446    else
     
    450450    msg.encode8(infocount);
    451451
    452     DLog("errorobject::serialize()", "2nd word encoded (now: 12 bytes incl. object header), starting now common header, bytes left in NetMsg: " << msg.get_bytes_left());
     452    //DLog("errorobject::serialize()", "2nd word encoded (now: 12 bytes incl. object header), starting now common header, bytes left in NetMsg: " << msg.get_bytes_left());
    453453
    454454    // encode common header
     
    461461    msg.encode8(ch_flags);
    462462
    463     DLog("errorobject::serialize()", "common header encoded (now: 20 bytes incl. object header), starting now common header, bytes left in NetMsg: " << msg.get_bytes_left());
     463    //DLog("errorobject::serialize()", "common header encoded (now: 20 bytes incl. object header), starting now common header, bytes left in NetMsg: " << msg.get_bytes_left());
    464464
    465465    uint32 written=0;
     
    474474      {
    475475        embedded_sessionid->serializeNoHead(msg, cod, written);
    476         DLog("errorobject::serialize()", "SessionID encoded, "<< written << " bytes, bytes left in NetMsg: " << msg.get_bytes_left());
     476        //DLog("errorobject::serialize()", "SessionID encoded, "<< written << " bytes, bytes left in NetMsg: " << msg.get_bytes_left());
    477477      }
    478478      else
     
    488488      embedded_mri->serializeNoHead(msg, cod, written);
    489489           
    490       DLog("errorobject::serialize()", "MRI encoded, "<< written << " bytes written, bytes left in NetMsg: " << msg.get_bytes_left());
     490      //DLog("errorobject::serialize()", "MRI encoded, "<< written << " bytes written, bytes left in NetMsg: " << msg.get_bytes_left());
    491491       
    492492    };
     
    497497    //                      in the message
    498498    if (mli) {
    499       DLog("errorobject::serialize()", "Encoding Msg Len Info (4 + 4 bytes), bytes left in NetMsg: " << msg.get_bytes_left());
     499            //DLog("errorobject::serialize()", "Encoding Msg Len Info (4 + 4 bytes), bytes left in NetMsg: " << msg.get_bytes_left());
    500500      msg.encode16(ai_Message_Length_Info);
    501501      msg.encode16(1);                                          // 32 bit words
    502502      msg.encode16(mli);
    503503      msg.encode16(0);   // lower 16 bits currently reserved
    504       DLog("errorobject::serialize()", "Msg Len Info encoded, 4 + 4 bytes, bytes left in NetMsg: " << msg.get_bytes_left());
     504      //DLog("errorobject::serialize()", "Msg Len Info encoded, 4 + 4 bytes, bytes left in NetMsg: " << msg.get_bytes_left());
    505505    }
    506506
    507507    // MTU info: MTU for a link along which a message could not be sent
    508508    if (mtu) {
    509       DLog("errorobject::serialize()", "Encoding MTU (4 + 4 bytes), bytes left in NetMsg: " << msg.get_bytes_left());
     509            //DLog("errorobject::serialize()", "Encoding MTU (4 + 4 bytes), bytes left in NetMsg: " << msg.get_bytes_left());
    510510      msg.encode16(ai_MTU_Info);
    511511      msg.encode16(1);                                          // 32 bit words
    512512      msg.encode16(mtu);
    513513      msg.encode16(0);   // lower 16 bits currently reserved
    514       DLog("errorobject::serialize()", "MTU encoded, 4 + 4 bytes, bytes left in NetMsg: " << msg.get_bytes_left());
     514      //DLog("errorobject::serialize()", "MTU encoded, 4 + 4 bytes, bytes left in NetMsg: " << msg.get_bytes_left());
    515515    }
    516516
    517517    // Object Type Info: provides info about the object that caused the error
    518518    if (oti != oti_not_set) {
    519       DLog("errorobject::serialize()", "Encoding Object Type Info (4 + 4 bytes), bytes left in NetMsg: " << msg.get_bytes_left());
     519            //DLog("errorobject::serialize()", "Encoding Object Type Info (4 + 4 bytes), bytes left in NetMsg: " << msg.get_bytes_left());
    520520      msg.encode16(ai_Object_Type_Info);
    521521      msg.encode16(1);                                          // 32 bit words
     
    526526      msg.encode16(oti & 0x0fff);
    527527      msg.encode16(0);   // lower 16 bits currently reserved
    528       DLog("errorobject::serialize()", "Object Type Info encoded, 4 + 4 bytes, bytes left in NetMsg: " << msg.get_bytes_left());
     528      //DLog("errorobject::serialize()", "Object Type Info encoded, 4 + 4 bytes, bytes left in NetMsg: " << msg.get_bytes_left());
    529529
    530530    }
     
    533533    if (ovi_object) {
    534534      uint16 ai_len;
    535       DLog("errorobject::serialize()", "Encoding Object value info 4 + " << ovi_object->get_serialized_size(protocol_v1)+4 <<" bytes, bytes left in NetMsg: " << msg.get_bytes_left());
     535      //DLog("errorobject::serialize()", "Encoding Object value info 4 + " << ovi_object->get_serialized_size(protocol_v1)+4 <<" bytes, bytes left in NetMsg: " << msg.get_bytes_left());
    536536      msg.encode16(ai_Object_Value_Info);
    537537      ai_len = ovi_object->get_serialized_size(protocol_v1) + 1;
     
    540540      msg.encode16(ovi_offset);
    541541      ovi_object->serialize(msg, cod, written);
    542       DLog("errorobject::serialize()", "Object value info encoded, "<< written << " bytes, bytes left in NetMsg: " << msg.get_bytes_left());
     542      //DLog("errorobject::serialize()", "Object value info encoded, "<< written << " bytes, bytes left in NetMsg: " << msg.get_bytes_left());
    543543    }
    544544
    545545    wbytes = ielen;
    546546       
    547     ostringstream tmpostr;
     547    //ostringstream tmpostr;
    548548    //msg.hexdump(tmpostr,msg.get_buffer()+save_pos,wbytes);
    549     DLog("errorobject::serialize()", "netmsg pos:" << msg.get_pos() << " netmsg @" << save_pos << ":" << tmpostr.str().c_str());
     549    //DLog("errorobject::serialize()", "netmsg pos:" << msg.get_pos() << " netmsg @" << save_pos << ":" << tmpostr.str().c_str());
    550550    return;
    551551} // end serialize
     
    734734
    735735
     736
     737const char *const
     738errorobject::get_errorsubcode_str() const
     739{
     740        switch (errorcode) {
     741
     742        case err_CommonHeaderParseError:
     743               
     744                switch (errorsubcode) {
     745                case errsub_UnknownVersion :
     746                        return "Unknown Version";
     747                       
     748                case    errsub_UnknownType :
     749                        return "Unknown Type";
     750
     751                case    errsub_InvalidRFlag :
     752                        return "Invalid R Flag";
     753
     754                case    errsub_IncorrectMsgLength :
     755                        return "Incorrect Message Length";
     756
     757                case    errsub_InvalidEFlag :
     758                        return "Invalid E Flag";
     759                       
     760                case    errsub_InvalidCFlag :
     761                        return "Invalid C Flag";
     762                default:
     763                        return "Unknown/Unimplemented Error Subcode";
     764                } // end switch errsub
     765                break;
     766
     767        case err_ObjectTypeError:
     768                switch (errorsubcode) {
     769                case errsub_DuplicateObject :
     770                        return "Duplicate Object";
     771
     772                case errsub_UnrecognizedObject  :
     773                        return "Unrecognized Object";
     774
     775                case errsub_MissingObject       :
     776                        return "Missing Object";
     777
     778                case errsub_InvalidObject       :
     779                        return "Invalid Object";
     780
     781                case errsub_UntranslatedObject  :
     782                        return "Untranslated Object";
     783
     784                case errsub_InvalidExtensibilityFlags :
     785                        return "Invalid Extensibility Flags";
     786
     787                default:
     788                        return "Unknown/Unimplemented Error Subcode";
     789                } // end switch errsub
     790                break;
     791
     792        case err_ObjectValueError:
     793                switch (errorsubcode) {
     794
     795                case    errsub_IncorrectLength :
     796                        return "Incorrect Length";
     797
     798                case    errsub_ValueNotSupported :
     799                        return "Value Not Supported";
     800
     801                case    errsub_InvalidFlagFieldCombination :
     802                        return "Invalid Flag Field Combination";
     803
     804                case    errsub_EmptyList :
     805                        return "Empty List";
     806
     807                case    errsub_InvalidCookie :
     808                        return "Invalid Cookie";
     809
     810                case    errsub_SP_SCD_Mismatch :
     811                        return "Stack Proposal/Stack Configuration Data Mismatch";
     812
     813                default:
     814                        return "Unknown/Unimplemented Error Subcode";
     815
     816                } // end switch errsub
     817                break;
     818
     819        case err_MRIValidationFailure :
     820                switch (errorsubcode) {
     821
     822                case errsub_MRITooWild :
     823                        return "MRI too wild";
     824
     825                case errsub_IPVersionMismatch :
     826                        return "IP Version Mismatch";
     827
     828                case errsub_IngressFilterFailure :
     829                        return "Ingress Filter Failure";
     830
     831
     832                default:
     833                        return "Unknown/Unimplemented Error Subcode";
     834                } // end switch errsub
     835                break;
     836
     837        default:
     838                switch (errorsubcode) {
     839                case errsub_Default :
     840                        return "(Plain/Default Subcode)";
     841                default:
     842                        return "Unknown/Unimplemented Error Subcode";
     843                } // end switch errsub
     844               
     845        } // end switch error code
     846}
     847
    736848ostream&
    737849errorobject::print(ostream& os, uint32 level, const uint32 indent, const char* name) const
     
    741853    if (name && (*name!=0)) os << name << endl;
    742854
    743     os << get_errorclass_str() << "(" << static_cast<unsigned int>(errorclass) << "):"
    744        << get_errorcode_str()  << "(" << static_cast<unsigned int>(errorcode) 
     855    os << get_errorclass_str() << "(" << static_cast<unsigned int>(errorclass) << "): "
     856       << get_errorcode_str() << " / " << get_errorsubcode_str()
     857       << " (" << static_cast<unsigned int>(errorcode) 
    745858       << "/" << static_cast<unsigned int>(errorsubcode) << ")" << endl;
    746859
Note: See TracChangeset for help on using the changeset viewer.