[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r8553 - usrp2/trunk/host-ng/lib
From: |
eb |
Subject: |
[Commit-gnuradio] r8553 - usrp2/trunk/host-ng/lib |
Date: |
Thu, 5 Jun 2008 07:40:28 -0600 (MDT) |
Author: eb
Date: 2008-06-05 07:40:26 -0600 (Thu, 05 Jun 2008)
New Revision: 8553
Added:
usrp2/trunk/host-ng/lib/eth_common.h
Modified:
usrp2/trunk/host-ng/lib/eth_buffer.h
Log:
work-in-progress on interface definition
Modified: usrp2/trunk/host-ng/lib/eth_buffer.h
===================================================================
--- usrp2/trunk/host-ng/lib/eth_buffer.h 2008-06-05 00:51:14 UTC (rev
8552)
+++ usrp2/trunk/host-ng/lib/eth_buffer.h 2008-06-05 13:40:26 UTC (rev
8553)
@@ -23,7 +23,9 @@
#include <boost/utility.hpp>
#include <stdint.h>
+#include <sys/uio.h>
#include "pktfilter.h"
+#include "eth_common.h"
namespace usrp2 {
@@ -59,7 +61,7 @@
* \param base points to the beginning of the frame (the 14-byte
ethernet header).
* \param len is the length in bytes of the frame.
*/
- virtual result operator()(void *base, size_t len) = 0;
+ virtual result operator()(const void *base, size_t len) = 0;
virtual ~handler();
};
@@ -97,28 +99,62 @@
*/
const uint8_t *mac() const { return d_mac; }
+
/*!
- * \brief Return the read file descriptor associated with socket
- * (for use with select/poll only)
+ * \brief Call \p f for each frame in the receive buffer.
+ * \param f is the frame handler
+ * \param flags is 0 or the bitwise-or of values from eth_flags
+ *
+ * \p f will be called on each ethernet frame that is available.
+ * \p f returns one of two values, FREE_FRAME, meaning I'm done
+ * with the frame, or KEEP_FRAME, meaning hold onto the frame and
+ * present it again on the next call to rx_frames.
+ *
+ * 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 \p f.
+ * See usrp2.cc for an example of the pattern.
+ *
+ * if \p flags contains EF_DONT_WAIT rx_frames will not wait for
+ * frames if none are available, and f will not be invoked.
+ *
+ * \returns 0 if flags contains EF_DONT_WAIT and the call would have
blocked
+ * \returns 1 if at least one frame was available
+ * \returns -1 if there was an unrecoverable error.
*/
- int read_fd() const { return d_fd; }
+ int rx_frames(handler *f, int flags=0);
- /*!
- * \brief Return the write file descriptor associated with socket
- * (for use with select/poll only)
+ /*
+ * \brief Write an ethernet frame to the interface.
+ *
+ * \param base points to the beginning of the frame (the 14-byte ethernet
header).
+ * \param len is the length of the frame in bytes.
+ * \param flags is 0 or the bitwise-or of values from eth_flags
+ *
+ * The frame must begin with a 14-byte ethernet header.
+ *
+ * \returns 0 if flags contains EF_DONT_WAIT and the call would have
blocked
+ * \returns 1 if the frame was successfully enqueued.
+ * \returns -1 if there was an unrecoverable error.
*/
- int write_fd() const { return d_fd; }
+ int tx_frame(const void *base, size_t len, int flags=0);
-
- //! Are there received frames available?
- bool rx_frames_available_p();
-
- /*!
- * \brief Call \p f for each frame in the receive buffer.
- * \param f is the frame handler
- * \param ok_to_block indicates whether it is OK to block until at least
one frame is received.
+ /*
+ * \brief Write an ethernet frame to the interface using scatter/gather.
+ *
+ * \param iov points to an array of iovec structs
+ * \param iovcnt is the number of entries
+ * \param flags is 0 or the bitwise-or of values from eth_flags
+ *
+ * The frame must begin with a 14-byte ethernet header.
+ *
+ * \returns 0 if flags contains EF_DONT_WAIT and the call would have
blocked
+ * \returns 1 if the frame was successfully enqueued.
+ * \returns -1 if there was an unrecoverable error.
*/
- void rx_frames(handler *f, bool ok_to_block=true);
+ int tx_framev(const eth_iovec *iov, int iovcnt, int flags=0);
};
}; // namespace usrp2
Added: usrp2/trunk/host-ng/lib/eth_common.h
===================================================================
--- usrp2/trunk/host-ng/lib/eth_common.h (rev 0)
+++ usrp2/trunk/host-ng/lib/eth_common.h 2008-06-05 13:40:26 UTC (rev
8553)
@@ -0,0 +1,38 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2008 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef INCLUDED_USRP2_ETH_COMMON_H
+#define INCLUDED_USRP2_ETH_COMMON_H
+
+#include <sys/uio.h> // FIXME autoconf this
+
+namespace usrp2 {
+
+ enum eth_flags {
+ EF_DONTWAIT = 0x0001,
+ };
+
+ typedef struct iovec eth_iovec; // FIXME autoconf this
+
+} // namespace usrp2
+
+
+#endif /* INCLUDED_USRP2_ETH_COMMON_H */
Property changes on: usrp2/trunk/host-ng/lib/eth_common.h
___________________________________________________________________
Name: svn:eol-style
+ native
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r8553 - usrp2/trunk/host-ng/lib,
eb <=