This is our old Q&A Site. Please post any new questions and answers at ask.wireshark.org.

I'm trying to get the first 4 bits and the last 4 bits of a byte.

proto_tree_add_bits_item(tree, hf_capability, tvb, bit_offset, 4, ENC_BIG_ENDIAN);
proto_tree_add_bits_item(tree, hf_capability, tvb, bit_offset+4, 4, ENC_BIG_ENDIAN);

    { &hf_capability,
        { "Capabilities", "status.capability",
        FT_UINT8, BASE_DEC, 
        VALS(capabilitynames), 0x0,
        NULL, HFILL }
    },

When I use this in wireshark, its clearly not happy.

(lt-wireshark:18421): Pango-WARNING **: Invalid UTF-8 string passed to pango_layout_set_text()

I think it's because its not a full 8 bits. Do I need to use a bitmask? How do I use a bitmask? I'm stumbling over syntax a lot, so please show me code examples of what I should do.

Here's where I'm mapping the integers to strings:

static const value_string capabilitynames[] = {
    { 1, "Switchable" },
    { 2, "Human" },
    { 4, "Mobile" },
};

asked 31 Jul '13, 12:42

Arwen17's gravatar image

Arwen17
46226
accept rate: 0%


One problem is that the value string isn't terminated with { 0, NULL} see if that resolves the problem.

permanent link

answered 01 Aug '13, 04:25

Anders's gravatar image

Anders ♦
4.6k952
accept rate: 17%

Thank you! That fixed it! I removed the { 0, NULL} a long time ago and it didn't give me any errors or warnings when I did so I assumed it was unnecessary. I only started getting an error when I started trying to work with bits instead of bytes.

(01 Aug '13, 07:19) Arwen17

That would have been easily caught by running tools/checkAPIs.pl epan/dissectors/packet-foo.c. Incidentally, you've chosen quite a poor name for your display filter of "status.capability". Try running tools/checkfiltername.pl, and also tools/checkhf.pl. These handy scripts will help you find many common mistakes.

(05 Aug '13, 07:46) cmaynard ♦♦
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×1,620
×637
×33

question asked: 31 Jul '13, 12:42

question was seen: 1,508 times

last updated: 05 Aug '13, 07:46

p​o​w​e​r​e​d by O​S​Q​A