Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

This appears to be a limitation of the tostring operation when run on a tvb.

The relevant call path looks like:

        epan/wslua/wslua_tvb.c:Tvb__tostring() ->

                epan/tvbuff.c:tvb_bytes_to_str() ->

                        epan/to_str.c:bytestring_to_str()

... which truncates the buffer holding the string to a maximum length of MAX_BYTE_STR_LEN/3. Since MAX_BYTE_STR_LEN is defined as 72, the maximum length of the resulting string is 24, which is what you're seeing.

I don't know a way to work around this except to:

  • Process 24 bytes of the SSID at a time
  • File a bug report requesting that the size be increased?

This appears to be a limitation of the tostring operation when run on a tvb.

The relevant call path looks like:

        epan/wslua/wslua_tvb.c:Tvb__tostring() ->

                epan/tvbuff.c:tvb_bytes_to_str() ->

                        epan/to_str.c:bytestring_to_str()

... which truncates the buffer holding the string to a maximum length of MAX_BYTE_STR_LEN/3. Since MAX_BYTE_STR_LEN is defined as 72, the maximum length of the resulting string is 24, which is what you're seeing.

I don't know a way to work around this except to:

  • Process 24 bytes of the SSID at a time
  • File a bug report requesting that the size be increased?

Maybe there's another way? Well, in case you're only option is the first idea, here's a sample code snippet to handle it (which isn't necessarily optimized):


wlanpost = Proto("WLANpost", "Append WLAN SSID to Info column")

wlan_ssid_f = Field.new("wlan.ssid")

function wlanpost.dissector(tvb, pinfo, tree)
    local wlan_ssid_ex = wlan_ssid_f()

    if wlan_ssid_ex then
        local wlan_ssid_tvb = wlan_ssid_ex.range
        pinfo.cols.info:append(" - SSID Len = " .. wlan_ssid_ex.len .. "; SSID = ")
        if wlan_ssid_ex.len <= 24 then
            local wlan_ssid_str = tostring(wlan_ssid_tvb)
            pinfo.cols.info:append(wlan_ssid_str)
        else
            local offset = 0
            local rem = wlan_ssid_ex.len
            while rem > 0 do
                if rem > 24 then
                    local wlan_ssid_str = tostring(wlan_ssid_tvb(offset, 24))
                    pinfo.cols.info:append(wlan_ssid_str)
                    rem = rem - 24
                    offset = offset + 24
                else
                    local wlan_ssid_str = tostring(wlan_ssid_tvb(offset, rem))
                    pinfo.cols.info:append(wlan_ssid_str)
                    rem = 0
                    offset = offset + rem
                end
            end
        end
    end
end  

register_postdissector(wlanpost)

This appears to be a limitation of the tostring operation when run on a tvb.

The relevant call path looks like:

        epan/wslua/wslua_tvb.c:Tvb__tostring() ->

                epan/tvbuff.c:tvb_bytes_to_str() ->

                        epan/to_str.c:bytestring_to_str()

... which truncates the buffer holding the string to a maximum length of MAX_BYTE_STR_LEN/3. Since MAX_BYTE_STR_LEN is defined as 72, the maximum length of the resulting string is 24, which is what you're seeing.

I don't know a way to work around this except to:

  • Process 24 bytes of the SSID at a time
  • File a bug report requesting that the size be increased?

Maybe there's another way? Well, in case you're your only option is the first idea, here's a sample code snippet to illustrate how one might handle it (which isn't necessarily optimized):


wlanpost = Proto("WLANpost", "Append WLAN SSID to Info column")

wlan_ssid_f = Field.new("wlan.ssid")

function wlanpost.dissector(tvb, pinfo, tree)
    local wlan_ssid_ex = wlan_ssid_f()

    if wlan_ssid_ex then
        local wlan_ssid_tvb = wlan_ssid_ex.range
        pinfo.cols.info:append(" - SSID Len = " .. wlan_ssid_ex.len .. "; SSID = ")
        if wlan_ssid_ex.len <= 24 then
            local wlan_ssid_str = tostring(wlan_ssid_tvb)
            pinfo.cols.info:append(wlan_ssid_str)
        else
            local offset = 0
            local rem = wlan_ssid_ex.len
            while rem > 0 do
                if rem > 24 then
                    local wlan_ssid_str = tostring(wlan_ssid_tvb(offset, 24))
                    pinfo.cols.info:append(wlan_ssid_str)
                    rem = rem - 24
                    offset = offset + 24
                else
                    local wlan_ssid_str = tostring(wlan_ssid_tvb(offset, rem))
                    pinfo.cols.info:append(wlan_ssid_str)
                    rem = 0
                    offset = offset + rem
                end
            end
        end
    end
end  

register_postdissector(wlanpost)

This appears to be a limitation of the tostring operation when run on a tvb.

The relevant call path looks like:

        epan/wslua/wslua_tvb.c:Tvb__tostring() ->

                epan/tvbuff.c:tvb_bytes_to_str() ->

                        epan/to_str.c:bytestring_to_str()

... which truncates the buffer holding the string to a maximum length of MAX_BYTE_STR_LEN/3. Since MAX_BYTE_STR_LEN is defined as 72, the maximum length of the resulting string is 24, which is what you're seeing.

I don't know a way to work around this except to:

  • Process 24 bytes of the SSID at a time
  • File a bug report requesting that the size be increased?

Maybe there's another way? Well, in case your only option is the first idea, here's a sample code snippet to illustrate how one might handle it (which isn't necessarily optimized):


wlanpost = Proto("WLANpost", "Append WLAN SSID to Info column")

wlan_ssid_f = Field.new("wlan.ssid")

function wlanpost.dissector(tvb, pinfo, tree)
    local wlan_ssid_ex = wlan_ssid_f()

    if wlan_ssid_ex then
        local wlan_ssid_tvb = wlan_ssid_ex.range
        pinfo.cols.info:append(" - SSID Len = " .. wlan_ssid_ex.len .. "; SSID = ")
        if wlan_ssid_ex.len <= 24 then
            local wlan_ssid_str = tostring(wlan_ssid_tvb)
            pinfo.cols.info:append(wlan_ssid_str)
        else
            local offset = 0
            local rem = wlan_ssid_ex.len
            while rem > 0 do
                if rem > 24 then
                    local wlan_ssid_str = tostring(wlan_ssid_tvb(offset, 24))
                    pinfo.cols.info:append(wlan_ssid_str)
                    rem = rem - 24
                    offset = offset + 24
                else
                    local wlan_ssid_str = tostring(wlan_ssid_tvb(offset, rem))
                    pinfo.cols.info:append(wlan_ssid_str)
                    rem = 0
                    offset = offset + rem
                end
            end
        end
    end
end  

register_postdissector(wlanpost)