-
-
Notifications
You must be signed in to change notification settings - Fork 30.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Missing support for Source Specific Multicast #89415
Comments
It appears that Python's socket module is missing support for the IGMPv3 socket options needed to support Source Specific Multicast. Many developers appear to be adding the necessary constants through something like: if not hasattr(socket, "IP_UNBLOCK_SOURCE"):
setattr(socket, "IP_UNBLOCK_SOURCE", 37)
if not hasattr(socket, "IP_BLOCK_SOURCE"):
setattr(socket, "IP_BLOCK_SOURCE", 38)
if not hasattr(socket, "IP_ADD_SOURCE_MEMBERSHIP"):
setattr(socket, "IP_ADD_SOURCE_MEMBERSHIP", 39)
if not hasattr(socket, "IP_DROP_SOURCE_MEMBERSHIP"):
setattr(socket, "IP_DROP_SOURCE_MEMBERSHIP", 40) ...but it would be nice if these were added to the official module as they are supported under current versions of Windows, Linux, and BSD at the least. |
Note that the code posted there is not correct for Windows, where the constant values are different. I think a more correct version would be something like: if platform.system().lower().startswith('win'):
if not hasattr(socket, "IP_UNBLOCK_SOURCE"):
setattr(socket, "IP_UNBLOCK_SOURCE", 18)
if not hasattr(socket, "IP_BLOCK_SOURCE"):
setattr(socket, "IP_BLOCK_SOURCE", 17)
if not hasattr(socket, "IP_ADD_SOURCE_MEMBERSHIP"):
setattr(socket, "IP_ADD_SOURCE_MEMBERSHIP", 15)
if not hasattr(socket, "IP_DROP_SOURCE_MEMBERSHIP"):
setattr(socket, "IP_DROP_SOURCE_MEMBERSHIP", 16)
else:
if not hasattr(socket, "IP_UNBLOCK_SOURCE"):
setattr(socket, "IP_UNBLOCK_SOURCE", 37)
if not hasattr(socket, "IP_BLOCK_SOURCE"):
setattr(socket, "IP_BLOCK_SOURCE", 38)
if not hasattr(socket, "IP_ADD_SOURCE_MEMBERSHIP"):
setattr(socket, "IP_ADD_SOURCE_MEMBERSHIP", 39)
if not hasattr(socket, "IP_DROP_SOURCE_MEMBERSHIP"):
setattr(socket, "IP_DROP_SOURCE_MEMBERSHIP", 40) |
I've been trying to figure out SSM suipport. confirm the flags on windows was causing errors. I've got passed this with the flag change. However the minimal code examples out there any attempt to use "SOL_IP" causes invalid argument. Is this the correct method for SSM ? 0.0.0.0 works for asm not sure for ssm yet.
|
@gpshead (as listed in the socket experts list) Any ideas if @multiplemonomials's snippet can be reliably used? |
Yes I just tested it in windows and those flags needed to change. For SSM multicast in windows the bind address needs to be '' also but for asm "0.0.0.0" seems ok. Ive yet to check on the network with the cisco router if I get data yet.
|
You need to look in the header files on your target platforms to determine if the snippet above adding the constants works. Regardless, this issue really is pretty much about plumbing. When these constants are defined we should expose them in the socket module. Much like we already do for many others. That'd obviate the need for hacks like the above. |
For anyone who wants to contribute a PR, it should pretty much just be adding stuff like you see in https://github.com/python/cpython/blob/main/Modules/socketmodule.c#L8104 with ifdef and PyModule_AddIntMacro. |
That is what I figured it needs to match the constant flags on the OS. For darwin it says 70. So mac needs something different ? |
I found a header for win 10 SDK. It says 15. https://github.com/tpn/winsdk-10/blob/master/Include/10.0.16299.0/shared/ws2ipdef.h |
I'm sorry to ask if getting the right flags setup. Is socket.IPPROTO_IP the correct way to setup SSM because the old examples out there using socket.SOL_IP cause endless "invalid argument" errors. The struct packing is similar to the windows docs. Needs to join the group, source ip, then local ip |
Here is a patch for windows and macOS I've come up with. Will eventually test on macOS but Windows first.
|
…103684) Add socket options for source-specific multicast when present as C #defines. Co-authored-by: Oleg Iarygin <dralife@yandex.ru>
…e docs (pythonGH-105266) (cherry picked from commit eaff9c3) Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
Linked PRs
IP_*
constants insocket
module in the docs #105266IP_*
constants insocket
module in the docs (GH-105266) #105270The text was updated successfully, but these errors were encountered: