def connection_open_vhost_parser(): parser = h.sequence( h.ch('\x01'), # type h.uint16(), # Channel h.uint32(), # Length h.token("\x00\x0a"), # Class h.token("\x00\x28"), # Method # Arguments h.uint16(), # Virtual-Host h.token("\x00\x00"), # most likely going to change this according to the message h.end_p() ) return parser
def connection_tune_ok_parser(): parser = h.sequence( h.ch('\x01'), # type h.uint16(), # Channel h.uint32(), # Length h.token("\x00\x0a"), # Class h.token("\x00\x1f"), # Method # Arguments h.uint16(), # Channel max h.uint32(), # Frame max h.uint16(), # Heartbeat h.end_p() ) return parser
def connection_close_parser(): parser = h.sequence( h.ch('\x01'), # type h.uint16(), # Channel h.uint32(), # Length h.token("\x00\x0a"), # Class h.token("\x00\x32"), # Method # Arguments h.uint16(), # Replay-code #Replay-text h.uint16(), # Class-Id h.uint16(), # Method-Id h.end_p() ) return parser
def basic_consume_parser(): parser = h.sequence( h.ch('\x01'), # type h.uint16(), # Channel h.uint32(), # Length h.token("\x00\x3c"), # Class h.token("\x00\x14"), # Method # Arguments h.uint16(), # Ticket # how do you parse that long message? #Queue h.many(h.ch_range('\x00', '\xff')), # consumer-tag h.end_p() ) return parser
def queue_declare_parser(): parser = h.sequence( h.ch('\x01'), # type h.uint16(), # Channel h.uint32(), # Length h.token("\x00\x32"), # Class h.token("\x00\x0a"), # Method # Arguments h.uint16(), # Ticket # how do you parse that long message?#Queue h.many(h.ch_range('\x00', '\xff')), #When you parse this out... (, ,, , 0L, ('','','','')) h.end_p() ) return parser
def connection_start_ok_parser(): parser = h.sequence( h.ch('\x01'), # type h.uint16(), # Channel h.uint32(), # Length h.token("\x00\x0a"), # Class h.token("\x00\x0b"), # Method h.end_p() ) return parser
def basic_deliver_parser(): parser = h.sequence( h.ch('\x01'), # type h.uint16(), # Channel h.uint32(), # Length h.token("\x00\x3c"), # Class h.token("\x00\x3c"), # Method h.end_p() ) return parser
def length_block(): parser = h.sequence( h.ch('\x01'), h.uint16(), h.and_(h._h_length_value(h.uint32(), h.ch_range('\x00', '\xff'))), h.uint32(), h.many(h.ch_range('\x00', '\xff')), h.end_p()) return parser
def peak_fast_meter_configuration_block(): header = h.token("\xa5\xc3") length = h.uint8() scale_factors = h.uint8() analog = h.uint8() samples = h.uint8() digital = h.uint8() analog_offset = h.uint16() timestamp_offset = h.uint16() digital_offset = h.uint16() analog_signal = h.repeat_n(h.uint8(), 10) all_signals = h.repeat_n(analog_signal, 5) checksum = h.ch_range('\x00', '\xff') calculation_blocks = h.uint8() parser = h.sequence(header, length, h.uint8(), h.uint8(), scale_factors, analog, samples, digital, calculation_blocks, analog_offset, timestamp_offset, digital_offset, all_signals, checksum) return parser
def connection_close_ok_parser(): parser = h.sequence( h.ch('\x01'), # type h.uint16(), # Channel h.uint32(), # Length h.token("\x00\x0a"), # Class h.token("\x00\x33"), # Method # No arguments h.end_p() ) return parser
def channel_open_ok_parser(): parser = h.sequence( h.ch('\x01'), # type h.uint16(), # Channel h.uint32(), # Length h.token("\x16\x28"), # Class h.token("\x00\x0b"), # Method # Arguments h.uint32(), # Channel-Id h.end_p() ) return parser
def basic_consume_ok_parser(): parser = h.sequence( h.ch('\x01'), # type h.uint16(), # Channel h.uint32(), # Length h.token("\x00\x3c"), # Class h.token("\x00\x15"), # Method # Arguments # consumer-tag h.end_p() ) return parser
def channel_open_parser(): parser = h.sequence( h.ch('\x01'), # type h.uint16(), # Channel h.uint32(), # Length h.token("\x00\x14"), # Class h.token("\x00\x0a"), # Method # Arguments h.ch('\x00'), # Out-of-bounds h.end_p() ) return parser
def relay_operate_configuration(): header = h.token('\xa5\xce') length = h.uint8() breaker_bits = h.uint8() remote_bits = h.uint16() remote_pulse = h.uint8() reserved = h.uint8() parser = h.sequence( header, length, breaker_bits, remote_bits, remote_pulse, reserved, h.repeat_n(h.uint8(), 2), h.repeat_n(h.sequence(h.uint8(), h.uint8(), h.uint8()), 32), h.uint8()) return parser
def fast_message_block(): header = h.token('\xa5\x46') length = h.uint8() routing_address = h.repeat_n(h.uint8(), 5) status = h.uint8() function_code = h.uint8() sequence_byte = h.uint8() response_number = h.uint8() any_value = h.many1(h.ch_range('\x00', '\xff')) crc = h.uint16() parser = h.sequence(header, length, routing_address, status, function_code, sequence_byte, response_number, any_value) return parser
def queue_declare_ok_parser(): parser = h.sequence( h.ch('\x01'), # type h.uint16(), # Channel h.uint32(), # Length h.token("\x00\x32"), # Class h.token("\x00\x0b"), # Method # Arguments #how do you parse that long message? #Queue h.many(h.ch_range('\x00', '\xff')), #h.uint32(), # message-count #h.uint32(), # consumer-count h.end_p() ) return parser
def setUpClass(cls): cls.parser = h.uint16()
import hammer as h abcd = h.sequence(h.many1(h.uint8()), h.many(h.uint16()), h.sequence(h.uint8())) efgh = h.sequence(h.many1(h.uint8()), h.many(h.uint16()), h.sequence(h.uint8()))