7 from optparse import OptionParser
12 usage = ("usage: %prog -a <address> -S <vif-socket> ")
14 parser = OptionParser(usage = usage)
16 parser.add_option("-a", "--address", dest="address",
17 help = "Socket address to send file descriptor to", type="str")
18 parser.add_option("-S", "--vif-socket", dest="vif_socket",
19 help = "Name for the unix socket to request the TAP file descriptor",
20 default = "tap.sock", type="str")
22 (options, args) = parser.parse_args()
24 return (options.address, options.vif_socket)
26 if __name__ == '__main__':
28 (address, vif_socket) = get_options()
30 # This script sends a message (PASSFD_MSG) to the process that created
31 # the TUN/TAP device to request that it sens the file descriptor associated
32 # to the TUN/TAP to another process. The other process is waiting for
33 # the file descriptor on 'address'
34 sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
35 sock.connect(vif_socket)
36 emsg = base64.b64encode(PASSFD_MSG)
38 encoded = "%s|%s\n" % (emsg, eargs)