Esempio n. 1
0
void addSessionToSessionList(char *eth_src,char *eth_dst,char *ip_src,char *ip_dst,unsigned int port,unsigned char *payload,int payloadSize)
{
    SESSION_INFO si;
    std::list<SESSION_INFO>::iterator tIt;
    if(SESSION_DEBUG) printf("addSessionToSessionList\n");
    int currentSessionSize=SESSION_LIST.size();
    unsigned char *npayload;

    //allocate memory for new payload buffer
    //npayload=new unsigned char[payloadSize+1];
    npayload=(unsigned char*)malloc(payloadSize+1);
    memcpy(npayload,payload,payloadSize);

    //filter
    if(!preCheck(payload)) { pthread_mutex_unlock(&tMutex); return; } //added (bug fix i would imagine)
    if(SESSION_DEBUG) printf("creating new session for payload!\n");
    strcpy(si.ether_src,eth_src);
    strcpy(si.ether_dst,eth_dst);
    strcpy(si.ip_src,ip_src);
    strcpy(si.ip_dst,ip_dst);
    si.port=port;
    si.cStarted=si.cEnded=si.cFound=si.lWritten=false; //added
    if(checkPayload(payload,si,payloadSize)) si.pData.push_back(npayload);
    else delete npayload;
    SESSION_LIST.push_back(si);

    if(SESSION_DEBUG) printf("adding new session to session slot: %i\n",currentSessionSize+1);
}
Esempio n. 2
0
			/// 数据源是二进制数据
			static void	decode(const void* start, size_t size, ParseStatus& parseStatus, RdResponse& rsp)
			{
				if (!preCheck(start,size,parseStatus)) {
					return;
				}
				const unsigned char* ptr = (const unsigned char*)start; 
				unsigned short playload = 0xFF * ptr[2] + ptr[3];
				size_t fullSize = playload + 4 + 1;
				if (fullSize > size) {
					parseStatus.bytes = fullSize - size;
					parseStatus.status = ParseStatus::kParseMoreData;
					return ;
				}
				unsigned char crc= crbcc(start , fullSize - 1);
				if (crc != ptr[fullSize - 1]) {
					parseStatus.bytes = fullSize;
					parseStatus.status = ParseStatus::kParseBadCrc;
					return;
				}
				//// done

				parseStatus.bytes = fullSize;
				parseStatus.status = ParseStatus::kParseDone;
				rsp.statusCode(ptr[1]);
				rsp.playload().append(ptr+4, playload);
			}
