PRIVATE_EXTERN int inet6_aifaddr(int s, const char * name, const struct in6_addr * addr, const struct in6_addr * dstaddr, int prefix_length, int flags, u_int32_t valid_lifetime, u_int32_t preferred_lifetime) { struct in6_aliasreq ifra_in6; bzero(&ifra_in6, sizeof(ifra_in6)); strncpy(ifra_in6.ifra_name, name, sizeof(ifra_in6.ifra_name)); ifra_in6.ifra_lifetime.ia6t_vltime = valid_lifetime; ifra_in6.ifra_lifetime.ia6t_pltime = preferred_lifetime; ifra_in6.ifra_flags = flags; if (addr != NULL) { set_sockaddr_in6(&ifra_in6.ifra_addr, addr); } if (dstaddr != NULL) { set_sockaddr_in6(&ifra_in6.ifra_dstaddr, dstaddr); } if (prefix_length != 0) { struct in6_addr prefixmask; in6_len2mask(&prefixmask, prefix_length); set_sockaddr_in6(&ifra_in6.ifra_prefixmask, &prefixmask); } return (ioctl(s, SIOCAIFADDR_IN6, &ifra_in6)); }
PRIVATE_EXTERN int inet6_difaddr(int s, const char * name, const struct in6_addr * addr) { struct in6_ifreq ifr; bzero(&ifr, sizeof(ifr)); strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)); if (addr != NULL) { set_sockaddr_in6(&ifr.ifr_ifru.ifru_addr, addr); } return (ioctl(s, SIOCDIFADDR_IN6, &ifr)); }
STATIC int siocgifaflag_in6(int s, const char * ifname, const struct in6_addr * in6_addr, int * ret_flags) { struct in6_ifreq ifr6; bzero((char *)&ifr6, sizeof(ifr6)); strncpy(ifr6.ifr_name, ifname, sizeof(ifr6.ifr_name)); set_sockaddr_in6(&ifr6.ifr_addr, in6_addr); if (ioctl(s, SIOCGIFAFLAG_IN6, &ifr6) < 0) { return (-1); } *ret_flags = ifr6.ifr_ifru.ifru_flags6; return (0); }
STATIC int siocgifalifetime_in6(int s, const char * ifname, const struct in6_addr * in6_addr, u_int32_t * ret_valid_lifetime, u_int32_t * ret_preferred_lifetime) { struct in6_ifreq ifr6; bzero((char *)&ifr6, sizeof(ifr6)); strncpy(ifr6.ifr_name, ifname, sizeof(ifr6.ifr_name)); set_sockaddr_in6(&ifr6.ifr_addr, in6_addr); if (ioctl(s, SIOCGIFALIFETIME_IN6, &ifr6) < 0) { return (-1); } *ret_valid_lifetime = ifr6.ifr_ifru.ifru_lifetime.ia6t_vltime; *ret_preferred_lifetime = ifr6.ifr_ifru.ifru_lifetime.ia6t_pltime; return (0); }
static int lw_nsnap_load_options(struct teamd_context *ctx, struct teamd_port *tdport, struct lw_psr_port_priv *psr_ppriv) { struct lw_nsnap_port_priv *nsnap_ppriv = lw_nsnap_ppriv_get(psr_ppriv); struct teamd_config_path_cookie *cpcookie = psr_ppriv->common.cpcookie; const char *host; int err; err = teamd_config_string_get(ctx, &host, "@.target_host", cpcookie); if (err) { teamd_log_err("Failed to get \"target_host\" link-watch option."); return -EINVAL; } err = set_sockaddr_in6(&nsnap_ppriv->dst, host); if (err) return err; teamd_log_dbg("target address \"%s\".", str_sockaddr_in6(&nsnap_ppriv->dst)); return 0; }