Esempio n. 1
0
void toall(void (*f)(struct sockaddr *, int, struct interface *, int), 
	int rtstate, struct interface *skipif)
{
	struct interface *ifp;
	struct sockaddr *dst;
	int flags;
	struct cfg_interface *ifcp;    // Added by Mason Yu for bind interface

	//if(!ripversion)
	//	return;

	for (ifp = ifnet; ifp; ifp = ifp->int_next) {
		/* check if this interface be configured to supply RIP */
		// Modified by Mason Yu for bind interface
		//if(!if_cfg_lookup(ifp->int_name))
		//	continue;
		ifcp = (struct cfg_interface *)if_cfg_lookup(ifp->int_name);
		// Kaohj -- check send mode
		//if (!ifcp)
		if (!ifcp || ifcp->send_mode == RIP_NONE)
			continue;		

		// Added by Mason Yu for bind interface
		// Kaohj
		#if 0
		//ripversion = ifcp->send_mode;
		if ( ifcp->send_mode == RIP_V1_COMPAT ) {
			ripversion = RIP_V2;
			multicast = 0;
		} else if ( ifcp->send_mode == RIP_V2 ) {
			multicast = 1;
		}
		#else
		if (ifcp->send_mode == RIP_V2 || ifcp->send_mode == RIP_V1_V2)
			multicast = 1;
		else
			multicast = 0;
		#endif
		
		if (ifp->int_flags & IFF_PASSIVE || ifp == skipif)
			continue;
		dst = ifp->int_flags & IFF_BROADCAST ? &ifp->int_broadaddr :
		      ifp->int_flags & IFF_POINTOPOINT ? &ifp->int_dstaddr :
		      &ifp->int_addr;

		flags = ifp->int_flags & IFF_INTERFACE ? MSG_DONTROUTE : 0;
		// Casey, set multicast interface
		// Kaohj modified
		//if(ripversion == 2 && multicast) {
		if(multicast) {
			set_mcast_if(&ifp->int_addr);
		}		
		//		
		(*f)(dst, flags, ifp, rtstate);
	}
}
Esempio n. 2
0
/*
 *      Set up sending multicast socket over UDP
 */
static struct socket * make_send_sock(void)
{
	struct socket *sock;

	/* First create a socket */
	if (sock_create(PF_INET, SOCK_DGRAM, IPPROTO_UDP, &sock) < 0) {
		IP_VS_ERR("Error during creation of socket; terminating\n");
		return NULL;
	}

	if (set_mcast_if(sock->sk, ip_vs_mcast_ifn) < 0) {
		IP_VS_ERR("Error setting outbound mcast interface\n");
		goto error;
	}

	set_mcast_loop(sock->sk, 0);
	set_mcast_ttl(sock->sk, 1);

	if (bind_mcastif_addr(sock, ip_vs_mcast_ifn) < 0) {
		IP_VS_ERR("Error binding address of the mcast interface\n");
		goto error;
	}

	if (sock->ops->connect(sock,
			       (struct sockaddr*)&mcast_addr,
			       sizeof(struct sockaddr), 0) < 0) {
		IP_VS_ERR("Error connecting to the multicast addr\n");
		goto error;
	}

	return sock;

  error:
	sock_release(sock);
	return NULL;
}