This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Linux/AM5708: UDP multicast sender issue

Part Number: AM5708

Tool/software: Linux

Hi:

     I have a Linux application running in the A15 in a AM5708 custom board.

I am able to send and receive UDP frames when the I know the remote IP. The problem is that

I want to send a UDP frame to a IP multicast "224.0.1.1" but in this case the frame is not being sent out by the interface.

I only have one ethernet interface over GMAC.. An snippet of the code is:          

           // Open socket
            proto = getprotobyname("udp");
            SNTP.header.socket_udp = socket(PF_INET, SOCK_DGRAM | SOCK_NONBLOCK, proto->p_proto);
            if(SNTP.header.socket_udp == -1)
            {
                PRINTF_0("(%u) ERROR creating UDP socket for SNTP anycast()\n", system_clock);
                SNTP.run.status = SNTP_ANYCAST_STATE_ERROR;
                return 0;
            }
        
            // Bind socket
            memset(&client, 0x00, sizeof(struct sockaddr_in));
            client.sin_family = AF_INET;
            client.sin_addr.s_addr = INADDR_ANY;
            client.sin_port = htons(SNTP_ANYCAST_LOCAL_PORT);
            status = bind(SNTP.header.socket_udp, (struct sockaddr *)&(client), sizeof(struct sockaddr));
            if(status == -1)
            {
                PRINTF_0("(%u) ERROR binding UDP socket for SNTP anycast()\n", system_clock);
                close(SNTP.header.socket_udp);
                SNTP.header.socket_udp = -1;
                SNTP.run.status = SNTP_ANYCAST_STATE_ERROR;
                return 0;
            }


            {
                static struct sockaddr_in to;
                static int len, to_len;

                // Send the packet
                memset(&to, 0x00, sizeof(struct sockaddr_in));
                to_len = (unsigned char)(sizeof(struct sockaddr_in));
                to.sin_family = AF_INET;
                to.sin_addr.s_addr = (SNTP.run.server_address);
                to.sin_port = htons(SNTP.run.server_port);
                memcpy(SNTP.header.buffer_tx, &(SNTP_FullPacket_Out.Basic), sizeof(NtpBasicInfo));
                len = sendto(SNTP.header.socket_udp,
                             "Hello world",
                             11,
                             0,
                             (struct sockaddr *)&to,
                             to_len);
                if (len == -1)
                {
                    PRINTF_0("(%u) ERROR sending SNTP packet in SNTP_tx()\n", system_clock);
                    perror("ANYCAST DIRECT");  // Billa
                    SNTP.run.status = SNTP_ANYCAST_STATE_ERROR;
                    return 0;
                }
            }

What am I doing wrong?

Regards

Billa