Esempio n. 1
0
void PacketStream::emit(IPacket& packet)
{
    TraceS(this) << "Emit: " << packet.size() << endl;

    // Ensure the stream is still running
    if (!stateEquals(PacketStreamState::Active)) {
        TraceS(this) << "Dropping packet on inactive stream: " << state()
                     << endl;
        return;
    }

    try {
        emitter.emit(packet);
    } catch (std::exception& exc) {
        handleException(exc);
    }

    TraceS(this) << "Emit: OK: " << packet.size() << endl;
}
void PrintPacketToSyslog (const IPacket &packet)
{
    std::stringstream ss;

    const char *buffer = (const char*)packet.buffer();

    for (int i = 0; i < packet.size(); ++i)
        ss << std::hex << std::setw(2) << std::setfill('0') << ((int)buffer[i] & 0xFF) << " ";

    syslog(LOG_DEBUG,"Hexed Packet:\n%s",ss.str().c_str());
}