I have to admit I stopped reading after the combined section on byte swapping and casting external data to a internal structure. Perhaps the author of the code should have used ntohs() instead of be16toh(), but the effect is the same? There aren't any conditionals in ntoh...
https://commandcenter.blogspot.com/2012/04/byte-order-fallac...
And will a compiler make use of native byte swapping instructions with the code proposed by the author?