I am adding IPv6 support to a network application. Some control packets should contain a mixed list of both IPv4 and IPv6 addresses (the current code only supports IPv4):
struct control_packet {
[...]
ushort ip1_afi;
struct in_addr ip1;
ushort ip2_afi;
struct in_addr ip2;
uchar reserved1;
uchar prefix_mask_len;
ushort prefix_afi;
struct in_addr prefix;
} __attribute__ ((__packed__));
How should I replace in_addr structures in oder to support both IPv4 and IPv6, depeding an the AFI value before?
I don't think I can use sockaddr_storage
for this, because it reserves more space than is necessary for the packet.
I have seen people using uchar ip1[0]
, but then I will probably have to assemble the packet manually, not using a struct. Any suggestions?
I also accept good RTFM links :)
Thanks!