3 ms·
Classic use case: creating a packed structures to directly read TCP packets. There is still the "convert from big to little endian" problem, but I think you can
by waynecochran 13y ago
Classic use case: creating a packed structures to directly read TCP packets. There is still the "convert from big to little endian" problem, but I think you can use GCC's method for individually packing a struct:
struct TCP_Packet {
uint16_t source_port;
uint16_t dest_port;
uint32_t seq_no;
uint16_t flags;
uint16_t window_size;
uint16_t checksum;
unit16_t urgent;
...
} __attribute__ ((packed));
- throwaway2048 13y agomany packet/wire formats are conceived as structs when they are designed