Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How can I read a Buffer in a Little Endian order?

How could I get the number (integer, float,...) from the following bytes -buffer(94,2)- in LITTLE ENDIAN? Afterwords I want to multiply this number by a constant "x".

What I did:

somefield = ProtoField.uint16("foo.somefield", "Some Field", base.DEC, nil, 0xffff) -- First of all, creation of the **protofield**

number = tonumber(tostring(buffer(94,2))) -- I get here the BIG ENDIAN number but I want the LITTLE ENDIAN one

x=2 -- value of the constant

number2 = number*x

subtree:add(somefield,number2)

As I said, with this code I get the BIG ENDIAN order from "number" and I want to get the LITTLE ENDIAN one and store it in "number". I would appreciate a lot if you could help me. Many thanks for your help!

How can I read a Buffer in a Little Endian order?

How could I get the number (integer, float,...) from the following bytes -buffer(94,2)- in LITTLE ENDIAN? Afterwords I want to multiply this number by a constant "x".

What I did:

somefield = ProtoField.uint16("foo.somefield", "Some Field", base.DEC, nil, 0xffff) -- First of all, creation of the **protofield**

number = tonumber(tostring(buffer(94,2))) -- I get here the BIG ENDIAN number but I want the LITTLE ENDIAN one

x=2 -- value of the constant

number2 = number*x

subtree:add(somefield,number2)

As I said, with this code I get the BIG ENDIAN order from "number" and I want to get the LITTLE ENDIAN one and store it in "number". I would appreciate a lot if you could help me. Many thanks for your help!

How can I read a Buffer in a Little Endian order?

How could I get the number (integer, float,...) from the following bytes -buffer(94,2)- in LITTLE ENDIAN? Afterwords I want to multiply this number by a constant "x".

What I did:

-- First of all, creation of the protofield

somefield = ProtoField.uint16("foo.somefield", "Some Field", base.DEC, nil, 0xffff) -- First of all, creation of the **protofield**
0xffff)

number = tonumber(tostring(buffer(94,2))) -- I get here the BIG ENDIAN number but I want the LITTLE ENDIAN one

x=2 -- value of the constant

number2 = number*x

subtree:add(somefield,number2)

As I said, with this code I get the BIG ENDIAN order from "number" and I want to get the LITTLE ENDIAN one and store it in "number". I would appreciate a lot if you could help me. Many thanks for your help!

How can I read a Buffer in a Little Endian order?

How In LUA, wow could I get the number (integer, float,...) from the following bytes -buffer(94,2)- in LITTLE ENDIAN? Afterwords I want to multiply this number by a constant "x".

What I did:

-- First of all, creation of the protofield

somefield = ProtoField.uint16("foo.somefield", "Some Field", base.DEC, nil, 0xffff)

number = tonumber(tostring(buffer(94,2))) -- I get here the BIG ENDIAN number but I want the LITTLE ENDIAN one

x=2 -- value of the constant

number2 = number*x

subtree:add(somefield,number2)

As I said, with this code I get the BIG ENDIAN order from "number" and I want to get the LITTLE ENDIAN one and store it in "number". I would appreciate a lot if you could help me. Many thanks for your help!