- # 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 {}!'.format(eid))
-
- def __str__(self):
- if self.eid_type == LispEIDType.IP4:
- return socket.inet_pton(socket.AF_INET, self.eid_address)
- elif self.eid_type == LispEIDType.IP6:
- return socket.inet_pton(socket.AF_INET6, self.eid_address)