Example #1
0
/* Rule option evaluation */
static int SIP_MethodEval(void *pkt, const uint8_t **cursor, void *data)
{
	SFSnortPacket *p = (SFSnortPacket *)pkt;
	SIPData *sd;
	SIP_Roptions *ropts;
	SipMethodRuleOptData *sdata = (SipMethodRuleOptData *)data;
    uint32_t methodFlag;

	DEBUG_WRAP(DebugMessage(DEBUG_SIP,
			"Evaluating \"%s\" rule option.\n", SIP_ROPT__METHOD));

	if (!SIP_RoptDoEval(p))
		return RULE_NOMATCH;

	sd = (SIPData *)_dpd.sessionAPI->get_application_data(p->stream_session, PP_SIP);
	if (sd == NULL)
	{
		DEBUG_WRAP(DebugMessage(DEBUG_SIP,
				"No session data - not evaluating.\n"));
		return RULE_NOMATCH;
	}

	ropts = &sd->ropts;

	DEBUG_WRAP(DebugMessage(DEBUG_SIP,
			"Rule Flags: %x Data Flags: %x, Mask: %x \n", sdata->flags, ropts->methodFlag, sdata->mask ));
    // Not response
	methodFlag = 1 << (ropts->methodFlag - 1);
	if (IsRequest(ropts) && ((sdata->flags & methodFlag) ^ sdata->mask))
	{
		return RULE_MATCH;
	}
	return RULE_NOMATCH;

}
Example #2
0
void AppLayer::SendRequest(APDU& arAPDU)
{
	this->Validate(arAPDU.GetControl(), true, true, false, false);

	if(!IsRequest(arAPDU.GetFunction()))
		throw ArgumentException(LOCATION, "Non-request function code");

	mSolicited.Send(arAPDU, this->GetRetries(arAPDU.GetFunction()));
}
Example #3
0
    std::string Message::ToString() const
    {
        bool isBindEvent = false;
        std::ostringstream stream;

        stream << "<";

        if (mIsEmpty)
        {
            stream << "EmptyMessage>";
            return stream.str();
        }

        if (IsReply())
        {
            if (!mName.compare(0, 7, "$.KBUS"))
                stream << "Status";
            else
                stream << "Reply";
        }
        else if (IsRequest())
            stream << "Request";
        else if (IsReplierBindEvent())
        {
            stream << "ReplierBindEvent";
            isBindEvent = true;
        }
        else
            stream << "Message";        // Hmm, or "Announcement"

        if (!isBindEvent)
            stream << " \"" << mName << '"';

        kbus_message_header *hdr = (kbus_message_header *)&mData[0];

        if (hdr->id.network_id != 0 || hdr->id.serial_num != 0)
            stream << " id=[" << hdr->id.network_id << "," << hdr->id.serial_num << "]";

        if (hdr->to)
            stream << " to=" << hdr->to;

        if (hdr->from)
            stream << " from=" << hdr->from;

        if (hdr->orig_from.network_id != 0 || hdr->orig_from.local_id != 0)
            stream << " orig_from=[" << hdr->orig_from.network_id << ","
                << hdr->orig_from.local_id << "]";

        if (hdr->final_to.network_id != 0 || hdr->final_to.local_id != 0)
            stream << " final_to=[" << hdr->final_to.network_id << ","
                << hdr->final_to.local_id << "]";

        if (hdr->in_reply_to.network_id != 0 || hdr->in_reply_to.serial_num != 0)
            stream << " in_reply_to=[" << hdr->in_reply_to.network_id << ","
                << hdr->in_reply_to.serial_num << "]";

        if (hdr->flags)
        {
            stream << " flags=" << std::hex << hdr->flags;
            stream << ' ' << MessageFlags::ToString(hdr->flags);
        }

        if (hdr->data_len > 0)
        {
            if (isBindEvent)
            {
                bool        isBind;
                uint32_t    binder;
                std::string msgName;
                (void) GetReplierBindEventData(isBind, binder, msgName);
                stream << " [" << (isBind?"Bind \"":"Unbind \"") << msgName <<
                    "\" for " << binder << "]";
            }
            else
            {
                const uint8_t *data = GetData();
                int ii, minlen = hdr->data_len<20?hdr->data_len:20;
                stream << " data=\"";
                for (ii=0; ii<minlen; ii++)
                {
                    char  ch = data[ii];
                    if (isprint(ch))
                        stream << ch;
                    else
                        stream << "\\x" << std::hex << (unsigned) ch;
                }
                if (hdr->data_len > 20)
                    stream << "...";
                stream << '"';
            }
        }
        stream << ">";
        return stream.str();
    }