Logo Search packages:      
Sourcecode: pwlib version File versions  Download package

BOOL PEthSocket::ReadPacket ( PBYTEArray &  buffer,
Address dest,
Address src,
WORD &  type,
PINDEX &  len,
BYTE *&  payload 

Read a packet from the interface and parse out the information specified by the parameters. This will automatically adjust for 802.2 and 802.3 ethernet frames.

TRUE if the packet read, FALSE on error.
buffer  Buffer to receive the raw packet
dest  Destination address of packet
src  Source address of packet
type  Packet frame type ID
len  Length of payload
payload  Pointer into buffer# of payload.

Definition at line 208 of file pethsock.cxx.

References PEthSocket::Frame::dst_addr, PChannel::lastReadCount, PEthSocket::Frame::Parse(), Read(), PEthSocket::Frame::snap, and PEthSocket::Frame::src_addr.

  Frame * frame = (Frame *)buffer.GetPointer(sizeof(Frame));
  const PINDEX MinFrameSize = sizeof(frame->dst_addr)+sizeof(frame->src_addr)+sizeof(frame->snap.length);

  do {
    if (!Read(frame, sizeof(*frame)))
      return FALSE;
  } while (lastReadCount < MinFrameSize);

  dest = frame->dst_addr;
  src = frame->src_addr;
  length = lastReadCount;
  frame->Parse(type, payload, length);

  return TRUE;

Generated by  Doxygen 1.6.0   Back to index