Add support for unicast ethernet faces to utility and helper methods.

Refs #5321

Change-Id: I2e28d092853fc21f59109cfbc23b946d30626a8c
diff --git a/minindn/util.py b/minindn/util.py
index 23092da..d44f20c 100644
--- a/minindn/util.py
+++ b/minindn/util.py
@@ -28,6 +28,10 @@
 
 from mininet.cli import CLI
 
+from mininet.log import error
+
+import re
+
 sshbase = ['ssh', '-q', '-t', '-i/home/mininet/.ssh/id_rsa']
 scpbase = ['scp', '-i', '/home/mininet/.ssh/id_rsa']
 devnull = open('/dev/null', 'w')
@@ -84,6 +88,17 @@
     return host.popen(cmd, cwd=host.params['params']['homeDir'],
                       env=popenGetEnv(host, envDict), **params)
 
+def MACToEther(mac):
+    # We use the regex filters from face-uri.cpp in ndn-cxx with minor modifications
+    if re.match('^\[((?:[a-fA-F0-9]{1,2}\:){5}(?:[a-fA-F0-9]{1,2}))\]$', mac):
+        return mac
+    elif re.match('^((?:[a-fA-F0-9]{1,2}\:){5}(?:[a-fA-F0-9]{1,2}))$', mac):
+        # URI syntax requires nfdc to use brackets for MAC and ethernet addresses due
+        # to the use of colons as separators. Incomplete brackets are a code issue.
+        return '[%s]' % mac
+    error('Potentially malformed MAC address, passing without alteration: %s' % mac)
+    return mac
+
 class MiniNDNCLI(CLI):
     prompt = 'mini-ndn> '
     def __init__(self, mininet, stdin=sys.stdin, script=None):