GNU Radio 3.4.2 C++ API
usrp2::ethernet Class Reference

Read and write ethernet frames. More...

#include <ethernet.h>

List of all members.

Public Member Functions

 ethernet ()
 ~ethernet ()
bool open (std::string ifname, int protocol)
bool close ()
bool attach_pktfilter (pktfilter *pf)
 attach packet filter to socket to restrict which packets read sees.
const uint8_tmac () const
 return 6 byte string containing our MAC address
int fd () const
 Return file descriptor associated with socket.
int read_packet (void *buf, int buflen)
 Read packet from interface.
int read_packet_dont_block (void *buf, int buflen)
 Read packet from interface, but don't block waiting.
int write_packet (const void *buf, int buflen)
int write_packetv (const eth_iovec *iov, size_t iovlen)

Static Public Attributes

static const int MAX_PKTLEN = 1512
static const int MIN_PKTLEN = 64

Detailed Description

Read and write ethernet frames.

This provides a low level interface to hardware that communicates via raw (non-IP) ethernet frames.


Constructor & Destructor Documentation

usrp2::ethernet::ethernet ( )
usrp2::ethernet::~ethernet ( )

Member Function Documentation

bool usrp2::ethernet::attach_pktfilter ( pktfilter pf)

attach packet filter to socket to restrict which packets read sees.

Parameters:
pfthe packet filter
bool usrp2::ethernet::close ( )
int usrp2::ethernet::fd ( ) const [inline]

Return file descriptor associated with socket.

const uint8_t* usrp2::ethernet::mac ( ) const [inline]

return 6 byte string containing our MAC address

bool usrp2::ethernet::open ( std::string  ifname,
int  protocol 
)
Parameters:
ifnameethernet interface name, e.g., "eth0"
protocolis the ethertype protocol number in network order. Use 0 to receive all protocols.
int usrp2::ethernet::read_packet ( void *  buf,
int  buflen 
)

Read packet from interface.

Parameters:
bufwhere to put the packet
buflenmaximum length of packet in bytes (should be >= 1528)
Returns:
number of bytes read or -1 if trouble.

Returned packet includes 14-byte ethhdr

int usrp2::ethernet::read_packet_dont_block ( void *  buf,
int  buflen 
)

Read packet from interface, but don't block waiting.

Parameters:
bufwhere to put the packet
buflenmaximum length of packet in bytes (should be >= 1528)
Returns:
number of bytes read, -1 if trouble or 0 if nothing available.

Returned packet includes 14-byte ethhdr

int usrp2::ethernet::write_packet ( const void *  buf,
int  buflen 
)
int usrp2::ethernet::write_packetv ( const eth_iovec *  iov,
size_t  iovlen 
)

Member Data Documentation

const int usrp2::ethernet::MAX_PKTLEN = 1512 [static]
const int usrp2::ethernet::MIN_PKTLEN = 64 [static]

The documentation for this class was generated from the following file: