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

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

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 ♦
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/ epan/dissectors/packet-foo.c. Incidentally, you've chosen quite a poor name for your display filter of "status.capability". Try running tools/, and also tools/ 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



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "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:


question asked: 31 Jul '13, 12:42

question was seen: 1,691 times

last updated: 05 Aug '13, 07:46

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