SPF: UDP broadcast to 255.255.255.255

SPF: UDP broadcast to 255.255.255.255

Post by Michael Ko » Wed, 14 Apr 2004 22:01:28


Hi,

I'm trying to broadcast a message to 255.255.255.255 via UDP using SPF
on OS-9/68K.
The problem is that OS-9 seems to recognize the the IP classes and
automatically sets the subnet mask to 255.255.255.0 in 192.168.x.y
networks, eg.

The socket is set up like this:

hSocket = socket(AF_INET, SOCK_DGRAM, 0);
SockAddr.sin_family = AF_INET;
SockAddr.sin_addr.s_addr = INADDR_ANY;
SockAddr.sin_port = htons(8001);
bind(hSocket, (struct sockaddr*) &SockAddr, sizeof(SockAddr));
iOn = 1;
setsockopt(hSocket, SOL_SOCKET, SO_BROADCAST, &iOn, sizeof(iOn));

The program then receives broadcasts on UDP port 8001 from an
application running on a PC:

recvfrom(hSocket, &sBuffer, MSG_SIZE, 0, (struct sockaddr*) &SockAddr,
&iLength);

After processing that message, the OS-9 program is supposed to
broadcast a message back to the port the original message came from,
but using 255.255.255.255 as the address:

SockAddr.sin_addr.s_addr = 0xFFFFFFFF;
sendto(hSocket, &sBuffer, iLength, 0, (struct sockaddr*) &SockAddr,
sizeof(SockAddr));

This works just fine when the OS-9 device and the PC are in the same
subnet, because SPF seems to change the address to x.y.z.255.

But the main purpose of the program is that the IP address of the OS-9
device can be configured via UDP if it doesn't have a valid IP address
yet.
I'm trying to reproduce the behaviour of a different embedded device
with a different operating system, and these deviced always broadcast
to 255.255.255.255, but I don't seem to be able to do that with OS-9.

Did I miss any option apart from setting the socket to broadcast with
setsockopt()?
Might it be a problem that I'm using the same socket for receiving and
sending messages? (Although it works just fine when the OS-9 device
already has an appropriate IP address...)

Thanks in advance!

--
M.I.K.e
 
 
 

SPF: UDP broadcast to 255.255.255.255

Post by d.simo » Thu, 15 Apr 2004 02:22:47


What is the exact OS-9 Version and SoftStax version you are using?

MfG.
Daniel Simon
---------------------------------------------------------------------------------------------------
_ SimTech Real-Time, Networking and Automation
/ \ Daniel Simon, Bonhoeffer Str. 9, D-52078 Aachen
/ / _ _ mailto: XXXX@XXXXX.COM http://www.yqcomputer.com/
/_/_(_/_/ / phone: ++49 (0) 241 562411
fax. : ++49 (0) 241 562433
mobil : ++49 (0) 171 5733573

 
 
 

SPF: UDP broadcast to 255.255.255.255

Post by Michael Ko » Thu, 15 Apr 2004 23:02:17

On 2004-04-13 19:22:47 +0200, XXXX@XXXXX.COM (Daniel Simon) said:

It's OS-9/68K V3.2, and according to my boss it's using the latest
SoftStax, but he couldn't tell me which one that is, and I'm not sure
how to find that out.

--
M.I.K.e
 
 
 

SPF: UDP broadcast to 255.255.255.255

Post by Michael Ko » Thu, 29 Apr 2004 00:34:50


32438.news.uni-berlin.de>:
> I'm trying to broadcast a message to 255.255.255.255 via UDP using SPF

Since I didn't seem to be able to do a local broadcast instead of a subnet
one even when setting the subnet broadcast address to 255.255.255.255 I
chose a different approach. Now I'm assembling my own UDP datagrams
including IP and Ethernet headers, which I then write to the Ethernet
driver. I know it sounds like overkill, but at least it works, unlike
anything else I've tried...
--
M.I.K.e