0

I have .Proto file as shown below

message Port {
    repeated Info info = 1;
}

message Info {
    required string if_name = 1 ;
    optional Stats in_stats = 2;

}

message Stats {

    required uint64 pkts = 1 ;
    repeated Accounting fc_stats = 2;
}

message Accounting {
     optional string family = 1 ;
}

extend Sensors {
    optional Port InterfaceExt = 7;
}

I am parsing it and every thing is working as fine except the "Repeated" Accounting element inside stats is not parsing correct data.

Also the Array list Size is Zero for Accounting element, meaning it is not populating properly, however if i print the sensor object it is bringing data in raw format as shown below,

info {
        if_name: "xe"
        in_stats {
          pkts: 27
          2: "\n\004IPv4\020\003\030\343\355\277\240e \200\343\355\277\240e"
        }
    }

Any idea what's wrong with it?

1 Answer 1

1

Each field need to have a unique id to distinguish it.

Your pkts and fc_stats both have an id of 1

I suggest making one of them 2.

Note: it can decode 1 as pkts but it doesn't know what to decode 2 as.

Sign up to request clarification or add additional context in comments.

4 Comments

@Ammad I would rerun your tests because it is field id 2 it couldn't decode.
I did rerun that and same result. My actual prorto file have id = 1 and 2.
I agree that the only explanation is that fc_stats is not defined or does not have ID 2 inside whatever program produced the text format output in the question. Make sure you've regenerated your generated code files and recompiled everything.
@PeterLawrey, Yes that was the issue. Proto file have right numbering but data is coming with wrong id i.e. 1 for both fields, thus able to decode first line but not second.info { if_name: "xe" in_stats { pkts: 27 1: "\n\004IPv4\020\003\030\343\355\277\240e \200\343\355\277\240e" } } Putting 2: instead of 1: fix that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.