Package dpkt :: Module aim
[hide private]
[frames] | no frames]

Source Code for Module dpkt.aim

 1  # $Id: aim.py 271 2006-01-11 16:03:33Z dugsong $ 
 2   
 3  """AOL Instant Messenger.""" 
 4   
 5  import dpkt 
 6  import struct 
 7   
 8  # OSCAR: http://iserverd1.khstu.ru/oscar/ 
 9   
10 -class FLAP(dpkt.Packet):
11 __hdr__ = ( 12 ('ast', 'B', 0x2a), # '*' 13 ('type', 'B', 0), 14 ('seq', 'H', 0), 15 ('len', 'H', 0) 16 )
17 - def unpack(self, buf):
18 dpkt.Packet.unpack(self, buf) 19 if self.ast != 0x2a: 20 raise dpkt.UnpackError('invalid FLAP header') 21 if len(self.data) < self.len: 22 raise dpkt.NeedData, '%d left, %d needed' % (len(self.data), self.len)
23
24 -class SNAC(dpkt.Packet):
25 __hdr__ = ( 26 ('family', 'H', 0), 27 ('subtype', 'H', 0), 28 ('flags', 'H', 0), 29 ('reqid', 'I', 0) 30 )
31
32 -def tlv(buf):
33 n = 4 34 try: 35 t, l = struct.unpack('>HH', buf[:n]) 36 except struct.error: 37 raise dpkt.UnpackError 38 v = buf[n:n+l] 39 if len(v) < l: 40 raise dpkt.NeedData 41 buf = buf[n+l:] 42 return (t,l,v, buf)
43 44 # TOC 1.0: http://jamwt.com/Py-TOC/PROTOCOL 45 46 # TOC 2.0: http://www.firestuff.org/projects/firetalk/doc/toc2.txt 47