您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ IN6_IS_ADDR_LINKLOCAL函数代码示例

51自学网 2021-06-01 21:29:45
  C++
这篇教程C++ IN6_IS_ADDR_LINKLOCAL函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中IN6_IS_ADDR_LINKLOCAL函数的典型用法代码示例。如果您正苦于以下问题:C++ IN6_IS_ADDR_LINKLOCAL函数的具体用法?C++ IN6_IS_ADDR_LINKLOCAL怎么用?C++ IN6_IS_ADDR_LINKLOCAL使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了IN6_IS_ADDR_LINKLOCAL函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: find_ipv6_addr

intfind_ipv6_addr(const char * ifname,               char * dst, int n){	struct ifaddrs * ifap;	struct ifaddrs * ife;	const struct sockaddr_in6 * addr;	char buf[64];	int r = 0;	if(!dst)		return -1;	if(getifaddrs(&ifap)<0)	{		syslog(LOG_ERR, "getifaddrs: %m");		return -1;	}	for(ife = ifap; ife; ife = ife->ifa_next)	{		/* skip other interfaces if one was specified */		if(ifname && (0 != strcmp(ifname, ife->ifa_name)))			continue;		if(ife->ifa_addr == NULL)			continue;		if(ife->ifa_addr->sa_family == AF_INET6)		{			addr = (const struct sockaddr_in6 *)ife->ifa_addr;			if(!IN6_IS_ADDR_LOOPBACK(&addr->sin6_addr)			   && !IN6_IS_ADDR_LINKLOCAL(&addr->sin6_addr))			{				inet_ntop(ife->ifa_addr->sa_family,				          &addr->sin6_addr,				          buf, sizeof(buf));				/* add brackets */				snprintf(dst, n, "[%s]", buf);				r = 1;			}		}	}	freeifaddrs(ifap);	return r;}
开发者ID:vapier,项目名称:miniupnp,代码行数:43,


示例2: sockunion_connect

