source: trunk/ETSI-Testsuites/ETSI_auto_IOT/adapter/src/Dispatcher/UdpDissector.cpp @ 32

Last change on this file since 32 was 22, checked in by rings, 14 years ago
  • Property svn:executable set to *
File size: 1.1 KB
Line 
1#include "UdpDissector.h"
2#include "Logger/Logger.h"
3#ifdef WIN32
4#include <Winsock2.h>
5#else
6#include <netinet/in.h>
7#endif
8
9UdpDissector::UdpDissector() :
10        m_udpHdr(0)
11{
12}
13
14UdpDissector::~UdpDissector()
15{
16        delete m_udpHdr;
17}
18
19UdpDissector * UdpDissector::Clone() const {
20  return new UdpDissector();
21}
22
23bool UdpDissector::Dissect(const unsigned char * pData, const ssize_t nDataLen) {
24  if (!m_udpHdr)
25    m_udpHdr = new UdpHeader;
26  memcpy(m_udpHdr, pData, sizeof(UdpHeader));
27#if BYTE_ORDER == LITTLE_ENDIAN
28  m_udpHdr->destPort = ntohs(m_udpHdr->destPort);
29  m_udpHdr->srcPort = ntohs(m_udpHdr->srcPort);
30#endif
31  pData += sizeof(UdpHeader);
32
33  SavePayload(pData, nDataLen - sizeof(UdpHeader));
34  SaveLayerInfo();
35  return true;
36}
37
38bool UdpDissector::NeedReassembly() const {
39  return false;
40}
41
42const EProtocolType UdpDissector::GetUpperLayerType() const
43{
44        return EProtocolType_None;
45}
46
47ProtocolInfoElement * UdpDissector::CreateLayerInfo()
48{
49        UdpInfo * pRes = new UdpInfo();
50        pRes->SetSourcePort(m_udpHdr->srcPort);
51        pRes->SetDestinationPort(m_udpHdr->destPort);
52        return pRes;
53}
Note: See TracBrowser for help on using the repository browser.