• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
broadcast address of a network interface
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

broadcast address of a network interface


  • Subject: broadcast address of a network interface
  • From: Joel Reymont <email@hidden>
  • Date: Mon, 9 Feb 2009 16:05:19 +0000

Folks,

I'm currently using this chunk of code (based on Quinn's post) to find the first network interface suitable for broadcasting. The code bombs, though, since ifa_broadaddr is 0.

How do I make a network broadcast address (.255) from the interface IP address?

This is the iPhone and broadcasting to 255.255.255.255 won't work in certain circumstances.

	Thanks, Joel

---

#if ! defined(IFT_ETHER)
#define IFT_ETHER 0x6/* Ethernet CSMACD */
#endif

-(void)findBroadcastAddress {

    struct ifaddrs          *addrs;
    const struct ifaddrs    *cursor;

if (getifaddrs(&addrs) == 0) {
cursor = addrs;
while (cursor != NULL) {
if ((cursor->ifa_addr->sa_family == AF_LINK)
&& (((const struct sockaddr_dl *)cursor->ifa_addr)- >sdl_type == IFT_ETHER)
&& (cursor->ifa_flags & (IFF_UP|IFF_BROADCAST)) > 0) {
broadcastAddress = [NSData dataWithBytes:(const struct sockaddr_dl *)cursor->ifa_broadaddr
length:sizeof(const struct sockaddr_dl)];
break;
}
cursor = cursor->ifa_next;
}
freeifaddrs(addrs);
}
}


---
http://tinyco.de
--- Mac & iPhone




_______________________________________________ Do not post admin requests to the list. They will be ignored. Macnetworkprog mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: broadcast address of a network interface
      • From: Jens Alfke <email@hidden>
  • Prev by Date: Re: CFReadStreamCopyProperty() returns NULL?
  • Next by Date: Re: broadcast address of a network interface
  • Previous by thread: When is it safe to enable filtering in an NKE?
  • Next by thread: Re: broadcast address of a network interface
  • Index(es):
    • Date
    • Thread