Bug fix on ndnpingclient and experiment script
Mininet host object is passed as a prefix from experiment
to ndnpingclient, string replacement operation on the
prefix fails at the client which crashes the Mini-NDN
Change-Id: I36c1f9e2e455321d8c650fd9711088b7e5ef2b22
diff --git a/minindn/util.py b/minindn/util.py
index 82fcdac..b7d060c 100644
--- a/minindn/util.py
+++ b/minindn/util.py
@@ -24,6 +24,8 @@
import sys
from os.path import isfile
from subprocess import call
+from six.moves.urllib.parse import quote
+
from mininet.cli import CLI
from mn_wifi.cli import CLI as CLI_wifi
@@ -31,6 +33,17 @@
scpbase = ['scp', '-i', '/home/mininet/.ssh/id_rsa']
devnull = open('/dev/null', 'w')
+def getSafeName(namePrefix):
+ """
+ Check if the prefix/string is safe to use with ndn commands or not.
+ return safe prefix.
+ :param namePrefix: name of the prefix
+ """
+ # remove redundant "/"es, multiple "/"es are an invalid representation for empty name component
+ # https://named-data.net/doc/NDN-packet-spec/current/changelog.html#version-0-3
+ namePrefix= "/" + ("/".join(filter(None, namePrefix.split("/"))))
+ return quote(namePrefix, safe='/')
+
def ssh(login, cmd):
rcmd = sshbase + [login, cmd]
call(rcmd, stdout=devnull, stderr=devnull)
@@ -80,4 +93,4 @@
class MiniNDNWifiCLI(CLI_wifi):
prompt = 'mini-ndn-wifi> '
def __init__(self, mininet, stdin=sys.stdin, script=None):
- CLI_wifi.__init__(self, mininet, stdin, script)
\ No newline at end of file
+ CLI_wifi.__init__(self, mininet, stdin, script)