Hi,
I am trying to write a linux code which will listen on a UDP port and revceive messages from Zyxel modems. (Zyxel modems have a remote packet tracing feature which uses UDP)
I achieved most of the task. The received packet is assigned to a string (char[1024]) variable.
But I need the 15th and 16th bytes of the received data to be converted to integer and assigned to an integer variable. (Because these bytes include the original packet size)
How can I get the 15 & 16th bytes of the char and calculate the integer value ?
With below example I can get the hex values to the string variable x. But that's not what I need. I need to get integer value.
sprintf(x,"%.2x%.2x", buf[15],buf[16]);
Thanks for your help.