3 * Copyright 2009 Free Software Foundation, Inc.
5 * This file is part of GNU Radio
7 * GNU Radio is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3, or (at your option)
12 * GNU Radio is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 #ifndef INCLUDED_VRT_RX_H
22 #define INCLUDED_VRT_RX_H
24 #include <boost/shared_ptr.hpp>
25 #include <boost/utility.hpp>
26 #include <vrt/rx_packet_handler.h>
30 class socket_rx_buffer;
33 * Relatively low-level interface to receive VRT packets over a datagram socket.
35 * (We'll refactor this if/when we use a non-UDP transport.)
36 * No VRT control issues are addressed here.
38 class rx : boost::noncopyable
41 socket_rx_buffer *d_srb;
45 * Shared pointer to this class
47 typedef boost::shared_ptr<rx> sptr;
50 * \brief Static function to return an instance of rx as a shared pointer.
52 * \param socket_fd file descriptor that data grams will be received from.
53 * It is assumed that some higher-level control software
54 * opened the appropriate UDP socket for us. This object
55 * assumes management of the socket's lifetime. The
56 * socket will be closed when our destructor fires.
58 * \param rx_bufsize is a hint as to the number of bytes of memory
59 * to allocate for received ethernet frames (0 -> reasonable default)
61 static sptr make(int socket_fd, size_t rx_bufsize = 0);
64 * \param socket_fd file descriptor that data grams will be received from.
65 * It is assumed that some higher-level control software
66 * opened the appropriate UDP socket for us. This object
67 * assumes management of the socket's lifetime. The
68 * socket will be closed when our destructor fires.
70 * \param rx_bufsize is a hint as to the number of bytes of memory
71 * to allocate for received ethernet frames (0 -> reasonable default)
73 rx(int socket_fd, size_t rx_bufsize = 0);
77 * \brief Receive packets from the given socket file descriptor.
79 * \p handler will be invoked for all available packets.
80 * Unless \p dont_wait is true, this function blocks until at
81 * least one packet has been processed.
83 bool rx_packets(rx_packet_handler *handler, bool dont_wait = false);
86 * \returns the socket_fd. Useful for select or poll.
88 int socket_fd() const { return d_socket_fd; }
93 #endif /* INCLUDED_VRT_RX_H */