- #include "packet.h"
- //顺序对换的函数
- //
- USHORT
- ntohs(
- IN USHORT netshort
- )
- {
- CHAR hostshort[4];
- PCHAR pnetshort = (PCHAR)&netshort;
- hostshort[0] = pnetshort[1];
- hostshort[1] = pnetshort[0];
- return *(USHORT *)hostshort;
- }
- ULONG
- ntohl(
- IN ULONG netlong
- )
- {
- CHAR hostlong[4];
- PCHAR pnetlong = (PCHAR)&netlong;
- hostlong[0] = pnetlong[3];
- hostlong[1] = pnetlong[2];
- hostlong[2] = pnetlong[1];
- hostlong[3] = pnetlong[0];
- return *(ULONG*)hostlong;
- }