Example #1
0
def canonicalized_ip(ip):
    if isinstance(ip, str):
        return ip_from_user(ip)
    elif isinstance(ip, IP):
        return ip
    else:
        raise TypeError('unsupported ip form')
Example #2
0
def canonicalized_ip(ip):
    if isinstance(ip, str):
        return ip_from_user(ip)
    elif isinstance(ip, IP):
        return ip
    else:
        raise TypeError('unsupported ip form')
Example #3
0
 def ip(self, val):
     if isinstance(val, str):
         if '/' in val:
             val, net_len = val.split('/')
             net_len = int(net_len)
             mask = '1' * net_len + '0' * (32 - net_len)
             self.mask = IP.from_bits(bitarray(mask))
     self._ip = ip_from_user(val)
Example #4
0
 def ip(self, val):
     if isinstance(val, str):
         if '/' in val:
             val, net_len = val.split('/')
             net_len = int(net_len)
             mask = '1' * net_len + '0' * (32 - net_len)
             self.mask = IP.from_bits(bitarray(mask))
     self._ip = ip_from_user(val)
Example #5
0
 def ip(self, val):
     if isinstance(val, str):
         if '/' not in val:
             raise ValueError(
                 'interface need subnet mask (e.g. "{}/24")'.format(val))
         val, net_len = val.split('/')
         net_len = int(net_len)
         mask = '1' * net_len + '0' * (32 - net_len)
         self.mask = IP.from_bits(bitarray(mask))
     self._ip = ip_from_user(val)
Example #6
0
 def ip(self, val):
     if isinstance(val, str):
         if '/' not in val:
             raise ValueError(
                 'interface need subnet mask (e.g. "{}/24")'.format(val))
         val, net_len = val.split('/')
         net_len = int(net_len)
         mask = '1' * net_len + '0' * (32 - net_len)
         self.mask = IP.from_bits(bitarray(mask))
     self._ip = ip_from_user(val)
Example #7
0
    def __init__(self, ip=None, mac=None):
        super(Host, self).__init__(n_tips=1)
        self.tip = self.tips[0]
        self.nic = NIC(self.tip)
        self.libsocket = LibSocket(self)

        if mac is None:
            mac = self.index
        if ip is None:
            ip = '1.0.0.{}'.format(self.index)
        self.ip = ip_from_user(ip)
        self.mac = mac_from_user(mac)

        self.ip2mac = CacheTable(entry_duration=1000)
        self.arp_table = self.ip2mac
        self.avail_ports = defaultdict(lambda: 49152)
        self.pending_packets = defaultdict(deque)
        self.pending_frames = deque()
        self.sockets = {}

        mint.worker(self.run)
Example #8
0
    def __init__(self, ip=None, mac=None):
        super(Host, self).__init__(n_tips=1)
        self.tip = self.tips[0]
        self.nic = NIC(self.tip)
        self.libsocket = LibSocket(self)

        if mac is None:
            mac = self.index
        if ip is None:
            ip = '1.0.0.{}'.format(self.index)
        self.ip = ip_from_user(ip)
        self.mac = mac_from_user(mac)

        self.ip2mac = CacheTable(entry_duration=1000)
        self.arp_table = self.ip2mac
        self.avail_ports = defaultdict(lambda: 49152)
        self.pending_packets = defaultdict(deque)
        self.pending_frames = deque()
        self.sockets = {}

        mint.worker(self.run)
Example #9
0
 def mask(self, val):
     self._mask = ip_from_user(val)
Example #10
0
 def mask(self, val):
     self._mask = ip_from_user(val)