def link(self, value): if type(value) is str: try: value = Link.resolve(value) except KeyError: raise ValueError() capi.rtnl_addr_set_link(self._rtnl_addr, value._rtnl_link) # ifindex is immutable but we assume that if _orig does not # have an ifindex specified, it was meant to be given here if capi.rtnl_addr_get_ifindex(self._orig) == 0: capi.rtnl_addr_set_ifindex(self._orig, value.ifindex)
def ifindex(self): """interface index""" return capi.rtnl_addr_get_ifindex(self._rtnl_addr)