Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(426)

Side by Side Diff: client/tests/kvm/scripts/multicast_guest.py

Issue 6246035: Merge remote branch 'cros/upstream' into master (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/autotest.git@master
Patch Set: patch Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 #!/usr/bin/python
2 import socket, struct, os, signal, sys
3 # -*- coding: utf-8 -*-
4
5 """
6 Script used to join machine into multicast groups.
7
8 @author Amos Kong <akong@redhat.com>
9 """
10
11 if __name__ == "__main__":
12 if len(sys.argv) < 4:
13 print """%s [mgroup_count] [prefix] [suffix]
14 mgroup_count: count of multicast addresses
15 prefix: multicast address prefix
16 suffix: multicast address suffix""" % sys.argv[0]
17 sys.exit()
18
19 mgroup_count = int(sys.argv[1])
20 prefix = sys.argv[2]
21 suffix = int(sys.argv[3])
22
23 s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
24 for i in range(mgroup_count):
25 mcast = prefix + "." + str(suffix + i)
26 try:
27 mreq = struct.pack("4sl", socket.inet_aton(mcast),
28 socket.INADDR_ANY)
29 s.setsockopt(socket.IPPROTO_IP, socket.IP_ADD_MEMBERSHIP, mreq)
30 except:
31 s.close()
32 print "Could not join multicast: %s" % mcast
33 raise
34
35 print "join_mcast_pid:%s" % os.getpid()
36 os.kill(os.getpid(), signal.SIGSTOP)
37 s.close()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698