예제 #1
0
 def test_decoding_multi_option_hop_by_hop(self):
     hop_by_hop_binary_packet = [
         0x3a, 0x00, 0x00, 0x01,
         0x03, 0x00, 0x00, 0x00]
     
     d = ImpactDecoder.HopByHopDecoder()        
     parsed_packet = d.decode(hop_by_hop_binary_packet)
     
     next_header = parsed_packet.get_next_header()
     header_extension_length = parsed_packet.get_header_extension_length()
     options = parsed_packet.get_options()
     
     self.assertEqual(2, len(options), "Simple Hop By Hop Parsing - Wrong Quantity of Options")
     
     pad1_option = options[0]
     pad1_option_type = pad1_option.get_option_type()
     
     padn_option = options[1]
     padn_option_type = padn_option.get_option_type()
     padn_option_length = padn_option.get_option_length()
     
     self.assertEqual(parsed_packet.get_header_type(), 0, "Hop By Hop with multiple options parsing - Incorrect packet")
     self.assertEqual(next_header, 58, "Hop By Hop with multiple options parsing - Incorrect next header value")
     self.assertEqual(header_extension_length, 0, "Hop By Hop with multiple options parsing - Incorrect size")
     self.assertEqual(pad1_option_type, 0, "Hop By Hop with multiple options parsing - Incorrect option type")
     self.assertEqual(padn_option_type, 1, "Hop By Hop with multiple options parsing - Incorrect option type")
     self.assertEqual(padn_option_length, 3, "Hop By Hop with multiple options parsing - Incorrect option size")
 def test_decoding_simple_hop_by_hop(self):
     hop_by_hop_binary_packet = [
         0x2b, 0x01, 0x01, 0x0C,
         0x00, 0x00, 0x00, 0x00,
         0x00, 0x00, 0x00, 0x00,
         0x00, 0x00, 0x00, 0x00]
     
     d = ImpactDecoder.HopByHopDecoder()        
     parsed_packet = d.decode(hop_by_hop_binary_packet)
     
     next_header = parsed_packet.get_next_header()
     header_extension_length = parsed_packet.get_header_extension_length()
     options = parsed_packet.get_options()
     
     self.assertEquals(1, len(options), "Simple Hop By Hop Parsing - Wrong Quantity of Options")
     
     padn_option = options[0]
     padn_option_type = padn_option.get_option_type()
     padn_option_length = padn_option.get_option_length()
     
     self.assertEquals(parsed_packet.get_header_type(), 0, "Simple Hop By Hop Parsing - Incorrect packet")
     self.assertEquals(next_header, 43, "Simple Hop By Hop Parsing - Incorrect next header value")
     self.assertEquals(header_extension_length, 1, "Simple Hop By Hop Parsing - Incorrect size")
     self.assertEquals(padn_option_type, 1, "Simple Hop By Hop Parsing - Incorrect option type")
     self.assertEquals(padn_option_length, 12, "Simple Hop By Hop Parsing - Incorrect option size")