2
2
# ether.py - lookup functions for ethernet addresses
4
# Copyright (C) 2010, 2011, 2012 Arthur de Jong
4
# Copyright (C) 2010, 2011, 2012, 2013 Arthur de Jong
6
6
# This library is free software; you can redistribute it and/or
7
7
# modify it under the terms of the GNU Lesser General Public
40
41
filter = '(objectClass=ieee802Device)'
43
class Search(common.Search):
44
class Search(search.LDAPSearch):
45
46
case_insensitive = ('cn', )
46
47
limit_attributes = ('cn', 'macAddress')
47
48
required = ('cn', 'macAddress')
51
# we need a custom mk_filter because this is an | query
52
if 'macAddress' in self.parameters:
53
ether = self.parameters['macAddress']
54
alt_ether = ':'.join('%02x' % int(x, 16) for x in ether.split(':'))
55
return '(&%s(|(%s=%s)(%s=%s)))' % (self.filter,
56
attmap['macAddress'], ether,
57
attmap['macAddress'], alt_ether)
58
return super(Search, self).mk_filter()
50
61
class Cache(cache.Cache):
64
CREATE TABLE IF NOT EXISTS `ether_cache`
65
( `cn` TEXT NOT NULL COLLATE NOCASE,
66
`macAddress` TEXT NOT NULL COLLATE NOCASE,
67
`mtime` TIMESTAMP NOT NULL,
68
UNIQUE (`cn`, `macAddress`) );
54
72
class EtherRequest(common.Request):