SHA1Update(&sc->sc_sha1, (void *)&cur6, sizeof(in6));
SHA1Update(&sc->sc_sha1, (void *)&cur6, sizeof(cur6));
carp_hmac_prepare(struct carp_softc *sc){	u_int8_t version = CARP_VERSION, type = CARP_ADVERTISEMENT;	u_int8_t vhid = sc->sc_vhid & 0xff;	SHA1_CTX sha1ctx;	u_int32_t kmd[5];	struct ifaddr *ifa;	int i, found;	struct in_addr last, cur, in;#ifdef INET6	struct in6_addr last6, cur6, in6;#endif /* INET6 */	/* compute ipad from key */	bzero(sc->sc_pad, sizeof(sc->sc_pad));	bcopy(sc->sc_key, sc->sc_pad, sizeof(sc->sc_key));	for (i = 0; i < sizeof(sc->sc_pad); i++)		sc->sc_pad[i] ^= 0x36;	/* precompute first part of inner hash */	SHA1Init(&sc->sc_sha1);	SHA1Update(&sc->sc_sha1, sc->sc_pad, sizeof(sc->sc_pad));	SHA1Update(&sc->sc_sha1, (void *)&version, sizeof(version));	SHA1Update(&sc->sc_sha1, (void *)&type, sizeof(type));	/* generate a key for the arpbalance hash, before the vhid is hashed */	bcopy(&sc->sc_sha1, &sha1ctx, sizeof(sha1ctx));	SHA1Final((unsigned char *)kmd, &sha1ctx);	sc->sc_hashkey[0] = kmd[0] ^ kmd[1];	sc->sc_hashkey[1] = kmd[2] ^ kmd[3];	/* the rest of the precomputation */	SHA1Update(&sc->sc_sha1, (void *)&vhid, sizeof(vhid));	/* Hash the addresses from smallest to largest, not interface order */#ifdef INET	cur.s_addr = 0;	do {		found = 0;		last = cur;		cur.s_addr = 0xffffff;		TAILQ_FOREACH(ifa, &sc->sc_if.if_addrlist, ifa_list) {			in.s_addr = ifatoia(ifa)->ia_addr.sin_addr.s_addr;			if (ifa->ifa_addr->sa_family == AF_INET && 		    	    in.s_addr > last.s_addr && in.s_addr < cur.s_addr) {				cur.s_addr = in.s_addr;				found++;			}		}		if (found)			SHA1Update(&sc->sc_sha1, (void *)&cur, sizeof(cur));	} while (found);#endif /* INET */#ifdef INET6	memset(&cur, 0x00, sizeof(cur));	do {		found = 0;		last6 = cur6;		memset(&cur, 0xff, sizeof(cur));		TAILQ_FOREACH(ifa, &sc->sc_if.if_addrlist, ifa_list) {			in6 = ifatoia6(ifa)->ia_addr.sin6_addr;			if (IN6_IS_ADDR_LINKLOCAL(&in6))				in6.s6_addr16[1] = 0;			if (ifa->ifa_addr->sa_family == AF_INET6 &&			    memcmp(&in6, &last6, sizeof(in6)) > 0 &&			    memcmp(&in6, &cur6, sizeof(in6)) < 0) {				cur6 = in6;				found++;			}		}		if (found)			SHA1Update(&sc->sc_sha1, (void *)&cur6, sizeof(in6));	} while (found);#endif /* INET6 */	/* convert ipad to opad */	for (i = 0; i < sizeof(sc->sc_pad); i++)		sc->sc_pad[i] ^= 0x36 ^ 0x5c;}