struct in6_addr has a single member, an array of 16 bytes named
s6_addr. It is in network byte order, i.e. most significant byte first. I don't know why you redefined the structure -- I'd just use
#include <arpa/inet.h>
Increase the last value in the array. If it turns zero, increase the previous value; if that turns zero, increase the one before that too, and so on. Finally, use
inet_ntop() to convert the modified address back to a string.
Code:
#include <arpa/inet.h>
#include <stdio.h>
struct in6_addr ipv6;
char addrbuf[INET6_ADDRSTRLEN]; /* 46 */
const char *addrstr;
int i;
if (inet_pton(AF_INET6, address_string, &ipv6) == 1) {
/* Increase address by one */
ipv6.s6_addr[15]++;
/* Carry over to more significant bytes */
i = 15;
while (i > 0 && !ipv6.s6_addr[i--])
ipv6.s6_addr[i]++;
/* Convert back to a string and print. */
if ((addrstr = inet_ntop(AF_INET6, &ipv6, addrbuf, sizeof(addrbuf))))
printf("%s\n", addrstr);
}