Permalink
Browse files

*** empty log message ***

  • Loading branch information...
1 parent 6fe30d6 commit 106ae59e065b41532d61ebcd7060a0c39fdb4c48 massie committed Dec 14, 2004
Showing with 152 additions and 183 deletions.
  1. +0 −3 monitor-core/gmond/conf.c
  2. +14 −32 monitor-core/gmond/gmond.c
  3. +0 −1 monitor-core/lib/Makefile.am
  4. +28 −86 monitor-core/lib/apr_net.c
  5. +110 −61 monitor-core/lib/protocol.x
@@ -1,9 +1,6 @@
#include <stdio.h>
#include "conf.h"
-#include "protocol.h"
-
-
extern cfg_t *config_file;
/* This function is necessary only because I need
View
@@ -375,12 +375,11 @@ poll_udp_recv_channels(apr_interval_time_t timeout)
for(i=0; i< num; i++)
{
apr_socket_t *socket;
- char buf[max_udp_message_len];
- apr_size_t len = max_udp_message_len;
apr_sockaddr_t *remotesa = NULL;
char *protocol, remoteip[256];
apr_ipsubnet_t *ipsub;
- hostdata_t *hostdata = NULL;
+ char buf[max_udp_message_len];
+ apr_size_t len = max_udp_message_len;
socket = descs[i].desc.s;
/* We could also use the apr_socket_data_get/set() functions
@@ -389,7 +388,6 @@ poll_udp_recv_channels(apr_interval_time_t timeout)
apr_socket_addr_get(&remotesa, APR_REMOTE, socket);
-
/* Grab the data */
status = apr_socket_recvfrom(remotesa, socket, 0, buf, &len);
if(status != APR_SUCCESS)
@@ -413,52 +411,36 @@ poll_udp_recv_channels(apr_interval_time_t timeout)
}
}
- /* Grab this host's data */
- hostdata = find_host_data( remoteip, remotesa );
- if(!hostdata)
- {
- continue;
- }
-
- fprintf(stderr,"Got a message from %s that is %d bytes long\n",
- hostdata->hostname, len);
-
-#if 0
if(!strcasecmp(protocol, "xdr"))
{
XDR x;
- gangliaMessage *msg = malloc(sizeof(gangliaMessage));
+ gangliaMessage msg;
+ hostdata_t *hostdata = NULL;
+ gangliaOldMetric *old_metric;
/* Create the XDR receive stream */
xdrmem_create(&x, buf, max_udp_message_len, XDR_DECODE);
- /* Flush the data in the (last) received gangliaMessage
- * TODO: Free memory from xdr_string calls XDR_FREE */
- memset( &hdr, 0, sizeof(gangliaMessageHeader));
+ /* Flush the data */
+ memset( &msg, 0, sizeof(gangliaMessage));
/* Read the gangliaMessage from the stream */
- if(!xdr_gangliaMessageHeader(&x, &hdr))
+ if(!xdr_gangliaMessage(&x, &msg))
{
continue;
}
- fprintf(stderr,"hdr.index=%d ", hdr.index);
- if(hdr.index<1024)
- {
- /* This is a 2.5.x data source */
- fprintf(stderr,"2.5.x data source\n");
- }
- else
+ /* Check if this is an old metric format */
+ old_metric = gangliaOldMetric_get( msg.format );
+ if(old_metric)
{
- fprintf(stderr,"new data source\n");
+ /* Move this data into a newer format (later) */
+ fprintf(stderr,"Got a %s message from %s\n", old_metric->name, remoteip);
}
-
-
+
/* If I want to find out how much data I decoded
decoded = xdr_getpos(&x); */
}
-#endif
-
}
}
}
@@ -22,6 +22,5 @@ libganglia_la_LDFLAGS = \
-export-dynamic
noinst_LIBRARIES = libgetopthelper.a
-# libdnet.a
# A little helper for getopt functions
libgetopthelper_a_SOURCES = getopt1.c getopt.c getopt_init.c getopt.h
View
@@ -1,5 +1,6 @@
#include <stdio.h>
#include <stdlib.h>
+#include <apr_strings.h>
#include "apr_network_io.h"
#include "apr_arch_networkio.h"
@@ -12,7 +13,6 @@
#include <sys/sockio.h> /* for SIOCGIFADDR */
#endif
-
/* This function is copied directly from the
* apr_sockaddr_ip_get() function and modified to take a static
* buffer instead of needing to malloc memory from a pool */
@@ -165,86 +165,6 @@ create_tcp_server(apr_pool_t *context, apr_port_t port, char *bind)
return sock;
}
-#if 0
-#include <netinet/in.h>
-static int is_multicast(apr_sockaddr_t *address)
-{
- switch (address->family)
- {
- case AF_INET:
- return IN_MULTICAST(ntohl(*(long *)&addr->sin);
-
-#ifdef AF_INET6
- case AF_INET6:
- return IN6_IS_ADDR_MULTICAST(&addr->sin6);
-#endif
- }
-
- return 0;
-}
-#endif
-
-#if 0
-static int
-mcast_set_if(apr_socket_t *sock, apr_sockaddr_t **sa, const char *ifname)
-{
- switch ( (*sa)->sa.sin.sin_family ) {
- case AF_INET: {
- struct in_addr inaddr;
- struct ifreq ifreq;
-
- if (ifname)
- {
- strncpy(ifreq.ifr_name, ifname, IFNAMSIZ);
- if (ioctl(sock->socketdes, SIOCGIFADDR, &ifreq) < 0)
- return(-1);
- memcpy(&inaddr,
- &((struct sockaddr_in *) &ifreq.ifr_addr)->sin_addr,
- sizeof(struct in_addr));
- }
- else
- {
- inaddr.s_addr = htonl(INADDR_ANY); /* remove prev. set default */
- }
-
- return(setsockopt(sock->socketdes, IPPROTO_IP, IP_MULTICAST_IF,
- &inaddr, sizeof(struct in_addr)));
- }
-
-#ifdef AF_INET6
- case AF_INET6: {
- u_int index;
-
- if ( (index = ifindex) == 0) {
- if (ifname == NULL) {
- errno = EINVAL; /* must supply either index or name */
- return(-1);
- }
- if ( (index = if_nametoindex(ifname)) == 0) {
- errno = ENXIO; /* i/f name not found */
- return(-1);
- }
- }
- return(setsockopt(sock->socketdes, IPPROTO_IPV6, IPV6_MULTICAST_IF,
- &index, sizeof(index)));
- }
-#endif
-
- default:
- errno = EPROTONOSUPPORT;
- return(-1);
- }
-}
-#endif
-
-static int
-set_interface( apr_socket_t *sock, struct ifreq *ifreq, char *ifname )
-{
- memset(ifreq, 0, sizeof(struct ifreq));
- strncpy(ifreq->ifr_name, ifname, IFNAMSIZ);
- return ioctl(sock->socketdes, SIOCGIFADDR, ifreq);
-}
-
static int
mcast_set_ttl(apr_socket_t *socket, int val)
{
@@ -308,13 +228,16 @@ mcast_join( apr_pool_t *context, apr_socket_t *sock, char *mcast_channel, apr_po
memset(&ifreq,0, sizeof(ifreq));
if(ifname)
{
- if(set_interface(sock, ifreq, ifname) == -1)
+ memset(ifreq, 0, sizeof(struct ifreq));
+ strncpy(ifreq->ifr_name, ifname, IFNAMSIZ);
+ if(ioctl(sock->socketdes, SIOCGIFADDR, ifreq) == -1)
{
return APR_EGENERAL;
}
}
else
{
+ /* wildcard address (let the kernel decide) */
mreq->imr_interface.s_addr = htonl(INADDR_ANY);
}
@@ -376,13 +299,32 @@ apr_socket_t *
create_mcast_server(apr_pool_t *context, char *mcast_ip, apr_port_t port, char *bind, char *interface)
{
apr_status_t status;
- /* i think we might want to check that bind and interface are sane later...
- * might request to bind to an address that doesn't match the interface */
+ /* NOTE: If bind is set to mcast_ip in the configuration file, then we will bind the
+ * the multicast address to the socket as well as the port and prevent any
+ * datagrams that might be delivered to this port from being processed. Otherwise,
+ * packets destined to the same port (but a different multicast/unicast channel) will be
+ * processed. */
apr_socket_t *socket = create_udp_server(context, port, bind);
if(!socket)
{
return NULL;
}
- status = mcast_join(context, socket, mcast_ip, port, interface );
- return status == APR_SUCCESS? socket : NULL;
+
+ /* TODO: We can probe for a list of interfaces and perform multiple join calls for the same
+ * socket to have it listen for multicast traffic on all interfaces (important for
+ * multihomed machines). */
+ if(interface && !apr_strnatcasecmp(interface, "ALL"))
+ {
+ /* for(each interface)
+ * {
+ * mcast_join(...);
+ * }
+ */
+ }
+ else
+ {
+ status = mcast_join(context, socket, mcast_ip, port, interface );
+ }
+
+ return status == APR_SUCCESS? socket: NULL;
}
Oops, something went wrong.

0 comments on commit 106ae59

Please sign in to comment.