/* Performs a non-blocking connect().  */enum connect_result sockunion_connect(int fd, const union sockunion *peersu,				      unsigned short port, ifindex_t ifindex){	int ret;	union sockunion su;	memcpy(&su, peersu, sizeof(union sockunion));	switch (su.sa.sa_family) {	case AF_INET:		su.sin.sin_port = port;		break;	case AF_INET6:		su.sin6.sin6_port = port;#ifdef KAME		if (IN6_IS_ADDR_LINKLOCAL(&su.sin6.sin6_addr) && ifindex) {			su.sin6.sin6_scope_id = ifindex;			SET_IN6_LINKLOCAL_IFINDEX(su.sin6.sin6_addr, ifindex);		}#endif /* KAME */		break;	}	/* Call connect function. */	ret = connect(fd, (struct sockaddr *)&su, sockunion_sizeof(&su));	/* Immediate success */	if (ret == 0)		return connect_success;	/* If connect is in progress then return 1 else it's real error. */	if (ret < 0) {		if (errno != EINPROGRESS) {			char str[SU_ADDRSTRLEN];			zlog_info("can't connect to %s fd %d : %s",				  sockunion_log(&su, str, sizeof str), fd,				  safe_strerror(errno));			return connect_error;		}	}	return connect_in_progress;}
开发者ID:Azure,项目名称:sonic-bcm-lkm,代码行数:44,


示例3: add_pktinfo

/** Adds packet info to ancillary control messages */static inline void add_pktinfo(struct msghdr *msg, const fastd_peer_address_t *local_addr) {#ifdef __ANDROID__	/* PKTINFO will mess with Android VpnService.protect(socket) */	if (conf.android_integration)		return;#endif	if (!local_addr)		return;	struct cmsghdr *cmsg = (struct cmsghdr *)((char *)msg->msg_control + msg->msg_controllen);#ifdef USE_PKTINFO	if (local_addr->sa.sa_family == AF_INET) {		cmsg->cmsg_level = IPPROTO_IP;		cmsg->cmsg_type = IP_PKTINFO;		cmsg->cmsg_len = CMSG_LEN(sizeof(struct in_pktinfo));		msg->msg_controllen += cmsg->cmsg_len;		struct in_pktinfo pktinfo = {};		pktinfo.ipi_spec_dst = local_addr->in.sin_addr;		memcpy(CMSG_DATA(cmsg), &pktinfo, sizeof(pktinfo));		return;	}#endif	if (local_addr->sa.sa_family == AF_INET6) {		cmsg->cmsg_level = IPPROTO_IPV6;		cmsg->cmsg_type = IPV6_PKTINFO;		cmsg->cmsg_len = CMSG_LEN(sizeof(struct in6_pktinfo));		msg->msg_controllen += cmsg->cmsg_len;		struct in6_pktinfo pktinfo = {};		pktinfo.ipi6_addr = local_addr->in6.sin6_addr;		if (IN6_IS_ADDR_LINKLOCAL(&local_addr->in6.sin6_addr))			pktinfo.ipi6_ifindex = local_addr->in6.sin6_scope_id;		memcpy(CMSG_DATA(cmsg), &pktinfo, sizeof(pktinfo));	}}
开发者ID:corny,项目名称:fastd,代码行数:43,


示例4: if_get_ipv6_local

static intif_get_ipv6_local (struct interface *ifp, struct in6_addr *addr){  struct listnode *cnode;  struct connected *connected;  struct prefix *cp;     for (ALL_LIST_ELEMENTS_RO (ifp->connected, cnode, connected))    {      cp = connected->address;	          if (cp->family == AF_INET6)	if (IN6_IS_ADDR_LINKLOCAL (&cp->u.prefix6))	  {	    memcpy (addr, &cp->u.prefix6, IPV6_MAX_BYTELEN);	    return 1;	  }    }  return 0;}
开发者ID:DorChen,项目名称:quagga,代码行数:20,


示例5: ip6_addr_to_string

static char *ip6_addr_to_string (const struct in6_addr *addr, const char *iface){	char buf[NM_UTILS_INET_ADDRSTRLEN];	if (IN6_IS_ADDR_V4MAPPED (addr))		nm_utils_inet4_ntop (addr->s6_addr32[3], buf);	else		nm_utils_inet6_ntop (addr, buf);	/* Need to scope link-local addresses with %<zone-id>. Before dnsmasq 2.58,	 * only '@' was supported as delimiter. Since 2.58, '@' and '%' are	 * supported. Due to a bug, since 2.73 only '%' works properly as "server"	 * address.	 */	return g_strdup_printf ("%s%c%s",	                        buf,	                        IN6_IS_ADDR_LINKLOCAL (addr) ? '%' : '@',	                        iface);}
开发者ID:abferm,项目名称:network-manager,代码行数:20,


示例6: ipv6ll_db_store

voidipv6ll_db_store(struct sockaddr_in6 *sin6, struct sockaddr_in6 *sin6mask,    int dbflag, char *ifname){	/*	 * If linklocal, store a version that will match conf output	 * with no scope id, ifname in separate database field	 */	if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr) ||	    IN6_IS_ADDR_MC_LINKLOCAL(&sin6->sin6_addr) ||	    IN6_IS_ADDR_MC_INTFACELOCAL(&sin6->sin6_addr)) {		sin6->sin6_addr.s6_addr[2] = sin6->sin6_addr.s6_addr[3] = 0;		sin6->sin6_scope_id = 0;		db_delete_flag_x_ctl_data("ipv6linklocal", ifname,		    netname6(sin6, sin6mask));		if (dbflag != DB_X_REMOVE)			db_insert_flag_x("ipv6linklocal", ifname, 0,			    dbflag, netname6(sin6, sin6mask));	}}
开发者ID:yellowman,项目名称:nsh,代码行数:20,


示例7: ospf6_interface_get_linklocal_address

static struct in6_addr *ospf6_interface_get_linklocal_address (struct interface *ifp){  struct listnode *n;  struct connected *c;  struct in6_addr *l = (struct in6_addr *) NULL;  /* for each connected address */  for (ALL_LIST_ELEMENTS_RO (ifp->connected, n, c))    {      /* if family not AF_INET6, ignore */      if (c->address->family != AF_INET6)        continue;      /* linklocal scope check */      if (IN6_IS_ADDR_LINKLOCAL (&c->address->u.prefix6))        l = &c->address->u.prefix6;    }  return l;}
开发者ID:rgmabs19357,项目名称:qpimd,代码行数:20,


示例8: if_lookup_linklocal

struct connected *if_lookup_linklocal (struct interface *ifp){#ifdef HAVE_IPV6  struct listnode *node;  struct connected *ifc;  if (ifp == NULL)    return NULL;  for (ALL_LIST_ELEMENTS_RO(ifp->connected, node, ifc))    {      if ((ifc->address->family == AF_INET6) &&          (IN6_IS_ADDR_LINKLOCAL (&ifc->address->u.prefix6)))        return ifc;    }#endif /* HAVE_IPV6 */  return NULL;}
开发者ID:AT-Corp,项目名称:quagga-atc,代码行数:20,


示例9: sock_send

int sock_send(int fd, char * addr, char * buf, int buflen, int port,int iface){	    ADDRINFO inforemote,*remote;    char addrStr[sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255")+5];    char portStr[10];    int i;    char packaddr[16];    char ifaceStr[10];    memset(addrStr,  0, sizeof(addrStr));    memset(portStr,  0, sizeof(portStr));    memset(packaddr, 0, sizeof(packaddr));    memset(ifaceStr, 0, sizeof(ifaceStr));        strcpy(addrStr,addr);    itoa(port,portStr,10);    itoa(iface,ifaceStr,10);    inet_pton6(addrStr,packaddr);        if(IN6_IS_ADDR_LINKLOCAL((struct in6_addr*)packaddr)       ||IN6_IS_ADDR_SITELOCAL((struct in6_addr*)packaddr))	strcat(strcat(addrStr,"%"),ifaceStr);          memset(&inforemote, 0, sizeof(inforemote));    inforemote.ai_flags=AI_NUMERICHOST;    inforemote.ai_family=PF_INET6;    inforemote.ai_socktype=SOCK_DGRAM;    inforemote.ai_protocol=IPPROTO_IPV6;    //inet_ntop6(addr,addrStr);    if(getaddrinfo(addrStr,portStr,&inforemote,&remote))	return 0;    i=sendto(fd,buf,buflen,0,remote->ai_addr,remote->ai_addrlen);	freeaddrinfo(remote);	if (i==SOCKET_ERROR)    {		error_message_set(WSAGetLastError());        return LOWLEVEL_ERROR_UNSPEC;    }    return LOWLEVEL_NO_ERROR;}
开发者ID:DorChen,项目名称:dibbler,代码行数:41,


示例10: svx_inetaddr_get_ipport

int svx_inetaddr_get_ipport(svx_inetaddr_t *self, char *ip, size_t ip_len, uint16_t *port){    size_t len;    if(NULL == self || ((NULL == ip || ip_len < SVX_INETADDR_STR_IP_LEN) && NULL == port))        SVX_LOG_ERRNO_RETURN_ERR(SVX_ERRNO_INVAL, "self:%p, ip:%p, ip_len:%zu, port:%p/n", self, ip, ip_len, port);        switch(self->storage.addr.sa_family)    {    case AF_INET:        if(NULL != ip && ip_len >= SVX_INETADDR_STR_IP_LEN)        {            memset(ip, 0, ip_len);            if(NULL == inet_ntop(AF_INET, &(self->storage.addr4.sin_addr), ip, (socklen_t)ip_len))                SVX_LOG_ERRNO_RETURN_ERR(errno, NULL);        }        if(NULL != port) *port = ntohs(self->storage.addr4.sin_port);        return 0;    case AF_INET6:        if(NULL != ip && ip_len >= SVX_INETADDR_STR_IP_LEN)        {            memset(ip, 0, ip_len);            if(NULL == inet_ntop(AF_INET6, &(self->storage.addr6.sin6_addr), ip, (socklen_t)ip_len))                SVX_LOG_ERRNO_RETURN_ERR(errno, NULL);                        /* append IPv6 link-local address interface name */            if(IN6_IS_ADDR_LINKLOCAL(&(self->storage.addr6.sin6_addr)) ||                IN6_IS_ADDR_MC_LINKLOCAL(&(self->storage.addr6.sin6_addr)))            {                len = strlen(ip);                ip[len++] = '%';                if(NULL == if_indextoname(self->storage.addr6.sin6_scope_id, ip + len))                    SVX_LOG_ERRNO_RETURN_ERR(errno, NULL);            }        }        if(NULL != port) *port = ntohs(self->storage.addr6.sin6_port);        return 0;    default:        SVX_LOG_ERRNO_RETURN_ERR(SVX_ERRNO_NOTSPT, "family:%u/n", self->storage.addr.sa_family);    }}
开发者ID:JamesLinus,项目名称:libsvx,代码行数:41,


示例11: bgp_nexthop_onlink

/* If nexthop exists on connected network return 1. */intbgp_nexthop_onlink (afi_t afi, struct attr *attr){  struct bgp_node *rn;    /* If zebra is not enabled return */  if (zlookup->sock < 0)    return 1;    /* Lookup the address is onlink or not. */  if (afi == AFI_IP)    {      rn = bgp_node_match_ipv4 (bgp_connected_table[AFI_IP], &attr->nexthop);      if (rn)	{	  bgp_unlock_node (rn);	  return 1;	}    }#ifdef HAVE_IPV6  else if (afi == AFI_IP6)    {      if (attr->extra->mp_nexthop_len == 32)	return 1;      else if (attr->extra->mp_nexthop_len == 16)	{	  if (IN6_IS_ADDR_LINKLOCAL (&attr->extra->mp_nexthop_global))	    return 1;	  rn = bgp_node_match_ipv6 (bgp_connected_table[AFI_IP6],				      &attr->extra->mp_nexthop_global);	  if (rn)	    {	      bgp_unlock_node (rn);	      return 1;	    }	}    }#endif /* HAVE_IPV6 */  return 0;}
开发者ID:AsherBond,项目名称:quagga,代码行数:42,


示例12: ip6_addr_to_string

static char *ip6_addr_to_string (const struct in6_addr *addr, const char *iface){	char *buf;	if (IN6_IS_ADDR_V4MAPPED (addr)) {		/* inet_ntop is probably supposed to do this for us, but it doesn't */		buf = g_malloc (INET_ADDRSTRLEN);		nm_utils_inet4_ntop (addr->s6_addr32[3], buf);	} else if (!iface || !iface[0] || !IN6_IS_ADDR_LINKLOCAL (addr)) {		buf = g_malloc (INET6_ADDRSTRLEN);		nm_utils_inet6_ntop (addr, buf);	} else {		/* If we got a scope identifier, we need use '%' instead of		 * '@', since dnsmasq supports '%' in server= addresses		 * only since version 2.58 and up		 */		buf = g_strconcat (nm_utils_inet6_ntop (addr, NULL), "@", iface, NULL);	}	return buf;}
开发者ID:gunchleoc,项目名称:NetworkManager,代码行数:21,


示例13: ip6_addr_to_string

static char *ip6_addr_to_string (const struct in6_addr *addr, const char *iface){	char *buf;	if (IN6_IS_ADDR_V4MAPPED (addr)) {		buf = g_malloc (INET_ADDRSTRLEN);		nm_utils_inet4_ntop (addr->s6_addr32[3], buf);	} else if (!iface || !iface[0] || !IN6_IS_ADDR_LINKLOCAL (addr)) {		buf = g_malloc (INET6_ADDRSTRLEN);		nm_utils_inet6_ntop (addr, buf);	} else {		/* Need to scope the address with %<zone-id>. Before dnsmasq 2.58,		 * only '@' was supported as delimiter. Since 2.58, '@' and '%'		 * are supported. Due to a bug, since 2.73 only '%' works properly		 * as "server" address.		 */		buf = g_strconcat (nm_utils_inet6_ntop (addr, NULL), "%", iface, NULL);	}	return buf;}
开发者ID:GalliumOS,项目名称:network-manager,代码行数:21,


示例14: relayd_forward_packet

// Forwards a packet on a specific interfacessize_t relayd_forward_packet(int socket, struct sockaddr_in6 *dest,		struct iovec *iov, size_t iov_len,		const struct relayd_interface *iface){	// Construct headers	uint8_t cmsg_buf[CMSG_SPACE(sizeof(struct in6_pktinfo))] = {0};	struct msghdr msg = {(void*)dest, sizeof(*dest), iov, iov_len,				cmsg_buf, sizeof(cmsg_buf), 0};	// Set control data (define destination interface)	struct cmsghdr *chdr = CMSG_FIRSTHDR(&msg);	chdr->cmsg_level = IPPROTO_IPV6;	chdr->cmsg_type = IPV6_PKTINFO;	chdr->cmsg_len = CMSG_LEN(sizeof(struct in6_pktinfo));	struct in6_pktinfo *pktinfo = (struct in6_pktinfo*)CMSG_DATA(chdr);	pktinfo->ipi6_ifindex = iface->ifindex;	// Also set scope ID if link-local	if (IN6_IS_ADDR_LINKLOCAL(&dest->sin6_addr)			|| IN6_IS_ADDR_MC_LINKLOCAL(&dest->sin6_addr))		dest->sin6_scope_id = iface->ifindex;	// IPV6_PKTINFO doesn't really work for IPv6-raw sockets (bug?)	if (dest->sin6_port == 0) {		msg.msg_control = NULL;		msg.msg_controllen = 0;	}	char ipbuf[INET6_ADDRSTRLEN];	inet_ntop(AF_INET6, &dest->sin6_addr, ipbuf, sizeof(ipbuf));	ssize_t sent = sendmsg(socket, &msg, MSG_DONTWAIT);	if (sent < 0)		syslog(LOG_WARNING, "Failed to relay to %s%%%s (%s)",				ipbuf, iface->ifname, strerror(errno));	else		syslog(LOG_NOTICE, "Relayed %li bytes to %s%%%s",				(long)sent, ipbuf, iface->ifname);	return sent;}
开发者ID:Antares84,项目名称:asuswrt-merlin,代码行数:41,


示例15: toAddrinfo

int Socket::BindToAddr(const std::string& addr, const std::string& port){    char str[INET6_ADDRSTRLEN];    bool success = false;    struct addrinfo *AddrInfo, *AI;    AddrInfo = toAddrinfo( addr, port, true );    for ( AI = AddrInfo; AI != NULL; AI = AI->ai_next )    {        struct sockaddr_in6 bindAddr;        toIpv6( AI, &bindAddr );        if ( ( IN6_IS_ADDR_LINKLOCAL((struct in6_addr *) &bindAddr.sin6_addr) ) &&             ( bindAddr.sin6_scope_id == 0) )        {            log(LOG_WARN) << "IPv6 link local addresses should specify a scope ID!";        }        inet_ntop( AF_INET6, &bindAddr.sin6_addr, str, sizeof(str));        log(LOG_NOTICE) << "attempting bind to /"" << addr << "/" -> ip " << str << " port " << ntohs(bindAddr.sin6_port);        if ( bind( socket_->fd, (struct sockaddr*) &bindAddr, sizeof(bindAddr) ) < 0 )        {            log(LOG_EMERG) << "bind attempt failed with error " << strerror(errno);        }        else        {            success = true;            break;        }    }    if ( AddrInfo )        freeaddrinfo( AddrInfo );    return success ? 0 : -1;}
开发者ID:jderehag,项目名称:spotifyserver,代码行数:40,


示例16: really_send

static int really_send(int sock, struct in6_addr const *dest, struct properties const *props, struct safe_buffer const *sb){	struct sockaddr_in6 addr;	memset((void *)&addr, 0, sizeof(addr));	addr.sin6_family = AF_INET6;	addr.sin6_port = htons(IPPROTO_ICMPV6);	memcpy(&addr.sin6_addr, dest, sizeof(struct in6_addr));	struct iovec iov;	iov.iov_len = sb->used;	iov.iov_base = (caddr_t)sb->buffer;	char __attribute__ ((aligned(8))) chdr[CMSG_SPACE(sizeof(struct in6_pktinfo))];	memset(chdr, 0, sizeof(chdr));	struct cmsghdr *cmsg = (struct cmsghdr *)chdr;	cmsg->cmsg_len = CMSG_LEN(sizeof(struct in6_pktinfo));	cmsg->cmsg_level = IPPROTO_IPV6;	cmsg->cmsg_type = IPV6_PKTINFO;	struct in6_pktinfo *pkt_info = (struct in6_pktinfo *)CMSG_DATA(cmsg);	pkt_info->ipi6_ifindex = props->if_index;	memcpy(&pkt_info->ipi6_addr, &props->if_addr, sizeof(struct in6_addr));#ifdef HAVE_SIN6_SCOPE_ID	if (IN6_IS_ADDR_LINKLOCAL(&addr.sin6_addr) || IN6_IS_ADDR_MC_LINKLOCAL(&addr.sin6_addr))		addr.sin6_scope_id = props->if_index;#endif	struct msghdr mhdr;	memset(&mhdr, 0, sizeof(mhdr));	mhdr.msg_name = (caddr_t) & addr;	mhdr.msg_namelen = sizeof(struct sockaddr_in6);	mhdr.msg_iov = &iov;	mhdr.msg_iovlen = 1;	mhdr.msg_control = (void *)cmsg;	mhdr.msg_controllen = sizeof(chdr);	return sendmsg(sock, &mhdr, 0);}
开发者ID:verrio,项目名称:radvd,代码行数:40,


示例17: defrouter_probe

/* * Probe if each router in the default router list is still alive.  */voiddefrouter_probe(int ifindex){	struct in6_drlist dr;	int s, i;	u_char ntopbuf[INET6_ADDRSTRLEN];	if ((s = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) {		warnmsg(LOG_ERR, __FUNCTION__, "socket: %s", strerror(errno));		return;	}	bzero(&dr, sizeof(dr));	strlcpy(dr.ifname, "lo0", sizeof(dr.ifname)); /* dummy interface */	if (ioctl(s, SIOCGDRLST_IN6, (caddr_t)&dr) < 0) {		warnmsg(LOG_ERR, __FUNCTION__, "ioctl(SIOCGDRLST_IN6): %s",		       strerror(errno));		goto closeandend;	}	for(i = 0; dr.defrouter[i].if_index && i < PRLSTSIZ; i++) {		if (ifindex && dr.defrouter[i].if_index == ifindex) {			/* sanity check */			if (!IN6_IS_ADDR_LINKLOCAL(&dr.defrouter[i].rtaddr)) {				warnmsg(LOG_ERR, __FUNCTION__,					"default router list contains a "					"non-linklocal address(%s)",				       inet_ntop(AF_INET6,						 &dr.defrouter[i].rtaddr,						 (char *)ntopbuf, INET6_ADDRSTRLEN));				continue; /* ignore the address */			}			sendprobe(&dr.defrouter[i].rtaddr,				  dr.defrouter[i].if_index);		}	}  closeandend:	close(s);	return;}
开发者ID:Leon555,项目名称:Mac-src-essentials,代码行数:43,


示例18: is_linklocal_addr

bool is_linklocal_addr(const struct sockaddr_storage *pss){#ifdef HAVE_IPV6	if (pss->ss_family == AF_INET6) {		const struct in6_addr *pin6 =			&((const struct sockaddr_in6 *)pss)->sin6_addr;		return IN6_IS_ADDR_LINKLOCAL(pin6);	}#endif	if (pss->ss_family == AF_INET) {		const struct in_addr *pin =			&((const struct sockaddr_in *)pss)->sin_addr;		struct in_addr ll_addr;		struct in_addr mask_addr;		/* 169.254.0.0/16, is link local, see RFC 3927 */		ll_addr.s_addr = 0xa9fe0000;		mask_addr.s_addr = 0xffff0000;		return same_net_v4(*pin, ll_addr, mask_addr);	}	return false;}
开发者ID:DanilKorotenko,项目名称:samba,代码行数:22,


示例19: incoming_prefix_opt

/* * Process a received prefix option. * Unless addrconf is turned off we process both the addrconf and the * onlink aspects of the prefix option. * * Note that when a flag (onlink or auto) is turned off we do nothing - * the prefix will time out. */static voidincoming_prefix_opt(struct phyint *pi, uchar_t *opt,    struct sockaddr_in6 *from, boolean_t loopback){	struct nd_opt_prefix_info *po = (struct nd_opt_prefix_info *)opt;	boolean_t	good_prefix = _B_TRUE;	if (8 * po->nd_opt_pi_len != sizeof (*po)) {		char abuf[INET6_ADDRSTRLEN];		(void) inet_ntop(AF_INET6, (void *)&from->sin6_addr,		    abuf, sizeof (abuf));		logmsg(LOG_INFO, "prefix option from %s on %s wrong size "		    "(%d bytes)/n",		    abuf, pi->pi_name,		    8 * (int)po->nd_opt_pi_len);		return;	}	if (IN6_IS_ADDR_LINKLOCAL(&po->nd_opt_pi_prefix)) {		char abuf[INET6_ADDRSTRLEN];		(void) inet_ntop(AF_INET6, (void *)&from->sin6_addr,		    abuf, sizeof (abuf));		logmsg(LOG_INFO, "RA from %s on %s contains link-local prefix "		    "- ignored/n",		    abuf, pi->pi_name);		return;	}	if ((po->nd_opt_pi_flags_reserved & ND_OPT_PI_FLAG_AUTO) &&	    pi->pi_stateless && pi->pi_autoconf) {		good_prefix = incoming_prefix_addrconf(pi, opt, from, loopback);	}	if ((po->nd_opt_pi_flags_reserved & ND_OPT_PI_FLAG_ONLINK) &&	    good_prefix) {		incoming_prefix_onlink(pi, opt);	}	if (pi->pi_stateful && pi->pi_autoconf)		incoming_prefix_stateful(pi, opt);}
开发者ID:CadeLaRen,项目名称:illumos-gate,代码行数:47,


示例20: _numerichost

/* * Write the numeric address */static int_numerichost(struct asr_query *as){	unsigned int	ifidx;	char		scope[IF_NAMESIZE + 1], *ifname;	void		*addr;	char		*buf = as->as.ni.hostname;	size_t		 buflen = as->as.ni.hostnamelen;	if (as->as.ni.sa.sa.sa_family == AF_INET)		addr = &as->as.ni.sa.sain.sin_addr;	else		addr = &as->as.ni.sa.sain6.sin6_addr;	if (inet_ntop(as->as.ni.sa.sa.sa_family, addr, buf, buflen) == NULL)		return (-1); /* errno set */	if (as->as.ni.sa.sa.sa_family == AF_INET6 &&	    as->as.ni.sa.sain6.sin6_scope_id) {		scope[0] = SCOPE_DELIMITER;		scope[1] = '/0';		ifidx = as->as.ni.sa.sain6.sin6_scope_id;		ifname = NULL;		if (IN6_IS_ADDR_LINKLOCAL(&as->as.ni.sa.sain6.sin6_addr) ||		    IN6_IS_ADDR_MC_LINKLOCAL(&as->as.ni.sa.sain6.sin6_addr) ||		    IN6_IS_ADDR_MC_NODELOCAL(&as->as.ni.sa.sain6.sin6_addr))			ifname = if_indextoname(ifidx, scope + 1);		if (ifname == NULL)			snprintf(scope + 1, sizeof(scope) - 1, "%u", ifidx);		strlcat(buf, scope, buflen);	}	return (0);}
开发者ID:bocal,项目名称:libasr,代码行数:42,


示例21: append_scopeid

static void append_scopeid(struct sockaddr_in6 *addr6, unsigned int flags,                           char *buf, size_t buflen){#ifdef HAVE_IF_INDEXTONAME  int is_ll, is_mcll;#endif  static const char fmt_u[] = "%u";  static const char fmt_lu[] = "%lu";  char tmpbuf[IF_NAMESIZE + 2];  size_t bufl;  const char *fmt = (sizeof(addr6->sin6_scope_id) > sizeof(unsigned int))?    fmt_lu:fmt_u;  tmpbuf[0] = '%';#ifdef HAVE_IF_INDEXTONAME  is_ll = IN6_IS_ADDR_LINKLOCAL(&addr6->sin6_addr);  is_mcll = IN6_IS_ADDR_MC_LINKLOCAL(&addr6->sin6_addr);  if ((flags & ARES_NI_NUMERICSCOPE) ||      (!is_ll && !is_mcll))    {       sprintf(&tmpbuf[1], fmt, addr6->sin6_scope_id);    }  else    {      if (if_indextoname(addr6->sin6_scope_id, &tmpbuf[1]) == NULL)        sprintf(&tmpbuf[1], fmt, addr6->sin6_scope_id);    }#else  sprintf(&tmpbuf[1], fmt, addr6->sin6_scope_id);  (void) flags;#endif  tmpbuf[IF_NAMESIZE + 1] = '/0';  bufl = strlen(buf);  if(bufl + strlen(tmpbuf) < buflen)    /* only append the scopeid string if it fits in the target buffer */    strcpy(&buf[bufl], tmpbuf);}
开发者ID:005,项目名称:gevent,代码行数:39,


示例22: valid_ipv6

static int valid_ipv6(char *str){	unsigned int prefix_len;	struct in6_addr addr; /* net order */	char *slash, *endp;	slash = strchr(str, '/');	if (!slash) {		fprintf(stderr, "Missing network prefix/n");		return 0;	}	*slash++ = 0;	prefix_len = strtoul(slash, &endp, 10);	if (*slash == '/0' || *endp != '/0')		fprintf(stderr, "Non-digit in prefix length/n");	else if (prefix_len <= 1 || prefix_len > 128)		fprintf(stderr,			"Invalid prefix len %d for IPv6/n", prefix_len);	else if (inet_pton(AF_INET6, str, &addr) <= 0)		fprintf(stderr, "Invalid IPv6 address/n");	else if (IN6_IS_ADDR_LINKLOCAL(&addr))		fprintf(stderr,			"Can not assign an address reserved for IPv6 link local/n");	else if (IN6_IS_ADDR_MULTICAST(&addr))		fprintf(stderr,			"Can not assign an address reserved for IPv6 multicast/n");	else if (IN6_IS_ADDR_UNSPECIFIED(&addr))		fprintf(stderr,			"Can not assign IPv6 reserved for IPv6 unspecified address/n");	else 		return 1;	/* is valid address and prefix */	return 0;	/* Invalid address */}
开发者ID:Roguelazer,项目名称:vyatta-cfg-system,代码行数:38,


示例23: xbind_connect

int xbind_connect(const len_and_sockaddr *lsa, const char *ip){	int fd;    /*Start of MNT 2008-10-13 14:40 for 传输超时检测 by z65940*/    g_TimeoutCnt = ATP_CONNECT_TIMEOUT_D;  // 每个命令的超时检测    /*End of MNT 2008-10-13 14:40 for by z65940*/    #if 0    /*Added by [email
C++ IN6_IS_ADDR_LOOPBACK函数代码示例
C++ IN6_ARE_ADDR_EQUAL函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。