summaryrefslogtreecommitdiff
path: root/src/multicast.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2014-05-28 15:05:57 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2014-05-28 15:05:57 +0200
commit0332e496347f6b563abb86d4ef9650bbd6ebc3e1 (patch)
tree74dadbe6e4f3216c8a3c8570e203aad0187febf3 /src/multicast.cc
parent8eb0759e2e8a5405b2dd9e6d72d3bd620b51bee4 (diff)
Port server to hugin.
Diffstat (limited to 'src/multicast.cc')
-rw-r--r--src/multicast.cc44
1 files changed, 18 insertions, 26 deletions
diff --git a/src/multicast.cc b/src/multicast.cc
index 2f3e7a8..35b0212 100644
--- a/src/multicast.cc
+++ b/src/multicast.cc
@@ -24,42 +24,34 @@
* along with MIaV; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
-#include "config.h"
#include "multicast.h"
-#include "multicast_configuration.h"
-
-#include "miav_config.h"
-
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <sys/param.h>
#include <arpa/inet.h>
#include <sys/types.h>
-
#include <string.h>
+#include <errno.h>
+#include <unistd.h>
-// For IP_MTU
-//#include <linux/in.h>
-//#ifndef IP_MTU
-//#define IP_MTU 14
-//#endif
+#include <hugin.hpp>
-#include <errno.h>
+#include "multicast_configuration.h"
+#include "miav_config.h"
-Multicast::Multicast(Info *i, mcastconf_t &mcclientconf)
+Multicast::Multicast(mcastconf_t &mcclientconf)
{
- info = i;
udp_buffer = NULL;
multicast_audio = mcclientconf.with_audio;
// Open connection socket
if(!UDPOpen(mcclientconf.addr.c_str(), mcclientconf.port))
- info->error("Error creating socket %s:%d",
- mcclientconf.addr.c_str(),
- mcclientconf.port);
+ ERR(multicast, "Error creating socket %s:%d",
+ mcclientconf.addr.c_str(),
+ mcclientconf.port);
int mtu = config->readInt("udp_packet_size");
@@ -71,11 +63,11 @@ Multicast::Multicast(Info *i, mcastconf_t &mcclientconf)
if(udp_buffer_size < 1) udp_buffer_size = 1;
udp_buffer = new char[udp_buffer_size];
udp_buffer_pointer = udp_buffer;
- info->info("UDP packet buffer size %db", udp_buffer_size);
+ DEBUG(multicast, "UDP packet buffer size %db", udp_buffer_size);
//} else {
- // info->error("Error getting MTU size from socket: %s", strerror(errno));
- // return;
+ // ERR(multicast, "Error getting MTU size from socket: %s", strerror(errno));
+ // return;
//}
}
@@ -88,7 +80,7 @@ int Multicast::Write(void* buf, int size)
{
if(!udp_buffer) return 0; // no buffer to write in... better break out!
- // info->info("To send: %d", size);
+ // DEBUG(multicast, "To send: %d", size);
char *p = (char*)buf;
int left = udp_buffer_size - (udp_buffer_pointer - udp_buffer);
@@ -104,12 +96,12 @@ int Multicast::Write(void* buf, int size)
p+=to_copy;
size-=to_copy;
- // info->info("Copied %d - %d to go", to_copy, size);
+ // DEBUG(multicast, "Copied %d - %d to go", to_copy, size);
if(left == 0) {
- // info->info("Sending full packet");
+ // DEBUG(multicast, "Sending full packet");
if(write(sock, udp_buffer, udp_buffer_size) != udp_buffer_size) {
- info->error("Could not write entire buffer to socket.");
+ ERR(multicast, "Could not write entire buffer to socket.");
}
left = udp_buffer_size;
udp_buffer_pointer = udp_buffer;
@@ -121,10 +113,10 @@ int Multicast::Write(void* buf, int size)
bool Multicast::is_address_multicast(unsigned long address)
{
if((address & 255) >= 224 && (address & 255) <= 239) {
- info->info("Address is multicast.");
+ INFO(multicast, "Address is multicast.");
return true;
}
- info->info("Address is NOT multicast.");
+ INFO(multicast, "Address is NOT multicast.");
return false;
}