broadcasting to issue


I’m running into a bit of an issue porting some code from Linux to QNX. I need to send a broadcast UDP packet to, but for some reason QNX (6.3.2) change the IP of the packet recipient to … which is the broadcast @ of the adapter … I have googled around and it seems that several people have encountered that issue, but I haven’t found any link to a solution … yet. :unamused:

Thanks in advance for any tips/advice or solution(s).


I don’t think it’s “legal” to broadcast outside of your segment.

AFAIK it is ‘legal’ … routers won’t propagate it. DHCP discovery (for example) use it.

Have you tried changing the netmask to see if the destination address changes?

yes, but setting the netmask to 0x000000000 doesn’t work, ifconfig change it automaticaly to 0xffffff00 :frowning:

Stevens: Unix Network Programming Volume 1, 2nd ed. (1998)
"… the subnet-directed broadcast address is the most common today. But some older systems still send datagrams destined to "

‘subnet-directed’ being what you’re seeing (netmask applied to the broadcast address)
BSD seems to have an IOCTL which will allow you to force the address but it’s not
supported in QNX.

You may be stuck with this behavior or have to go to raw sockets - and there’s no guaruntee it’ll
work there either.

“… A special type of IP address is the limited broadcast address A broadcast involves delivering a message from one sender to many recipients. This broadcast is ‘limited’ in that it does not reach every node on the Internet, only nodes on the LAN.”

We use this broadcast address (RFC1122) to discover devices (cameras) on the local network, this is what the standard (GigE Vision) request. QNX is the only OS to not allow it AFAIK. Assigning a broadcast address of with ifconfig to the adapter “solve” the issue … but I’m not sure this is an acceptable solution :frowning:

While I agree that you should be able to send to the general boradcast address, this does bring up an obvious question. If your subnet covers the local lan, why would a local broadcast address not be sufficient for your needs? I’m just trying to be practical here.

Well, broadcasting to garantee that we can “reach” any devices on the local network, inlcuding the ones that are not configured properly (unreachable otherwise as they won’t answer a subnet broadcast as they don’t know, or have an incorrect, netmask.

Please post “ifconfig -a” and “netstat -rn”.

One suggestion:
assuming you have an IP on en0, try the below command

route add -host -interface

“route add -host -interface” didn’t help, the broadcast are still sent with as recipient :frowning:

Here’s the output of the commands:

/sbin/ifconfig -a

lo0: flags=8009<UP,LOOPBACK,MULTICAST> mtu 33212
inet netmask 0xff000000
address: 00:0c:f1:6c:aa:7e
inet netmask 0xffff0000 broadcast

netstat -rn

Routing tables

Destination Gateway Flags Refs Use Mtu Interface
default UG 2 2493 - en0 UH 0 0 33212 lo0
192.168/16 link#2 UC 2 0 - en0 00:05:5d:75:0b:03 UHLc 1 0 - en0 link#2 UHLc 0 2 - en0

A few things you could try:

route add -host -interface

route add -net 255.255.255 -interface

no luck, noc :frowning: And actualy, the second one (corrected to instead of 255.255.255) mess the routing table.

Using ping and a packet sniffer (Ethereal on XP) you can see that when
pinging the address is NOT getting mangled.

If you look at the source for ping (I don’t have that handy) you’ll see
that it uses a raw socket. So apparently you can bypass this addressing
issue by going to a lower level in the stack.

That explains it. I was testing using ping and all worked. Was wondering why it failed for jlv.