MCPcopy Create free account
hub / github.com/DanielOgorchock/ST_Anything / parsePacket

Method parsePacket

Arduino/libraries/Ethernet2/src/EthernetUdp2.cpp:122–149  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

120}
121
122int EthernetUDP::parsePacket()
123{
124 // discard any remaining bytes in the last packet
125 flush();
126
127 if (w5500.getRXReceivedSize(_sock) > 0)
128 {
129 //HACK - hand-parse the UDP packet using TCP recv method
130 uint8_t tmpBuf[8];
131 int ret =0;
132 //read 8 header bytes and get IP and port from it
133 ret = recv(_sock,tmpBuf,8);
134 if (ret > 0)
135 {
136 _remoteIP = tmpBuf;
137 _remotePort = tmpBuf[4];
138 _remotePort = (_remotePort << 8) + tmpBuf[5];
139 _remaining = tmpBuf[6];
140 _remaining = (_remaining << 8) + tmpBuf[7];
141
142 // When we get here, any remaining bytes are the data
143 ret = _remaining;
144 }
145 return ret;
146 }
147 // There aren't any packets available
148 return 0;
149}
150
151int EthernetUDP::read()
152{

Callers 2

ProcessResponseMethod · 0.45
parseDHCPResponseMethod · 0.45

Calls 3

flushFunction · 0.85
getRXReceivedSizeMethod · 0.80
recvFunction · 0.50

Tested by

no test coverage detected