This is the mail archive of the mailing list for the eCos project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: How to send UDP broadcast to

On Mon, Jun 15, 2009 at 05:41:54PM +0000, Grant Edwards wrote:
> I've been asked by one of my internal customers how to send a
> UDP broadcast packet to IP address

Hi Grant

If you have a debugger handy, try putting a break point here:

in_pcbladdr(inp, nam, plocal_sin)
        register struct inpcb *inp;
        struct sockaddr *nam;
        struct sockaddr_in **plocal_sin;
        struct in_ifaddr *ia;
        register struct sockaddr_in *sin = (struct sockaddr_in *)nam;

        if (nam->sa_len != sizeof (*sin))
                return (EINVAL);
        if (sin->sin_family != AF_INET)
                return (EAFNOSUPPORT);
        if (sin->sin_port == 0)
                return (EADDRNOTAVAIL);
        if (!TAILQ_EMPTY(&in_ifaddrhead)) {
                 * If the destination address is INADDR_ANY,
                 * use the primary local address.
                 * If the supplied address is INADDR_BROADCAST,
                 * and the primary interface supports broadcast,
                 * choose the broadcast address for that interface.
#define satosin(sa)     ((struct sockaddr_in *)(sa))
#define sintosa(sin)    ((struct sockaddr *)(sin))
#define ifatoia(ifa)    ((struct in_ifaddr *)(ifa))
                if (sin->sin_addr.s_addr == INADDR_ANY)
                    sin->sin_addr = IA_SIN(TAILQ_FIRST(&in_ifaddrhead))->sin_addr;
                else if (sin->sin_addr.s_addr == (u_long)INADDR_BROADCAST &&
                  (TAILQ_FIRST(&in_ifaddrhead)->ia_ifp->if_flags & IFF_BROADCAST))
                    sin->sin_addr = satosin(&TAILQ_FIRST(&in_ifaddrhead)->ia_broadaddr)->sin_addr;

Unfortunately, if this is the place the address is being changed, i
don't see an obvious way around this.


Before posting, please read the FAQ:
and search the list archive:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]