problems to make my net driver working for multicasting

Diego Sanz dshernan80 at gmail.com
Wed Jan 20 13:08:00 UTC 2010


Hello

My network works correctly, sending and receiving unicast packets for UDP.

Now I want to receive and send multicast packets.

First, in the main code of my applications I have configured the sockets in
this way:

/******************************************MAIN
CODE*********************************************/
.
.
.
int net_state=0;
int s,sockIDfrom,exito_conexion;
struct sockaddr_in myAddr, farAddr,buffer;
struct sockaddr* hola;
char cbuf[300];
char msg[10];
int i;
int f, flags;
unsigned long int broadaddr=0;
struct ip_mreq mreq;
ssize_t stat;
unsigned int yes=1;

         s=socket(AF_INET,SOCK_DGRAM,0);
         if (s < 0)
         {
                    printf("Can't create client socket: %s\n",
strerror(errno));
                    return;
         }
         printf("\n He  entrado en UDP");

    memset(&myAddr, 0, sizeof myAddr);
    myAddr.sin_family = AF_INET;
    myAddr.sin_port = 319;
    myAddr.sin_addr.s_addr = inet_addr("138.100.48.242");
    //myAddr.sin_addr.s_addr = htonl(INADDR_ANY);

    if (bind(s, (struct sockaddr *)&myAddr, sizeof myAddr) < 0)
    {
        printf("Can't bind socket: %s\n", strerror(errno));
    }



    mreq.imr_interface.s_addr=inet_addr("138.100.48.242");
    mreq.imr_multiaddr.s_addr=inet_addr("224.0.1.129");

    if (setsockopt(s,SOL_SOCKET,SO_REUSEADDR,&yes,sizeof(yes))<0)
    {
        printf("\n Error in REUSEADDR configuration");
    }

    if
(setsockopt(s,IPPROTO_IP,IP_MULTICAST_IF,&mreq.imr_interface.s_addr,sizeof(struct
in_addr))<0)
    {
        printf("\n Error in  IP_MULTICAST_IF configuration");
    }


    if (setsockopt(s,IPPROTO_IP,IP_ADD_MEMBERSHIP,&mreq,sizeof(mreq))<0)
    {
        printf("\n Error in IP_ADD_MEMBERSHIP");
    }

     memset(&farAddr, 0, sizeof farAddr);
     farAddr.sin_family = AF_INET;
     farAddr.sin_port=319;
     farAddr.sin_addr.s_addr = inet_addr("138.100.48.253");

.
.
.
/***********************************************************************************************/

In the ioctl Function in the networkdriver on the path:
/home/rtems/rtems-work/rtems/c/src/lib/libbsp/m68k/mcf5235/network

I have included:

First, do the microcontroller to be in promiscued mode to accpet all
packets, and in the ioctl function I have add this:


fec_ioctl(struct ifnet *ifp, ioctl_command_t command, caddr_t data)
{
    struct mcf5235_enet_struct *sc = ifp->if_softc;
    struct ifreq *ifr = (struct ifreq *) data;
    int error = 0;
printf("\n Entra en ioctl\n");
    switch (command) {
        case SIOCGIFADDR:
        case SIOCSIFADDR:
            ether_ioctl(ifp, command, data);
            break;

        case SIOCSIFFLAGS:
            switch (ifp->if_flags & (IFF_UP | IFF_RUNNING)) {
                case IFF_RUNNING:
                    fec_stop(sc);
                    break;

                case IFF_UP:
                    fec_init(sc);
                    break;

                case IFF_UP | IFF_RUNNING:
                    fec_stop(sc);
                    fec_init(sc);
                    break;

                default:

                    break;
            }
            break;
    case SIOCADDMULTI:
        case SIOCDELMULTI:
                error=(command == SIOCADDMULTI)? ether_addmulti(ifr,
&sc->arpcom): ether_delmulti(ifr, &sc->arpcom);

           break;
.
.
.
.

But the function ether_addmulti(), returns error....
I would like to know the functions I have to call from the driver to
configure the system for multicasting

Thanks!!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/users/attachments/20100120/90ceacd1/attachment.html>


More information about the users mailing list