Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

UDP socket can't recv the UDP Broadcast Package--help

124 views
Skip to first unread message

Sam Becker

unread,
Sep 15, 2000, 11:23:19 PM9/15/00
to
I am now developing the driver for IPOA under vxworks. I CAN get the
singlecast package for my UDP socket, but CANNOT recv the BroadCast
package (from BOOTP request)

I've traced that my IPOA driver does get the package and does submit it
to MUX(IP driver).But i can not get any data from the socket.

some related codes as following:

sockAddrSize = sizeof(struct sockaddr_in);
bzero((char *) &serverAddr, sockAddrSize);
serverAddr.sin_len = (u_char)sockAddrSize;
serverAddr.sin_family = AF_INET;
serverAddr.sin_port = 67;
serverAddr.sin_addr.s_addr = inet_addr("16.16.3.33");

if ((sFd = socket(AF_INET, SOCK_DGRAM, 0)) == ERROR)
{
printf("Open socket fail!\n");
return;
}

if (bind (sFd, (struct sockaddr *)&serverAddr, sockAddrSize) ==
ERROR)
{
printf("Bind socket fail!\n");
close(sFd);
return;
}

if(recvfrom(sFd, (char *)&bootpMsg, sizeof(bootpMsg), 0,
(struct sockaddr *)&clientAddr,
&sockAddrSize) == ERROR)
{
printf("Receive message fail!\n");
close(sFd);
return;
}

Thank U very much!

--
底岩岩岩岩抿岩岩岩岩弧
↑↑↑↑↑↑↑↑↑↑↑
∵∵∵∵∵∵∵∵∵∵∵
←←←←←←←←←←←


Sent via Deja.com http://www.deja.com/
Before you buy.

Ken Bass

unread,
Sep 16, 2000, 3:00:00 AM9/16/00
to
Have you dont ipstatShow and udpstatShow? What counters are
incrementing?

Chris Chock

unread,
Sep 19, 2000, 6:25:54 AM9/19/00
to
I found this at the WRS Site. Hope it helps.

Why recvfrom does not receive broadcast message
if socket's local address is not INADDR_ANY

Solution ID:
16.0.638539.2492251
Solution Type:
Product Solution
Solution Status:
Confirmed

Goal:
Why recvfrom does not receive broadcast message if socket's
local address is not
INADDR_ANY
Fact:
It works if socket's local IP address is bound to INADDR_ANY
Fact:
Tornado 2.0
Fact:
VxWorks / 5.4
Fact:
Socket's local address is not INADDR_ANY
Symptom:
Broadcast messages are not received
Symptom:
Specifying the local address as one of the local IP addreses
returns no errors, but
broadcast messages are not received.
Fix:
If the s_addr member of the sockaddr_in structure contains
INADDR_ANY when
the socket binds and calls recvfrom then, the socket will
receive any messages
destined for that port.

If s_addr is not INADDR_ANY, for example: 192.100.1.12, then the
IP destination
address must match the socket's local address. Since the
broadcast message's
destination address, 192.100.1.255 will not match 192.100.1.12,
the message will be
dropped.

The network stack in vxWorks is based on BSD44 which has the
following code in
udp_input:

if (in_broadcast(ip->;ip_dst, m->;m_pkthdr.rcvif)) {
struct socket *last;
/*
* Deliver a multicast or broadcast datagram to *all
* sockets for which the local and remote addresses
* and ports match those of the incoming datagram.
...
if (inp->;inp_lport != uh->;uh_dport)
continue;
if (inp->;inp_laddr.s_addr != INADDR_ANY) {
if (inp->;inp_laddr.s_addr !=
ip->;ip_dst.s_addr)
continue;
}
if (inp->;inp_faddr.s_addr != INADDR_ANY) {
if (inp->;inp_faddr.s_addr !=
ip->;ip_src.s_addr ||
inp->;inp_fport != uh->;uh_sport)
continue;

0 new messages