Set the char[2] array at ip to a 16-bit int value, swizzling bytes as needed for network order.
| 26 | |
| 27 | // Set the char[2] array at ip to a 16-bit int value, swizzling bytes as needed for network order. |
| 28 | void sethtons(ByteType *cp,unsigned value) |
| 29 | { |
| 30 | uint16_t tmp = htons(value); |
| 31 | ByteType *tp = (ByteType*)&tmp; |
| 32 | cp[0]=tp[0]; cp[1]=tp[1]; // Overkill but safe. |
| 33 | } |
| 34 | |
| 35 | // Set the char[4] array at ip to a 32-bit int value, swizzling bytes as needed for network order. |
| 36 | void sethtonl(ByteType *cp,unsigned value) |