25 : fragmentationCount_(0)
31 unsigned payloadSize (eth.size() - senf::EthernetPacketParser::fixed_bytes -
34 return payloadSize > threshold;
39 unsigned tmp (fragmentationCount_);
40 fragmentationCount_ = 0;
47 unsigned fragmentNr (1);
50 size_type payloadSize (pkt.size() - senf::EthernetPacketParser::fixed_bytes);
52 ((vlanCPresent||vlanSPresent) * senf::EthVLanPacketParser::fixed_bytes)));
55 fragmentationCount_++;
61 size_type fragmentPayloadSize (
std::min( size_type(std::distance(payloadIter, payloadEnd)),
62 threshold - senf::EthOUIExtensionPacketParser::fixed_bytes - EthernetFragmentPacketParser::fixed_bytes));
65 senf::EthernetPacketParser::fixed_bytes +
66 ((vlanCPresent||vlanSPresent) * senf::EthVLanPacketParser::fixed_bytes) +
67 senf::EthOUIExtensionPacketParser::fixed_bytes +
68 EthernetFragmentPacketParser::fixed_bytes +
69 fragmentPayloadSize );
73 senf::DataPacket fragmentPayload (senf::DataPacket::createAfter(fragmentHeader, fragmentPayloadSize+padding,
senf::noinit));
75 std::copy( payloadIter, std::next(payloadIter, fragmentPayloadSize), fragmentPayload.data().begin());
76 std::advance( payloadIter, fragmentPayloadSize);
78 fragmentHeader->moreFragment() << (payloadIter != payloadEnd);
79 fragmentHeader->size() << (fragmentNr == 1 ? payloadSize : fragmentPayloadSize);
80 fragmentHeader->fragmentNr() << fragmentNr++;
83 else if (vlanCPresent)
86 fragmentHeader->type_length() << pkt->type_length();
88 eth.finalizeTo(fragmentHeader);
90 v_outputFragment(eth);
92 }
while (payloadIter != payloadEnd);
106 fragments_.emplace_back(eth);
116 : defaultFragThresh_(
std::
max(
std::uint16_t(576),defaultFragThresh))
127 defaultFragThresh_ =
std::max(std::uint16_t(576), threshold);
128 fragThreshMap_.clear();
130 fragThreshMap_.erase(dst);
132 fragThreshMap_.insert(std::make_pair(dst,
std::max(std::uint16_t(576), threshold)));
140 auto const it (fragThreshMap_.find(dst));
145 return defaultFragThresh_;
151 return fragThreshMap_;
156 fragThreshMap_.clear();
162 input.
onRequest( on ? &EthernetFragmenterModule::onRequestBypass : &EthernetFragmenterModule::onRequest);
177 prefix_ void senf::emu::EthernetFragmenterModule::onRequest()
186 prefix_ void senf::emu::EthernetFragmenterModule::onRequestBypass()
Route< connector::InputConnector, connector::OutputConnector > & route(connector::InputConnector &input, connector::OutputConnector &output)
static const unsigned minPayloadSize
senf::detail::packet::iterator iterator
ConcretePacket< EthVLanSPacketType > EthVLanSPacket
static const EtherTypes::key_t etherType
EthernetFragmenterModule(std::uint16_t defaultFragThresh=1500u)
static const EtherTypes::key_t etherType
void fragmentationThreshold(std::uint16_t _fragmentationThreshold, senf::MACAddress const &dst=senf::MACAddress::None)
boost::unordered_map< senf::MACAddress, std::uint16_t > const & fragThreshMap() const
std::vector< senf::EthernetPacket > & fragments()
senf::ppi::connector::PassiveInput< senf::EthernetPacket > input
raw_container::size_type size_type
senf::detail::packet::size_type size_type
senf::ppi::connector::ActiveOutput< senf::EthernetPacket > output
void fragmentFrame(senf::EthernetPacket const &pkt, unsigned treshold)
ConcretePacket< EthVLanCPacketType > EthVLanCPacket
void onRequest(Handler handler)
void do_fragmentFrame(senf::EthernetPacket const ð, unsigned threshold)
unsigned fragmentationCount()
ConcretePacket< EthernetPacketType > EthernetPacket
static ConcretePacket createAfter(Packet const &packet)
static bool fragmentationRequired(senf::EthernetPacket const &pkt, unsigned threshold)