CHENGQI YANG / SmartLab_MuRata
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers UDPReceivedIndication.cpp Source File

UDPReceivedIndication.cpp

00001 #include "UDPReceivedIndication.h"
00002 
00003 using namespace SmartLabMuRata;
00004 
00005 UDPReceivedIndication::UDPReceivedIndication(Payload * payload)
00006     : Payload(payload)
00007 {
00008     if (payload == NULL)
00009         return;
00010         
00011     receiveLength = GetData()[9] << 8 | GetData()[10];
00012 }
00013 
00014 char UDPReceivedIndication::GetServerSocketID()
00015 {
00016     return GetData()[2];
00017 }
00018 
00019 IPAddress UDPReceivedIndication::GetRemoteIP()
00020 {
00021     IPAddress ip;
00022     ip.SetValue(GetData(), 3);
00023     return ip;
00024 }
00025 
00026 int UDPReceivedIndication::GetRemotePort()
00027 {
00028     return GetData()[7] << 8 | GetData()[8];
00029 }
00030 
00031 int UDPReceivedIndication::GetPayloadLength()
00032 {
00033     return receiveLength;
00034 }
00035 
00036 char UDPReceivedIndication::GetPayload(int index)
00037 {
00038     return GetData()[index + PAYLOAD_OFFSET];
00039 }
00040 
00041 const char * UDPReceivedIndication::GetPayload()
00042 {
00043     return GetData() + PAYLOAD_OFFSET;
00044 }
00045 
00046 int UDPReceivedIndication::GetPayloadOffset()
00047 {
00048     return PAYLOAD_OFFSET;
00049 }