lwip-users
[Top][All Lists]
Advanced

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

[lwip-users] Sockets api udp packets receive error


From: newlwip
Subject: [lwip-users] Sockets api udp packets receive error
Date: Fri, 16 Feb 2007 02:46:29 -0800 (PST)

Hi,
   I am using LWIP sockets api for sending and receiving UDP packets on
xilinx ML403 powerpc board with xilkernel.
I am able to send a UDP packet to a pc and the network sniffer application
running on the PC could capture it.
Similarly when I send a paclket from the pc to the xilinx board, the sniffer
captures it and the ethernet driver of my board is able to receive the
packet.But LWIP recvfrom function is failing.I have given the code
below.Could someone tell me where am I going wrong?In sockets.c
Sock->rcvevent is never set and hence netconn->send is never executed
returning -1.

void* socket_process_thread(void* arg)   
{
   int len;
   int s = *((int*) arg);
   
   print ("SOCKET: Processing data for connection...");
   while(1) {
     len=recvfrom(s, buf, 200,MSG_DONTWAIT,
        (struct sockaddr *) &cliaddr, cliAddrLen);
       xil_printf("%d len\r\n",len);
   }
   print ("SOCKET: Closing socket...");
   close(s);
   print ("done.\r\n");
}
void*
socket_app_thread(void *arg)
{
   struct ip_addr ipaddr, netmask, gw;
   struct netif *default_netif;
   char fullmac[6] = {0x00, 0x0A, 0x35, 0x01, 0x7e, 0x55};
   char ip[4] =      {192,168,15,34};
   char subnet[4] =  {255,255,255,0};
   char gateway[4] = {192,168,15,1};

   int sock,s;
   int len;
   struct sockaddr_in addr,rem;
    
   
   XTemacIf_Config *xtemacif_ptr = &XTemacIf_ConfigTable[0];
   
   xtemacif_setmac(0, (u8_t *) fullmac);                        //Set MAC
   IP4_ADDR(&gw, gateway[0],gateway[1],gateway[2],gateway[3]); //Set gateway
   IP4_ADDR(&ipaddr, ip[0],ip[1],ip[2],ip[3]);                 //Set ip
   IP4_ADDR(&netmask,subnet[0],subnet[1],subnet[2],subnet[3]); //Set subnet
msk
   
   default_netif = mem_malloc(sizeof(struct netif));

   if (default_netif == NULL) {
      print(NETIF_DEBUG, ("netif_add(): out of memory for
default_netif\n"));
      return NULL;
   }
   default_netif = netif_add(default_netif,
                             &ipaddr, 
                             &netmask,
                             NULL,
                             &XTemacIf_ConfigTable[0],
                             xtemacif_init,
                             tcpip_input
                             );
   
   netif_set_default(default_netif);

   register_int_handler(XPAR_OPB_INTC_0_TRIMODE_MAC_GMII_IP2INTC_IRPT_INTR,
                        (XInterruptHandler)XTemac_IntrFifoHandler,
                        xtemacif_ptr->instance_ptr);
   
   /* Enable EMAC interrupts in XMK */
   enable_interrupt(XPAR_OPB_INTC_0_TRIMODE_MAC_GMII_IP2INTC_IRPT_INTR);

 
/*-----------------------------------------------------------------------*/
  /* create socket and start application                                  
*/
 
/*-----------------------------------------------------------------------*/
   print ("SOCKET: Creating socket..");
    sock = socket(AF_INET,SOCK_DGRAM,IPPROTO_UDP);
   addr.sin_family = AF_INET;
   addr.sin_port = htons(0x0898); 
   addr.sin_addr.s_addr = INADDR_ANY;
         
        cliaddr.sin_family = AF_INET;
        cliaddr.sin_port = htons(0x0898);
        cliaddr.sin_addr.s_addr = CLIENT_ADDR;
        cliAddrLen = sizeof(cliaddr);

    
   bind(sock,(struct sockaddr *)&addr,sizeof(addr));
     
    sys_thread_new(socket_process_thread, &sock, 7);
}

-- 
View this message in context: 
http://www.nabble.com/Sockets-api-udp-packets-receive-error-tf3238796.html#a9002213
Sent from the lwip-users mailing list archive at Nabble.com.





reply via email to

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