+function ifnameof(self, x)
+ if utl.instanceof(x, interface) then
+ return x:name()
+ elseif utl.instanceof(x, protocol) then
+ return x:ifname()
+ elseif type(x) == "string" then
+ return x:match("^[^:]+")
+ end
+end
+
+function get_protocol(self, protoname, netname)
+ local v = _protocols[protoname]
+ if v then
+ return v(netname or "__dummy__")
+ end
+end
+
+function get_protocols(self)
+ local p = { }
+ local _, v
+ for _, v in ipairs(_protocols) do
+ p[#p+1] = v("__dummy__")
+ end
+ return p
+end
+
+function register_protocol(self, protoname)
+ local proto = utl.class(protocol)
+
+ function proto.__init__(self, name)
+ self.sid = name
+ end
+
+ function proto.proto(self)
+ return protoname
+ end
+
+ _protocols[#_protocols+1] = proto
+ _protocols[protoname] = proto
+
+ return proto
+end
+
+function register_pattern_virtual(self, pat)
+ IFACE_PATTERNS_VIRTUAL[#IFACE_PATTERNS_VIRTUAL+1] = pat
+end
+
+