1.1 --- a/doc/Makefile.in Mon Mar 24 11:35:35 2014 +0000
1.2 +++ b/doc/Makefile.in Mon Mar 24 15:48:54 2014 +0000
1.3 @@ -155,9 +155,9 @@
1.4 exit 1;; \
1.5 esac; \
1.6 done; \
1.7 - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu doc/Makefile'; \
1.8 + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign doc/Makefile'; \
1.9 $(am__cd) $(top_srcdir) && \
1.10 - $(AUTOMAKE) --gnu doc/Makefile
1.11 + $(AUTOMAKE) --foreign doc/Makefile
1.12 .PRECIOUS: Makefile
1.13 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
1.14 @case '$?' in \
2.1 --- a/include/ltp_base.h Mon Mar 24 11:35:35 2014 +0000
2.2 +++ b/include/ltp_base.h Mon Mar 24 15:48:54 2014 +0000
2.3 @@ -178,6 +178,11 @@
2.4 #endif
2.5 #endif
2.6
2.7 +// stephen@tolerantnetworks.com: multicast stuff for MUDSAT
2.8 +#define LTP_MULTICAST
2.9 +#define LTP_MC_DEBUG
2.10 +
2.11 +
2.12 extern const char *ADDRANY; ///< this is an address which is a wildcard (used in whos_listening etc)
2.13
2.14 /*!
3.1 --- a/include/ltp_int.h Mon Mar 24 11:35:35 2014 +0000
3.2 +++ b/include/ltp_int.h Mon Mar 24 15:48:54 2014 +0000
3.3 @@ -542,5 +542,14 @@
3.4 */
3.5 int octets2ltpaddr(ltpc_octets *sp, ltpaddr *ad);
3.6
3.7 +#ifdef LTP_MULTICAST
3.8 +/*!
3.9 + * @fn int ltp_is_multi(addr)
3.10 + * @brief utility fnc to determine if target addr is MC or not
3.11 + * @return zero MC, error (1) if not
3.12 + */
3.13 +int ltp_is_multi(ltpaddr *addr);
3.14 #endif
3.15
3.16 +#endif
3.17 +
4.1 --- a/include/ltp_udp.h Mon Mar 24 11:35:35 2014 +0000
4.2 +++ b/include/ltp_udp.h Mon Mar 24 15:48:54 2014 +0000
4.3 @@ -56,12 +56,13 @@
4.4 #define L2_DEFPORT UDP_DEF_PORT
4.5
4.6 /*!
4.7 - * @fn int l2_s_udp_init(int port)
4.8 + * @fn int l2_s_udp_init(int port, sockaddr_in *mcp)
4.9 * @brief initialise a listener on some port
4.10 * @param port is the place to listen:-)
4.11 + * @param mcp is NULL or (should be) a multicast group address
4.12 * @return zero or error
4.13 */
4.14 -int l2_s_udp_init(int port);
4.15 +int l2_s_udp_init(int port,sockaddr_in *mcp);
4.16
4.17 /*!
4.18 * @fn int l2_s_udp_arrival(void)
5.1 --- a/lib/Makefile.in Mon Mar 24 11:35:35 2014 +0000
5.2 +++ b/lib/Makefile.in Mon Mar 24 15:48:54 2014 +0000
5.3 @@ -157,9 +157,9 @@
5.4 exit 1;; \
5.5 esac; \
5.6 done; \
5.7 - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu lib/Makefile'; \
5.8 + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign lib/Makefile'; \
5.9 $(am__cd) $(top_srcdir) && \
5.10 - $(AUTOMAKE) --gnu lib/Makefile
5.11 + $(AUTOMAKE) --foreign lib/Makefile
5.12 .PRECIOUS: Makefile
5.13 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
5.14 @case '$?' in \
6.1 --- a/src/Makefile.in Mon Mar 24 11:35:35 2014 +0000
6.2 +++ b/src/Makefile.in Mon Mar 24 15:48:54 2014 +0000
6.3 @@ -293,9 +293,9 @@
6.4 exit 1;; \
6.5 esac; \
6.6 done; \
6.7 - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Makefile'; \
6.8 + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/Makefile'; \
6.9 $(am__cd) $(top_srcdir) && \
6.10 - $(AUTOMAKE) --gnu src/Makefile
6.11 + $(AUTOMAKE) --foreign src/Makefile
6.12 .PRECIOUS: Makefile
6.13 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
6.14 @case '$?' in \
7.1 --- a/src/ltp_cues.cc Mon Mar 24 11:35:35 2014 +0000
7.2 +++ b/src/ltp_cues.cc Mon Mar 24 15:48:54 2014 +0000
7.3 @@ -52,6 +52,7 @@
7.4 #include <sys/socket.h>
7.5 #include <sys/types.h>
7.6 #include "ltp_base.h"
7.7 +#include "ltp_int.h"
7.8 #include "ltp.h"
7.9 #ifdef THREADS
7.10 #include <pthread.h>
7.11 @@ -208,6 +209,7 @@
7.12 #endif
7.13 localme=*me; // struct copy
7.14 localmeset=true;
7.15 +
7.16 #ifdef LTP_VERBOSE
7.17 snprintf(ltpstr,LTPSTR_LEN,"ltp_cue_set_whoiam set to %s\n",ltpaddr2str(me));
7.18 ltp_log(LTP_LOG_MAX,ltpstr);
8.1 --- a/src/ltp_l2.cc Mon Mar 24 11:35:35 2014 +0000
8.2 +++ b/src/ltp_l2.cc Mon Mar 24 15:48:54 2014 +0000
8.3 @@ -89,6 +89,8 @@
8.4 #include "ltp.h"
8.5 #include "ltp_l2.h"
8.6 #include "ltp_udp.h"
8.7 +#include "ltp_cues.h"
8.8 +#include "ltp_int.h"
8.9
8.10 #ifdef THREADS
8.11 #include "pthread.h"
8.12 @@ -805,11 +807,24 @@
8.13 ltp_log(LTP_LOG_ADVISORY,ltpstr);
8.14 ltp_log_flush();
8.15
8.16 + sockaddr_in *mcp=NULL;
8.17 +#ifdef LTP_MULTICAST
8.18 + ltpaddr foo;
8.19 + int wrv=ltp_cue_whoami(&foo);
8.20 + if (!ltp_is_multi(&foo)) {
8.21 +#ifdef LTP_MC_DEBUG
8.22 + snprintf(ltpstr,LTPSTR_LEN,"MC: ltp_is_multi says yes %s is MC",ltpaddr2str(&foo));
8.23 + ltp_log(LTP_LOG_MAX,ltpstr);
8.24 +#endif
8.25 + mcp=&foo.sock;
8.26 + }
8.27 +#endif
8.28 +
8.29 // fprintf(stderr,"Grabbing listener (in %s)...",__FUNCTION__);
8.30 // pthread_mutex_lock(&l2_listener_mutex);
8.31 // fprintf(stderr,"..got it\n");
8.32 listener_port=rx_port;
8.33 - rv=l2_s_udp_init(rx_port);
8.34 + rv=l2_s_udp_init(rx_port,mcp);
8.35 if (rv) {
8.36 snprintf(ltpstr,LTPSTR_LEN,"Failed to init UDP listener on %d (rv=%d)\n",rx_port,rv);
8.37 ltp_log(LTP_LOG_ERR,ltpstr);
8.38 @@ -847,7 +862,7 @@
8.39 // pthread_mutex_lock(&l2_listener_mutex);
8.40 // fprintf(stderr,"..got it\n");
8.41 listener_port=rx_port;
8.42 - int rv=l2_s_udp_init(rx_port);
8.43 + int rv=l2_s_udp_init(rx_port,mcp);
8.44 if (rv) {
8.45 snprintf(ltpstr,LTPSTR_LEN,"Failed to init UDP listener on %d (rv=%d)\n",rx_port,rv);
8.46 ltp_log(LTP_LOG_ERR,ltpstr);
9.1 --- a/src/ltp_log.cc Mon Mar 24 11:35:35 2014 +0000
9.2 +++ b/src/ltp_log.cc Mon Mar 24 15:48:54 2014 +0000
9.3 @@ -1178,3 +1178,29 @@
9.4 if (memcmp((void*)guy,(void*)<pany,len)) return(false);
9.5 else return(true);
9.6 }
9.7 +
9.8 +#ifdef LTP_MULTICAST
9.9 +/*!
9.10 + * @fn int ltp_is_multi(addr)
9.11 + * @brief utility fnc to determine if target addr is MC or not
9.12 + * @return zero MC, error (1) if not
9.13 + */
9.14 +int ltp_is_multi(ltpaddr *addr)
9.15 +{
9.16 + unsigned long a32=htonl(addr->sock.sin_addr.s_addr);
9.17 + unsigned int topbyte=(a32>>24) & 0xff;
9.18 + if (topbyte >= 224 && topbyte <= 239) {
9.19 +#ifdef LTP_MC_DEBUG
9.20 + snprintf(ltpstr,LTPSTR_LEN,"MC: ltp_is_multi says yes %lx is MC",a32);
9.21 + ltp_log(LTP_LOG_MAX,ltpstr);
9.22 +#endif
9.23 + return(LTP_OK);
9.24 + }
9.25 +#ifdef LTP_MC_DEBUG
9.26 + snprintf(ltpstr,LTPSTR_LEN,"MC: ltp_is_multi says no %lx is not MC",a32);
9.27 + ltp_log(LTP_LOG_MAX,ltpstr);
9.28 +#endif
9.29 + return(LTP_ERR);
9.30 +}
9.31 +#endif
9.32 +
10.1 --- a/src/ltp_udp.cc Mon Mar 24 11:35:35 2014 +0000
10.2 +++ b/src/ltp_udp.cc Mon Mar 24 15:48:54 2014 +0000
10.3 @@ -52,9 +52,11 @@
10.4 #include <sys/ioctl.h>
10.5
10.6 #include "ltp_base.h"
10.7 +#include "ltp_int.h"
10.8 #include "ltp.h"
10.9 #include "ltp_l2.h"
10.10
10.11 +
10.12 // I love global vars:-)
10.13
10.14 /// Transmit socket descriptor
10.15 @@ -81,9 +83,10 @@
10.16 * @fn int l2_s_udp_init(int port)
10.17 * @brief initialise a listener on some port
10.18 * @param port is the place to listen:-)
10.19 + * @param mcp is NULL or (should be) a multicast group address
10.20 * @return zero or error
10.21 */
10.22 -int l2_s_udp_init(int port)
10.23 +int l2_s_udp_init(int port, sockaddr_in *mcp)
10.24 {
10.25 r_port=port;
10.26 if ((r_sockfd=socket(AF_INET,MYSOCKTYPE,0))==-1) {
10.27 @@ -95,6 +98,26 @@
10.28 Target.sin_addr.s_addr=htonl(INADDR_ANY);
10.29 if (port) r_port=port;
10.30 Target.sin_port=htons(r_port);
10.31 +
10.32 +#ifdef LTP_MULTICAST
10.33 + if (mcp) {
10.34 + // should be a MC group, higher layers checked, but let's be anal:-)
10.35 + ltpaddr foo;
10.36 + foo.sock=*mcp;
10.37 + if (!ltp_is_multi(&foo)) {
10.38 + // set to listen to MC group
10.39 + struct ip_mreq bar;
10.40 + bar.imr_multiaddr=mcp->sin_addr;
10.41 + in_addr local;
10.42 + local.s_addr=htonl(INADDR_ANY);
10.43 + bar.imr_interface=local;
10.44 + int sorv=setsockopt(r_sockfd, IPPROTO_IP, IP_ADD_MEMBERSHIP, (char *)&bar, sizeof(bar));
10.45 + if (sorv<0) return(sorv);
10.46 + }
10.47 +
10.48 + }
10.49 +#endif
10.50 +
10.51 if (bind(r_sockfd,(struct sockaddr*)&Target,sizeof(Target))==-1) {
10.52 return(-2);
10.53 }
10.54 @@ -202,36 +225,6 @@
10.55 }
10.56
10.57
10.58 -// stephen@tolerantnetworks.com: multicast stuff
10.59 -#define LTP_MULTICAST
10.60 -#define LTP_MC_DEBUG
10.61 -
10.62 -#ifdef LTP_MULTICAST
10.63 -/*!
10.64 - * @fn int ltp_is_multi(addr)
10.65 - * @brief utility fnc to determine if target addr is MC or not
10.66 - * @return zero MC, error (1) if not
10.67 - */
10.68 -int ltp_is_multi(sockaddr_in *addr)
10.69 -{
10.70 - unsigned long a32=htonl(addr->sin_addr.s_addr);
10.71 - unsigned int topbyte=(a32>>24) & 0xff;
10.72 - if (topbyte >= 224 && topbyte <= 239) {
10.73 -#ifdef LTP_MC_DEBUG
10.74 - snprintf(ltpstr,LTPSTR_LEN,"MC: ltp_is_multi says yes %lx is MC",a32);
10.75 - ltp_log(LTP_LOG_MAX,ltpstr);
10.76 -#endif
10.77 - return(LTP_OK);
10.78 - }
10.79 -#ifdef LTP_MC_DEBUG
10.80 - snprintf(ltpstr,LTPSTR_LEN,"MC: ltp_is_multi says no %lx is not MC",a32);
10.81 - ltp_log(LTP_LOG_MAX,ltpstr);
10.82 -#endif
10.83 - return(LTP_ERR);
10.84 -}
10.85 -
10.86 -#endif
10.87 -
10.88 /*!
10.89 * @fn int l2_c_udp_init(void)
10.90 * @brief initialise a UDP client to be able to send in a moment
10.91 @@ -308,7 +301,7 @@
10.92 // is currently hardcoded based on the address matching 224/4 (which
10.93 // means multicast).
10.94 // to do this we just set a socket option
10.95 - if (!ltp_is_multi(&Target)) {
10.96 + if (!ltp_is_multi(&peer->addr)) {
10.97 // set TTL to 2
10.98 unsigned char ttl=2;
10.99 int srv=setsockopt(t_sockfd, IPPROTO_IP, IP_MULTICAST_TTL, &ttl, sizeof(ttl));
11.1 --- a/test/Makefile.in Mon Mar 24 11:35:35 2014 +0000
11.2 +++ b/test/Makefile.in Mon Mar 24 15:48:54 2014 +0000
11.3 @@ -197,9 +197,9 @@
11.4 exit 1;; \
11.5 esac; \
11.6 done; \
11.7 - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu test/Makefile'; \
11.8 + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign test/Makefile'; \
11.9 $(am__cd) $(top_srcdir) && \
11.10 - $(AUTOMAKE) --gnu test/Makefile
11.11 + $(AUTOMAKE) --foreign test/Makefile
11.12 .PRECIOUS: Makefile
11.13 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
11.14 @case '$?' in \