gr_udp_sink.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef INCLUDED_GR_UDP_SINK_H
00024 #define INCLUDED_GR_UDP_SINK_H
00025
00026 #include <gr_sync_block.h>
00027 #include <omnithread.h>
00028 #if defined(HAVE_SOCKET)
00029 #include <sys/socket.h>
00030 #include <arpa/inet.h>
00031 #elif defined(HAVE_WINDOWS_H)
00032 #include <winsock2.h>
00033 #include <windows.h>
00034 #endif
00035 #if defined(HAVE_NETINET_IN_H)
00036 #include <netinet/in.h>
00037 #endif
00038
00039 class gr_udp_sink;
00040 typedef boost::shared_ptr<gr_udp_sink> gr_udp_sink_sptr;
00041
00042 gr_udp_sink_sptr
00043 gr_make_udp_sink (size_t itemsize,
00044 const char *src, unsigned short port_src,
00045 const char *dst, unsigned short port_dst,
00046 int payload_size=1472);
00047
00063 class gr_udp_sink : public gr_sync_block
00064 {
00065 friend gr_udp_sink_sptr gr_make_udp_sink (size_t itemsize,
00066 const char *src, unsigned short port_src,
00067 const char *dst, unsigned short port_dst,
00068 int payload_size);
00069 private:
00070 size_t d_itemsize;
00071 bool d_updated;
00072 omni_mutex d_mutex;
00073
00074 int d_payload_size;
00075 int d_socket;
00076 int d_socket_rcv;
00077 struct in_addr d_ip_src;
00078 struct in_addr d_ip_dst;
00079 unsigned short d_port_src;
00080 unsigned short d_port_dst;
00081 struct sockaddr_in d_sockaddr_src;
00082 struct sockaddr_in d_sockaddr_dst;
00083
00084 protected:
00098 gr_udp_sink (size_t itemsize,
00099 const char *src, unsigned short port_src,
00100 const char *dst, unsigned short port_dst,
00101 int payload_size);
00102
00103 public:
00104 ~gr_udp_sink ();
00105
00112 bool open();
00113
00119 void close();
00120
00122 int payload_size() { return d_payload_size; }
00123
00124
00125
00126 int work (int noutput_items,
00127 gr_vector_const_void_star &input_items,
00128 gr_vector_void_star &output_items);
00129 };
00130
00131 #endif