Merge TCP handshake stuff
[nepi.git] / src / nepi / testbeds / planetlab / tunproto.py
index 0f4537a..13e0c03 100644 (file)
@@ -26,6 +26,7 @@ class TunProtoBase(object):
         self.port = 15000
         self.mode = 'pl-tun'
         self.key = key
+        self.cross_slice = False
         
         self.home_path = home_path
        
@@ -198,9 +199,10 @@ class TunProtoBase(object):
         local_snat = local.snat
         local_txq  = local.txqueuelen
         local_p2p  = local.pointopoint
-        local_cipher = local.tun_cipher
-        local_mcast = local.multicast
-        local_bwlim = local.bwlimit
+        local_cipher=local.tun_cipher
+        local_mcast= local.multicast
+        local_bwlim= local.bwlimit
+        local_mcastfwd = local.multicast_forwarder
         
         if not local_p2p and hasattr(peer, 'address'):
             local_p2p = peer.address
@@ -231,7 +233,8 @@ class TunProtoBase(object):
             "-t", str(check_proto),
             "-A", str(local_addr),
             "-M", str(local_mask),
-            "-C", str(local_cipher)]
+            "-C", str(local_cipher),
+            ]
         
         if check_proto == 'fd':
             passfd_arg = str(peer_addr)
@@ -244,8 +247,12 @@ class TunProtoBase(object):
                 "--pass-fd", passfd_arg
             ])
         elif check_proto == 'gre':
+            if self.cross_slice:
+                args.extend([
+                    "-K", str(self.key.strip('='))
+                ])
+
             args.extend([
-                "-K", str(min(local_port, peer_port)),
                 "-a", str(peer_addr),
             ])
         # both udp and tcp
@@ -267,14 +274,14 @@ class TunProtoBase(object):
             args.append("-N")
         elif local_cap == 'pcap':
             args.extend(('-c','pcap'))
-        if local_mcast:
-            args.append("--multicast")
         if local_bwlim:
             args.extend(("-b",str(local_bwlim*1024)))
         if filter_module:
             args.extend(("--filter", filter_module))
         if filter_args:
             args.extend(("--filter-args", filter_args))
+        if local_mcast and local_mcastfwd:
+            args.extend(("--multicast-forwarder", local_mcastfwd))
 
         self._logger.info("Starting %s", self)
         
@@ -324,7 +331,7 @@ class TunProtoBase(object):
             
             # Connected?
             (out,err),proc = server.eintr_retry(server.popen_ssh_command)(
-                "cd %(home)s ; grep -c Connected capture" % dict(
+                "cd %(home)s ; grep -a -c Connected capture" % dict(
                     home = server.shell_escape(self.home_path)),
                 host = local.node.hostname,
                 port = None,
@@ -342,7 +349,7 @@ class TunProtoBase(object):
 
             # At least listening?
             (out,err),proc = server.eintr_retry(server.popen_ssh_command)(
-                "cd %(home)s ; grep -c Listening capture" % dict(
+                "cd %(home)s ; grep -a -c Listening capture" % dict(
                     home = server.shell_escape(self.home_path)),
                 host = local.node.hostname,
                 port = None,
@@ -381,7 +388,7 @@ class TunProtoBase(object):
             # Inspect the trace to check the assigned iface
             local = self.local()
             if local:
-                cmd = "cd %(home)s ; grep 'Using tun:' capture | head -1" % dict(
+                cmd = "cd %(home)s ; grep -a 'Using tun:' capture | head -1" % dict(
                             home = server.shell_escape(self.home_path))
                 for spin in xrange(30):
                     (out,err),proc = server.eintr_retry(server.popen_ssh_command)(