raw icon indicating copy to clipboard operation
raw copied to clipboard

add data link layer multicast join/drop for Linux and BSD

Open bpillatsch opened this issue 8 years ago • 6 comments

Add SetMulticast(b bool, addr net.Addr) to Linux and BSD. Stub in others with ErrNotImplemented.

Linux implementation through setsockopt(), as such any multicast groups joined will automatically be dropped on socket close.

BSD implementation though dummy syscall.Socket and ioctl. Each multicast group joined/dropped is added/deleted to/from a net.HardwareAddr slice inside the Addr structure. This keeps track of the number of added hardware addresses at the time of Conn.Close(). Inside the .Close() function any remaining hardware addresses are dropped prior to exiting.

bpillatsch avatar Aug 02 '17 21:08 bpillatsch

Forgot to migrate to accepting net.HardwareAddr for the function. Let me know what you think about the rest and i'll update the PR with net.HardwareAddr when i have a free moment if its not already done by the time you review.

-edit- updated PR

bpillatsch avatar Aug 03 '17 00:08 bpillatsch

How would you like me to update the PR, I can squash my commits with a local reset and forced push to my branch so it appears as one concise commit for this PR, or I can push individual commits to the PR as we continue to review.

Thanks for all the comments this is super helpful, apologies on the typos.

bpillatsch avatar Aug 03 '17 16:08 bpillatsch

Either is fine I suppose since I can just squash and merge if I want to later anyway. Separate commits could be handy for review purposes.

mdlayher avatar Aug 03 '17 17:08 mdlayher

Thank you again for all of your hard work on this. This is open source at its finest!

I'll be traveling for the next week or so and will have limited or zero time for further review, unfortunately. I should be available again on August 14th if nothing else.

mdlayher avatar Aug 05 '17 16:08 mdlayher

Forgive the delay; I'm running into a very small hurtle. Trying to determine how best to abstract out the OS specifics. Unsure if creating an interface or just moving the entire SetMulticast function to OS specific build files. That aside I have tested FreeBSD and OpenBSD framework, once I solve for abstraction I will test of other platforms.

bpillatsch avatar Aug 15 '17 19:08 bpillatsch

An interface for the BSD family feels reasonable to me.

mdlayher avatar Aug 15 '17 19:08 mdlayher