Esempio n. 3
0
TER Transactor::apply ()
{
    TER terResult (preCheck ());

    if (terResult != tesSUCCESS)
        return (terResult);

    // Restructure this to avoid the dependency on LedgerBase::mLock
    Ledger::ScopedLockType sl (mEngine->getLedger ()->mLock);

    mTxnAccount = mEngine->entryCache (ltACCOUNT_ROOT,
        Ledger::getAccountRootIndex (mTxnAccountID));
    calculateFee ();

    // Find source account
    // If are only forwarding, due to resource limitations, we might verifying
    // only some transactions, this would be probabilistic.

    if (!mTxnAccount)
    {
        if (mustHaveValidAccount ())
        {
            m_journal.trace <<
                "apply: delay transaction: source account does not exist " <<
                mTxn.getSourceAccount ().humanAccountID ();
            return terNO_ACCOUNT;
        }
    }
    else
    {
        mPriorBalance   = mTxnAccount->getFieldAmount (sfBalance);
        mSourceBalance  = mPriorBalance;
        mHasAuthKey     = mTxnAccount->isFieldPresent (sfRegularKey);
    }

    terResult = checkSeq ();

    if (terResult != tesSUCCESS) return (terResult);

    terResult = payFee ();

    if (terResult != tesSUCCESS) return (terResult);

    terResult = checkSig ();

    if (terResult != tesSUCCESS) return (terResult);

    terResult = precheckAgainstLedger();

    if (terResult != tesSUCCESS) return (terResult);

    if (!mEngine->mClosingLedger) {
        return tesSUCCESS;
    }

    if (mTxnAccount)
        mEngine->entryModify (mTxnAccount);

    return doApply ();
}
Esempio n. 4
0
void SLintVisitor::visit(const ast::FieldExp & e)
{
    auto range = preCheck(e);
    e.getHead()->accept(*this);
    e.getTail()->accept(*this);
    postCheck(e, range);
}
Esempio n. 5
0
void SLintVisitor::visit(const ast::CaseExp & e)
{
    auto range = preCheck(e);
    e.getTest()->accept(*this);
    e.getBody()->accept(*this);
    postCheck(e, range);
}
Esempio n. 6
0
void SLintVisitor::visit(const ast::LogicalOpExp & e)
{
    auto range = preCheck(e);
    e.getLeft().accept(*this);
    e.getRight().accept(*this);
    postCheck(e, range);
}
Esempio n. 7
0
void SLintVisitor::visit(const ast::TryCatchExp & e)
{
    auto range = preCheck(e);
    e.getTry().accept(*this);
    e.getCatch().accept(*this);
    postCheck(e, range);
}
Esempio n. 8
0
void SLintVisitor::visit(const ast::AssignExp & e)
{
    context.setLHSExp(&e.getLeftExp());
    auto range = preCheck(e);
    e.getRightExp().accept(*this);
    e.getLeftExp().accept(*this);
    postCheck(e, range);
    context.setLHSExp(nullptr);
}
Esempio n. 9
0
void SLintVisitor::visit(const ast::ForExp & e)
{
    context.pushLoop(&e);
    auto range = preCheck(e);
    e.getVardec().accept(*this);
    e.getBody().accept(*this);
    postCheck(e, range);
    context.popLoop();
}
Esempio n. 10
0
void SLintVisitor::visit(const ast::FunctionDec & e)
{
    context.pushFn(&e);
    auto range = preCheck(e);
    e.getBody().accept(*this);
    postCheck(e, range);

    context.popFn();
}
Esempio n. 11
0
void SLintVisitor::visit(const ast::ReturnExp & e)
{
    auto range = preCheck(e);
    if (!e.isGlobal())
    {
        e.getExp().accept(*this);
    }
    postCheck(e, range);
}
Esempio n. 12
0
void SLintVisitor::visit(const ast::MatrixLineExp & e)
{
    auto range = preCheck(e);
    const ast::exps_t & columns = e.getColumns();
    for (const auto column : columns)
    {
        column->accept(*this);
    }
    postCheck(e, range);
}
Esempio n. 13
0
void SLintVisitor::visit(const ast::CellExp & e)
{
    auto range = preCheck(e);
    ast::exps_t lines = e.getLines();
    for (ast::exps_t::const_iterator it = lines.begin(), itEnd = lines.end(); it != itEnd ; ++it)
    {
        (*it)->accept(*this);
    }
    postCheck(e, range);
}
Esempio n. 14
0
void SLintVisitor::visit(const ast::AssignListExp & e)
{
    auto range = preCheck(e);
    const ast::exps_t & exps = e.getExps();
    for (ast::exps_t::const_iterator it = exps.begin(), itEnd = exps.end(); it != itEnd; ++it)
    {
        (*it)->accept(*this);
    }
    postCheck(e, range);
}
Esempio n. 15
0
void SLintVisitor::visit(const ast::ArrayListVar & e)
{
    auto range = preCheck(e);
    ast::exps_t vars = e.getVars();
    for (ast::exps_t::const_iterator it = vars.begin (), itEnd = vars.end(); it != itEnd; ++it)
    {
        (*it)->accept(*this);
    }
    postCheck(e, range);
}
Esempio n. 16
0
void SLintVisitor::visit(const ast::ListExp & e)
{
    auto range = preCheck(e);
    e.getStart().accept(*this);
    if (e.hasExplicitStep())
    {
        e.getStep().accept(*this);
    }
    e.getEnd().accept(*this);
    postCheck(e, range);
}
Esempio n. 17
0
void SLintVisitor::visit(const ast::IfExp & e)
{
    auto range = preCheck(e);
    e.getTest().accept(*this);
    e.getThen().accept(*this);
    if (e.hasElse())
    {
        e.getElse().accept(*this);
    }
    postCheck(e, range);
}
Esempio n. 18
0
void SLintVisitor::visit(const ast::CellCallExp & e)
{
    auto range = preCheck(e);
    e.getName().accept(*this);

    ast::exps_t args = e.getArgs();
    for (auto arg : args)
    {
        arg->accept(*this);
    }
    postCheck(e, range);
}
Esempio n. 19
0
void SLintVisitor::visit(const ast::SeqExp & e)
{
    const ast::exps_t & exps = e.getExps();
    seqExpIts.emplace(exps.begin(), exps.end());
    auto range = preCheck(e);
    ast::exps_t::const_iterator & seqExpIt = seqExpIts.top().first;
    const ast::exps_t::const_iterator & seqExpEnd = seqExpIts.top().second;
    for (; seqExpIt != seqExpEnd; ++seqExpIt)
    {
        (*seqExpIt)->accept(*this);
    }
    postCheck(e, range);
    seqExpIts.pop();
}
Esempio n. 20
0
TER Transactor::apply ()
{
    TER     terResult   = tesSUCCESS;
    terResult = preCheck ();

    if (terResult != tesSUCCESS) return (terResult);

    Ledger::ScopedLockType sl (mEngine->getLedger ()->mLock, __FILE__, __LINE__);

    mTxnAccount = mEngine->entryCache (ltACCOUNT_ROOT, Ledger::getAccountRootIndex (mTxnAccountID));
    calculateFee ();

    // Find source account
    // If are only forwarding, due to resource limitations, we might verifying only some transactions, this would be probabilistic.

    if (!mTxnAccount)
    {
        if (mustHaveValidAccount ())
        {
            WriteLog (lsTRACE, Transactor) << boost::str (boost::format ("applyTransaction: Delay transaction: source account does not exist: %s") %
                                           mTxn.getSourceAccount ().humanAccountID ());

            return terNO_ACCOUNT;
        }
    }
    else
    {
        mPriorBalance   = mTxnAccount->getFieldAmount (sfBalance);
        mSourceBalance  = mPriorBalance;
        mHasAuthKey     = mTxnAccount->isFieldPresent (sfRegularKey);
    }

    terResult = checkSeq ();

    if (terResult != tesSUCCESS) return (terResult);

    terResult = payFee ();

    if (terResult != tesSUCCESS) return (terResult);

    terResult = checkSig ();

    if (terResult != tesSUCCESS) return (terResult);

    if (mTxnAccount)
        mEngine->entryModify (mTxnAccount);

    return doApply ();
}
Esempio n. 21
0
void SLintVisitor::visit(const ast::SelectExp & e)
{
    auto range = preCheck(e);
    e.getSelect()->accept(*this);

    ast::exps_t cases = e.getCases();
    for (auto exp : cases)
    {
        exp->accept(*this);
    }

    if (e.getDefaultCase() != NULL)
    {
        e.getDefaultCase()->accept(*this);
    }

    postCheck(e, range);
}
Esempio n. 22
0
void SLintVisitor::visit(const ast::MemfillExp & e)
{
    auto range = preCheck(e);
    e.getOriginal()->accept(*this);
    postCheck(e, range);
}
Esempio n. 23
0
void SLintVisitor::visit(const ast::VarDec & e)
{
    auto range = preCheck(e);
    e.getInit().accept(*this);
    postCheck(e, range);
}
Esempio n. 24
0
void SLintVisitor::visit(const ast::TransposeExp & e)
{
    auto range = preCheck(e);
    e.getExp().accept(*this);
    postCheck(e, range);
}
Esempio n. 25
0
void SLintVisitor::visit(const ast::ColonVar & e)
{
    auto range = preCheck(e);

    postCheck(e, range);
}
Esempio n. 26
0
void SLintVisitor::visit(const ast::BreakExp & e)
{
    auto range = preCheck(e);

    postCheck(e, range);
}
Esempio n. 27
0
void SLintVisitor::visit(const ast::ContinueExp & e)
{
    auto range = preCheck(e);

    postCheck(e, range);
}