Background
I am creating a simple BOOTP/DHCP server, and I am struggling with creating some of the packet bytes – in particular, the DHCP option 13, FileSize.
The spec states the option as having a total length of 64 bytes => 1 byte for ID (13), 1 byte for data length, and the remaining bytes as data OR 0.
Problem
I need to express the int value 14236 as my data, which equates to 379C in HEX, but this needs to be spread over 2 bytes of data. How do I take an int and get a char[] of the data?
Be careful: You need to make sure the two bytes are placed in the array in network order, which if I ‘m not mistaken is big endian.