30 #ifndef PTLIB_ETHSOCKET_H
31 #define PTLIB_ETHSOCKET_H
52 bool promiscuous =
true,
54 unsigned snapLength = 65536
172 unsigned queueSize = 5,
235 PINDEX maxSize = 65536
305 const void * data = NULL
325 const void * data = NULL
361 ) {
return frame.
Read(*
this); }
384 #define PDECLARE_EthFrameNotifier(cls, fn) PDECLARE_NOTIFIER2(PEthSocket, cls, fn, PEthSocket::Frame &)
393 PThread::Priority priority = PThread::NormalPriority
419 #endif // PTLIB_ETHSOCKET_H
BYTE b[6]
Definition: ethsock.h:76
FrameNotifier m_notifier
Definition: ethsock.h:411
~PEthSocketThread()
Definition: ethsock.h:388
unsigned m_dataLinkType
Definition: ethsock.h:339
void SetDataLinkType(unsigned dataLinkType)
Definition: ethsock.h:333
bool GetTCP(PBYTEArray &payload, WORD &srcPort, WORD &dstPort)
Extract the TCP payload.
PINDEX m_rawSize
Definition: ethsock.h:338
WORD s
Definition: ethsock.h:80
~PEthSocket()
Close the socket.
Definition: ethsock.h:380
BYTE * CreateIP(const PIPSocket::Address &src, const PIPSocket::Address &dst, unsigned proto, PINDEX length)
bool IsFragmentated() const
Definition: ethsock.h:329
virtual PBoolean OpenSocket()
This class defines an absolute time and date.
Definition: ptime.h:49
MediumType GetMedium()
Return the data link of the interface.
BYTE * CreateDataLink(const Address &src, const Address &dst, unsigned proto, PINDEX length)
WORD w[3]
Definition: ethsock.h:77
PEthSocket(bool promiscuous=true, unsigned snapLength=65536)
Create a new ethernet packet socket.
friend ostream & operator<<(ostream &s, const Address &a)
Definition: ethsock.h:97
PIPSocket::Address m_fragmentDstIP
Definition: ethsock.h:348
An ethernet MAC Address specification.
Definition: ethsock.h:75
static PStringArray EnumInterfaces(bool detailed=true)
Enumerate all the interfaces that are capable of being accessed at the ethernet level.
virtual PBoolean Close()
Close the channel, shutting down the link to the data source.
PINDEX GetSize() const
Definition: ethsock.h:331
This is an array collection class of PString objects.
Definition: pstring.h:2365
void SetNotifier(const FrameNotifier ¬ifier)
Definition: ethsock.h:402
A class describing an IP address and port number combination.
Definition: ipsock.h:278
BYTE * CreateUDP(const PIPSocketAddressAndPort &src, const PIPSocketAddressAndPort &dst, PINDEX length, const void *data=NULL)
PBYTEArray m_fragments
Definition: ethsock.h:341
bool operator==(const BYTE *eth) const
virtual const char * GetProtocolName() const
This function returns the protocol name for the socket type.
Array of unsigned characters.
Definition: array.h:605
virtual bool Start(const PString &device, const PString &filter=PString::Empty(), PThread::Priority priority=PThread::NormalPriority)
Abstract class defining I/O channel semantics.
Definition: channel.h:103
unsigned m_fragmentProto
Definition: ethsock.h:343
PTime m_lastPacketTime
Definition: ethsock.h:376
PEthSocketThread(const FrameNotifier ¬ifier=NULL)
bool m_fragmentated
Definition: ethsock.h:342
bool PBoolean
Definition: object.h:174
const PTime & GetTimestamp() const
Definition: ethsock.h:328
PThread * m_thread
Definition: ethsock.h:412
bool operator!=(const Address ð) const
Definition: ethsock.h:93
PString m_filter
Definition: ethsock.h:371
PEthSocket * GetSocket() const
Definition: ethsock.h:406
bool m_promiscuous
Definition: ethsock.h:369
const PTime & GetLastPacketTime() const
Return the capture time of the last read packet.
Definition: ethsock.h:204
#define P_MAX_INDEX
Definition: object.h:80
The character string class.
Definition: pstring.h:108
bool operator!=(const BYTE *eth) const
PEthSocket::Frame m_frame
Definition: ethsock.h:414
int GetDataLink(PBYTEArray &payload)
Extract the data link payload.
bool IsRunning() const
Definition: ethsock.h:398
P_DECLARE_STREAMABLE_ENUM(MediumType, MediumLoop, Medium802_3, MediumWan, MediumLinuxSLL, MediumUnknown)
Medium types for the open interface.
const PString & GetFilter() const
Get the current filtering criteria for receiving packets.
Definition: ethsock.h:212
PIPSocket::Address m_fragmentSrcIP
Definition: ethsock.h:347
BYTE * CreateTCP(const PIPSocketAddressAndPort &src, const PIPSocketAddressAndPort &dst, PINDEX length, const void *data=NULL)
This class defines a thread of execution in the system.
Definition: thread.h:66
virtual PBoolean Connect(const PString &address)
Connect a socket to an interface.
virtual PBoolean Write(const void *buf, PINDEX len)
Low level write to the channel.
bool GetUDP(PBYTEArray &payload, WORD &srcPort, WORD &dstPort)
Extract the UDP payload.
static const PString & Empty()
Return an empty string.
A class describing an IP address.
Definition: ipsock.h:59
InternalData * m_internal
Definition: ethsock.h:373
DWORD l
Definition: ethsock.h:79
bool m_running
Definition: ethsock.h:415
virtual PEthSocket * CreateEthSocket() const
PTime m_timestamp
Definition: ethsock.h:346
PBYTEArray m_rawData
Definition: ethsock.h:337
unsigned GetDataLinkType() const
Definition: ethsock.h:334
PString m_channelName
Definition: ethsock.h:368
virtual bool Read(PChannel &channel, PINDEX packetSize=P_MAX_INDEX)
An ethernet MAC frame.
Definition: ethsock.h:230
virtual PString GetName() const
Get the platform and I/O channel type name of the channel.
Definition: ethsock.h:109
bool operator==(const Address ð) const
Definition: ethsock.h:92
A network communications channel.
Definition: socket.h:59
PNotifierTemplate< PEthSocket::Frame & > FrameNotifier
Definition: ethsock.h:385
virtual PBoolean Read(void *buf, PINDEX len)
Low level read from the channel.
virtual PBoolean Listen(unsigned queueSize=5, WORD port=0, Reusability reuse=AddressIsExclusive)
This function is illegal and will assert if attempted.
int GetIP(PBYTEArray &payload)
Extract the Internet Protocol payload.
Reusability
Flags to reuse of port numbers in Listen() function.
Definition: socket.h:85
Ultimate parent class for all objects in the class library.
Definition: object.h:2204
This class describes a type of socket that will communicate using raw ethernet packets.
Definition: ethsock.h:43
unsigned m_snapLength
Definition: ethsock.h:370
struct PEthSocket::Address::@1 ls
Frame(PINDEX maxSize=65536)
bool SetFilter(const PString &filter)
Set the current filtering criteria for receiving packets.
virtual bool Write(PChannel &channel) const
Address & operator=(const Address &addr)
bool ReadFrame(Frame &frame)
Read a frame from the interface.
Definition: ethsock.h:359
PEthSocket * m_socket
Definition: ethsock.h:413
bool m_fragmentProcessed
Definition: ethsock.h:344