Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Parse Google Protocol Buffers datagram without .proto file?

is it possible to parse an incoming google protocol buffers datagram without any .proto file? I merely now its been serialized using protocol buffers but have no idea about the IDL file.

I'm looking for a way to just iterate through any value by some sort of reflection? Is this possible?

Thank you!

like image 299
Hhut Avatar asked Jan 31 '13 13:01

Hhut


1 Answers

protoc --decode_raw < my_file

You need to take the following things into account when inspecting the output:

  • None of the field names are visible, just the tag numbers.
  • All varint-fields are shown as integers. This is ok for most types, but sint* will appear in the "zigzagged" format.
  • Doubles and floats will be shown as hex.
  • Bytes, string fields and submessages all appear the same, i.e. just a bunch of bytes.

If you want to decode the messages programmatically, you can write your own .proto file after you have figured out what the fields mean using the above method.

like image 186
jpa Avatar answered Sep 29 '22 10:09

jpa