usrp2::eth_buffer Class Reference
high-performance interface to send and receive raw ethernet frames with out-of-order retirement of received frames.
More...
#include <eth_buffer.h>
List of all members.
Detailed Description
high-performance interface to send and receive raw ethernet frames with out-of-order retirement of received frames.
On many systems it should be possible to implement this on top of libpcap
Member Enumeration Documentation
- Enumerator:
EB_OK |
|
EB_ERROR |
|
EB_WOULD_BLOCK |
|
EB_TIMED_OUT |
|
Constructor & Destructor Documentation
usrp2::eth_buffer::eth_buffer |
( |
size_t |
rx_bufsize = 0 |
) |
|
- Parameters:
-
| rx_bufsize | is a hint as to the number of bytes of memory to allocate for received ethernet frames (0 -> reasonable default) |
usrp2::eth_buffer::~eth_buffer |
( |
|
) |
|
Member Function Documentation
attach packet filter to socket to restrict which packets read sees.
- Parameters:
-
bool usrp2::eth_buffer::close |
( |
|
) |
|
const uint8_t* usrp2::eth_buffer::mac |
( |
|
) |
const [inline] |
return 6 byte string containing our MAC address
unsigned int usrp2::eth_buffer::max_frames |
( |
|
) |
const [inline] |
bool usrp2::eth_buffer::open |
( |
const std::string & |
ifname, |
|
|
int |
protocol | |
|
) |
| | |
open the specified interface
- Parameters:
-
| ifname | ethernet interface name, e.g., "eth0" |
| protocol | is the ethertype protocol number in network order. Use 0 to receive all protocols. |
void usrp2::eth_buffer::release_frame |
( |
void * |
p |
) |
|
Call f
for each frame in the receive buffer.
- Parameters:
-
| f | is the frame data handler |
| timeout | (in ms) controls behavior when there are no frames to read |
If timeout
is 0, rx_frames will not wait for frames if none are available, and f will not be invoked. If timeout
is -1 (the default), rx_frames will block indefinitely until frames are available. If timeout
is positive, it indicates the number of milliseconds to wait for a frame to become available. Once the timeout has expired, rx_frames will return, f never having been invoked.
f
will be called on each ethernet frame that is available. f
returns a bit mask with one of the following set or cleared:
data_handler::KEEP - hold onto the frame and present it again during the next call to rx_frames, otherwise discard it
data_handler::DONE - return from rx_frames now even though more frames might be available; otherwise continue if more frames are ready.
The idea of holding onto a frame for the next iteration allows the caller to scan the received packet stream for particular classes of frames (such as command replies) leaving the rest intact. On the next call all kept frames, followed by any new frames received, will be presented in order to f
. See usrp2.cc for an example of the pattern.
- Returns:
- EB_OK if at least one frame was received
-
EB_WOULD_BLOCK if
timeout
is 0 and the call would have blocked
-
EB_TIMED_OUT if timeout occurred
-
EB_ERROR if there was an unrecoverable error.
result usrp2::eth_buffer::tx_frame |
( |
const void * |
base, |
|
|
size_t |
len, |
|
|
int |
flags = 0 | |
|
) |
| | |
result usrp2::eth_buffer::tx_framev |
( |
const eth_iovec * |
iov, |
|
|
int |
iovcnt, |
|
|
int |
flags = 0 | |
|
) |
| | |
Member Data Documentation
The documentation for this class was generated from the following file: