Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet/ip_carp.c
Show First 20 Lines • Show All 112 Lines • ▼ Show 20 Lines | #endif | ||||
int sc_sendad_errors; | int sc_sendad_errors; | ||||
#define CARP_SENDAD_MAX_ERRORS 3 | #define CARP_SENDAD_MAX_ERRORS 3 | ||||
int sc_sendad_success; | int sc_sendad_success; | ||||
#define CARP_SENDAD_MIN_SUCCESS 3 | #define CARP_SENDAD_MIN_SUCCESS 3 | ||||
int sc_init_counter; | int sc_init_counter; | ||||
uint64_t sc_counter; | uint64_t sc_counter; | ||||
unsigned sc_ip_id; /* IP ID number */ | |||||
/* authentication */ | /* authentication */ | ||||
#define CARP_HMAC_PAD 64 | #define CARP_HMAC_PAD 64 | ||||
unsigned char sc_key[CARP_KEY_LEN]; | unsigned char sc_key[CARP_KEY_LEN]; | ||||
unsigned char sc_pad[CARP_HMAC_PAD]; | unsigned char sc_pad[CARP_HMAC_PAD]; | ||||
SHA1_CTX sc_sha1; | SHA1_CTX sc_sha1; | ||||
TAILQ_ENTRY(carp_softc) sc_list; /* On the carp_if list. */ | TAILQ_ENTRY(carp_softc) sc_list; /* On the carp_if list. */ | ||||
LIST_ENTRY(carp_softc) sc_next; /* On the global list. */ | LIST_ENTRY(carp_softc) sc_next; /* On the global list. */ | ||||
▲ Show 20 Lines • Show All 708 Lines • ▼ Show 20 Lines | if (sc->sc_naddrs) { | ||||
ip->ip_v = IPVERSION; | ip->ip_v = IPVERSION; | ||||
ip->ip_hl = sizeof(*ip) >> 2; | ip->ip_hl = sizeof(*ip) >> 2; | ||||
ip->ip_tos = IPTOS_LOWDELAY; | ip->ip_tos = IPTOS_LOWDELAY; | ||||
ip->ip_len = htons(len); | ip->ip_len = htons(len); | ||||
ip->ip_off = htons(IP_DF); | ip->ip_off = htons(IP_DF); | ||||
ip->ip_ttl = CARP_DFLTTL; | ip->ip_ttl = CARP_DFLTTL; | ||||
ip->ip_p = IPPROTO_CARP; | ip->ip_p = IPPROTO_CARP; | ||||
ip->ip_sum = 0; | ip->ip_sum = 0; | ||||
ip_fillid(ip); | ip_fillid(ip, &sc->sc_ip_id); | ||||
bzero(&sa, sizeof(sa)); | bzero(&sa, sizeof(sa)); | ||||
sa.sa_family = AF_INET; | sa.sa_family = AF_INET; | ||||
ifa = ifaof_ifpforaddr(&sa, sc->sc_carpdev); | ifa = ifaof_ifpforaddr(&sa, sc->sc_carpdev); | ||||
if (ifa != NULL) { | if (ifa != NULL) { | ||||
ip->ip_src.s_addr = | ip->ip_src.s_addr = | ||||
ifatoia(ifa)->ia_addr.sin_addr.s_addr; | ifatoia(ifa)->ia_addr.sin_addr.s_addr; | ||||
ifa_free(ifa); | ifa_free(ifa); | ||||
▲ Show 20 Lines • Show All 618 Lines • ▼ Show 20 Lines | carp_alloc(struct ifnet *ifp) | ||||
struct carp_softc *sc; | struct carp_softc *sc; | ||||
struct carp_if *cif; | struct carp_if *cif; | ||||
if ((cif = ifp->if_carp) == NULL) | if ((cif = ifp->if_carp) == NULL) | ||||
cif = carp_alloc_if(ifp); | cif = carp_alloc_if(ifp); | ||||
sc = malloc(sizeof(*sc), M_CARP, M_WAITOK|M_ZERO); | sc = malloc(sizeof(*sc), M_CARP, M_WAITOK|M_ZERO); | ||||
sc->sc_ip_id = ip_initid(); | |||||
sc->sc_advbase = CARP_DFLTINTV; | sc->sc_advbase = CARP_DFLTINTV; | ||||
sc->sc_vhid = -1; /* required setting */ | sc->sc_vhid = -1; /* required setting */ | ||||
sc->sc_init_counter = 1; | sc->sc_init_counter = 1; | ||||
sc->sc_state = INIT; | sc->sc_state = INIT; | ||||
sc->sc_ifasiz = sizeof(struct ifaddr *); | sc->sc_ifasiz = sizeof(struct ifaddr *); | ||||
sc->sc_ifas = malloc(sc->sc_ifasiz, M_CARP, M_WAITOK|M_ZERO); | sc->sc_ifas = malloc(sc->sc_ifasiz, M_CARP, M_WAITOK|M_ZERO); | ||||
sc->sc_carpdev = ifp; | sc->sc_carpdev = ifp; | ||||
▲ Show 20 Lines • Show All 700 Lines • Show Last 20 Lines |