|
5 | 5 | // University of Rostock, Germany
|
6 | 6 | //
|
7 | 7 |
|
8 |
| -#include "Gptp.h" |
9 |
| - |
10 |
| -#include "GptpPacket_m.h" |
| 8 | +#include "inet/linklayer/ieee8021as/Gptp.h" |
11 | 9 |
|
12 | 10 | #include "inet/clock/model/SettableClock.h"
|
13 |
| -#include "inet/common/IProtocolRegistrationListener.h" |
14 | 11 | #include "inet/common/clock/ClockUserModuleBase.h"
|
| 12 | +#include "inet/common/IProtocolRegistrationListener.h" |
| 13 | +#include "inet/common/packet/dissector/PacketDissector.h" |
15 | 14 | #include "inet/linklayer/common/InterfaceTag_m.h"
|
16 | 15 | #include "inet/linklayer/common/MacAddress.h"
|
17 | 16 | #include "inet/linklayer/common/MacAddressTag_m.h"
|
18 | 17 | #include "inet/linklayer/ethernet/common/Ethernet.h"
|
19 | 18 | #include "inet/linklayer/ethernet/common/EthernetMacHeader_m.h"
|
| 19 | +#include "inet/linklayer/ieee8021as/GptpPacket_m.h" |
20 | 20 | #include "inet/networklayer/common/NetworkInterface.h"
|
21 | 21 | #include "inet/physicallayer/wired/ethernet/EthernetPhyHeader_m.h"
|
22 | 22 |
|
@@ -493,17 +493,11 @@ void Gptp::processPdelayRespFollowUp(Packet *packet, const GptpPdelayRespFollowU
|
493 | 493 |
|
494 | 494 | const GptpBase *Gptp::extractGptpHeader(Packet *packet)
|
495 | 495 | {
|
496 |
| - auto protocol = packet->getTag<PacketProtocolTag>()->getProtocol(); |
497 |
| - if (*protocol != Protocol::ethernetPhy) |
498 |
| - return nullptr; |
499 |
| - |
500 |
| - const auto& ethPhyHeader = packet->peekAtFront<physicallayer::EthernetPhyHeader>(); |
501 |
| - const auto& ethMacHeader = packet->peekDataAt<EthernetMacHeader>(ethPhyHeader->getChunkLength()); |
502 |
| - if (ethMacHeader->getTypeOrLength() != ETHERTYPE_GPTP) |
503 |
| - return nullptr; |
504 |
| - |
505 |
| - b offset = ethPhyHeader->getChunkLength() + ethMacHeader->getChunkLength(); |
506 |
| - return packet->peekDataAt<GptpBase>(offset).get(); |
| 496 | + PacketDissector::ChunkFinder chunkFinder(&Protocol::gptp); |
| 497 | + PacketDissector packetDissector(ProtocolDissectorRegistry::getInstance(), chunkFinder); |
| 498 | + packetDissector.dissectPacket(packet); |
| 499 | + const auto& chunk = staticPtrCast<const GptpBase>(chunkFinder.getChunk()); |
| 500 | + return chunk != nullptr ? chunk.get() : nullptr; |
507 | 501 | }
|
508 | 502 |
|
509 | 503 | void Gptp::receiveSignal(cComponent *source, simsignal_t simSignal, cObject *obj, cObject *details)
|
|
0 commit comments