2 # NEPI, a framework to manage network experiments
3 # Copyright (C) 2013 INRIA
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License version 2 as
7 # published by the Free Software Foundation;
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17 # Author: Alina Quereilhac <alina.quereilhac@inria.fr>
24 from optparse import OptionParser
29 usage = ("usage: %prog -N <vif-name> -S <socket-name>")
31 parser = OptionParser(usage = usage)
33 parser.add_option("-N", "--vif-name", dest="vif_name",
34 help = "The name of the virtual interface, or a "
35 "unique numeric identifier to name the interface "
36 "if GRE mode is used.",
39 parser.add_option("-S", "--socket-name", dest="socket_name",
40 help = "Name for the unix socket used to interact with this process",
43 (options, args) = parser.parse_args()
45 return (options.socket_name, options.vif_name)
47 if __name__ == '__main__':
49 (socket_name, vif_name) = get_options()
51 # If a socket name is sent, send the STOP message and wait for a reply
52 sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
54 sock.connect(socket_name)
55 encoded = base64.b64encode(STOP_MSG)
56 sock.send("%s\n" % encoded)
57 reply = sock.recv(1024)
58 reply = base64.b64decode(reply)
61 print("Did not properly shutdown device")