/** \brief Unhandled error condition */
struct ErrorException : public senf::Exception
- { ErrorException() : senf::Exception("senf::ppi::IOEvent::ErrorException"){} };
+ { ErrorException() : senf::Exception("senf::ppi::IOEvent::ErrorException") {} };
/** \brief Unhandled hangup condition */
struct HangupException : public senf::Exception
- { HangupException() : senf::Exception("senf::ppi::IOEvent::HangupException"){} };
+ { HangupException() : senf::Exception("senf::ppi::IOEvent::HangupException") {} };
protected:
#define prefix_
-prefix_ senf::ppi::IPv4SourceForcingDgramWriter::IPv4SourceForcingDgramWriter(){
+prefix_ senf::ppi::IPv4SourceForcingDgramWriter::IPv4SourceForcingDgramWriter()
+{
source_ = senf::INet4Address::from_string("0.0.0.0");
destination_ = senf::INet4Address::from_string("0.0.0.0");
protocolId_ = 0;
}
-prefix_ senf::ppi::IPv4SourceForcingDgramWriter::IPv4SourceForcingDgramWriter(senf::INet4Address sourceAddr, senf::INet4SocketAddress destAddr){
+prefix_ senf::ppi::IPv4SourceForcingDgramWriter::
+IPv4SourceForcingDgramWriter(senf::INet4Address sourceAddr, senf::INet4SocketAddress destAddr)
+{
source(sourceAddr);
destination(destAddr);
}
-prefix_ void senf::ppi::IPv4SourceForcingDgramWriter::source(senf::INet4Address & source){
+prefix_ void senf::ppi::IPv4SourceForcingDgramWriter::source(senf::INet4Address & source)
+{
source_ = source;
}
-prefix_ void senf::ppi::IPv4SourceForcingDgramWriter::destination(senf::INet4SocketAddress & dest){
+
+prefix_ void senf::ppi::IPv4SourceForcingDgramWriter::destination(senf::INet4SocketAddress & dest)
+{
destination_ = dest.address();
protocolId_ = dest.port();
}
return sendmsg(sock, &h, 0);
}
-prefix_ senf::ppi::IPv6SourceForcingDgramWriter::IPv6SourceForcingDgramWriter(){
+prefix_ senf::ppi::IPv6SourceForcingDgramWriter::IPv6SourceForcingDgramWriter()
+{
source_ = senf::INet6Address::from_string("0::0");
destination_ = senf::INet6Address::from_string("0::0");
protocolId_ = 0;
}
-prefix_ senf::ppi::IPv6SourceForcingDgramWriter::IPv6SourceForcingDgramWriter(senf::INet6Address sourceAddr, senf::INet6SocketAddress destAddr){
+prefix_ senf::ppi::IPv6SourceForcingDgramWriter::
+IPv6SourceForcingDgramWriter(senf::INet6Address sourceAddr, senf::INet6SocketAddress destAddr)
+{
source(sourceAddr);
destination(destAddr);
}
-prefix_ void senf::ppi::IPv6SourceForcingDgramWriter::source(senf::INet6Address & source){
+prefix_ void senf::ppi::IPv6SourceForcingDgramWriter::source(senf::INet6Address & source)
+{
source_ = source;
}
-prefix_ void senf::ppi::IPv6SourceForcingDgramWriter::destination(senf::INet6SocketAddress & dest){
+
+prefix_ void senf::ppi::IPv6SourceForcingDgramWriter::destination(senf::INet6SocketAddress & dest)
+{
destination_ = dest.address();
protocolId_ = dest.port();
}
prefix_ void senf::ppi::IPv6SourceForcingDgramWriter::operator()(Handle handle,
- Packet const & packet){
+ Packet const & packet)
+{
sendtoandfrom(
handle.fd(),
reinterpret_cast<void*> (&*packet.data().begin()),
{
boost::io::ios_all_saver ias(os);
os << "Radiotap:\n"
- << " version : " << unsigned( p->version()) << "\n"
- << " length : " << unsigned( p->length()) << "\n";
+ << senf::fieldName("version") << unsigned( p->version()) << "\n"
+ << senf::fieldName("length") << unsigned( p->length()) << "\n";
if (p->has_tsft())
- os << " MAC timestamp : " << unsigned( p->tsft()) << "\n";
+ os << senf::fieldName("MAC timestamp") << unsigned( p->tsft()) << "\n";
// TODO: flags
if (p->has_rate())
- os << " rate : " << unsigned( p->rate()) << "\n";
+ os << senf::fieldName("rate") << unsigned( p->rate()) << "\n";
// TODO: channelOptions
if (p->has_fhss())
- os << " FHSS : " << unsigned( p->fhss()) << "\n";
+ os << senf::fieldName("FHSS") << unsigned( p->fhss()) << "\n";
if (p->has_dbmAntennaSignal())
- os << " antenna signal (dBm) : " << signed( p->dbmAntennaSignal()) << "\n";
+ os << senf::fieldName("antenna signal (dBm)") << signed( p->dbmAntennaSignal()) << "\n";
if (p->has_dbmAntennaNoise())
- os << " antenna noise (dBm) : " << signed( p->dbmAntennaNoise()) << "\n";
+ os << senf::fieldName("antenna noise (dBm)") << signed( p->dbmAntennaNoise()) << "\n";
if (p->has_lockQuality())
- os << " lock quality : " << unsigned( p->lockQuality()) << "\n";
+ os << senf::fieldName("lock quality") << unsigned( p->lockQuality()) << "\n";
if (p->has_txAttenuation())
- os << " tx attenuation : " << unsigned( p->txAttenuation()) << "\n";
+ os << senf::fieldName("tx attenuation") << unsigned( p->txAttenuation()) << "\n";
if (p->has_dbTxAttenuation())
- os << " tx attenuation (dB) : " << unsigned( p->dbTxAttenuation()) << "\n";
+ os << senf::fieldName("tx attenuation (dB)") << unsigned( p->dbTxAttenuation()) << "\n";
if (p->has_dbmTxAttenuation())
- os << " tx attenuation (dBm) : " << signed( p->dbmTxAttenuation()) << "\n";
+ os << senf::fieldName("tx attenuation (dBm)") << signed( p->dbmTxAttenuation()) << "\n";
if (p->has_antenna())
- os << " antenna : " << unsigned( p->antenna()) << "\n";
+ os << senf::fieldName("antenna") << unsigned( p->antenna()) << "\n";
if (p->has_dbAntennaSignal())
- os << " antenna signal (dB) : " << unsigned( p->dbAntennaSignal()) << "\n";
+ os << senf::fieldName("antenna signal (dB)") << unsigned( p->dbAntennaSignal()) << "\n";
if (p->has_dbAntennaNoise())
- os << " antenna noise (dB) : " << unsigned( p->dbAntennaNoise()) << "\n";
+ os << senf::fieldName("antenna noise (dB)") << unsigned( p->dbAntennaNoise()) << "\n";
if (p->has_headerFcs())
- os << " FCS : " << unsigned( p->fcs()) << "\n";
+ os << senf::fieldName("FCS") << unsigned( p->fcs()) << "\n";
}
prefix_ void senf::RadiotapPacketType::finalize(packet p)
prefix_ void senf::WLANPacket_MgtFrameType::dump(packet p, std::ostream &os)
{
boost::io::ios_all_saver ias(os);
- os << "802.11 MAC Mangement Frame:\n";
+ os << "802.11 MAC Mangement Frame:\n";
dumpBase(p.parser(), os);
- os << " destination : " << p->destinationAddress() << "\n"
- << " source : " << p->sourceAddress() << "\n"
- << " bss id : " << p->bssid() << "\n"
- << " sequence number : " << p->sequenceNumber() << "\n"
- << " fragment number : " << p->fragmentNumber() << "\n";
+ os << senf::fieldName("destination") << p->destinationAddress() << "\n"
+ << senf::fieldName("source") << p->sourceAddress() << "\n"
+ << senf::fieldName("bss id") << p->bssid() << "\n"
+ << senf::fieldName("sequence number") << p->sequenceNumber() << "\n"
+ << senf::fieldName("fragment number") << p->fragmentNumber() << "\n";
}
prefix_ void senf::WLANPacket_CtrlFrameType::dump(packet p, std::ostream &os)
{
boost::io::ios_all_saver ias(os);
- os << "802.11 MAC Control Frame:\n";
+ os << "802.11 MAC Control Frame:\n";
dumpBase(p.parser(), os);
- os << " receiver : " << p->receiverAddress() << "\n";
+ os << senf::fieldName("receiver") << p->receiverAddress() << "\n";
if (p->is_rts())
- os << " source : " << p->sourceAddress() << "\n";
+ os << senf::fieldName("source") << p->sourceAddress() << "\n";
}
prefix_ senf::MACAddressParser senf::WLANPacket_DataFrameParser::destinationAddress()
prefix_ void senf::WLANPacket_DataFrameType::dump(packet p, std::ostream &os)
{
boost::io::ios_all_saver ias(os);
- os << "802.11 MAC Data Frame:\n";
+ os << "802.11 MAC Data Frame:\n";
dumpBase(p.parser(), os);
- os << " destination : " << p->destinationAddress();
+ os << senf::fieldName("destination") << p->destinationAddress();
if (p->dsBits()==0 || p->dsBits()==2) os << " (receiver)";
- os << "\n"
- << " source : " << p->sourceAddress();
+ os << "\n"
+ << senf::fieldName("source") << p->sourceAddress();
if (p->dsBits()==0 || p->dsBits()==1) os << " (transmitter)";
- os << "\n"
- << " bss id : " << p->bssid();
+ os << "\n"
+ << senf::fieldName("bss id") << p->bssid();
if (p->dsBits()==1) os << " (receiver)";
else if (p->dsBits()!=0) os << " (transmitter)";
- os << "\n"
- << " sequence number : " << p->sequenceNumber() << "\n"
- << " fragment number : " << p->fragmentNumber() << "\n";
+ os << "\n"
+ << senf::fieldName("sequence number") << p->sequenceNumber() << "\n"
+ << senf::fieldName("fragment number") << p->fragmentNumber() << "\n";
if (p->has_qosField())
- os << " QOS data : " << p->qosField() << "\n";
+ os << senf::fieldName("QOS data") << p->qosField() << "\n";
}
#undef prefix_
{
boost::io::ios_all_saver ias(os);
os << "MIH Packet:\n"
- << " protocol header:\n"
- << " version : " << unsigned( p->version()) << "\n"
- << " ack request : " << p->ackRequest() << "\n"
- << " ack response : " << p->ackResponse() << "\n"
- << " UIR : " << p->uir() << "\n"
- << " more fragments : " << p->moreFragment() << "\n"
- << " fragment number : " << p->fragmentNr() << "\n"
- << " message ID (MID) : " << unsigned( p->messageId()) << "\n"
- << " sid : " << unsigned( p->sid()) << "\n"
- << " opcode : " << unsigned( p->opcode()) << "\n"
- << " aid : " << unsigned( p->aid()) << "\n"
- << " transaction id : " << unsigned( p->transactionId()) << "\n"
- << " payload length : " << unsigned( p->payloadLength()) << "\n"
- << " source MIHF_Id TLV :\n"
- << " type : " << unsigned (p->src_mihfId().type()) << "\n"
- << " length : " << unsigned (p->src_mihfId().length()) << "\n"
- << " value :\n";
+ << " protocol header:\n"
+ << senf::fieldName(" version") << unsigned( p->version()) << "\n"
+ << senf::fieldName(" ack request") << p->ackRequest() << "\n"
+ << senf::fieldName(" ack response") << p->ackResponse() << "\n"
+ << senf::fieldName(" UIR") << p->uir() << "\n"
+ << senf::fieldName(" more fragments") << p->moreFragment() << "\n"
+ << senf::fieldName(" fragment number") << p->fragmentNr() << "\n"
+ << senf::fieldName(" message ID (MID)") << unsigned( p->messageId()) << "\n"
+ << senf::fieldName(" sid") << unsigned( p->sid()) << "\n"
+ << senf::fieldName(" opcode") << unsigned( p->opcode()) << "\n"
+ << senf::fieldName(" aid") << unsigned( p->aid()) << "\n"
+ << senf::fieldName(" transaction id") << unsigned( p->transactionId()) << "\n"
+ << senf::fieldName(" payload length") << unsigned( p->payloadLength()) << "\n"
+ << " source MIHF_Id TLV:\n"
+ << senf::fieldName(" type") << unsigned (p->src_mihfId().type()) << "\n"
+ << senf::fieldName(" length") << unsigned (p->src_mihfId().length()) << "\n"
+ << " value:\n";
std::string src_mihfId (p->src_mihfId().asString());
hexdump(src_mihfId.begin(), src_mihfId.end(), os);
- os << " destination MIHF_Id TLV:\n"
- << " type : " << unsigned (p->dst_mihfId().type()) << "\n"
- << " length : " << unsigned (p->dst_mihfId().length()) << "\n"
- << " value :\n";
+ os << " destination MIHF_Id TLV:\n"
+ << senf::fieldName(" type") << unsigned (p->dst_mihfId().type()) << "\n"
+ << senf::fieldName(" length") << unsigned (p->dst_mihfId().length()) << "\n"
+ << " value:\n";
std::string dst_mihfId (p->dst_mihfId().asString());
hexdump(dst_mihfId.begin(), dst_mihfId.end(), os);
}
if (b != 3) resize(3);
return;
}
- if (v <= UInt24Parser::max_value + 128 ){
+ if (v <= UInt24Parser::max_value + 128 ) {
if (b != 4) resize(4);
return;
}
boost::io::ios_all_saver ias(os);
os << "GenericTLVPacket:\n"
<< std::dec
- << " type : " << unsigned( p->type()) << "\n"
- << " length : " << unsigned( p->length()) << "\n"
- << " value\n : ";
+ << senf::fieldName("type") << unsigned( p->type()) << "\n"
+ << senf::fieldName("length") << unsigned( p->length()) << "\n"
+ << " value:\n";
senf::hexdump( p->value().begin(), p->value().end(), os);
}
else
os << "Ethernet 802.3 (bad ethertype >1500 and <1536)";
os << ": \n"
- << " destination : " << p->destination() << "\n"
- << " source : " << p->source() << "\n"
- << " type/length : 0x"
- << std::hex << std::setw(4) << std::setfill('0') << p->type_length() << "\n";
+ << senf::fieldName("destination") << p->destination() << "\n"
+ << senf::fieldName("source") << p->source() << "\n"
+ << senf::fieldName("type/length") << senf::prettyNumber(p->type_length().value()) << "\n";
}
prefix_ senf::PacketInterpreterBase::factory_t senf::EthernetPacketType::nextPacketType(packet p)
prefix_ void senf::EthVLanPacketType::dump(packet p, std::ostream & os)
{
boost::io::ios_all_saver ias(os);
- os << "Ethernet 802.1q (VLAN):\n"
- << " priority : " << p->priority() << "\n"
- << " cfi : " << p->cfi() << "\n"
- << " vlan-ID : " << p->vlanId() << "\n"
- << " ethertype : 0x"
- << std::hex << std::setw(4) << std::setfill('0') << p->type() << "\n";
+ os << "Ethernet 802.1q (VLAN):\n"
+ << senf::fieldName("priority") << p->priority() << "\n"
+ << senf::fieldName("cfi") << p->cfi() << "\n"
+ << senf::fieldName("vlan-ID") << p->vlanId() << "\n"
+ << senf::fieldName("ethertype")
+ << " 0x" << std::hex << std::setw(4) << std::setfill('0') << p->type() << "\n";
}
prefix_ void senf::EthVLanPacketType::finalize(packet p)
{
boost::io::ios_all_saver ias(os);
os << "ICMPv6 protocol:\n"
- << " type : " << unsigned(p->type()) <<"\n"
- << " code : " << unsigned(p->code()) <<"\n"
- << " checksum : 0x"
- << std::hex << std::setw(4) << unsigned(p->checksum()) << "\n";
+ << senf::fieldName("type") << unsigned(p->type()) <<"\n"
+ << senf::fieldName("code") << unsigned(p->code()) <<"\n"
+ << senf::fieldName("checksum")
+ << "0x" << std::hex << std::setw(4) << unsigned(p->checksum()) << "\n";
}
///////////////////////////////cc.e////////////////////////////////////////
registerMLDv2ListenerReport (143);
}
-prefix_ void senf::ICMPv6EchoRequestType::dump(packet p, std::ostream & os){
+prefix_ void senf::ICMPv6EchoRequestType::dump(packet p, std::ostream & os)
+{
os << "ICMPv6 Echo Request:\n"
- <<" Identifier : " << unsigned(p->identifier() )
- <<"\n SequenceNumber : " << unsigned(p->seqNr() ) << "\n";
+ << senf::fieldName("Identifier") << unsigned(p->identifier()) << "\n"
+ << senf::fieldName("SequenceNumber") << unsigned(p->seqNr() ) << "\n";
}
-prefix_ void senf::ICMPv6EchoReplyType::dump(packet p, std::ostream & os){
+prefix_ void senf::ICMPv6EchoReplyType::dump(packet p, std::ostream & os)
+{
os << "ICMPv6 Echo Reply:\n"
- <<" Identifier : " << unsigned(p->identifier() )
- <<"\n SequenceNumber : " << unsigned(p->seqNr() ) << "\n";
+ << senf::fieldName("Identifier") << unsigned(p->identifier()) << "\n"
+ << senf::fieldName("SequenceNumber") << unsigned(p->seqNr()) << "\n";
}
-prefix_ void senf::ICMPv6ErrDestUnreachableType::dump(packet p, std::ostream & os){
+prefix_ void senf::ICMPv6ErrDestUnreachableType::dump(packet p, std::ostream & os)
+{
os << "ICMPv6 Error Destination Unreachable (no further fields available here)\n";
}
-prefix_ void senf::ICMPv6ErrTooBigType::dump(packet p, std::ostream & os){
+prefix_ void senf::ICMPv6ErrTooBigType::dump(packet p, std::ostream & os)
+{
os << "ICMPv6 Error Packet Too Big:\n"
- <<" MTU : " << unsigned(p->mtu() ) << "\n";
+ << senf::fieldName("MTU") << unsigned(p->mtu() ) << "\n";
}
-prefix_ void senf::ICMPv6ErrTimeExceededType::dump(packet p, std::ostream & os){
+prefix_ void senf::ICMPv6ErrTimeExceededType::dump(packet p, std::ostream & os)
+{
os << "ICMPv6 Error Time Exceeded:\n"
- <<" Unused(32Bit) : " << unsigned(p->unused() ) << "\n";
+ << senf::fieldName("Unused(32Bit)") << unsigned(p->unused() ) << "\n";
}
-prefix_ void senf::ICMPv6ErrParamProblemType::dump(packet p, std::ostream & os){
+prefix_ void senf::ICMPv6ErrParamProblemType::dump(packet p, std::ostream & os)
+{
os << "ICMPv6 Error Parameter Problem:\n"
- <<" Pointer : " << unsigned(p->pointer() ) << "\n";
+ << senf::fieldName("Pointer") << unsigned(p->pointer() ) << "\n";
}
-prefix_ void senf::MLDv2ListenerQueryType::dump(packet p, std::ostream & os){
+prefix_ void senf::MLDv2ListenerQueryType::dump(packet p, std::ostream & os)
+{
os << "ICMPv6 Multicast Listener Query:\n"
- <<" Max. ResponseCode : " << unsigned(p->maxResponseCode() )
- <<"\n Reserved(16Bit) : " << unsigned(p->reserved() )
- <<"\n Multicast Address : " << p->mcAddress()
- <<"\n Reserver(4Bit) : " << unsigned(p->resv() )
- <<"\n Suppress Router-Side Processing: " << unsigned(p->sFlag() )
- <<"\n Querier's Robustness Variable: " << unsigned(p->qrv() )
- <<"\n Querier's Query Interval Code: " << unsigned(p->qqic() )
- <<"\n Source Addresses: " << "\n";
- senf::MLDv2ListenerQuery::Parser::srcAddresses_t::container c (p->srcAddresses() );
- senf::MLDv2ListenerQuery::Parser::srcAddresses_t::container::iterator i (c.begin() );
- for (unsigned int nr =1; i != c.end(); ++i, ++nr)
- os << " " << nr << ".) " <<*i << "\n";
- os << "\n";
+ << senf::fieldName("Max. ResponseCode") << unsigned(p->maxResponseCode()) << "\n"
+ << senf::fieldName("Reserved(16Bit)") << unsigned(p->reserved()) << "\n"
+ << senf::fieldName("Multicast Address") << p->mcAddress() << "\n"
+ << senf::fieldName("Reserver(4Bit)") << unsigned(p->resv()) << "\n"
+ << senf::fieldName("Suppress Router-Side Processing") << unsigned(p->sFlag()) << "\n"
+ << senf::fieldName("Querier's Robustness Variable") << unsigned(p->qrv()) << "\n"
+ << senf::fieldName("Querier's Query Interval Code") << unsigned(p->qqic()) << "\n"
+ << " Source Addresses:\n";
+ senf::MLDv2ListenerQuery::Parser::srcAddresses_t::container c (p->srcAddresses());
+ senf::MLDv2ListenerQuery::Parser::srcAddresses_t::container::iterator i (c.begin());
+ for (unsigned int nr =1; i != c.end(); ++i, ++nr)
+ os << " " << nr << ".) " << *i << "\n";
+ os << "\n";
}
-prefix_ void senf::MLDv2ListenerReportType::dump(packet p, std::ostream & os){
+prefix_ void senf::MLDv2ListenerReportType::dump(packet p, std::ostream & os)
+{
os << "ICMPv6 Multicast Listener Report Message:\n"
- <<" Reserved : " << unsigned(p->reserved() )
- <<"\n Multicast Address Records:\n";
+ << senf::fieldName("Reserved") << unsigned(p->reserved() )
+ <<"\n Multicast Address Records:\n";
senf::MLDv2ListenerReport::Parser::mcastAddrRecords_t::container cAddrR (p->mcastAddrRecords() );
senf::MLDv2ListenerReport::Parser::mcastAddrRecords_t::container::iterator iAddrR (cAddrR.begin() );
- for (; iAddrR != cAddrR.end(); ++iAddrR){
- os << " Record Type : " << unsigned(iAddrR->recordType() )
- <<"\n Multicast Address : " << iAddrR->mcAddress()
- <<"\n Source Addresses :\n";
-
- senf::MLDv2AddressRecordParser::srcAddresses_t::container cSrcAddr (iAddrR->srcAddresses() );
- senf::MLDv2AddressRecordParser::srcAddresses_t::container::iterator iSrcAddr ( cSrcAddr.begin() );
+ for (; iAddrR != cAddrR.end(); ++iAddrR) {
+ os << senf::fieldName(" Record Type") << unsigned(iAddrR->recordType()) << "\n"
+ << senf::fieldName(" Multicast Address") << iAddrR->mcAddress() << "\n"
+ << " Source Addresses\n:";
+ senf::MLDv2AddressRecordParser::srcAddresses_t::container cSrcAddr (iAddrR->srcAddresses());
+ senf::MLDv2AddressRecordParser::srcAddresses_t::container::iterator iSrcAddr (cSrcAddr.begin());
for (;iSrcAddr != cSrcAddr.end();++iSrcAddr)
- os <<" " << *iSrcAddr << "\n";
- os << " Auxiliary Data :\n";
+ os << " " << *iSrcAddr << "\n";
+ os << " Auxiliary Data:\n";
senf::MLDv2AddressRecordParser::auxData_t::container cAuxD ( iAddrR->auxData() );
senf::MLDv2AddressRecordParser::auxData_t::container::iterator iAuxD (cAuxD.begin() );
for (;iAuxD != cAuxD.end(); ++iAuxD)
- os <<" " << *iAuxD << "\n";
+ os << " " << *iAuxD << "\n";
}
}
-
-
-
-
-
-#undef prefix_
\ No newline at end of file
+#undef prefix_
SENF_PARSER_FIELD ( unused, UInt32Parser );
/* Code 0 - Hop limit exceeded in transit
1 - Fragment reassembly time exceeded */
- void setErrCode(int code){
+ void setErrCode(int code)
+ {
ICMPv6Packet icmpv6 (packet().rfind<ICMPv6Packet>(senf::nothrow));
icmpv6->code() = code;
}
1 - Unrecognized Next Header type encountered
2 - Unrecognized IPv6 option encountered */
- void setErrCode(int code){
+ void setErrCode(int code)
+ {
ICMPv6Packet icmpv6 (packet().rfind<ICMPv6Packet>(senf::nothrow));
icmpv6->code() = code;
}
prefix_ void senf::IPv4PacketType::dump(packet p, std::ostream & os)
{
boost::io::ios_all_saver ias(os);
- os << "Internet protocol Version 4:\n"
- << " version : " << p->version() << "\n"
- << " ip header length : " << p->ihl() << "\n"
- << " tos : " << unsigned(p->tos()) << "\n"
- << " length : " << p->length() << "\n"
- << " identifier : " << p->identifier() << "\n"
- << " dont fragment : " << p->df() << "\n"
- << " more fragments : " << p->mf() << "\n"
- << " fragment : " << p->frag() << "\n"
- << " ttl : " << unsigned(p->ttl()) << "\n"
- << " protocol : " << unsigned(p->protocol()) << "\n"
- << " checksum : 0x"
- << std::hex << std::setw(4) << std::setfill('0') << p->checksum() << std::dec << "\n"
- << " source : " << p->source() << "\n"
- << " destination : " << p->destination() << "\n";
+ os << "Internet protocol Version 4:\n"
+ << senf::fieldName("version") << p->version() << "\n"
+ << senf::fieldName("ip header length") << p->ihl() << "\n"
+ << senf::fieldName("tos") << unsigned(p->tos()) << "\n"
+ << senf::fieldName("length") << p->length() << "\n"
+ << senf::fieldName("identifier") << p->identifier() << "\n"
+ << senf::fieldName("dont fragment") << p->df() << "\n"
+ << senf::fieldName("more fragments") << p->mf() << "\n"
+ << senf::fieldName("fragment") << p->frag() << "\n"
+ << senf::fieldName("ttl") << unsigned(p->ttl()) << "\n"
+ << senf::fieldName("protocol") << unsigned(p->protocol()) << "\n"
+ << senf::fieldName("checksum")
+ << "0x" << std::hex << std::setw(4) << std::setfill('0') << p->checksum() << std::dec << "\n"
+ << senf::fieldName("source") << p->source() << "\n"
+ << senf::fieldName("destination") << p->destination() << "\n";
}
prefix_ void senf::IPv4PacketType::finalize(packet p)
prefix_ void senf::IPv6FragmentPacketType::dump(packet p, std::ostream & os)
{
os << "Internet protocol Version 6 fragment extension:\n"
- << " next header : " << unsigned(p->nextHeader()) << "\n"
- << " fragment offset : " << std::hex << unsigned(p->fragmentOffset()) << "\n"
- << " more fragments : " << (p->moreFragments()?"yes":"no") << "\n"
- << " id : " << std::hex << unsigned(p->id()) << "\n";
+ << senf::fieldName("next header") << unsigned(p->nextHeader()) << "\n"
+ << senf::fieldName("fragment offset")
+ << "0x" << std::hex << unsigned(p->fragmentOffset()) << "\n"
+ << senf::fieldName("more fragments") << (p->moreFragments()?"yes":"no") << "\n"
+ << senf::fieldName("id")
+ << "0x" << std::hex << unsigned(p->id()) << "\n";
}
prefix_ void senf::IPv6RoutingPacketType::dump(packet p, std::ostream & os)
{
os << "Internet protocol Version 6 routing extension:\n"
- << " next header : " << unsigned (p->nextHeader()) << "\n"
- << " header length : " << unsigned (p->headerLength()) << "\n"
- << " routing type : " << unsigned (p->routingType()) << "\n"
- << " segments left : " << unsigned (p->segmentsLeft()) << "\n"
- << " further Hop Addresses : \n";
+ << senf::fieldName("next header") << unsigned(p->nextHeader()) << "\n"
+ << senf::fieldName("header length") << unsigned(p->headerLength()) << "\n"
+ << senf::fieldName("routing type") << unsigned(p->routingType()) << "\n"
+ << senf::fieldName("segments left") << unsigned(p->segmentsLeft()) << "\n"
+ << " further Hop Addresses:\n";
typedef IPv6RoutingPacket::Parser::hopAddresses_t::container addrContainer_t;
addrContainer_t hopAddresses (p->hopAddresses());
if ( p->segmentsLeft() != 0 )
for (addrContainer_t::iterator i (hopAddresses.begin()); i != hopAddresses.end(); ++i)
- os << *i << "\n";
+ os << " " << *i << "\n";
}
prefix_ void senf::IPv6HopByHopOptionsPacketType::dump(packet p, std::ostream & os)
{
os << "Internet protocol Version 6 Hop-By-Hop extension:\n"
- << " next header : " << unsigned (p->nextHeader()) << "\n"
- << " header length : " << unsigned (p->headerLength()) << "\n";
- os << " OptionTypes:\n";
+ << senf::fieldName("next header") << unsigned(p->nextHeader()) << "\n"
+ << senf::fieldName("header length") << unsigned(p->headerLength()) << "\n";
+ os << " OptionTypes:\n";
typedef IPv6HopByHopOptionsPacket::Parser::options_t::container optContainer_t;
optContainer_t options (p->options());
optContainer_t::iterator optIter(options.begin());
for(; optIter != options.end(); ++optIter) {
- os << " AltAction : " << (unsigned) optIter->altAction()
- << "\n ChangeFlag : " << (unsigned) optIter->changeFlag()
- << "\n Option Type : " << (unsigned) optIter->optionType()
- << "\n OptionLength : " << (unsigned) optIter->optionLength() <<"\n";
+ os << senf::fieldName(" AltAction") << unsigned(optIter->altAction()) << "\n"
+ << senf::fieldName(" ChangeFlag") << unsigned(optIter->changeFlag()) << "\n"
+ << senf::fieldName(" Option Type") << unsigned(optIter->optionType()) << "\n"
+ << senf::fieldName(" OptionLength") << unsigned(optIter->optionLength()) <<"\n";
senf::hexdump(boost::begin(optIter->value()) , boost::end(optIter->value()), os );
}
}
prefix_ void senf::IPv6DestinationOptionsPacketType::dump(packet p, std::ostream & os)
{
os << "Internet protocol Version 6 Destination Options extension:\n"
- << " next header : " << unsigned (p->nextHeader()) << "\n"
- << " header length : " << unsigned (p->headerLength()) << "\n";
+ << senf::fieldName("next header") << unsigned (p->nextHeader()) << "\n"
+ << senf::fieldName("header length") << unsigned (p->headerLength()) << "\n";
}
///////////////////////////////cc.e////////////////////////////////////////
prefix_ void senf::IPv6PacketType::dump(packet p, std::ostream & os)
{
boost::io::ios_all_saver ias(os);
- os << "Internet protocol Version 6:\n"
- << " version : " << unsigned(p->version()) << "\n"
- << " traffic class : 0x"
- << std::hex << std::setw(2) << std::setfill('0') << unsigned(p->trafficClass()) << "\n"
- << " flow label : 0x"
- << std::hex << std::setw(5) << std::setfill('0') << unsigned(p->flowLabel()) << "\n"
- << " payload length : " << std::dec << unsigned(p->length()) << "\n"
- << " next header : " << unsigned(p->nextHeader()) << "\n"
- << " hop limit : " << unsigned(p->hopLimit()) << "\n"
- << " source : " << p->source() << "\n"
- << " destination : " << p->destination() << "\n";
+ os << "Internet protocol Version 6:\n"
+ << senf::fieldName("version") << unsigned(p->version()) << "\n"
+ << senf::fieldName("traffic class")
+ << "0x" << std::hex << std::setw(2) << std::setfill('0') << unsigned(p->trafficClass()) << "\n"
+ << senf::fieldName("flow label")
+ << "0x" << std::hex << std::setw(5) << std::setfill('0') << unsigned(p->flowLabel()) << "\n"
+ << senf::fieldName("payload length") << std::dec << unsigned(p->length()) << "\n"
+ << senf::fieldName("next header") << unsigned(p->nextHeader()) << "\n"
+ << senf::fieldName("hop limit") << unsigned(p->hopLimit()) << "\n"
+ << senf::fieldName("source") << p->source() << "\n"
+ << senf::fieldName("destination") << p->destination() << "\n";
}
prefix_ void senf::IPv6PacketType::finalize(packet p)
boost::io::ios_all_saver ias(os);
os << "LLC/SNAP:\n"
<< std::hex << std::setfill('0')
- << " LLC\n"
- << " dsap : 0x" << unsigned(p->dsap()) << "\n"
- << " ssap : 0x" << unsigned(p->ssap()) << "\n"
- << " control id : 0x" << unsigned(p->ctrl()) << "\n"
- << " SNAP\n"
- << " protocol id : 0x" << std::setw(6) << unsigned(p->protocolId()) << "\n"
- << " type/length : 0x" << std::setw(4) << unsigned(p->type_length()) << "\n";
+ << " LLC\n"
+ << senf::fieldName(" dsap") << "0x" << unsigned(p->dsap()) << "\n"
+ << senf::fieldName(" ssap") << "0x" << unsigned(p->ssap()) << "\n"
+ << senf::fieldName(" control id") << "0x" << unsigned(p->ctrl()) << "\n"
+ << " SNAP\n"
+ << senf::fieldName(" protocol id") << "0x" << std::setw(6) << unsigned(p->protocolId()) << "\n"
+ << senf::fieldName(" type/length") << "0x" << std::setw(4) << unsigned(p->type_length()) << "\n";
}
prefix_ senf::PacketInterpreterBase::factory_t senf::LlcSnapPacketType::nextPacketType(packet p)
namespace
{
- std::string ptName(int pt){
+ std::string ptName(int pt)
+ {
struct pt_item
{
int pt;
{116,"32L16S"},{127,"HTML"},{-1,""}
};
int n = 0;
- while ( ptList[n].pt != -1)
+ while (ptList[n].pt != -1)
{
- if( ptList[n].pt == pt)
+ if (ptList[n].pt == pt)
return ptList[n].name;
++n;
}
{
boost::io::ios_all_saver ias(os);
os << "Real Time Protocol:\n"
- << " version : " << p->version() << "\n"
- << " padding : " << p->padding() << "\n"
- << " extension : " << p->extension() << "\n"
- << " contributing source cnt : " << p->csrcCount() << "\n"
- << " marker : " << p->marker() << "\n"
- << " payload type : " << p->payloadType() << " "<< ptName(p->payloadType() ) <<"\n"
- << " sequence number : " << p->seqNumber() << "\n"
- << " timestamp : " << p->timeStamp() << "\n"
- << " sync source id : " << p->synSourceId() << "\n";
+ << senf::fieldName("version") << p->version() << "\n"
+ << senf::fieldName("padding") << p->padding() << "\n"
+ << senf::fieldName("extension") << p->extension() << "\n"
+ << senf::fieldName("contributing source cnt") << p->csrcCount() << "\n"
+ << senf::fieldName("marker") << p->marker() << "\n"
+ << senf::fieldName("payload type") << p->payloadType() << " "<< ptName(p->payloadType() ) <<"\n"
+ << senf::fieldName("sequence number") << p->seqNumber() << "\n"
+ << senf::fieldName("timestamp") << p->timeStamp() << "\n"
+ << senf::fieldName("sync source id") << p->synSourceId() << "\n";
}
#undef prefix_
{
boost::io::ios_all_saver ias(os);
os << "TCP:\n"
- << " source port : " << p->source() << "\n"
- << " destination port : " << p->destination() << "\n"
- << " sequence number : " << p->sequencenumber() << "\n"
- << " acknowledgment number : " << p->acknowledgmentnumber() << "\n"
- << " data offset : " << p->dataoffset() << "\n"
- << " urgent flag : " << p->urgf() << "\n"
- << " ack flag : " << p->ackf() << "\n"
- << " push flag : " << p->pshf() << "\n"
- << " reset flag : " << p->rstf() << "\n"
- << " syn flag : " << p->synf() << "\n"
- << " fin flag : " << p->finf() << "\n"
- << " window size : " << p->window() << "\n"
- << " checksum : "
- << std::hex << std::setw(4) << std::setfill('0') << p->checksum() << "\n"
- << " urgent pointer : " << p->urgentpointer() << "\n";
+ << senf::fieldName("source port") << p->source() << "\n"
+ << senf::fieldName("destination port") << p->destination() << "\n"
+ << senf::fieldName("sequence number") << p->sequencenumber() << "\n"
+ << senf::fieldName("acknowledgment number") << p->acknowledgmentnumber() << "\n"
+ << senf::fieldName("data offset") << p->dataoffset() << "\n"
+ << senf::fieldName("urgent flag") << p->urgf() << "\n"
+ << senf::fieldName("ack flag") << p->ackf() << "\n"
+ << senf::fieldName("push flag") << p->pshf() << "\n"
+ << senf::fieldName("reset flag") << p->rstf() << "\n"
+ << senf::fieldName("syn flag") << p->synf() << "\n"
+ << senf::fieldName("fin flag") << p->finf() << "\n"
+ << senf::fieldName("window size") << p->window() << "\n"
+ << senf::fieldName("checksum")
+ << "0x" << std::hex << std::setw(4) << std::setfill('0') << p->checksum() << "\n"
+ << senf::fieldName("urgent pointer") << p->urgentpointer() << "\n";
}
prefix_ void senf::TCPPacketType::finalize(packet p)
{
boost::io::ios_all_saver ias(os);
os << "UDP:\n"
- << " source port : " << p->source() << "\n"
- << " dest port : " << p->destination() << "\n"
- << " length : " << p->length() << "\n"
- << " checksum : "
- << std::hex << std::setw(4) << std::setfill('0') << p->checksum() << "\n";
+ << senf::fieldName("source port") << p->source() << "\n"
+ << senf::fieldName("dest port") << p->destination() << "\n"
+ << senf::fieldName("length") << p->length() << "\n"
+ << senf::fieldName("checksum")
+ << "0x" << std::hex << std::setw(4) << std::setfill('0') << p->checksum() << "\n";
}
prefix_ void senf::UDPPacketType::finalize(packet p)
"8", "9", "10", "11", "12", "13", "14", "15" };
boost::io::ios_all_saver ias(os);
os << "DTCP HELLO Packet:" << std::endl
- << " version : " << p->versionNumber() << std::endl
- << " command : " << COMMANDS[p->command()] << std::endl
- << " interval : " << unsigned(p->interval()) << std::endl
- << " sequence number : " << p->sequenceNumber() << std::endl
- << " receive capable feed : " << (p->receiveCapableFeed() ? "yes" : "no") << std::endl
- << " ip version : " << p->ipVersion() << std::endl
- << " tunnel protocol : " << unsigned(p->tunnelProtocol()) << std::endl
- << " number of BDL ips : " << unsigned(p->fbipCount()) << std::endl
- << " feed BDL ips : ";
+ << senf::fieldName("version") << p->versionNumber() << "\n"
+ << senf::fieldName("command") << COMMANDS[p->command()] << "\n"
+ << senf::fieldName("interval") << unsigned(p->interval()) << "\n"
+ << senf::fieldName("sequence number") << p->sequenceNumber() << "\n"
+ << senf::fieldName("receive capable feed") << (p->receiveCapableFeed() ? "yes" : "no") << "\n"
+ << senf::fieldName("ip version") << p->ipVersion() << "\n"
+ << senf::fieldName("tunnel protocol") << unsigned(p->tunnelProtocol()) << "\n"
+ << senf::fieldName("number of BDL ips") << unsigned(p->fbipCount()) << "\n"
+ << " feed BDL ips:\n";
switch (p->ipVersion()) {
case 4 : {
FBIPList::container::iterator i (fbips.begin());
FBIPList::container::iterator const i_end (fbips.end());
for (; i != i_end; ++i)
- os << "\n " << *i;
+ os << " " << *i << "\n";
break;
}
case 6 : {
FBIPList::container::iterator i (fbips.begin());
FBIPList::container::iterator const i_end (fbips.end());
for (; i != i_end; ++i)
- os << "\n " << *i;
+ os << " " << *i << "\n";
break;
}
default:
- os << "unknown ip version";
+ os << " unknown ip version\n";
}
-
- os << std::endl;
}
#undef prefix_
" ip version : 4\n"
" tunnel protocol : 23\n"
" number of BDL ips : 2\n"
- " feed BDL ips : \n"
+ " feed BDL ips:\n"
" 101.102.103.104\n"
" 201.202.203.204\n" );
{
boost::io::ios_all_saver ias(os);
os << "GRE Encapsulation:\n"
- << " checksum_present : " << p->checksum_present() << "\n"
- << " protocol_type : 0x" << std::hex << p->protocol_type() << "\n"
- ;
+ << senf::fieldName("checksum_present") << p->checksum_present() << "\n"
+ << senf::fieldName("protocol_type") << "0x" << std::hex << p->protocol_type() << "\n";
}
///////////////////////////////cc.e////////////////////////////////////////
boost::io::ios_all_saver ias(os);
os << "MPE Section:\n"
<< std::hex
- << " table_id : 0x" << unsigned(p->table_id()) << "\n"
- << " section syntax indicator: " << p->section_syntax_indicator() << "\n"
- << " private indicator : " << p->private_indicator() << "\n"
+ << senf::fieldName("table_id") << "0x" << unsigned(p->table_id()) << "\n"
+ << senf::fieldName("section syntax indicator") << p->section_syntax_indicator() << "\n"
+ << senf::fieldName("private indicator") << p->private_indicator() << "\n"
<< std::dec
- << " section length : " << p->section_length() << "\n"
+ << senf::fieldName("section length") << p->section_length() << "\n"
<< std::hex
- << " MAC address 6 : 0x" << unsigned(p->mac_addr_6()) << "\n"
- << " MAC address 5 : 0x" << unsigned(p->mac_addr_5()) << "\n"
- << " payload scrambling ctrl : 0x" << p->payload_scrmbl_ctrl() << "\n"
- << " address scrambling ctrl : 0x" << p-> addr_scrmbl_ctrl() << "\n"
- << " LLC/SNAP flag : 0x" << p->llc_snap_flag() << "\n"
- << " current next indicator : 0x" << p->curr_next_indicator() << "\n"
- << " section number : 0x" << unsigned(p->section_num()) << "\n"
- << " last section number : 0x" << unsigned(p->last_section_num()) << "\n"
- << " real time parameters : \n"
- << " delta_t : 0x" << unsigned(p->real_time_parameters().delta_t()) << "\n"
- << " table boundary : 0x" << unsigned(p->real_time_parameters().table_boundary()) << "\n"
- << " frame boundary : 0x" << unsigned(p->real_time_parameters().frame_boundary()) << "\n"
- << " address : 0x" << unsigned(p->real_time_parameters().address()) << "\n"
+ << senf::fieldName("MAC address 6") << "0x" << unsigned(p->mac_addr_6()) << "\n"
+ << senf::fieldName("MAC address 5") << "0x" << unsigned(p->mac_addr_5()) << "\n"
+ << senf::fieldName("payload scrambling ctrl") << "0x" << p->payload_scrmbl_ctrl() << "\n"
+ << senf::fieldName("address scrambling ctrl") << "0x" << p-> addr_scrmbl_ctrl() << "\n"
+ << senf::fieldName("LLC/SNAP flag") << "0x" << p->llc_snap_flag() << "\n"
+ << senf::fieldName("current next indicator") << "0x" << p->curr_next_indicator() << "\n"
+ << senf::fieldName("section number") << "0x" << unsigned(p->section_num()) << "\n"
+ << senf::fieldName("last section number") << "0x" << unsigned(p->last_section_num()) << "\n"
+ << senf::fieldName("real time parameters") << "\n"
+ << senf::fieldName(" delta_t") << "0x" << unsigned(p->real_time_parameters().delta_t()) << "\n"
+ << senf::fieldName(" table boundary") << "0x" << unsigned(p->real_time_parameters().table_boundary()) << "\n"
+ << senf::fieldName(" frame boundary") << "0x" << unsigned(p->real_time_parameters().frame_boundary()) << "\n"
+ << senf::fieldName(" address") << "0x" << unsigned(p->real_time_parameters().address()) << "\n"
<< std::dec
- << " crc : " << unsigned(p->crc()) << "\n";
+ << senf::fieldName("crc") << unsigned(p->crc()) << "\n";
}
prefix_ senf::PacketParserBase::size_type senf::MPESectionType::initSize()
{
os << "SNDUPacket:\n"
<< std::dec
- << " d_bit : " << p->d_bit() << "\n"
- << " length : " << unsigned(p->length()) << "\n"
+ << senf::fieldName("d_bit") << p->d_bit() << "\n"
+ << senf::fieldName("length") << unsigned(p->length()) << "\n"
<< std::hex
- << " type : 0x" << unsigned(p->type()) << "\n"
+ << senf::fieldName("type") << "0x" << unsigned(p->type()) << "\n"
<< std::dec
- << " crc : " << unsigned(p->crc()) << "\n";
+ << senf::fieldName("crc") << unsigned(p->crc()) << "\n";
}
prefix_ senf::PacketParserBase::size_type senf::SNDUPacketType::initSize()
boost::io::ios_all_saver ias(os);
os << "TransportPacket:\n"
<< std::hex
- << " syncByte : 0x" << unsigned(p->sync_byte()) << "\n"
- << " transport error ind. : 0x" << unsigned(p->transport_error_indicator()) << "\n"
- << " payload unit start ind. : 0x" << unsigned(p->pusi()) << "\n"
- << " transport priority : 0x" << unsigned(p->transport_priority()) << "\n"
+ << senf::fieldName("syncByte") << "0x" << unsigned(p->sync_byte()) << "\n"
+ << senf::fieldName("transport error ind.") << "0x" << unsigned(p->transport_error_indicator()) << "\n"
+ << senf::fieldName("payload unit start ind.") << "0x" << unsigned(p->pusi()) << "\n"
+ << senf::fieldName("transport priority") << "0x" << unsigned(p->transport_priority()) << "\n"
<< std::dec
- << " pid : " << unsigned(p->pid()) << "\n"
+ << senf::fieldName("pid") << unsigned(p->pid()) << "\n"
<< std::hex
- << " transport scrambling c. : 0x" << unsigned(p->transport_scrmbl_ctrl()) << "\n"
- << " adaptation field ctrl : 0x" << unsigned(p->adaptation_field_ctrl()) << "\n"
- << " continuity counter : 0x" << unsigned(p->continuity_counter()) << "\n";
+ << senf::fieldName("transport scrambling c.") << "0x" << unsigned(p->transport_scrmbl_ctrl()) << "\n"
+ << senf::fieldName("adaptation field ctrl") << "0x" << unsigned(p->adaptation_field_ctrl()) << "\n"
+ << senf::fieldName("continuity counter") << "0x" << unsigned(p->continuity_counter()) << "\n";
if (p->pusi())
- os << " pointer field : 0x" << unsigned(p->pointer_field()) << "\n";
+ os << senf::fieldName("pointer field") << "0x" << unsigned(p->pointer_field()) << "\n";
}
///////////////////////////////cc.e////////////////////////////////////////
byte. If the packet has been implemented correctly, this signals a malformed packet.
*/
struct TruncatedPacketException : public senf::Exception
- { TruncatedPacketException() : senf::Exception("truncated packet"){} };
+ { TruncatedPacketException() : senf::Exception("truncated packet") {} };
}
chain member and other similar error conditions.
*/
struct InvalidPacketChainException : public senf::Exception
- { InvalidPacketChainException() : senf::Exception("invalid packet chain"){} };
+ { InvalidPacketChainException() : senf::Exception("invalid packet chain") {} };
}
This exception is signaled whenever a throwing lookup operation fails.
*/
struct PacketTypeNotRegisteredException : public senf::Exception
- { PacketTypeNotRegisteredException() : senf::Exception("packet type not registered"){} };
+ { PacketTypeNotRegisteredException() : senf::Exception("packet type not registered") {} };
}
{
configFile.close();
}
-prefix_ void senf::DVBConfigParser::initConfigFile(string configFilePath_){
+
+prefix_ void senf::DVBConfigParser::initConfigFile(string configFilePath_)
+{
if (configFilePath_.size() == 0) {
if ( !(::getenv ("HOME")) )
SENF_THROW_SYSTEM_EXCEPTION("$HOME not set! You need it to use default configfile.");
}
configFilePath = configFilePath_;
configFile.open( configFilePath.c_str(), ios_base::in);
- if(configFile.bad())
+ if (configFile.bad())
SENF_LOG((senf::log::IMPORTANT) ("Could not open channels file"<< configFilePath << "." ));
configFile.close();
}
transform(channel.begin(), channel.end(), channel.begin(), ::toupper);
configFile.open( configFilePath.c_str(), ios_base::in);
- if(configFile.bad())
+ if (configFile.bad())
SENF_THROW_SYSTEM_EXCEPTION("Could not read channels file: ") << configFilePath << ".";
- while (configFile.good()){
+ while (configFile.good()) {
getline( configFile, configLine );
SENF_LOG((senf::log::NOTICE) ("configLine: " << configLine ));
transform(configLine.begin(), configLine.end(), configLine.begin(), ::toupper);
pos = configLine.find(channel);
- if(pos != string::npos && pos == 0){ // only first matching number should be interpreted as channel number
+ if (pos != string::npos && pos == 0) { // only first matching number should be interpreted as channel number
configFile.close();
return configLine; // Line found!
}
return channel;
}
-prefix_ dvb_frontend_parameters senf::DVBConfigParser::getFrontendParam(string configLine){
+prefix_ dvb_frontend_parameters senf::DVBConfigParser::getFrontendParam(string configLine)
+{
struct dvb_frontend_parameters frontend;
transform(configLine.begin(), configLine.end(), configLine.begin(), ::toupper);
boost::char_separator<char> sep(":");
return frontend;
}
-prefix_ dvb_frontend_parameters senf::DVBConfigParser::getFrontendParamDVB_T( const tokenizer & tokens){
-
+prefix_ dvb_frontend_parameters
+senf::DVBConfigParser::getFrontendParamDVB_T(const tokenizer & tokens)
+{
struct dvb_frontend_parameters frontend;
istringstream isst;
int number;
::memset(&frontend, 0, sizeof(struct dvb_frontend_parameters));
- /*if(words.size() < 10)
+ /*if (words.size() < 10)
SENF_THROW_SYSTEM_EXCEPTION("Too few arguments! There must be at least 10, but there are only: ") << words.size();*/
isst.str(words[p_Frequency]);
isst >> number;
- if(isst.fail())
+ if (isst.fail())
SENF_THROW_SYSTEM_EXCEPTION("Cant parse frequency");
frontend.frequency = number;
- if( params.inversion.find(words[p_Inversion]) == params.inversion.end())
+ if (params.inversion.find(words[p_Inversion]) == params.inversion.end())
SENF_THROW_SYSTEM_EXCEPTION("Cant parse inversion");
frontend.inversion = params.inversion.find(words[p_Inversion])->second;
- if( params.bandwidth.find(words[p_Bandwidth]) == params.bandwidth.end())
+ if (params.bandwidth.find(words[p_Bandwidth]) == params.bandwidth.end())
SENF_THROW_SYSTEM_EXCEPTION("Cant parse bandwidth");
frontend.u.ofdm.bandwidth = params.bandwidth.find(words[p_Bandwidth])->second;
- if( params.code_rate.find(words[p_hp_code_rate]) == params.code_rate.end())
+ if (params.code_rate.find(words[p_hp_code_rate]) == params.code_rate.end())
SENF_THROW_SYSTEM_EXCEPTION("Cant parse high priority stream code rate");
frontend.u.ofdm.code_rate_HP = params.code_rate.find(words[p_hp_code_rate])->second;
- if( params.code_rate.find(words[p_lp_code_rate]) == params.code_rate.end())
+ if (params.code_rate.find(words[p_lp_code_rate]) == params.code_rate.end())
SENF_THROW_SYSTEM_EXCEPTION("Cant parse low priority stream code rate");
frontend.u.ofdm.code_rate_LP = params.code_rate.find(words[p_lp_code_rate])->second;
- if( params.modulation.find(words[p_Mudualtion]) == params.modulation.end())
+ if (params.modulation.find(words[p_Mudualtion]) == params.modulation.end())
SENF_THROW_SYSTEM_EXCEPTION("Cant parse modulation");
frontend.u.ofdm.constellation = params.modulation.find(words[p_Mudualtion])->second;
- if( params.transmit_mode.find(words[p_Transmission]) == params.transmit_mode.end())
+ if (params.transmit_mode.find(words[p_Transmission]) == params.transmit_mode.end())
SENF_THROW_SYSTEM_EXCEPTION("Cant parse transmission mode");
frontend.u.ofdm.transmission_mode = params.transmit_mode.find(words[p_Transmission])->second;
- if( params.guard_interval.find(words[p_guard]) == params.guard_interval.end())
+ if (params.guard_interval.find(words[p_guard]) == params.guard_interval.end())
SENF_THROW_SYSTEM_EXCEPTION("Cant parse guard interval");
frontend.u.ofdm.guard_interval = params.guard_interval.find(words[p_guard])->second;
- if( params.hierarchy.find(words[p_hierarchy]) == params.hierarchy.end())
+ if (params.hierarchy.find(words[p_hierarchy]) == params.hierarchy.end())
SENF_THROW_SYSTEM_EXCEPTION("Cant parse hierarchy");
frontend.u.ofdm.hierarchy_information = params.hierarchy.find(words[p_hierarchy])->second;
return frontend;
}
-prefix_ dvb_frontend_parameters senf::DVBConfigParser::getFrontendParamDVB_S( const tokenizer & tokens){
+prefix_ dvb_frontend_parameters
+senf::DVBConfigParser::getFrontendParamDVB_S(const tokenizer & tokens)
+{
struct dvb_frontend_parameters frontend;
istringstream isst;
int number;
::memset(&frontend, 0, sizeof(struct dvb_frontend_parameters));
- if(words.size() < 5)
+ if (words.size() < 5)
SENF_THROW_SYSTEM_EXCEPTION("Too few arguments! There must be at least 5, but there are only: ") << words.size();
isst.str(words[p_Frequency]);
return frontend;
}
-prefix_ dvb_frontend_parameters senf::DVBConfigParser::getFrontendParamDVB_C( const tokenizer & tokens){
+prefix_ dvb_frontend_parameters
+senf::DVBConfigParser::getFrontendParamDVB_C(const tokenizer & tokens)
+{
struct dvb_frontend_parameters frontend;
istringstream isst;
int number;
::memset(&frontend, 0, sizeof(struct dvb_frontend_parameters));
- if(words.size() < 6)
+ if (words.size() < 6)
SENF_THROW_SYSTEM_EXCEPTION("Too few arguments! There must be at least 6, but there are only: ") << words.size();
isst.str(words[p_Frequency]);
{
std::string devDemux = str( boost::format("/dev/dvb/adapter%d/demux%d") % adapter % device);
int f = open(devDemux.c_str(), O_RDONLY | O_NONBLOCK);
- if (f < 0){
+ if (f < 0) {
SENF_THROW_SYSTEM_EXCEPTION("Could not open demux device of DVB adapter ") << devDemux << ".";
}
fd(f);
*/
class DVBProtocolWrapper :public boost::enable_shared_from_this<DVBProtocolWrapper> {
public:
- DVBProtocolWrapper(){}
- virtual ~DVBProtocolWrapper(){}
+ DVBProtocolWrapper() {}
+ virtual ~DVBProtocolWrapper() {}
};
/** \brief Baseclass for DVBSocketProtocols which want use Wrappers for console.
*/
{
wrap_ = wrap;
}
- virtual void close(){
+ virtual void close()
+ {
wrap_.reset();
SocketProtocol::close();
prefix_ void senf::DVBFrontendSocketProtocol::setNonBlock(bool on)
const
{
- if(on)
+ if (on)
::fcntl(fd(), F_SETFL, ::fcntl(fd(), F_GETFL) | O_NONBLOCK);
else
::fcntl(fd(), F_SETFL, ::fcntl(fd(), F_GETFL) & ~O_NONBLOCK);
struct dvb_frontend_info info;
::memset(&info, 0, sizeof(struct dvb_frontend_info));
- if( ::ioctl(fd(), FE_GET_INFO, &info) ) {
+ if (::ioctl(fd(), FE_GET_INFO, &info)) {
SENF_THROW_SYSTEM_EXCEPTION("") << "Could not read on fildescriptor.";
}
return info;
::memset(&frontend_, 0, sizeof(struct dvb_frontend_parameters));
- if(::ioctl(fd(), FE_GET_FRONTEND, &frontend_)) {
+ if (::ioctl(fd(), FE_GET_FRONTEND, &frontend_)) {
switch(errno) {
case EBADF:
SENF_THROW_SYSTEM_EXCEPTION("fd is not a valid open file descriptor.");
::memset(&ev, 0, sizeof(struct dvb_frontend_event));
- if(::ioctl(fd(), FE_GET_EVENT, &ev)) {
+ if (::ioctl(fd(), FE_GET_EVENT, &ev)) {
switch(errno) {
case EBADF:
SENF_THROW_SYSTEM_EXCEPTION("Could not read from frontend device, read-only access to the device is sufficient.");
}
prefix_ senf::DVBSocketController::~DVBSocketController()
-{
-}
+{}
-prefix_ senf::DVBDemuxSectionHandle senf::DVBSocketController::createDVBDemuxSectionHandle( int adapternumber, int demuxnumber, bool addToConsole ){
+prefix_ senf::DVBDemuxSectionHandle
+senf::DVBSocketController::createDVBDemuxSectionHandle(int adapternumber, int demuxnumber,
+ bool addToConsole)
+{
DVBDemuxSectionHandle sectionHandle(adapternumber, demuxnumber);
- if(addToConsole)
+ if (addToConsole)
this->addToConsole(sectionHandle);
return sectionHandle;
}
-prefix_ senf::DVBDemuxPESHandle senf::DVBSocketController::createDVBDemuxPESHandle( int adapternumber, int demuxnumber, bool addToConsole ){
+prefix_ senf::DVBDemuxPESHandle
+senf::DVBSocketController::createDVBDemuxPESHandle(int adapternumber, int demuxnumber,
+ bool addToConsole)
+{
DVBDemuxPESHandle pesHandle(adapternumber, demuxnumber);
- if(addToConsole )
+ if (addToConsole)
this->addToConsole(pesHandle);
return pesHandle;
}
-prefix_ void senf::DVBSocketController::addToConsole(senf::DVBDemuxSectionHandle sh){
+prefix_ void senf::DVBSocketController::addToConsole(senf::DVBDemuxSectionHandle sh)
+{
boost::shared_ptr<DVBSectionProtocolWrapper> wrap(new DVBSectionProtocolWrapper(sh));
sh.protocol().addWrapper(wrap);
dir.node().add("section" + senf::str(sectionNr), wrap->dir);
sectionNr++;
}
-prefix_ void senf::DVBSocketController::addToConsole(senf::DVBDemuxPESHandle sh){
+
+prefix_ void senf::DVBSocketController::addToConsole(senf::DVBDemuxPESHandle sh)
+{
boost::shared_ptr<DVBPESProtocolWrapper> wrap(new DVBPESProtocolWrapper(sh));
sh.protocol().addWrapper(wrap);
dir.node().add("pes"+ senf::str(pesNr), wrap->dir);
struct dvb_frontend_parameters frontend;
// no valid configline, so it will be treaten like a channel name
- if (input.find(":")==string::npos){
+ if (input.find(":")==string::npos)
+ {
if (mode.c_str()[0]=='a')
tuneTo(input);
else
// add psydo name "foo" to complete configline syntax
frontend = parser.getFrontendParam("foo:"+input);
- if (mode.c_str()[0]=='a'){
+ if (mode.c_str()[0]=='a') {
switch (type) {
case FE_QPSK:
tuneDVB_S(frontend.frequency, frontend.inversion, frontend.u.qpsk.symbol_rate, frontend.u.qpsk.fec_inner);
fe_hierarchy_t hierarchy_information
)
{
- if(type != FE_OFDM)
+ if (type != FE_OFDM)
SENF_THROW_SYSTEM_EXCEPTION("Type of card is: ") << getTypeString() << " for this operation you need a DVB-T Card!";
event.enable();
prefix_ void senf::DVBSocketController::tuneDVB_S(unsigned int frequency, fe_spectral_inversion_t inversion, unsigned int symbole_rate, fe_code_rate_t code_rate)
{
- if(type != FE_QPSK)
+ if (type != FE_QPSK)
SENF_THROW_SYSTEM_EXCEPTION("Type of card is: ") << getTypeString() << " for this operation you need a DVB-S Card!";
event.enable();
fe_modulation_t modulation
)
{
- if(type != FE_QAM)
+ if (type != FE_QAM)
SENF_THROW_SYSTEM_EXCEPTION("Type of card is: ") << getTypeString() << " for this operation you need a DVB-C Card!";
event.enable();
fe_hierarchy_t hierarchy_information
)
{
- if(type != FE_OFDM)
+ if (type != FE_OFDM)
SENF_THROW_SYSTEM_EXCEPTION("Type of card is: ") << getTypeString() << " for this operation you need a DVB-T Card!";
event.disable();
guard_interval,
hierarchy_information);
- if(!frontendHandle.waitOOBReadable(senf::ClockService::seconds(2)))
+ if (!frontendHandle.waitOOBReadable(senf::ClockService::seconds(2)))
SENF_THROW_SYSTEM_EXCEPTION("Could not tune to channel!");
return frontendHandle.protocol().getEvent();
}
-prefix_ dvb_frontend_event senf::DVBSocketController::tuneDVB_S_sync(unsigned int frequency, fe_spectral_inversion_t inversion, unsigned int symbole_rate, fe_code_rate_t code_rate){
- if(type != FE_QPSK)
+prefix_ dvb_frontend_event
+senf::DVBSocketController::tuneDVB_S_sync(unsigned int frequency,
+ fe_spectral_inversion_t inversion,
+ unsigned int symbole_rate, fe_code_rate_t code_rate)
+{
+ if (type != FE_QPSK)
SENF_THROW_SYSTEM_EXCEPTION("Type of card is: ") << getTypeString() << " for this operation you need a DVB-S Card!";
event.disable();
frontendHandle.protocol().tuneDVB_S(frequency, inversion, symbole_rate, code_rate);
- if(!frontendHandle.waitOOBReadable(senf::ClockService::seconds(2)))
+ if (!frontendHandle.waitOOBReadable(senf::ClockService::seconds(2)))
SENF_THROW_SYSTEM_EXCEPTION("Could not tune to channel!");
return frontendHandle.protocol().getEvent();
}
fe_modulation_t modulation
)
{
- if(type != FE_QAM)
+ if (type != FE_QAM)
SENF_THROW_SYSTEM_EXCEPTION("Type of card is: ") << getTypeString() << " for this operation you need a DVB-C Card!";
event.disable();
frontendHandle.protocol().setNonBlock(false);
frontendHandle.protocol().tuneDVB_C(frequency, inversion, symbol_rate, fec_inner, modulation);
- if(!frontendHandle.waitOOBReadable(senf::ClockService::seconds(2)))
+ if (!frontendHandle.waitOOBReadable(senf::ClockService::seconds(2)))
SENF_THROW_SYSTEM_EXCEPTION("Could not tune to channel!");
return frontendHandle.protocol().getEvent();
info << hex;
- for(unsigned int i = 0; i < conf.size(); ++i){
- if(i>0)
+ for (unsigned int i = 0; i < conf.size(); ++i) {
+ if (i>0)
info << " | ";
- switch(cConf[i]){
+ switch (cConf[i]) {
case 'S' :
info << "signal " << signal;
break;
prefix_ void senf::DVBSocketController::readEvent(int event)
{
- if(cb)
+ if (cb)
cb(frontendHandle.protocol().getEvent());
}
const
{
init_client(protocol);
- if(address.boolean_test()) {
+ if (address.boolean_test()) {
//only connect if socket is not [::]:0, this results in an irreversible binding to the lo interface (linux 2.6.15)
clientHandle().connect(address);
}
BOOST_CHECKPOINT( 7 );
inputSocket.close();
-// if( unlink(socketPath.c_str()) != 0)
+// if (unlink(socketPath.c_str()) != 0)
// perror( "unlink failed");
}
namespace {
int cb1(int a, double b) { return int(a+b); }
- double cb2(){ return 1.2; }
+ double cb2() { return 1.2; }
void cb3(int i) { }
std::string cb4(std::ostream & os) { os << "text\n"; return "value"; }
void cb5(std::ostream & os, std::string const & v) { os << "Value: " << v << "\n"; }
prefix_ std::ostream & senf::log::operator<<(std::ostream & os, senf::log::Target::action_t const & action)
{
- if( action == Target::ACCEPT) os << "ACCEPT";
- else if( action == Target::REJECT) os << "REJECT";
+ if (action == Target::ACCEPT) os << "ACCEPT";
+ else if (action == Target::REJECT) os << "REJECT";
else os << "unknown action";
return os;
}
/** \brief Exception: Invalid stream */
struct InvalidStreamException : public senf::Exception
{ InvalidStreamException()
- : senf::Exception("senf::log::Target::InvalidStreamException"){} };
+ : senf::Exception("senf::log::Target::InvalidStreamException") {} };
/** \brief Exception: Invalid area */
struct InvalidAreaException : public senf::Exception
{ InvalidAreaException()
- : senf::Exception("senf::log::Target::InvalidAreaException"){} };
+ : senf::Exception("senf::log::Target::InvalidAreaException") {} };
iterator begin() const; ///< Iterator to beginning of routing table
iterator end() const; ///< Iterator past the end of routing table
char *format_eng( float f)
{
static char buf[16];
- if( f > 0){
+ if (f > 0) {
int n = 0;
- while( f >= 1000.0f){
+ while( f >= 1000.0f) {
f /= 1000.f;
n+=3;
}
sprintf( buf, " %3.2fe%+03d", f, n);
}
- else if( f < 0){
+ else if (f < 0) {
int n = 0;
- while( f <= -1000.0f){
+ while( f <= -1000.0f) {
f *= 1000.f;
n+=3;
}
lexical_stream()
{
stream.unsetf(std::ios::skipws);
- if(std::numeric_limits<Target>::is_specialized)
+ if (std::numeric_limits<Target>::is_specialized)
stream.precision(std::numeric_limits<Target>::digits10 + 1);
}
template <class Source>
bool operator<<(const Source &input)
{
- if(std::numeric_limits<Source>::is_specialized)
+ if (std::numeric_limits<Source>::is_specialized)
stream.precision(std::numeric_limits<Source>::digits10 + 1);
return !(stream << input).fail();
}
Target operator()(Source const & arg) const
{
Target result;
- if(!((*interpreter_) << arg && (*interpreter_) >> result))
+ if (!((*interpreter_) << arg && (*interpreter_) >> result))
boost::throw_exception(boost::bad_lexical_cast(typeid(Source), typeid(Target)));
return result;
}
senf::detail::lexical_stream<Target> interpreter;
Target result;
- if(!(interpreter << arg && interpreter >> result))
+ if (!(interpreter << arg && interpreter >> result))
boost::throw_exception(boost::bad_lexical_cast(typeid(Source), typeid(Target)));
return result;
}