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.

Problem receiving limited broadcast UDP packet on DM8148 Linux

Other Parts Discussed in Thread: DM3730

Hi, we have a product based on DM8148 running EZSDK 5.50.02.00 + linux-04.04.00.02 PSP (linux 2.6.37).

We are having a strange problem receiving limited (or non directed) broadcast packets (destination IP is 255.255.255.255), depending on who sends the packet.

  • DM8148:  192.168.2.4      mask 255.255.255.0.
  • PC1 :       192.168.1.10,    mask 255.255.255.0
  • PC2 :       192.168.2.10,    mask 255.255.255.0

When a broadcast UDP packet is sent from PC2, DM8148 receives the packet.  When the packet is sent from PC1, DM8148 doesn't receive it.

Here is the part of the code (error handling is omitted):

  int rv, sock;
  struct sockaddr_in addr;
  char buf[2048];

  sock = socket(AF_INET, SOCK_DGRAM, 0);
  addr.sin_family = AF_INET;
  addr.sin_port = htons(port_num);
  addr.sin_addr.s_addr = htonl(INADDR_ANY);

  rv = bind(sock, (struct sockaddr *)&addr, sizeof(addr));

  int optval = 1;
  struct sockaddr sin1;
  socklen_t tmp = sizeof(sin1);
  memset(&sin1, 0, tmp);

  rv = setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char*)&optval, sizeof(int));
  rv = setsockopt(sock, SOL_SOCKET, SO_BROADCAST, (char*)&optval, sizeof(int));
  
  memset(buf, 0, sizeof(buf));
  rv = recvfrom(sock, buf, sizeof(buf), 0, &sin1, &tmp);

I checked all the return values and there were no errors.

If I use raw socket, then I can see the packet, so it looks like the Linux kernel and/or TCP/IP layer is somehow throwing away the packet.

Here is ifconfig result:

~# ifconfig
eth0      Link encap:Ethernet  HWaddr 84:7E:40:3A:31:3C
          inet addr:192.168.2.4  Bcast:255.255.255.255  Mask:255.255.255.0
          UP BROADCAST RUNNING PROMISC ALLMULTI MULTICAST  MTU:1500  Metric:1
          RX packets:371585 errors:0 dropped:7225 overruns:0 frame:0
          TX packets:4303 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:397472934 (379.0 MiB)  TX bytes:381438 (372.4 KiB)
          Interrupt:40

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:8 errors:0 dropped:0 overruns:0 frame:0
          TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:496 (496.0 B)  TX bytes:496 (496.0 B)

We have another product based on DM3730 (LogicPD SOM, based on Linux 3.0), and the same exact code works fine.