summaryrefslogtreecommitdiff
path: root/src/multicast.cc
diff options
context:
space:
mode:
authordeva <deva>2005-10-13 09:08:32 +0000
committerdeva <deva>2005-10-13 09:08:32 +0000
commit56632c4b32abc705f613475c3b78ae7a5dd4a3d2 (patch)
tree1e64789daa4111a30b20b99405c9cc15c0da98c7 /src/multicast.cc
parent1d30dc5da0c148982032a2b5a5bdece10b3e80ae (diff)
*** empty log message ***
Diffstat (limited to 'src/multicast.cc')
-rw-r--r--src/multicast.cc37
1 files changed, 4 insertions, 33 deletions
diff --git a/src/multicast.cc b/src/multicast.cc
index 80be2ce..34c7241 100644
--- a/src/multicast.cc
+++ b/src/multicast.cc
@@ -35,22 +35,6 @@
Multicast::Multicast(Info *i, char *addr, int port)
{
- /*
- Multicast adresses:
- 224.0.0.1 All systems on this subnet
- 224.0.0.2 All routers on this subnet
- 224.0.0.5 OSPF routers
- 224.0.0.6 OSPF designated routers
- 224.0.0.12 DHCP server/relay agent
-server_multicast = true
-server_multicast_addr = "224.0.0.1"
-server_multicast_port = 1234
- */
-
- // Multicast to all systems on this subnet
- // char addr[] = "224.0.0.1";
- // int port = 1234;
-
info = i;
if(!UDPOpen(addr, port)) info->error("Error creating socket %s:%d", addr, port);
}
@@ -61,17 +45,9 @@ Multicast::~Multicast()
void Multicast::Write(void* buf, int size)
{
- // char addr[] = "192.168.0.10";
- // int port = 1234;
-
- if(write(sock, buf, size) != size) {
- info->error("Error Writing to socket.");
- // if(!UDPOpen(addr, port)) info->error("Error creating socket %s:%d", addr, port);
- }
+ if(write(sock, buf, size) != size) info->error("Error Writing to socket.");
}
-#define USE_MULTICAST
-
bool Multicast::is_address_multicast(unsigned long address)
{
if((address & 255) >= 224 && (address & 255) <= 239) {
@@ -106,12 +82,10 @@ bool Multicast::UDPOpen(char *address, int port)
if(setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char *) &enable, sizeof(unsigned long int)) < 0)
return false;
-#ifdef USE_MULTICAST
// If the address is multicast, register to the multicast group
- if(is_address_multicast(stAddr.sin_addr.s_addr))
- {
+ if(is_address_multicast(stAddr.sin_addr.s_addr)) {
struct ip_mreq stMreq;
-
+
// Bind the socket to port
stLclAddr.sin_family = AF_INET;
stLclAddr.sin_addr.s_addr = htonl(INADDR_ANY);
@@ -123,10 +97,7 @@ bool Multicast::UDPOpen(char *address, int port)
stMreq.imr_interface.s_addr = INADDR_ANY;
if(setsockopt(sock, IPPROTO_IP, IP_ADD_MEMBERSHIP, (char *) & stMreq, sizeof(stMreq)) < 0)
return false;
- }
- else
-#endif
- {
+ } else {
// Bind the socket to port
stLclAddr.sin_family = AF_INET;
stLclAddr.sin_addr.s_addr = htonl(INADDR_ANY);