pedr0
unread,Oct 1, 2012, 4:14:31 AM10/1/12You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to
Hello,
I wrote this piece of code but I am not able to modify it in order to use IGMPV3
and use the source feature of IGMPV3, how can I add a membership for a group on an interface for specified source ?
Something like this piece of code (C under Linux):
setsockopt(fd,SOL_IP,MCAST_JOIN_SOURCE_GROUP, &group_source_req,
sizeof(group_source_req));
import socket
import fcntl
import struct
import sys
def get_ip_address(ifname):
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
return socket.inet_ntoa(fcntl.ioctl(
s.fileno(),
0x8915, # SIOCGIFADDR
struct.pack('256s', ifname[:15])
)[20:24])
if len(sys.argv) < 3:
print 'Usage : [MCAST_ADDR] [PORT] [IFNAME]'
sys.exit(1)
MCAST_GRP = sys.argv[1]
MCAST_PORT = int(sys.argv[2])
IF = sys.argv[3]
ip_if = get_ip_address(IF)
packet = 0
print("Capturing from "+IF+"("+ip_if+") group "+MCAST_GRP+":"+str(MCAST_PORT))
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
sock.bind(('', MCAST_PORT))
sock.setsockopt(socket.IPPROTO_IP, socket.IP_ADD_MEMBERSHIP, socket.inet_aton(MCAST_GRP)+socket.inet_aton(ip_if))
while True:
try:
sock.recv(1024)
print '1K received'
packet = packet +1
except:
print 'Received '+str(packet*1024)+' bytes'
sock.setsockopt(socket.IPPROTO_IP, socket.IP_DROP_MEMBERSHIP, socket.inet_aton(MCAST_GRP)+socket.inet_aton(ip_if))
sys.exit(0)