[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-users] Netconn UDP Multicast Receive issue

From: nhindle
Subject: [lwip-users] Netconn UDP Multicast Receive issue
Date: Fri, 7 Mar 2014 09:29:51 -0800 (PST)

I am trying to implement a multicast UDP Netconn for receiving and
transmitting.  Currently the netconn will transmit but will not receive. 
>From reading other posts about the setup and configuration as well as
problems the following code should be setup properly.  I have verified that
it is not the external hardware or switches within the network as other
multicast messages are being transmitted and received on other devices.

*Sorry if some of the variables names change slightly, I have compressed a
couple of functions into one routine for this post and my proofread may have
missed something.

//---------------------------- SOURCE CODE ------------------------------//
    // Open IP stack
    lwip_1 = lwip_open( LWIP_1 ); 
    // Set up Lwip_1 and run DHCP testing connection, runs DHCP
    if( lwip_start( lwip_1 )  )
        return ERROR_LWIP_ERR_CLSD;

    netif_set_down( netif_default );
    netif_default->flags |= NETIF_FLAG_IGMP| NETIF_FLAG_BROADCAST;
    netif_set_addr( netif_default, &(tIpAddress), &(tIpMask), &(tGateway));
    netif_set_up( netif_default );

    pConn = netconn_new( NETCONN_UDP );

    // Set the listen timeout
    pConn->recv_timeout = PTP_NETCONN_TIMEOUT_MILLISEC;

    // Bind to 123
    netconn_bind( pConn, IP_ADDR_ANY, 123);

    //  UDP does not use nteconn_connect()
    // Join multicast group for PTP messages
    netconn_join_leave_group( pConn, &(tBroadcastIPAddress), &(tIPAddress),

    while( true )
        switch( netconn_recv( pConn, &pNetBuf ) )
        case ERR_OK:      //pNetBuf Received  - No Error
        case ERR_TIMEOUT:     //Timed out  - No Error
        default:    // ERROR_NETCONN_RECV

        // Check to see if there was any error
        if ( netconn_err( pConn ) == ERR_OK )
            // pNetBuf is assigned if there was data received
            // Given control of the pNetBuf thus responsible to delete it
            if ( pNetBuf )
                // Strip the data from the UDP netconn
                if ( netbuf_data( pNetBuf, (void **) &pBuf, (uint16_t
*)&uiBufLength ) )
                    netbuf_delete( pNetBuf );
                    return PTP_NO_MSG;
                  ..  Use the Buf 
           netbuf_delete( pNetBuf );

    if( txMsg ) 
        pNetBuf = netbuf_new(); 
        status = netbuf_ref( pNetBuf , (void *) txMsg , length );
        if( status )
            uiRetVal = ERROR_NETBUF_DATA;
        // Broadcast message
        status = netconn_sendto( pConn, pNetBuf , (ip_addr_t *)
&tBroadcastIPAddress, 123 );
        netbuf_delete( pNetBuf );

View this message in context: 
Sent from the lwip-users mailing list archive at Nabble.com.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]