[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r10986 - in gnuradio/branches/developers/eb/vrt/vrt: i
From: |
eb |
Subject: |
[Commit-gnuradio] r10986 - in gnuradio/branches/developers/eb/vrt/vrt: include/vrt lib |
Date: |
Thu, 7 May 2009 03:01:08 -0600 (MDT) |
Author: eb
Date: 2009-05-07 03:01:07 -0600 (Thu, 07 May 2009)
New Revision: 10986
Modified:
gnuradio/branches/developers/eb/vrt/vrt/include/vrt/rx_udp.h
gnuradio/branches/developers/eb/vrt/vrt/lib/rx_udp.cc
gnuradio/branches/developers/eb/vrt/vrt/lib/socket_rx_buffer.h
Log:
work-in-progress
Modified: gnuradio/branches/developers/eb/vrt/vrt/include/vrt/rx_udp.h
===================================================================
--- gnuradio/branches/developers/eb/vrt/vrt/include/vrt/rx_udp.h
2009-05-07 08:29:15 UTC (rev 10985)
+++ gnuradio/branches/developers/eb/vrt/vrt/include/vrt/rx_udp.h
2009-05-07 09:01:07 UTC (rev 10986)
@@ -27,6 +27,8 @@
namespace vrt {
+ class socket_rx_buffer;
+
/*!
* Relatively low-level interface to receive VRT packets over UDP.
*
@@ -35,7 +37,8 @@
*/
class rx_udp : boost::noncopyable
{
- int d_socket_fd;
+ int d_socket_fd;
+ socket_rx_buffer *d_srb;
public:
/*!
@@ -51,8 +54,11 @@
* opened the appropriate UDP socket for us. This object
* assumes management of the socket's lifetime. The
* socket will be closed when our destructor fires.
+ *
+ * \param rx_bufsize is a hint as to the number of bytes of memory
+ * to allocate for received ethernet frames (0 ->
reasonable default)
*/
- static sptr make(int socket_fd);
+ static sptr make(int socket_fd, size_t rx_bufsize = 0);
/*!
* \param socket_fd file descriptor that data grams will be received from.
@@ -60,8 +66,11 @@
* opened the appropriate UDP socket for us. This object
* assumes management of the socket's lifetime. The
* socket will be closed when our destructor fires.
+ *
+ * \param rx_bufsize is a hint as to the number of bytes of memory
+ * to allocate for received ethernet frames (0 ->
reasonable default)
*/
- rx_udp(int socket_fd);
+ rx_udp(int socket_fd, size_t rx_bufsize = 0);
~rx_udp();
/*!
Modified: gnuradio/branches/developers/eb/vrt/vrt/lib/rx_udp.cc
===================================================================
--- gnuradio/branches/developers/eb/vrt/vrt/lib/rx_udp.cc 2009-05-07
08:29:15 UTC (rev 10985)
+++ gnuradio/branches/developers/eb/vrt/vrt/lib/rx_udp.cc 2009-05-07
09:01:07 UTC (rev 10986)
@@ -23,32 +23,62 @@
#endif
#include <vrt/rx_udp.h>
#include <unistd.h>
+#include "socket_rx_buffer.h"
+#include "data_handler.h"
namespace vrt {
rx_udp::sptr
- rx_udp::make(int socket_fd)
+ rx_udp::make(int socket_fd, size_t rx_bufsize)
{
- return sptr(new rx_udp(socket_fd));
+ return sptr(new rx_udp(socket_fd, rx_bufsize));
}
- rx_udp::rx_udp(int socket_fd)
- : d_socket_fd(socket_fd)
+ rx_udp::rx_udp(int socket_fd, size_t rx_bufsize)
+ : d_socket_fd(socket_fd),
+ d_srb(new socket_rx_buffer(socket_fd, rx_bufsize))
{
}
rx_udp::~rx_udp()
{
+ delete d_srb;
::close(d_socket_fd);
}
+ class vrt_data_handler : public data_handler
+ {
+ rx_packet_handler *d_handler;
+
+ public:
+ vrt_data_handler(rx_packet_handler *handler)
+ : d_handler(handler){}
+
+ ~vrt_data_handler();
+
+ result operator()(const void *base, size_t len);
+ };
+
+ vrt_data_handler::~vrt_data_handler(){}
+
+ data_handler::result
+ vrt_data_handler::operator()(const void *base, size_t len)
+ {
+ const uint32_t *payload = 0; // FIXME
+ size_t n32_bit_words = 0; // FIXME
+ expanded_headers hdrs; // FIXME
+ bool want_more = (*d_handler)(payload, n32_bit_words, &hdrs);
+ return !want_more ? data_handler::DONE : 0;
+ }
+
+
bool
rx_udp::rx_packets(rx_packet_handler *handler)
{
- // FIXME do something ;-)
-
- return true;
+ vrt_data_handler h(handler);
+ socket_rx_buffer::result r = d_srb->rx_frames(&h, -1);
+ return r == socket_rx_buffer::EB_OK;
}
}; // vrt
Modified: gnuradio/branches/developers/eb/vrt/vrt/lib/socket_rx_buffer.h
===================================================================
--- gnuradio/branches/developers/eb/vrt/vrt/lib/socket_rx_buffer.h
2009-05-07 08:29:15 UTC (rev 10985)
+++ gnuradio/branches/developers/eb/vrt/vrt/lib/socket_rx_buffer.h
2009-05-07 09:01:07 UTC (rev 10986)
@@ -97,7 +97,7 @@
* timeout has expired, rx_frames will return, f never having been
* invoked.
*
- * \p f will be called on each ethernet frame that is available.
+ * \p f will be called on each frame that is available.
* \p f returns a bit mask with one of the following set or cleared:
*
* data_handler::DONE - return from rx_frames now even though more frames
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r10986 - in gnuradio/branches/developers/eb/vrt/vrt: include/vrt lib,
eb <=