Menu

Unber: where is the value?

Help
Stéphane
2012-09-25
2013-03-19
  • Stéphane

    Stéphane - 2012-09-25

    Hello

    I use this command :

    unber "file" | grep WORD > output.txt

    In the output.txt i have:

    <P O="123" T="" TL="2" V="8" A="GraphicString">WORD</P>

    I would like to know where is the value matching with "WORD".

    Can you help me?

    Thanks.

     
  • Lev Walkin

    Lev Walkin - 2012-09-25

    It is in the file named "file", at byte offset 123.

     
  • Stéphane

    Stéphane - 2012-09-26

    Thanks, it's in "file" ou in "output"?

    The only difference is output is the file decoded.

    The offset is the line, isn't it?

    I want the to know where is the value who correspond with "WORD".

    Is it the number "25"?

     
  • Lev Walkin

    Lev Walkin - 2012-09-26

    I fail to understand the question. Would you please rephrase it differently?

     
  • Stéphane

    Stéphane - 2012-09-26

    In the file "output.txt", I have 200 000 lines, so I search the line containing "WORD".

    So, I have this line :

    <P O="123" T="" TL="2" V="8" A="GraphicString">WORD</P>

    Normally, there is a value in this line matching with "WORD", and I want to know where is it.

    O = Offset of the encoded element in the unber input stream.
    T = The tag class and value in human readable form.
    V = The  length  of the value (V, encoded by the L), may be "Indefinite".

    Where is my value? I don't really know what are this letters.

     
  • Stéphane

    Stéphane - 2012-09-26

    When I decode with asn1c, I have that:
                     <MeasValue>
                                <measObjInstId>41 42 49 53 49 50 2E 52 58 4F 54 47 2D 35 31</measObjInstId>
                                <measResults>
                                        <iValue>63576</iValue>
                                        <iValue>60332</iValue>
                                        <iValue>0</iValue>
                                        <iValue>900</iValue>
                                        <iValue>131844</iValue>
                                        <iValue>0</iValue>
                                </measResults>
                                <suspectFlag><false/></suspectFlag>
                            </MeasValue>

    There is many value but "measObjInstId" is in HEX, and i can't find "WORD".

    So I use "unber" for find WORD but now I can't find the value.

     
  • Lev Walkin

    Lev Walkin - 2012-09-26

    If I understand you correctly, you'd like to know which field in the ASN.1 specification this WORD value corresponds to. You can infer this information, although not as quickly as you'd like.

    The "unber" tool just decodes the BER-encoded binary byte stream. That BER stream must have been produced by the BER-compliant encoder, possibly with the help of some ASN.1 compiler and the corresponding ASN.1 module specification. The specification text (the "measObjInstId") is not retained in the BER-encoded binary byte stream. Unlike XML, the names which you see in the ASN.1 specifications do not get stored in BER files. Therefore, the "unber" tool cannot pinpoint the corresponding ASN.1 type by scanning the BER output. The "unber" tool has no knowledge of the ASN.1 specification involved in producing that BER file. It just outputs the raw BER structure that it sees in a little bit more readable way, and that structure does not contain the ASN.1 type names.

    However, the BER structure contains the tag names that you can manually associate with the corresponding ASN.1 type.

    Unfortunately, the version of MEAS specification that I have does not have the GraphicString type, so I suspect you either have a different version spec or that spec is possibly broken. It is almost certainly broken, since I see in my ASN.1 spec that measObjInstId is of type PrintableString, not of type GraphicString, and that spec would have ben outputted using human readable characters instead of hexadecimal bytes. The hexadecimal bytes in your <measObjInstId> means that asn1c thinks the string is not supposed to contain human readable values, and consequently does not print them as human readable values.

    You can try to convert the values of <measObjInstId> back to string to see its contents:

    > echo "41 42 49 53 49 50 2E 52 58 4F 54 47 2D 35 31" | xxd -r
    BISIP.RXOTG-51
    >

    This is likely the string that you were looking for.

    In order to make asn1c generate code which would print this as a human readable string, you'd have to trick it into thinking this is a PrintableString. Somewhat like this: instead of

    measObjInstId GraphicString

    you'd put

    measObjInstId  IMPLICIT PrintableString

    into the spec. This way, the value will be printed as human readable one.

     

Log in to post a comment.