Changeset 4867
- Timestamp:
- 05/31/09 18:00:15 (4 years ago)
- Files:
-
- 1 modified
-
branch/zion/umit/zion/scan/sniff.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branch/zion/umit/zion/scan/sniff.py
r4866 r4867 253 253 return "\n".join(s) 254 254 255 FRAME_TYPES = {'sll': SLL, 256 'ether': Ethernet, 257 'ipv4': IPv4, 258 'ipv6': IPv6, 259 'tcp': TCP} 260 255 261 class Packet(object): 256 262 """ … … 282 288 # Disassembling first frame. 283 289 # There are two options to make this work right: 290 # 284 291 # 1. Disassembly the link layer and see what the next protocol on 285 292 # their data fields; 286 293 # 2. Ignore the first `n' bytes of link layer data. Where `n' stands 287 294 # for size of link layer protocol header. 295 # 288 296 # The second one can fail when the link layer protocol has a variable 289 297 # header length. So, is not correct do this way. Moreover, we can be … … 346 354 proto, attr = field.split('.') 347 355 348 for p in self.__packet: 349 if proto == 'ether' and type(p) == Ethernet and hasattr(p, attr): 350 return getattr(p, attr) 351 elif proto == 'ipv4' and type(p) == IPv4 and hasattr(p, attr): 352 return getattr(p, attr) 353 elif proto == 'ipv6' and type(p) == IPv6 and hasattr(p, attr): 354 return getattr(p, attr) 355 elif proto == 'tcp' and type(p) == TCP and hasattr(p, attr): 356 return getattr(p, attr) 356 if proto in FRAME_TYPES.keys(): 357 for p in self.__packet: 358 if hasattr(p, attr) and type(p) == FRAME_TYPES[proto]: 359 return getattr(p, attr) 357 360 358 361 return None
