• 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
Converting UDP unicast to broadcast with NKE
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Converting UDP unicast to broadcast with NKE


  • Subject: Converting UDP unicast to broadcast with NKE
  • From: Mark Hunt <email@hidden>
  • Date: Wed, 16 May 2012 10:59:16 +0000
  • Thread-topic: Converting UDP unicast to broadcast with NKE

Hi.

I'm receiving UDP data (which is normally broadcast) which has to be delivered to multiple sockets.

By using SO_REUSEADDR on each socket, every socket gets a copy of each incoming broadcast packet.

I'd like to replace the broadcast messages with unicast (multicasting isn't an option), but then only one of the sockets in the computer receives the packets.

I thought of using an IP Filter NKE to replace the destination address of the incoming messages with the broadcast address, so that any UDP data for the port goes to all the sockets in the computer.

This seems to work for packets from-to 127.0.0.1, but not for "real" data from the network.

In my ipf_input routine, after checking for UDP and port number (ih is an ip*):

printf("Packet from x to x\n", htonl(ih->ip_src.s_addr), htonl(ih->ip_dst.s_addr));

// pass through if already a broadcast packet
if(ih->ip_dst.s_addr == -1) return 0;


// make the destination address broadcast
ih->ip_dst.s_addr = -1;
ih->ip_sum = 0;

mbuf_inet_cksum(*data, 0, 0, ih->ip_hl << 2, &ih->ip_sum);


ipf_inject_input(*data, NULL);


return EJUSTRETURN;

From 127.0.0.1->127.0.0.1, I see duplicate copies of each packet arrive at all my sockets. This works even if I don't recalculate the checksum!

From other sources, the packets just disappear - they don't get delivered anywhere.

I've tried with and without the ipf_inject_input() and EJUSTRETURN (returning 0), but the behaviour is just the same (and 127.0.0.1 still works!).

The printf() shows each packet being processed twice, once with the original destination, and again with the broadcast destination, but the data doesn't get to the sockets.

Clearly I'm doing (or not doing) something stupid.

Can anyone help please?

Mark




 _______________________________________________
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

  • Prev by Date: Re: SSL host name checking doesn't understand wildcard subdomains?
  • Next by Date: EADDRNOTAVAIL after opening a number of sockets
  • Previous by thread: Re: Using CFHTTPMessage to parse response header but not body?
  • Next by thread: EADDRNOTAVAIL after opening a number of sockets
  • Index(es):
    • Date
    • Thread