def destination(tokeniser): data = tokeniser() if data.count('.') == 3 and data.count(':') == 0: ip, netmask = data.split('/') raw = concat_bytes_i(character(int(_)) for _ in ip.split('.')) yield Flow4Destination(raw, int(netmask)) elif data.count('/') == 1: ip, netmask = data.split('/') offset = 0 yield Flow6Destination(IP.pton(ip), int(netmask), int(offset)) else: ip, netmask, offset = data.split('/') yield Flow6Destination(IP.pton(ip), int(netmask), int(offset))
def destination(tokeniser): data = tokeniser() if data.count('.') == 3 and data.count(':') == 0: ip, netmask = data.split('/') raw = b''.join(bytes([int(_)]) for _ in ip.split('.')) yield Flow4Destination(raw, int(netmask)) elif data.count('/') == 1: ip, netmask = data.split('/') offset = 0 yield Flow6Destination(IP.pton(ip), int(netmask), int(offset)) else: ip, netmask, offset = data.split('/') yield Flow6Destination(IP.pton(ip), int(netmask), int(offset))
def destination(tokeniser): data = tokeniser() if data.count('/') == 1: ip, netmask = data.split('/') raw = ''.join(chr(int(_)) for _ in ip.split('.')) yield Flow4Destination(raw, int(netmask)) return else: ip, netmask, offset = data.split('/') yield Flow6Destination(IP.pton(ip), int(netmask), int(offset))
def destination(self, scope, name, command, tokens): try: data = tokens.pop(0) if data.count('/') == 1: ip, netmask = data.split('/') raw = ''.join(chr(int(_)) for _ in ip.split('.')) if not scope[-1]['announce'][-1].nlri.add( Flow4Destination(raw, int(netmask))): return self.error.set('Flow can only have one destination') else: ip, netmask, offset = data.split('/') change = scope[-1]['announce'][-1] # XXX: This is ugly change.nlri.afi = AFI(AFI.ipv6) if not change.nlri.add( Flow6Destination(IP.pton(ip), int(netmask), int(offset))): return self.error.set('Flow can only have one destination') return True except (IndexError, ValueError): return self.error.set(self.syntax)