Subject: Solaris multicast problem

From: "Garry, Edward J" <[email-masked]>
Date: Sat, 14 Feb 1998 07:15:31 -0600

I saw info from you on multicasting and thought you might be able to
help me with this problem.
I am trying to receive an ethernet multicast on an Ultra-10 Sparc
running 2.5.1.
The code below runs okay on a DEC Alpha machine. It gets an error when
running on Solaris. Ideas?

Thanks
Ed Garry
612-456-7757

Shown below is the printout when we run the multicast program:

<<< ERROR: (No such file or directory) Setting hme0 multicast
03.07.01.00.00.30 >>> 

Shown below is the test program we are running. 

#include	<stdio.h>
#include	<math.h>
#include	<sys/types.h>
#include	<sys/ioctl.h>
#include	<sys/fcntl.h>
#include	<sys/socket.h>
#include	<sys/sockio.h>
#include	<netinet/in.h>
#include	<net/if.h>
#include	<netdb.h>
#include	<arpa/inet.h>
#include	<errno.h>
#include	<sys/time.h>
#include	<sys/ipc.h>
#include	<sys/shm.h>
#include	<sys/msg.h>
#include	<sys/sem.h>
#include	<sys/file.h>
#include	<limits.h>
#include	<sys/un.h>
#include	<unistd.h>
#include	<memory.h>
#include	<sys/dlpi.h>

void main()
{
	int		i,cc,sock;
	struct sockaddr_in 	stFrom;
	struct sockaddr_in 	from_addr;
	int					from_len;
	char				ebuf[1500];
	struct ifreq		req;

			/* Open communications socket */
   if((sock = socket(AF_INET, SOCK_DGRAM, 0)) == -1) {
      printf("\n<<< ERROR(rcvr_daemon2): (%s) Unable to open sock
socket! >>>\n",
	    strerror(errno));
      exit(1);
   }
   stFrom.sin_family      = AF_INET;
   stFrom.sin_port        = htons(2050);
   stFrom.sin_addr.s_addr = inet_addr("129.218.23.255");
   for (i = 0; i < 8; ++i)
       stFrom.sin_zero[i] = 0;

   if(bind(sock,(struct sockaddr*)  &stFrom, sizeof(struct sockaddr_in))
== -1) {
	printf("Unable to bind the socket\n");
	return;
   }

   if(fcntl(sock, F_SETFL, FNDELAY) == -1) {
      printf("\n<<< ERROR(rcvr_daemon2): (%s) Unable to make sock socket
nonblocking! >>>\n",
	    strerror(errno));
      exit(1);
   }
			/* Set Multicast Interface Addresses */
   strcpy(req.ifr_name,"hme0");	
   req.ifr_ifru.ifru_addr.sa_data[0] = 0x03;	 /* Set ethernet mcast
addr */
   req.ifr_ifru.ifru_addr.sa_data[1] = 0x07;
   req.ifr_ifru.ifru_addr.sa_data[2] = 0x01;
   req.ifr_ifru.ifru_addr.sa_data[3] = 0x00;
   req.ifr_ifru.ifru_addr.sa_data[4] = 0x00;
   req.ifr_ifru.ifru_addr.sa_data[5] = 0x30;
/*   if((ioctl(sock,SIOCADDMULTI,&req)) == -1) { /* */
   if((ioctl(sock,DL_ENABMULTI_REQ,&req)) == -1) {
       printf("<<< ERROR: (%s) Setting %s multicast 03.07.01.00.00.30
>>> \n",
       strerror(errno),req.ifr_name);
      exit(1);
   }

	while (1) {
		cc = recvfrom(sock,  ebuf, 1500, MSG_DONTROUTE,(struct
sockaddr*) &from_addr, &from_len);
		if (cc>=120) {
			printf("Received %d bytes\n", cc );
		}
	}
}

---

From: Bill Fenner <[email-masked]>
Date: Sun, 15 Feb 1998 23:01:15 PST

>   if((ioctl(sock,DL_ENABMULTI_REQ,&req)) == -1) {

DL_ENABMULTI_REQ needs a dl_enabmulti_req_t, not a struct ifreq.

  Bill