- # find out whether EID is ip4 prefix, ip6 prefix or MAC
- if self.eid.find("/") != -1:
- if self.eid.find(":") == -1:
- self.eid_type = LispEIDType.IP4
- self.data_length = 4
- else:
- self.eid_type = LispEIDType.IP6
- self.data_length = 16
-
- self.eid_address = self.eid.split("/")[0]
- self.prefix_length = int(self.eid.split("/")[1])
- elif self.eid.count(":") == 5: # MAC address
- self.eid_type = LispEIDType.MAC
- self.eid_address = self.eid
- self.prefix_length = 0
- self.data_length = 6
- else:
- raise Exception('Unsupported EID format {!s}!'.format(eid))
+ @property
+ def eid_type(self):
+ return self._type
+
+ @property
+ def address(self):
+ if self.eid_type == LispEIDType.PREFIX:
+ return self.prefix
+ elif self.eid_type == LispEIDType.MAC:
+ return self.mac
+ elif self.eid_type == LispEIDType.NSH:
+ return Exception("Unimplemented")