1 # RADIUS DAS extensions to pyrad
2 # Copyright (c) 2014, Jouni Malinen <j@w1.fi>
4 # This software may be distributed under the terms of the BSD license.
5 # See README for more details.
12 class DisconnectPacket(pyrad.packet.Packet):
13 def __init__(self, code=pyrad.packet.DisconnectRequest, id=None,
14 secret=None, authenticator=None, **attributes):
15 pyrad.packet.Packet.__init__(self, code, id, secret, authenticator,
18 def RequestPacket(self):
19 attr = self._PktEncodeAttributes()
22 self.id = random.randrange(0, 256)
24 header = struct.pack('!BBH', self.code, self.id, (20 + len(attr)))
25 self.authenticator = hashlib.md5(header[0:4] + 16 * b'\x00' + attr
26 + self.secret).digest()
27 return header + self.authenticator + attr
29 class CoAPacket(pyrad.packet.Packet):
30 def __init__(self, code=pyrad.packet.CoARequest, id=None,
31 secret=None, authenticator=None, **attributes):
32 pyrad.packet.Packet.__init__(self, code, id, secret, authenticator,
35 def RequestPacket(self):
36 attr = self._PktEncodeAttributes()
39 self.id = random.randrange(0, 256)
41 header = struct.pack('!BBH', self.code, self.id, (20 + len(attr)))
42 self.authenticator = hashlib.md5(header[0:4] + 16 * b'\x00' + attr
43 + self.secret).digest()
44 return header + self.authenticator + attr