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

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

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

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

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

示例1: nm_ip6_manager_get_ip6_config

NMIP6Config *nm_ip6_manager_get_ip6_config (NMIP6Manager *manager, int ifindex){	NMIP6ManagerPrivate *priv;	NMIP6Device *device;	NMIP6Config *config;	struct rtnl_addr *rtnladdr;	struct nl_addr *nladdr;	struct in6_addr *addr;	NMIP6Address *ip6addr;	struct rtnl_route *rtnlroute;	struct nl_addr *nldest, *nlgateway;	const struct in6_addr *dest, *gateway;	uint32_t metric;	NMIP6Route *ip6route;	int i;	g_return_val_if_fail (NM_IS_IP6_MANAGER (manager), NULL);	g_return_val_if_fail (ifindex > 0, NULL);	priv = NM_IP6_MANAGER_GET_PRIVATE (manager);	device = (NMIP6Device *) g_hash_table_lookup (priv->devices,	                                              GINT_TO_POINTER (ifindex));	if (!device) {		nm_log_warn (LOGD_IP6, "(%d): addrconf not started.", ifindex);		return NULL;	}	config = nm_ip6_config_new ();	if (!config) {		nm_log_err (LOGD_IP6, "(%s): out of memory creating IP6 config object.",		            device->iface);		return NULL;	}	/* Make sure we refill the route and address caches, otherwise we won't get	 * up-to-date information here since the netlink route/addr change messages	 * may be lagging a bit.	 */	nl_cache_refill (priv->nlh, priv->route_cache);	nl_cache_refill (priv->nlh, priv->addr_cache);	/* Add routes */	for (rtnlroute = FIRST_ROUTE (priv->route_cache); rtnlroute; rtnlroute = NEXT_ROUTE (rtnlroute)) {		/* Make sure it's an IPv6 route for this device */		if (rtnl_route_get_oif (rtnlroute) != device->ifindex)			continue;		if (rtnl_route_get_family (rtnlroute) != AF_INET6)			continue;		/* And ignore cache/cloned routes as they aren't part of the interface's		 * permanent routing configuration.		 */		if (rtnl_route_get_flags (rtnlroute) & RTM_F_CLONED)			continue;		nldest = rtnl_route_get_dst (rtnlroute);		if (!nldest || nl_addr_get_family (nldest) != AF_INET6)			continue;		dest = nl_addr_get_binary_addr (nldest);		nlgateway = rtnl_route_get_gateway (rtnlroute);		if (!nlgateway || nl_addr_get_family (nlgateway) != AF_INET6)			continue;		gateway = nl_addr_get_binary_addr (nlgateway);		if (rtnl_route_get_dst_len (rtnlroute) == 0) {			/* Default gateway route; cache the router's address for later */			if (!nm_ip6_config_get_gateway (config))				nm_ip6_config_set_gateway (config, gateway);			continue;		}		/* Also ignore link-local routes where the destination and gateway are		 * the same, which apparently get added by the kernel but return -EINVAL		 * when we try to add them via netlink.		 */		if (gateway && IN6_ARE_ADDR_EQUAL (dest, gateway))			continue;		ip6route = nm_ip6_route_new ();		nm_ip6_route_set_dest (ip6route, dest);		nm_ip6_route_set_prefix (ip6route, rtnl_route_get_dst_len (rtnlroute));		nm_ip6_route_set_next_hop (ip6route, gateway);		rtnl_route_get_metric(rtnlroute, 1, &metric);		if (metric != UINT_MAX)			nm_ip6_route_set_metric (ip6route, metric);		nm_ip6_config_take_route (config, ip6route);	}	/* Add addresses */	for (rtnladdr = FIRST_ADDR (priv->addr_cache); rtnladdr; rtnladdr = NEXT_ADDR (rtnladdr)) {		if (rtnl_addr_get_ifindex (rtnladdr) != device->ifindex)			continue;		nladdr = rtnl_addr_get_local (rtnladdr);		if (!nladdr || nl_addr_get_family (nladdr) != AF_INET6)			continue;//.........这里部分代码省略.........
开发者ID:alexander-naumov,项目名称:NetworkManager,代码行数:101,


示例2: udp6_input

//.........这里部分代码省略.........	pcbinfo = udp_get_inpcbinfo(nxt);	if (IN6_IS_ADDR_MULTICAST(&ip6->ip6_dst)) {		struct inpcb *last;		struct inpcbhead *pcblist;		struct ip6_moptions *imo;		INP_INFO_RLOCK(pcbinfo);		/*		 * In the event that laddr should be set to the link-local		 * address (this happens in RIPng), the multicast address		 * specified in the received packet will not match laddr.  To		 * handle this situation, matching is relaxed if the		 * receiving interface is the same as one specified in the		 * socket and if the destination multicast address matches		 * one of the multicast groups specified in the socket.		 */		/*		 * KAME note: traditionally we dropped udpiphdr from mbuf		 * here.  We need udphdr for IPsec processing so we do that		 * later.		 */		pcblist = udp_get_pcblist(nxt);		last = NULL;		LIST_FOREACH(inp, pcblist, inp_list) {			if ((inp->inp_vflag & INP_IPV6) == 0)				continue;			if (inp->inp_lport != uh->uh_dport)				continue;			if (inp->inp_fport != 0 &&			    inp->inp_fport != uh->uh_sport)				continue;			if (!IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_laddr)) {				if (!IN6_ARE_ADDR_EQUAL(&inp->in6p_laddr,							&ip6->ip6_dst))					continue;			}			if (!IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_faddr)) {				if (!IN6_ARE_ADDR_EQUAL(&inp->in6p_faddr,							&ip6->ip6_src) ||				    inp->inp_fport != uh->uh_sport)					continue;			}			/*			 * XXXRW: Because we weren't holding either the inpcb			 * or the hash lock when we checked for a match 			 * before, we should probably recheck now that the 			 * inpcb lock is (supposed to be) held.			 */			/*			 * Handle socket delivery policy for any-source			 * and source-specific multicast. [RFC3678]			 */			imo = inp->in6p_moptions;			if (imo && IN6_IS_ADDR_MULTICAST(&ip6->ip6_dst)) {				struct sockaddr_in6	 mcaddr;				int			 blocked;				INP_RLOCK(inp);				bzero(&mcaddr, sizeof(struct sockaddr_in6));				mcaddr.sin6_len = sizeof(struct sockaddr_in6);				mcaddr.sin6_family = AF_INET6;				mcaddr.sin6_addr = ip6->ip6_dst;
开发者ID:jaredmcneill,项目名称:freebsd,代码行数:67,


示例3: ip6_tryforward

//.........这里部分代码省略.........		goto dropin;	}	/*	 * We used slow path processing for packets with scoped addresses.	 * So, scope checks aren't needed here.	 */	if (m->m_pkthdr.len > nh.nh_mtu) {		in6_ifstat_inc(nh.nh_ifp, ifs6_in_toobig);		icmp6_error(m, ICMP6_PACKET_TOO_BIG, 0, nh.nh_mtu);		m = NULL;		goto dropout;	}	/*	 * Outgoing packet firewall processing.	 */	if (!PFIL_HOOKED(&V_inet6_pfil_hook))		goto passout;	if (pfil_run_hooks(&V_inet6_pfil_hook, &m, nh.nh_ifp, PFIL_OUT,	    NULL) != 0 || m == NULL)		goto dropout;	/*	 * If packet filter sets the M_FASTFWD_OURS flag, this means	 * that new destination or next hop is our local address.	 * So, we can just go back to ip6_input.	 *	 * Also it can forward packet to another destination, e.g.	 * M_IP6_NEXTHOP flag is set and fwd_tag is attached to mbuf.	 */	if (m->m_flags & M_FASTFWD_OURS) {		/*		 * XXX: we did one hop and should decrement hop limit. But		 * now we are the destination and just don't pay attention.		 */		return (m);	}	/*	 * Again. A packet filter could change the destination address.	 */	ip6 = mtod(m, struct ip6_hdr *);	if (m->m_flags & M_IP6_NEXTHOP)		fwd_tag = m_tag_find(m, PACKET_TAG_IPFORWARD, NULL);	else		fwd_tag = NULL;	if (fwd_tag != NULL ||	    !IN6_ARE_ADDR_EQUAL(&dst.sin6_addr, &ip6->ip6_dst)) {		if (fwd_tag != NULL) {			bcopy((fwd_tag + 1), &dst, sizeof(dst));			m->m_flags &= ~M_IP6_NEXTHOP;			m_tag_delete(m, fwd_tag);		} else			dst.sin6_addr = ip6->ip6_dst;		/*		 * Redo route lookup with new destination address		 */		if (ip6_findroute(&nh, &dst, m) != 0) {			m = NULL;			goto dropout;		}	}passout:#ifdef IPSTEALTH	if (!V_ip6stealth)#endif	{		ip6->ip6_hlim -= IPV6_HLIMDEC;	}	m_clrprotoflags(m);	/* Avoid confusing lower layers. */	IP_PROBE(send, NULL, NULL, ip6, nh.nh_ifp, NULL, ip6);	/*	 * XXX: we need to use destination address with embedded scope	 * zone id, because LLTABLE uses such form of addresses for lookup.	 */	dst.sin6_addr = nh.nh_addr;	if (IN6_IS_SCOPE_LINKLOCAL(&dst.sin6_addr))		dst.sin6_addr.s6_addr16[1] = htons(nh.nh_ifp->if_index & 0xffff);	error = (*nh.nh_ifp->if_output)(nh.nh_ifp, m,	    (struct sockaddr *)&dst, NULL);	if (error != 0) {		in6_ifstat_inc(nh.nh_ifp, ifs6_out_discard);		IP6STAT_INC(ip6s_cantforward);	} else {		in6_ifstat_inc(nh.nh_ifp, ifs6_out_forward);		IP6STAT_INC(ip6s_forward);	}	return (NULL);dropin:	in6_ifstat_inc(rcvif, ifs6_in_discard);	goto drop;dropout:	in6_ifstat_inc(nh.nh_ifp, ifs6_out_discard);drop:	if (m != NULL)		m_freem(m);	return (NULL);}
开发者ID:bsd-hacker,项目名称:freebsd,代码行数:101,


示例4: l2tp_ctrl_purge_ipsec_sa

/** Delete the IPsec SA for disconnection */static voidl2tp_ctrl_purge_ipsec_sa(l2tp_ctrl *_this){	int is_natt, proto;	struct sockaddr_storage peer, sock;	hash_link *hl;#ifdef USE_LIBSOCKUTIL	struct in_ipsec_sa_cookie *ipsec_sa_cookie;#endif	l2tp_ctrl *anot;	/*	 * Search another tunnel that uses the same IPsec SA	 * by lineer.	 */	for (hl = hash_first(_this->l2tpd->ctrl_map);	    hl != NULL; hl = hash_next(_this->l2tpd->ctrl_map)) {		anot = hl->item;		if (anot == _this)			continue;		if (_this->peer.ss_family != anot->peer.ss_family)			continue;		if (_this->peer.ss_family == AF_INET) {			if (SIN(&_this->peer)->sin_addr.s_addr !=			    SIN(&anot->peer)->sin_addr.s_addr)				continue;		} else if (_this->peer.ss_family == AF_INET6) {			if (!IN6_ARE_ADDR_EQUAL(			    &(SIN6(&_this->peer)->sin6_addr),			    &(SIN6(&anot->peer)->sin6_addr)))				continue;		}#ifdef USE_LIBSOCKUTIL		if (_this->sa_cookie != NULL && anot->sa_cookie != NULL) {			/* Both tunnels belong the same NAT box.  */			if (memcmp(_this->sa_cookie, anot->sa_cookie,			    sizeof(struct in_ipsec_sa_cookie)) != 0)				/* Different hosts behind the NAT box.  */				continue;			/* The SA is shared by another tunnels by one host. */			return;	/* don't purge the sa */		} else if (_this->sa_cookie != NULL || anot->sa_cookie != NULL)			/* Only one is behind the NAT */			continue;#endif		return;	/* don't purge the sa */	}#if defined(USE_LIBSOCKUTIL)  && defined(IP_IPSEC_SA_COOKIE)	is_natt = (_this->sa_cookie != NULL)? 1 : 0;#else	is_natt = 0;#endif	proto = 0;	memcpy(&peer, &_this->peer, _this->peer.ss_len);	memcpy(&sock, &_this->sock, _this->sock.ss_len);	if (!is_natt)		SIN(&peer)->sin_port = SIN(&sock)->sin_port = 0;#if defined(USE_LIBSOCKUTIL)  && defined(IP_IPSEC_SA_COOKIE)	else {		ipsec_sa_cookie = _this->sa_cookie;		SIN(&peer)->sin_port = ipsec_sa_cookie->remote_port;		SIN(&sock)->sin_port = ipsec_sa_cookie->local_port;#if 1		/*		 * XXX: As RFC 2367, protocol sould be specified if the port		 * XXX: number is non-zero.		 */		proto = 0;#else		proto = IPPROTO_UDP;#endif	}#endif	if (ipsec_util_purge_transport_sa((struct sockaddr *)&peer,	    (struct sockaddr *)&sock, proto, IPSEC_UTIL_DIRECTION_BOTH) != 0)		l2tp_ctrl_log(_this, LOG_NOTICE, "failed to purge IPSec SA");}
开发者ID:ajinkya93,项目名称:OpenBSD,代码行数:83,


示例5: nd6_ns_input

//.........这里部分代码省略.........				/*				 * proxy NDP for single entry				 */				proxydl = *SDL(&rt_gateway);				ifa = (struct ifaddr *)in6ifa_ifpforlinklocal(				    ifp, IN6_IFF_NOTREADY|IN6_IFF_ANYCAST);				if (ifa)					proxy = 1;			}		}	}	if (ifa == NULL) {		/*		 * We've got an NS packet, and we don't have that adddress		 * assigned for us.  We MUST silently ignore it.		 * See RFC2461 7.2.3.		 */		goto freeit;	}	myaddr6 = *IFA_IN6(ifa);	anycast = ((struct in6_ifaddr *)ifa)->ia6_flags & IN6_IFF_ANYCAST;	tentative = ((struct in6_ifaddr *)ifa)->ia6_flags & IN6_IFF_TENTATIVE;	if (((struct in6_ifaddr *)ifa)->ia6_flags & IN6_IFF_DUPLICATED)		goto freeit;	if (lladdr && ((ifp->if_addrlen + 2 + 7) & ~7) != lladdrlen) {		nd6log((LOG_INFO, "nd6_ns_input: lladdrlen mismatch for %s "		    "(if %d, NS packet %d)/n",		    ip6_sprintf(ip6bufs, &taddr6),		    ifp->if_addrlen, lladdrlen - 2));		goto bad;	}	if (IN6_ARE_ADDR_EQUAL(&myaddr6, &saddr6)) {		nd6log((LOG_INFO, "nd6_ns_input: duplicate IP6 address %s/n",		    ip6_sprintf(ip6bufs, &saddr6)));		goto freeit;	}	/*	 * We have neighbor solicitation packet, with target address equals to	 * one of my tentative address.	 *	 * src addr	how to process?	 * ---		---	 * multicast	of course, invalid (rejected in ip6_input)	 * unicast	somebody is doing address resolution -> ignore	 * unspec	dup address detection	 *	 * The processing is defined in RFC 2462.	 */	if (tentative) {		/*		 * If source address is unspecified address, it is for		 * duplicate address detection.		 *		 * If not, the packet is for addess resolution;		 * silently ignore it.		 */		if (IN6_IS_ADDR_UNSPECIFIED(&saddr6))			nd6_dad_ns_input(ifa, ndopts.nd_opts_nonce);		goto freeit;	}	/*
开发者ID:mulichao,项目名称:freebsd,代码行数:67,


示例6: inetport

static int inetport(struct Listener* listener){  struct irc_sockaddr lsin;  int                fd;  int                opt = 1;  /*   * At first, open a new socket   */  fd = comm_open(DEF_FAM, SOCK_STREAM, 0, "Listener socket");#ifdef IPV6  if (!IN6_ARE_ADDR_EQUAL((struct in6_addr *)&listener->addr, &in6addr_any))  {#else  if (INADDR_ANY != listener->addr.sins.sin.s_addr)  {#endif    inetntop(DEF_FAM, &IN_ADDR(listener->addr), listener->vhost, HOSTLEN);    listener->name = listener->vhost;  }  if (fd == -1)  {    report_error(L_ALL, "opening listener socket %s:%s",                 get_listener_name(listener), errno);    return 0;  }  else if ((HARD_FDLIMIT - 10) < fd)  {    report_error(L_ALL, "no more connections left for listener %s:%s",                 get_listener_name(listener), errno);    fd_close(fd);    return 0;  }  /*   * XXX - we don't want to do all this crap for a listener   * set_sock_opts(listener);   */  if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char*) &opt, sizeof(opt)))  {    report_error(L_ALL, "setting SO_REUSEADDR for listener %s:%s",                 get_listener_name(listener), errno);    fd_close(fd);    return 0;  }  /*   * Bind a port to listen for new connections if port is non-null,   * else assume it is already open and try get something from it.   */  memset(&lsin, 0, sizeof(struct irc_sockaddr));  S_FAM(lsin) = DEF_FAM;  copy_s_addr(S_ADDR(lsin), IN_ADDR(listener->addr));  S_PORT(lsin) = htons(listener->port);  if (bind(fd, (struct sockaddr*) &SOCKADDR(lsin),      sizeof(struct irc_sockaddr)))  {    report_error(L_ALL, "binding listener socket %s:%s",                 get_listener_name(listener), errno);    fd_close(fd);    return 0;  }  if (listen(fd, HYBRID_SOMAXCONN)) {    report_error(L_ALL, "listen failed for %s:%s",                 get_listener_name(listener), errno);    fd_close(fd);    return 0;  }  /*   * XXX - this should always work, performance will suck if it doesn't   */  if (!set_non_blocking(fd))    report_error(L_ALL, NONB_ERROR_MSG, get_listener_name(listener), errno);  listener->fd = fd;  /* Listen completion events are READ events .. */  accept_connection(fd, listener);  return 1;}static struct Listener* find_listener(int port, struct irc_inaddr *addr){  struct Listener* listener = NULL;  struct Listener* last_closed = NULL;  for (listener = ListenerPollList; listener; listener = listener->next)  {    if ( (port == listener->port) &&         (!memcmp(&PIN_ADDR(addr),                 &IN_ADDR(listener->addr),//.........这里部分代码省略.........
开发者ID:Cloudxtreme,项目名称:ircd-ratbox,代码行数:101,


示例7: map_fix_local_rlocs

static int map_fix_local_rlocs(struct locator_chain * lcptr){        int error = EINVAL;	struct sockaddr_in *rloc_inet = NULL;	struct sockaddr_in6 *rloc_inet6 = NULL;	struct in_ifaddr *ia = NULL;	struct in6_ifaddr *ia6 = NULL;	while ( lcptr ) {	       /* Scan the chain checking if the RLOC is the address 		* of a local interface. 		*/ 	        switch (lcptr->rloc.rloc_addr->ss_family) {      			case AF_INET:				        rloc_inet = (struct sockaddr_in *) lcptr->rloc.rloc_addr;				INADDR_TO_IFADDR(rloc_inet->sin_addr, ia); 				/*				 * If the address matches, set RLOCF_LIF 				 * flag and MTU.				 */				if ((ia != NULL) &&				    (IA_SIN(ia)->sin_addr.s_addr == rloc_inet->sin_addr.s_addr)) {				        lcptr->rloc.rloc_metrix.rlocmtx.flags |= RLOCF_LIF;					lcptr->rloc.rloc_metrix.rlocmtx.mtu = (ia->ia_ifp)->if_mtu;										error = 0;  				}; 			  				break;		    			case AF_INET6:			        rloc_inet6 = (struct sockaddr_in6 *) lcptr->rloc.rloc_addr;							ia6 = (struct in6_ifaddr *)ifa_ifwithaddr((struct sockaddr *)(rloc_inet6));				/*				 * If the address matches, set RLOCF_LIF 				 * flag and MTU.				 */				if ((ia6 != NULL) &&				    (IN6_ARE_ADDR_EQUAL(&ia6->ia_addr.sin6_addr,							&rloc_inet6->sin6_addr))) {				        lcptr->rloc.rloc_metrix.rlocmtx.flags |= RLOCF_LIF;					lcptr->rloc.rloc_metrix.rlocmtx.mtu = (ia6->ia_ifp)->if_mtu;										error = 0;  				};				break;		};	        lcptr = lcptr->next;	};#ifdef LISP_DEBUG	if (error) {	        DEBUGLISP("[MAP_FIX_LOCAL_RLOC] No local IF RLOCs Provided for local mapping! /n");	};#endif /* LISP_DEBUG */	return (error);}  /* map_fix_local_rloc() */
开发者ID:chavula,项目名称:data-plane,代码行数:78,


示例8: failed_service

static status_e failed_service(struct service *sp,                                 connection_s *cp,                                 access_e result){   struct service_config *scp = SVC_CONF( sp ) ;   if ( result != AC_OK )   {      bool_int report_failure = TRUE ;      /*       * Try to avoid reporting multiple times a failed attempt to access       * a datagram-based service from a bad address. We do this because       * the clients of such services usually send multiple datagrams        * before reporting a timeout (we have no way of telling them that       * their request has been denied).       */      if ( result == AC_ADDRESS && SVC_SOCKET_TYPE( sp ) == SOCK_DGRAM )      {         if( SC_IPV4( scp ) ) {            struct sockaddr_in *sinp = SAIN(CONN_ADDRESS( cp )) ;            struct sockaddr_in *last = SAIN(SVC_LAST_DGRAM_ADDR(sp)) ;            time_t current_time ;            if (sinp == NULL )               return FAILED;            if ( last == NULL ) {               last = SAIN( calloc( 1, sizeof(union xsockaddr) ) );	       SVC_LAST_DGRAM_ADDR(sp) = (union xsockaddr *)last;            }            (void) time( &current_time ) ;            if ( sinp->sin_addr.s_addr == last->sin_addr.s_addr &&                                          sinp->sin_port == last->sin_port )            {               if( current_time - SVC_LAST_DGRAM_TIME(sp) <= DGRAM_IGNORE_TIME )                  report_failure = FALSE ;               else                  SVC_LAST_DGRAM_TIME(sp) = current_time ;            }            else            {               memcpy(SVC_LAST_DGRAM_ADDR(sp), sinp,sizeof(struct sockaddr_in));               SVC_LAST_DGRAM_TIME(sp) = current_time ;            }         } else if( SC_IPV6( scp ) ) {            struct sockaddr_in6 *sinp = SAIN6(CONN_ADDRESS( cp )) ;            struct sockaddr_in6 *last = SAIN6(SVC_LAST_DGRAM_ADDR(sp)) ;            time_t current_time ;	    if (sinp == NULL )               return FAILED;	    if( last == NULL ) {               last = SAIN6(calloc( 1, sizeof(union xsockaddr) ) );	       SVC_LAST_DGRAM_ADDR( sp ) = (union xsockaddr *)last;            }            (void) time( &current_time ) ;            if ( IN6_ARE_ADDR_EQUAL(&(sinp->sin6_addr), &(last->sin6_addr)) &&                  sinp->sin6_port == last->sin6_port )            {               if((current_time - SVC_LAST_DGRAM_TIME(sp)) <= DGRAM_IGNORE_TIME)                  report_failure = FALSE ;               else                  SVC_LAST_DGRAM_TIME(sp) = current_time ;            }            else            {               memcpy(SVC_LAST_DGRAM_ADDR(sp),sinp,sizeof(struct sockaddr_in6));               SVC_LAST_DGRAM_TIME(sp) = current_time ;            }         }      }      if ( report_failure )         svc_log_failure( sp, cp, result ) ;      banner_fail(sp, cp);      return( FAILED ) ;   }   return( OK );}
开发者ID:Veilen,项目名称:xinetd,代码行数:86,


示例9: in6_selectsrc

//.........这里部分代码省略.........	/*	 * If the destination address is a link-local unicast address or	 * a link/interface-local multicast address, and if the outgoing	 * interface is specified by the sin6_scope_id filed, use an address	 * associated with the interface.	 * XXX: We're now trying to define more specific semantics of	 *      sin6_scope_id field, so this part will be rewritten in	 *      the near future.	 */	if ((IN6_IS_ADDR_LINKLOCAL(dst) || IN6_IS_ADDR_MC_LINKLOCAL(dst) ||	     IN6_IS_ADDR_MC_INTFACELOCAL(dst)) && dstsock->sin6_scope_id) {		ifp = if_get(dstsock->sin6_scope_id);		if (ifp == NULL)			return (ENXIO); /* XXX: better error? */		ia6 = in6_ifawithscope(ifp, dst, rtableid);		if_put(ifp);		if (ia6 == NULL)			return (EADDRNOTAVAIL);		*in6src = &ia6->ia_addr.sin6_addr;		return (0);	}	/*	 * If the destination address is a multicast address and	 * the outgoing interface for the address is specified	 * by the caller, use an address associated with the interface.	 * Even if the outgoing interface is not specified, we also	 * choose a loopback interface as the outgoing interface.	 */	if (IN6_IS_ADDR_MULTICAST(dst)) {		ifp = mopts ? if_get(mopts->im6o_ifidx) : NULL;		if (!ifp && dstsock->sin6_scope_id)			ifp = if_get(htons(dstsock->sin6_scope_id));		if (ifp) {			ia6 = in6_ifawithscope(ifp, dst, rtableid);			if_put(ifp);			if (ia6 == NULL)				return (EADDRNOTAVAIL);			*in6src = &ia6->ia_addr.sin6_addr;			return (0);		}	}	/*	 * If route is known or can be allocated now,	 * our src addr is taken from the i/f, else punt.	 */	if (ro) {		if (!rtisvalid(ro->ro_rt) || (ro->ro_tableid != rtableid) ||		    !IN6_ARE_ADDR_EQUAL(&ro->ro_dst.sin6_addr, dst)) {			rtfree(ro->ro_rt);			ro->ro_rt = NULL;		}		if (ro->ro_rt == NULL) {			struct sockaddr_in6 *sa6;			/* No route yet, so try to acquire one */			bzero(&ro->ro_dst, sizeof(struct sockaddr_in6));			ro->ro_tableid = rtableid;			sa6 = &ro->ro_dst;			sa6->sin6_family = AF_INET6;			sa6->sin6_len = sizeof(struct sockaddr_in6);			sa6->sin6_addr = *dst;			sa6->sin6_scope_id = dstsock->sin6_scope_id;			ro->ro_rt = rtalloc(sin6tosa(&ro->ro_dst),			    RT_RESOLVE, ro->ro_tableid);		}		/*		 * in_pcbconnect() checks out IFF_LOOPBACK to skip using		 * the address. But we don't know why it does so.		 * It is necessary to ensure the scope even for lo0		 * so doesn't check out IFF_LOOPBACK.		 */		if (ro->ro_rt) {			ifp = if_get(ro->ro_rt->rt_ifidx);			if (ifp != NULL) {				ia6 = in6_ifawithscope(ifp, dst, rtableid);				if_put(ifp);			}			if (ia6 == NULL) /* xxx scope error ?*/				ia6 = ifatoia6(ro->ro_rt->rt_ifa);		}		if (ia6 == NULL)			return (EHOSTUNREACH);	/* no route */		*in6src = &ia6->ia_addr.sin6_addr;		return (0);	}	return (EADDRNOTAVAIL);}
开发者ID:ajinkya93,项目名称:OpenBSD,代码行数:101,


示例10: reload_config_file

/* * Re-Read the configuration file. * Return 1 on success, 0 on failure. * In case of failure, the old configuration will be unchanged (although the cache may not) and * **errstr will refer to a newly allocated string containing an error message. */int reload_config_file(const char *nm, char **errstr){	globparm_t global_new;	servparm_array servers_new;	global_new=global;	global_new.cache_dir=NULL;	global_new.pidfile=NULL;	global_new.scheme_file=NULL;	global_new.deleg_only_zones=NULL;	global_new.onquery=0;	servers_new=NULL;	if(read_config_file(nm,&global_new,&servers_new,0,errstr)) {		if(global_new.cache_dir && strcmp(global_new.cache_dir,global.cache_dir)) {			*errstr=strdup("Cannot reload config file: the specified cache_dir directory has changed./n"				       "Try restarting pdnsd instead.");			goto cleanup_return;		}		if(global_new.pidfile && (!global.pidfile || strcmp(global_new.pidfile,global.pidfile))) {			*errstr=strdup("Cannot reload config file: the specified pid_file has changed./n"				       "Try restarting pdnsd instead.");			goto cleanup_return;		}		if(global_new.scheme_file && strcmp(global_new.scheme_file,global.scheme_file)) {			*errstr=strdup("Cannot reload config file: the specified scheme_file has changed./n"				       "Try restarting pdnsd instead.");			goto cleanup_return;		}		if(global_new.port!=global.port) {			*errstr=strdup("Cannot reload config file: the specified server_port has changed./n"				       "Try restarting pdnsd instead.");			goto cleanup_return;		}		if(!ADDR_EQUIV(&global_new.a,&global.a)) {			*errstr=strdup("Cannot reload config file: the specified interface address (server_ip) has changed./n"				       "Try restarting pdnsd instead.");			goto cleanup_return;		}#ifdef ENABLE_IPV6		if(!IN6_ARE_ADDR_EQUAL(&global_new.ipv4_6_prefix,&global.ipv4_6_prefix)) {			*errstr=strdup("Cannot reload config file: the specified ipv4_6_prefix has changed./n"				       "Try restarting pdnsd instead.");			goto cleanup_return;		}#endif		if(strcmp(global_new.run_as,global.run_as)) {			*errstr=strdup("Cannot reload config file: the specified run_as id has changed./n"				       "Try restarting pdnsd instead.");			goto cleanup_return;		}		if(global_new.daemon!=global.daemon) {			*errstr=strdup("Cannot reload config file: the daemon option has changed./n"				       "Try restarting pdnsd instead.");			goto cleanup_return;		}		if(global_new.debug!=global.debug) {			*errstr=strdup("Cannot reload config file: the debug option has changed./n"				       "Try restarting pdnsd instead.");			goto cleanup_return;		}		if(global_new.stat_pipe!=global.stat_pipe) {			*errstr=strdup("Cannot reload config file: the status_ctl option has changed./n"				       "Try restarting pdnsd instead.");			goto cleanup_return;		}		if(global_new.notcp!=global.notcp) {			*errstr=strdup("Cannot reload config file: the tcp_server option has changed./n"				       "Try restarting pdnsd instead.");			goto cleanup_return;		}		if(global_new.strict_suid!=global.strict_suid) {			*errstr=strdup("Cannot reload config file: the strict_setuid option has changed./n"				       "Try restarting pdnsd instead.");			goto cleanup_return;		}		if(global_new.ctl_perms!=global.ctl_perms) {			*errstr=strdup("Cannot reload config file: the specified ctl_perms has changed./n"				       "Try restarting pdnsd instead.");			goto cleanup_return;		}		if(ping_isocket==-1#ifdef ENABLE_IPV6		   && ping6_isocket==-1#endif		  ) {			int i,n=DA_NEL(servers_new);			for (i=0;i<n;++i) {				if (DA_INDEX(servers_new,i).uptest==C_PING) {					if(asprintf(errstr,"Cannot reload config file: the ping socket is not initialized"						    " and the new config contains uptest=ping in server section %i./n"						    "Try restarting pdnsd instead.",i)<0)						*errstr=NULL;					goto cleanup_return;				}//.........这里部分代码省略.........
开发者ID:Leon1108,项目名称:shadowsocks-android,代码行数:101,


示例11: insertRoute

//.........这里部分代码省略.........            // No location set, so insert in on the table top.            routing_table = newroute;            IF_DEBUG atlog(LOG_DEBUG, 0, "No routes in table. Insert at beginning.");        }        else         {            IF_DEBUG atlog(LOG_DEBUG, 0, "Found existing routes. Find insert location.");            // Check if the route could be inserted at the beginning...            if( memcmp(&routing_table->group, group, sizeof(struct in6_addr)) > 0 )             {                //IF_DEBUG atlog(LOG_DEBUG, 0, "Inserting at beginning, before route %s",inetFmt(routing_table->group,s1));                // Insert at beginning...                newroute->nextroute = routing_table;                newroute->prevroute = NULL;                routing_table = newroute;                // If the route has a next node, the previous pointer must be updated.                if(newroute->nextroute != NULL)                 {                    newroute->nextroute->prevroute = newroute;                }            }             else             {                // Find the location which is closest to the route.                for( croute = routing_table; croute->nextroute != NULL; croute = croute->nextroute )                 {                    // Find insert position.                    if( memcmp( &(croute->nextroute->group), group, sizeof(struct in6_addr) ) > 0 )                         break;                }                //IF_DEBUG atlog(LOG_DEBUG, 0, "Inserting after route %s",inetFmt(croute->group,s1));                                // Insert after current...                newroute->nextroute = croute->nextroute;                newroute->prevroute = croute;                if(croute->nextroute != NULL)                 {                    croute->nextroute->prevroute = newroute;                 }                croute->nextroute = newroute;            }        }        // Set the new route as the current...        croute = newroute;             if( !IN6_ARE_ADDR_EQUAL( &croute->originAddr, &allzero_addr) )         {            // Update route in kernel...            if( !internUpdateKernelRoute(croute, 1) )             {                atlog(LOG_WARNING, 0, "The insertion into Kernel failed.");                return 0;            }        }        }     else if(from->sin6_scope_id >= 0)     {        if( !IN6_ARE_ADDR_EQUAL( &croute->originAddr, &allzero_addr) )         {            // The route exists already, so just update it.            BIT_SET(croute->vifBits, from->sin6_scope_id);                        // Register the VIF activity for the aging routine            BIT_SET(croute->ageVifBits, from->sin6_scope_id);        }        else        {            tmpRoute = findNextRoute(group, NULL);            while (tmpRoute != NULL)            {                // The route exists already, so just update it.                BIT_SET(tmpRoute->vifBits, from->sin6_scope_id);                                // Register the VIF activity for the aging routine                BIT_SET(tmpRoute->ageVifBits, from->sin6_scope_id);                if (tmpRoute->nextroute)                    tmpRoute = findNextRoute(group, tmpRoute->nextroute);                  else                    break;            }        }    }    // Send join message upstream, if the route has no joined flag...    if(croute->upstrState != ROUTESTATE_JOINED)    {        // Send Join request upstream        sendJoinLeaveUpstream(croute, 1);    }    IF_DEBUG atlogRouteTable("Insert Route");    return 1;}
开发者ID:springware,项目名称:92u10,代码行数:101,


示例12: process_nduseropt_rdnss

static gbooleanprocess_nduseropt_rdnss (NMIP6Device *device, struct nd_opt_hdr *opt){	size_t opt_len;	struct nd_opt_rdnss *rdnss_opt;	time_t now = time (NULL);	struct in6_addr *addr;	GArray *new_servers;	NMIP6RDNSS server, *cur_server;	gboolean changed = FALSE;	guint i;	opt_len = opt->nd_opt_len;	if (opt_len < 3 || (opt_len & 1) == 0)		return FALSE;	rdnss_opt = (struct nd_opt_rdnss *) opt;	new_servers = g_array_new (FALSE, FALSE, sizeof (NMIP6RDNSS));	/* Pad the DNS server expiry somewhat to give a bit of slack in cases	 * where one RA gets lost or something (which can happen on unreliable	 * links like WiFi where certain types of frames are not retransmitted).	 * Note that 0 has special meaning and is therefore not adjusted.	 */	server.expires = ntohl (rdnss_opt->nd_opt_rdnss_lifetime);	if (server.expires > 0)		if (server.expires < 7200)			server.expires = 7200;		server.expires += now;	for (addr = (struct in6_addr *) (rdnss_opt + 1); opt_len >= 2; addr++, opt_len -= 2) {		char buf[INET6_ADDRSTRLEN + 1];		if (!inet_ntop (AF_INET6, addr, buf, sizeof (buf))) {			nm_log_warn (LOGD_IP6, "(%s): received invalid RA-provided nameserver", device->iface);			continue;		}		/* Update the cached timeout if we already saw this server */		for (i = 0; i < device->rdnss_servers->len; i++) {			cur_server = &(g_array_index (device->rdnss_servers, NMIP6RDNSS, i));			if (!IN6_ARE_ADDR_EQUAL (addr, &cur_server->addr))				continue;			cur_server->expires = server.expires;			if (server.expires > 0) {				nm_log_dbg (LOGD_IP6, "(%s): refreshing RA-provided nameserver %s (expires in %ld seconds)",				            device->iface, buf,				            server.expires - now);				break;			}			nm_log_dbg (LOGD_IP6, "(%s): removing RA-provided nameserver %s on router request",			            device->iface, buf);			g_array_remove_index (device->rdnss_servers, i);			changed = TRUE;			break;		}		if (server.expires == 0)			continue;		if (i < device->rdnss_servers->len)			continue;		nm_log_dbg (LOGD_IP6, "(%s): found RA-provided nameserver %s (expires in %ld seconds)",		            device->iface, buf, server.expires - now);		server.addr = *addr;		g_array_append_val (new_servers, server);	}	/* New servers must be added in the order they are listed in the	 * RA option and before any existing servers.	 *	 * Note: This is the place to remove servers if we want to cap the	 *       number of resolvers. The RFC states that the one to expire	 *       first of the existing servers should be removed.	 */	if (new_servers->len) {		g_array_prepend_vals (device->rdnss_servers,		                      new_servers->data, new_servers->len);		changed = TRUE;	}	g_array_free (new_servers, TRUE);	/* Timeouts may have changed even if IPs didn't */	set_rdnss_timeout (device);	return changed;}
开发者ID:alexander-naumov,项目名称:NetworkManager,代码行数:96,


示例13: ip6_forward

//.........这里部分代码省略.........	if (!srcrt) {		/*		 * ip6forward_rt->ro_dst.sin6_addr is equal to ip6->ip6_dst		 */		if (ROUTE_UNUSABLE(ip6forward_rt)) {			if (rt != NULL) {				/* Release extra ref */				RT_REMREF_LOCKED(rt);				RT_UNLOCK(rt);			}			ROUTE_RELEASE(ip6forward_rt);			/* this probably fails but give it a try again */			rtalloc_scoped_ign((struct route *)ip6forward_rt,			    RTF_PRCLONING, ifscope);			if ((rt = ip6forward_rt->ro_rt) != NULL) {				RT_LOCK(rt);				/* Take an extra ref for ourselves */				RT_ADDREF_LOCKED(rt);			}		}		if (rt == NULL) {			ip6stat.ip6s_noroute++;			in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_noroute);			if (mcopy)				icmp6_error(mcopy, ICMP6_DST_UNREACH,					    ICMP6_DST_UNREACH_NOROUTE, 0);			m_freem(m);			return (NULL);		}		RT_LOCK_ASSERT_HELD(rt);	} else if (ROUTE_UNUSABLE(ip6forward_rt) ||	    !IN6_ARE_ADDR_EQUAL(&ip6->ip6_dst, &dst->sin6_addr)) {		if (rt != NULL) {			/* Release extra ref */			RT_REMREF_LOCKED(rt);			RT_UNLOCK(rt);		}		ROUTE_RELEASE(ip6forward_rt);		bzero(dst, sizeof(*dst));		dst->sin6_len = sizeof(struct sockaddr_in6);		dst->sin6_family = AF_INET6;		dst->sin6_addr = ip6->ip6_dst;		rtalloc_scoped_ign((struct route *)ip6forward_rt,		    RTF_PRCLONING, ifscope);		if ((rt = ip6forward_rt->ro_rt) == NULL) {			ip6stat.ip6s_noroute++;			in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_noroute);			if (mcopy)				icmp6_error(mcopy, ICMP6_DST_UNREACH,				    ICMP6_DST_UNREACH_NOROUTE, 0);			m_freem(m);			return (NULL);		}		RT_LOCK(rt);		/* Take an extra ref for ourselves */		RT_ADDREF_LOCKED(rt);	}	/*	 * Source scope check: if a packet can't be delivered to its	 * destination for the reason that the destination is beyond the scope	 * of the source address, discard the packet and return an icmp6
开发者ID:JackieXie168,项目名称:xnu,代码行数:67,


示例14: nd6_ns_input

//.........这里部分代码省略.........				 * target mac, else our mac is used.				 */				if (cmpifp == rtifp &&				    (rt->rt_flags & RTF_ANNOUNCE) &&				    rt->rt_gateway->sa_family == AF_LINK) {					proxydl = SDL(rt->rt_gateway);				}			}		}		if (rt != NULL)			--rt->rt_refcnt;	}	if (ifa == NULL) {		/*		 * We've got an NS packet, and we don't have that adddress		 * assigned for us.  We MUST silently ignore it.		 * See RFC2461 7.2.3.		 */		goto freeit;	}	myaddr6 = *IFA_IN6(ifa);	anycast = ((struct in6_ifaddr *)ifa)->ia6_flags & IN6_IFF_ANYCAST;	tentative = ((struct in6_ifaddr *)ifa)->ia6_flags & IN6_IFF_TENTATIVE;	if (((struct in6_ifaddr *)ifa)->ia6_flags & IN6_IFF_DUPLICATED)		goto freeit;	if (lladdr && ((cmpifp->if_addrlen + 2 + 7) & ~7) != lladdrlen) {		nd6log((LOG_INFO, "nd6_ns_input: lladdrlen mismatch for %s "		    "(if %d, NS packet %d)/n",		    ip6_sprintf(&taddr6), cmpifp->if_addrlen, lladdrlen - 2));		goto bad;	}	if (IN6_ARE_ADDR_EQUAL(&myaddr6, &saddr6)) {		nd6log((LOG_INFO, "nd6_ns_input: duplicate IP6 address %s/n",		    ip6_sprintf(&saddr6)));		goto freeit;	}	/*	 * We have neighbor solicitation packet, with target address equals to	 * one of my tentative address.	 *	 * src addr	how to process?	 * ---		---	 * multicast	of course, invalid (rejected in ip6_input)	 * unicast	somebody is doing address resolution -> ignore	 * unspec	dup address detection	 *	 * The processing is defined in RFC 2462.	 */	if (tentative) {		/*		 * If source address is unspecified address, it is for		 * duplicated address detection.		 *		 * If not, the packet is for addess resolution;		 * silently ignore it.		 */		if (IN6_IS_ADDR_UNSPECIFIED(&saddr6))			nd6_dad_ns_input(ifa);		goto freeit;	}	/*
开发者ID:iHaD,项目名称:DragonFlyBSD,代码行数:67,


示例15: sctp_ire_cache_flush

/* * Walk the SCTP global list and refrele the ire for this ipif * This is called when an address goes down, so that we release any reference * to the ire associated with this address. Additionally, for any SCTP if * this was the only/last address in its source list, we don't kill the * assoc., if there is no address added subsequently, or if this does not * come up, then the assoc. will die a natural death (i.e. timeout). */voidsctp_ire_cache_flush(ipif_t *ipif){	sctp_t			*sctp;	sctp_t			*sctp_prev = NULL;	sctp_faddr_t		*fp;	conn_t			*connp;	ire_t			*ire;	sctp = gsctp;	mutex_enter(&sctp_g_lock);	while (sctp != NULL) {		mutex_enter(&sctp->sctp_reflock);		if (sctp->sctp_condemned) {			mutex_exit(&sctp->sctp_reflock);			sctp = list_next(&sctp_g_list, sctp);			continue;		}		sctp->sctp_refcnt++;		mutex_exit(&sctp->sctp_reflock);		mutex_exit(&sctp_g_lock);		if (sctp_prev != NULL)			SCTP_REFRELE(sctp_prev);		RUN_SCTP(sctp);		connp = sctp->sctp_connp;		mutex_enter(&connp->conn_lock);		ire = connp->conn_ire_cache;		if (ire != NULL && ire->ire_ipif == ipif) {			connp->conn_ire_cache = NULL;			mutex_exit(&connp->conn_lock);			IRE_REFRELE_NOTR(ire);		} else {			mutex_exit(&connp->conn_lock);		}		/* check for ires cached in faddr */		for (fp = sctp->sctp_faddrs; fp != NULL; fp = fp->next) {			/*			 * If this ipif is being used as the source address			 * we need to update it as well, else we will end			 * up using the dead source address.			 */			ire = fp->ire;			if (ire != NULL && ire->ire_ipif == ipif) {				fp->ire = NULL;				IRE_REFRELE_NOTR(ire);			}			/*			 * This may result in setting the fp as unreachable,			 * i.e. if all the source addresses are down. In			 * that case the assoc. would timeout.			 */			if (IN6_ARE_ADDR_EQUAL(&ipif->ipif_v6lcl_addr,			    &fp->saddr)) {				sctp_set_saddr(sctp, fp);				if (fp == sctp->sctp_current &&				    fp->state != SCTP_FADDRS_UNREACH) {					sctp_set_faddr_current(sctp, fp);				}			}		}		WAKE_SCTP(sctp);		sctp_prev = sctp;		mutex_enter(&sctp_g_lock);		sctp = list_next(&sctp_g_list, sctp);	}	mutex_exit(&sctp_g_lock);	if (sctp_prev != NULL)		SCTP_REFRELE(sctp_prev);}
开发者ID:andreiw,项目名称:polaris,代码行数:78,


示例16: v6_v6_equal

static gbooleanv6_v6_equal (const struct sockaddr_in6 *a,	     const struct sockaddr_in6 *b){	return IN6_ARE_ADDR_EQUAL (&a->sin6_addr, &b->sin6_addr);}
开发者ID:Distrotech,项目名称:gnome-vfs,代码行数:6,


示例17: processNS

//.........这里部分代码省略.........    if ( IN6_IS_ADDR_UNSPECIFIED(srcaddr) )    {         flog(LOG_DEBUG, "Unspecified src addr - DAD activity. Ignoring NS.");        return;    }        // Based upon the dstaddr, record if this was a unicast or multicast NS.    // If unicast, we'll use that later when we decide whether to add the    // target link-layer option to any outgoing NA.    if ( IN6_IS_ADDR_MULTICAST(dstaddr) )    {        // This was a multicast NS        flog(LOG_DEBUG2, "Multicast NS");        multicastNS = 1;    }else    {        // This was a unicast NS        flog(LOG_DEBUG2, "Unicast NS");        multicastNS=0;    }        // Within the NS, who are they looking for?    targetaddr = (struct in6_addr *)&(ns->nd_ns_target);    if (debug || listLog)    {        print_addr16(targetaddr, targetaddr_str);        print_addr16(&prefixaddr, prefixaddr_str);        flog(LOG_DEBUG, "NS target addr: %s", targetaddr_str);        flog(LOG_DEBUG, "Local prefix: %s", prefixaddr_str);    }        // If tgt-addr == dst-addr then ignore this, as the automatic mechanisms    // will reply themselves - we don't need to.    if ( nsIgnoreLocal && IN6_ARE_ADDR_EQUAL(targetaddr, dstaddr) )    {        flog(LOG_DEBUG, "tgt==dst - Ignore.");        return;    }        // Check for black or white listing compliance    switch (listType) {        case NOLIST:            flog(LOG_DEBUG2, "Neither white nor black listing in operation.");            break;                    case BLACKLIST:            // See if the address matches an expression            if((compareExpression(targetaddr) == 1))            {                flog(LISTLOGGING, "NS for blacklisted EXPR address: %s", targetaddr_str);                return; // Abandon            }            // If active and tgt is in the list, bail.            if ( tfind( (void *)targetaddr, &lRoot, tCompare) )            {                flog(LISTLOGGING, "NS for blacklisted specific addr: %s", targetaddr_str);                return; //Abandon            }            break;                    case WHITELIST:            // See if the address matches an expression            if((compareExpression(targetaddr) == 1))            {                flog(LISTLOGGING, "NS for whitelisted EXPR: %s", targetaddr_str);                break;	// Don't check further - we got a hit.
开发者ID:ju5t,项目名称:npd6,代码行数:67,


示例18: ipsp_process_packet

//.........这里部分代码省略.........					return ENOBUFS;			}#ifdef INET			if (af == AF_INET) {				ip = mtod(m, struct ip *);				/*				 * This is not a bridge packet, remember if we				 * had IP_DF.				 */				setdf = ip->ip_off & htons(IP_DF);			}#endif /* INET */#ifdef INET6			if (af == AF_INET6)				ip6 = mtod(m, struct ip6_hdr *);#endif /* INET6 */		}		/* Do the appropriate encapsulation, if necessary. */		if ((tdb->tdb_dst.sa.sa_family != af) || /* PF mismatch */		    (tdb->tdb_flags & TDBF_TUNNELING) || /* Tunneling needed */		    (tdb->tdb_xform->xf_type == XF_IP4) || /* ditto */#ifdef INET		    ((tdb->tdb_dst.sa.sa_family == AF_INET) &&			(tdb->tdb_dst.sin.sin_addr.s_addr != INADDR_ANY) &&			(tdb->tdb_dst.sin.sin_addr.s_addr != ip->ip_dst.s_addr)) ||#endif /* INET */#ifdef INET6		    ((tdb->tdb_dst.sa.sa_family == AF_INET6) &&			(!IN6_IS_ADDR_UNSPECIFIED(&tdb->tdb_dst.sin6.sin6_addr)) &&			(!IN6_ARE_ADDR_EQUAL(&tdb->tdb_dst.sin6.sin6_addr,			    &ip6->ip6_dst))) ||#endif /* INET6 */		    0) {#ifdef INET			/* Fix IPv4 header checksum and length. */			if (af == AF_INET) {				if (m->m_len < sizeof(struct ip))					if ((m = m_pullup(m,					    sizeof(struct ip))) == NULL)						return ENOBUFS;				ip = mtod(m, struct ip *);				ip->ip_len = htons(m->m_pkthdr.len);				ip->ip_sum = 0;				ip->ip_sum = in_cksum(m, ip->ip_hl << 2);			}#endif /* INET */#ifdef INET6			/* Fix IPv6 header payload length. */			if (af == AF_INET6) {				if (m->m_len < sizeof(struct ip6_hdr))					if ((m = m_pullup(m,					    sizeof(struct ip6_hdr))) == NULL)						return ENOBUFS;				if (m->m_pkthdr.len - sizeof(*ip6) >				    IPV6_MAXPACKET) {					/* No jumbogram support. */					m_freem(m);					return ENXIO;	/*?*/				}
开发者ID:bradla,项目名称:OpenBSD-Hammer2,代码行数:67,


示例19: in6_pcbnotify

//.........这里部分代码省略.........	flowinfo = sa6_src.sin6_flowinfo;	/*	 * Redirects go to all references to the destination,	 * and use in_rtchange to invalidate the route cache.	 * Dead host indications: also use in_rtchange to invalidate	 * the cache, and deliver the error to all the sockets.	 * Otherwise, if we have knowledge of the local port and address,	 * deliver only to that socket.	 */	if (PRC_IS_REDIRECT(cmd) || cmd == PRC_HOSTDEAD) {		fport = 0;		lport = 0;		sa6_src.sin6_addr = in6addr_any;		if (cmd != PRC_HOSTDEAD)			notify = in_rtchange;	}	errno = inet6ctlerrmap[cmd];	for (inp = CIRCLEQ_FIRST(&head->inpt_queue);	     inp != CIRCLEQ_END(&head->inpt_queue); inp = ninp) {		ninp = CIRCLEQ_NEXT(inp, inp_queue);		if ((inp->inp_flags & INP_IPV6) == 0)			continue;		/*		 * Under the following condition, notify of redirects		 * to the pcb, without making address matches against inpcb.		 * - redirect notification is arrived.		 * - the inpcb is unconnected.		 * - the inpcb is caching !RTF_HOST routing entry.		 * - the ICMPv6 notification is from the gateway cached in the		 *   inpcb.  i.e. ICMPv6 notification is from nexthop gateway		 *   the inpcb used very recently.		 *		 * This is to improve interaction between netbsd/openbsd		 * redirect handling code, and inpcb route cache code.		 * without the clause, !RTF_HOST routing entry (which carries		 * gateway used by inpcb right before the ICMPv6 redirect)		 * will be cached forever in unconnected inpcb.		 *		 * There still is a question regarding to what is TRT:		 * - On bsdi/freebsd, RTF_HOST (cloned) routing entry will be		 *   generated on packet output.  inpcb will always cache		 *   RTF_HOST routing entry so there's no need for the clause		 *   (ICMPv6 redirect will update RTF_HOST routing entry,		 *   and inpcb is caching it already).		 *   However, bsdi/freebsd are vulnerable to local DoS attacks		 *   due to the cloned routing entries.		 * - Specwise, "destination cache" is mentioned in RFC2461.		 *   Jinmei says that it implies bsdi/freebsd behavior, itojun		 *   is not really convinced.		 * - Having hiwat/lowat on # of cloned host route (redirect/		 *   pmtud) may be a good idea.  netbsd/openbsd has it.  see		 *   icmp6_mtudisc_update().		 */		if ((PRC_IS_REDIRECT(cmd) || cmd == PRC_HOSTDEAD) &&		    IN6_IS_ADDR_UNSPECIFIED(&inp->inp_laddr6) &&		    inp->inp_route.ro_rt &&		    !(inp->inp_route.ro_rt->rt_flags & RTF_HOST)) {			struct sockaddr_in6 *dst6;			dst6 = (struct sockaddr_in6 *)&inp->inp_route.ro_dst;			if (IN6_ARE_ADDR_EQUAL(&dst6->sin6_addr,			    &sa6_dst->sin6_addr))				goto do_notify;		}		/*		 * Detect if we should notify the error. If no source and		 * destination ports are specified, but non-zero flowinfo and		 * local address match, notify the error. This is the case		 * when the error is delivered with an encrypted buffer		 * by ESP. Otherwise, just compare addresses and ports		 * as usual.		 */		if (lport == 0 && fport == 0 && flowinfo &&		    inp->inp_socket != NULL &&		    flowinfo == (inp->inp_flowinfo & IPV6_FLOWLABEL_MASK) &&		    IN6_ARE_ADDR_EQUAL(&inp->inp_laddr6, &sa6_src.sin6_addr))			goto do_notify;		else if (!IN6_ARE_ADDR_EQUAL(&inp->inp_faddr6,					     &sa6_dst->sin6_addr) ||			 inp->inp_socket == 0 ||			 (lport && inp->inp_lport != lport) ||			 (!IN6_IS_ADDR_UNSPECIFIED(&sa6_src.sin6_addr) &&			  !IN6_ARE_ADDR_EQUAL(&inp->inp_laddr6,					      &sa6_src.sin6_addr)) ||			 (fport && inp->inp_fport != fport)) {			continue;		}	  do_notify:		nmatch++;		if (notify)			(*notify)(inp, errno);	}	return (nmatch);}
开发者ID:7shi,项目名称:openbsd-loongson-vc,代码行数:101,


示例20: ip6_addr_match

int __inline__ ip6_addr_match(struct in6_addr *addr) {    return IN6_ARE_ADDR_EQUAL(addr, &if_ip6_addr);}
开发者ID:githublefantian,项目名称:iftopd,代码行数:3,


示例21: inetport

static intinetport(struct Listener *listener){	int fd;	int opt = 1;	/*	 * At first, open a new socket	 */	fd = comm_socket(listener->addr.ss_family, SOCK_STREAM, 0, "Listener socket");#ifdef IPV6	if(listener->addr.ss_family == AF_INET6)	{		struct sockaddr_in6 *in6 = (struct sockaddr_in6 *) &listener->addr;		if(!IN6_ARE_ADDR_EQUAL(&in6->sin6_addr, &in6addr_any))		{			inetntop(AF_INET6, &in6->sin6_addr, listener->vhost,				 sizeof(listener->vhost));			listener->name = listener->vhost;		}	}	else#endif	{		struct sockaddr_in *in = (struct sockaddr_in *) &listener->addr;		if(in->sin_addr.s_addr != INADDR_ANY)		{			inetntop(AF_INET, &in->sin_addr, listener->vhost, sizeof(listener->vhost));			listener->name = listener->vhost;		}	}	if(fd == -1)	{		report_error("opening listener socket %s:%s",			     get_listener_name(listener), get_listener_name(listener), errno);		return 0;	}	else if((maxconnections - 10) < fd)	{		report_error("no more connections left for listener %s:%s",			     get_listener_name(listener), get_listener_name(listener), errno);		comm_close(fd);		return 0;	}	/*	 * XXX - we don't want to do all this crap for a listener	 * set_sock_opts(listener);	 */	if(setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char *) &opt, sizeof(opt)))	{		report_error("setting SO_REUSEADDR for listener %s:%s",			     get_listener_name(listener), get_listener_name(listener), errno);		comm_close(fd);		return 0;	}	/*	 * Bind a port to listen for new connections if port is non-null,	 * else assume it is already open and try get something from it.	 */	if(bind(fd, (struct sockaddr *) &listener->addr, GET_SS_LEN(listener->addr)))	{		report_error("binding listener socket %s:%s",			     get_listener_name(listener), get_listener_name(listener), errno);		comm_close(fd);		return 0;	}	if(listen(fd, RATBOX_SOMAXCONN))	{		report_error("listen failed for %s:%s",			     get_listener_name(listener), get_listener_name(listener), errno);		comm_close(fd);		return 0;	}	listener->fd = fd;	/* Listen completion events are READ events .. */	accept_connection(fd, listener);	return 1;}
开发者ID:BackupTheBerlios,项目名称:phoenixfn-svn,代码行数:88,


示例22: handle_ip_packet

//.........这里部分代码省略.........            /* out of network */            assign_addr_pair(&ap, iptr, 0);            direction = 1;        }        else if(in_filter_net(iptr->ip_dst) && !in_filter_net(iptr->ip_src)) {            /* into network */            assign_addr_pair(&ap, iptr, 1);            direction = 0;        }        else {            /* drop packet */            return ;        }    }    if(IP_V(iptr) == 6 && options.netfilter6 != 0) {        /*         * Net filter IPv6 active.         */        int j;        //else if((IP_V(iptr) == 6) && have_ip6_addr && ip6_addr_match(&ip6tr->ip6_dst)) {        /* First reduce the participating addresses using the netfilter prefix.         * We need scratch pads to do this.         */        for (j=0; j < 16; ++j) {            scribdst.s6_addr[j] = ip6tr->ip6_dst.s6_addr[j]                                        & options.netfilter6mask.s6_addr[j];            scribsrc.s6_addr[j] = ip6tr->ip6_src.s6_addr[j]                                        & options.netfilter6mask.s6_addr[j];        }        /* Now look for any hits. */        //if(in_filter_net(iptr->ip_src) && !in_filter_net(iptr->ip_dst)) {        if (IN6_ARE_ADDR_EQUAL(&scribsrc, &options.netfilter6net)                && ! IN6_ARE_ADDR_EQUAL(&scribdst, &options.netfilter6net)) {            /* out of network */            assign_addr_pair(&ap, iptr, 0);            direction = 1;        }        //else if(in_filter_net(iptr->ip_dst) && !in_filter_net(iptr->ip_src)) {        else if (! IN6_ARE_ADDR_EQUAL(&scribsrc, &options.netfilter6net)                    && IN6_ARE_ADDR_EQUAL(&scribdst, &options.netfilter6net)) {            /* into network */            assign_addr_pair(&ap, iptr, 1);            direction = 0;        }        else {            /* drop packet */            return ;        }    }#if 1    /* Test if link-local IPv6 packets should be dropped. */    if( IP_V(iptr) == 6 && !options.link_local            && (IN6_IS_ADDR_LINKLOCAL(&ip6tr->ip6_dst)                || IN6_IS_ADDR_LINKLOCAL(&ip6tr->ip6_src)) )        return;#endif    /* Do address resolving. */    switch (IP_V(iptr)) {      case 4:          ap.protocol = iptr->ip_p;          /* Add the addresses to be resolved */          /* The IPv4 address is embedded in a in6_addr structure,
开发者ID:githublefantian,项目名称:iftopd,代码行数:67,


示例23: l2tp_ctrl_input

//.........这里部分代码省略.........			    avp_mes_type_string(mestype));			goto bad_packet;		}		if ((ctrl = l2tp_ctrl_create()) == NULL) {			l2tp_ctrl_log(ctrl, LOG_ERR,			    "l2tp_ctrl_create() failed: %m");			goto fail;		}		if (l2tp_ctrl_init(ctrl, _this, peer, sock, nat_t_ctx) != 0) {			l2tp_ctrl_log(ctrl, LOG_ERR,			    "l2tp_ctrl_start() failed: %m");			goto fail;		}		ctrl->listener_index = listener_index;		l2tp_ctrl_reload(ctrl);	} else {		/*		 * treat as an error if src address and port is not		 * match. (because it is potentially DoS attach)		 */		int notmatch = 0;		if (ctrl->peer.ss_family != peer->sa_family)			notmatch = 1;		else if (peer->sa_family == AF_INET) {			if (SIN(peer)->sin_addr.s_addr != 			    SIN(&ctrl->peer)->sin_addr.s_addr ||			    SIN(peer)->sin_port != SIN(&ctrl->peer)->sin_port)				notmatch = 1;		} else if (peer->sa_family == AF_INET6) {			if (!IN6_ARE_ADDR_EQUAL(&(SIN6(peer)->sin6_addr),				    &(SIN6(&ctrl->peer)->sin6_addr)) ||			    SIN6(peer)->sin6_port !=				    SIN6(&ctrl->peer)->sin6_port)				notmatch = 1; 		}		if (notmatch) {			snprintf(errmsg, sizeof(errmsg),			    "tunnelId=%u is already assigned for %s",			    hdr.tunnel_id, addrport_tostring(				(struct sockaddr *)&ctrl->peer,				ctrl->peer.ss_len, hbuf, sizeof(hbuf)));			goto bad_packet;		}	}	ctrl->last_rcv = curr_time;	call = NULL;	if (hdr.session_id != 0) {		/* search l2tp_call by Session ID */		/* linear search is enough for this purpose */		len = slist_length(&ctrl->call_list);		for (i = 0; i < len; i++) {			call = slist_get(&ctrl->call_list, i);			if (call->session_id == hdr.session_id)				break;			call = NULL;		}	}	if (!is_ctrl) {		int delayed = 0;		/* L2TP data */		if (ctrl->state != L2TP_CTRL_STATE_ESTABLISHED) {
开发者ID:ajinkya93,项目名称:OpenBSD,代码行数:67,


示例24: udp6_input

//.........这里部分代码省略.........		/*		 * Construct sockaddr format source address.		 */		init_sin6(&udp_in6, m); /* general init */		udp_in6.sin6_port = uh->uh_sport;		/*		 * KAME note: traditionally we dropped udpiphdr from mbuf here.		 * We need udphdr for IPsec processing so we do that later.		 */		/*		 * Locate pcb(s) for datagram.		 * (Algorithm copied from raw_intr().)		 */		last = NULL;		marker = in_pcbmarker(mycpuid);		GET_PCBINFO_TOKEN(pcbinfo);		LIST_INSERT_HEAD(&pcbinfo->pcblisthead, marker, inp_list);		while ((in6p = LIST_NEXT(marker, inp_list)) != NULL) {			LIST_REMOVE(marker, inp_list);			LIST_INSERT_AFTER(in6p, marker, inp_list);			if (in6p->inp_flags & INP_PLACEMARKER)				continue;			if (!INP_ISIPV6(in6p))				continue;			if (in6p->in6p_lport != uh->uh_dport)				continue;			if (!IN6_IS_ADDR_UNSPECIFIED(&in6p->in6p_laddr)) {				if (!IN6_ARE_ADDR_EQUAL(&in6p->in6p_laddr,							&ip6->ip6_dst) &&				    !in6_mcmatch(in6p, &ip6->ip6_dst,						 m->m_pkthdr.rcvif))					continue;			}			if (!IN6_IS_ADDR_UNSPECIFIED(&in6p->in6p_faddr)) {				if (!IN6_ARE_ADDR_EQUAL(&in6p->in6p_faddr,							&ip6->ip6_src) ||				   in6p->in6p_fport != uh->uh_sport)					continue;			}			if (last != NULL) {				struct mbuf *n;#ifdef IPSEC				/*				 * Check AH/ESP integrity.				 */				if (ipsec6_in_reject_so(m, last->inp_socket))					ipsec6stat.in_polvio++;					/* do not inject data into pcb */				else#endif /* IPSEC */#ifdef FAST_IPSEC				/*				 * Check AH/ESP integrity.				 */				if (ipsec6_in_reject(m, last))					;				else#endif /* FAST_IPSEC */
开发者ID:wan721,项目名称:DragonFlyBSD,代码行数:67,


示例25: main

//.........这里部分代码省略.........#endif			    setsockopt(probe_fd, SOL_SOCKET, SO_BINDTODEVICE, device, strlen(device)+1) == -1) {				perror("setsockopt(SO_BINDTODEVICE)");				exit(2);			}			disable_capability_raw();		}		firsthop.sin6_port = htons(1025);		if (connect(probe_fd, (struct sockaddr*)&firsthop, sizeof(firsthop)) == -1) {			perror("connect");			exit(2);		}		alen = sizeof(source);		if (getsockname(probe_fd, (struct sockaddr*)&source, &alen) == -1) {			perror("getsockname");			exit(2);		}		source.sin6_port = 0;		close(probe_fd);#ifndef WITHOUT_IFADDRS		if (device) {			struct ifaddrs *ifa0, *ifa;			if (getifaddrs(&ifa0)) {				perror("getifaddrs");				exit(2);			}			for (ifa = ifa0; ifa; ifa = ifa->ifa_next) {				if (!ifa->ifa_addr || ifa->ifa_addr->sa_family != AF_INET6)					continue;				if (!strncmp(ifa->ifa_name, device, sizeof(device) - 1) &&				    IN6_ARE_ADDR_EQUAL(&((struct sockaddr_in6 *)ifa->ifa_addr)->sin6_addr,						       &source.sin6_addr))					break;			}			if (!ifa)				fprintf(stderr, "ping6: Warning: source address might be selected on device other than %s./n", device);			freeifaddrs(ifa0);		}#endif	}#ifdef HAVE_SIN6_SCOPEID	else if (device && (IN6_IS_ADDR_LINKLOCAL(&source.sin6_addr) ||			    IN6_IS_ADDR_MC_LINKLOCAL(&source.sin6_addr)))		source.sin6_scope_id = if_name2index(device);#endif	if (icmp_sock < 0) {		errno = socket_errno;		perror("ping: icmp open socket");		exit(2);	}	if (device) {		struct cmsghdr *cmsg;		struct in6_pktinfo *ipi;		cmsg = (struct cmsghdr*)(cmsgbuf+cmsglen);		cmsglen += CMSG_SPACE(sizeof(*ipi));		cmsg->cmsg_len = CMSG_LEN(sizeof(*ipi));		cmsg->cmsg_level = SOL_IPV6;		cmsg->cmsg_type = IPV6_PKTINFO;
开发者ID:IAmTheOneTheyCallNeo,项目名称:android_external_iputils,代码行数:66,


示例26: add_m6fc

/* * Add an mfc entry */static intadd_m6fc(struct mf6cctl *mfccp){	struct mf6c *rt;	u_long hash;	struct rtdetq *rte;	u_short nstl;	int s;	MF6CFIND(mfccp->mf6cc_origin.sin6_addr,		 mfccp->mf6cc_mcastgrp.sin6_addr, rt);	/* If an entry already exists, just update the fields */	if (rt) {#ifdef MRT6DEBUG		if (mrt6debug & DEBUG_MFC)			log(LOG_DEBUG,"add_m6fc update o %s g %s p %x/n",			    ip6_sprintf(&mfccp->mf6cc_origin.sin6_addr),			    ip6_sprintf(&mfccp->mf6cc_mcastgrp.sin6_addr),			    mfccp->mf6cc_parent);#endif		s = splsoftnet();		rt->mf6c_parent = mfccp->mf6cc_parent;		rt->mf6c_ifset = mfccp->mf6cc_ifset;		splx(s);		return 0;	}	/*	 * Find the entry for which the upcall was made and update	 */	s = splsoftnet();	hash = MF6CHASH(mfccp->mf6cc_origin.sin6_addr,			mfccp->mf6cc_mcastgrp.sin6_addr);	for (rt = mf6ctable[hash], nstl = 0; rt; rt = rt->mf6c_next) {		if (IN6_ARE_ADDR_EQUAL(&rt->mf6c_origin.sin6_addr,				       &mfccp->mf6cc_origin.sin6_addr) &&		    IN6_ARE_ADDR_EQUAL(&rt->mf6c_mcastgrp.sin6_addr,				       &mfccp->mf6cc_mcastgrp.sin6_addr) &&		    (rt->mf6c_stall != NULL)) {			if (nstl++)				log(LOG_ERR,				    "add_m6fc: %s o %s g %s p %x dbx %p/n",				    "multiple kernel entries",				    ip6_sprintf(&mfccp->mf6cc_origin.sin6_addr),				    ip6_sprintf(&mfccp->mf6cc_mcastgrp.sin6_addr),				    mfccp->mf6cc_parent, rt->mf6c_stall);#ifdef MRT6DEBUG			if (mrt6debug & DEBUG_MFC)				log(LOG_DEBUG,				    "add_m6fc o %s g %s p %x dbg %p/n",				    ip6_sprintf(&mfccp->mf6cc_origin.sin6_addr),				    ip6_sprintf(&mfccp->mf6cc_mcastgrp.sin6_addr),				    mfccp->mf6cc_parent, rt->mf6c_stall);#endif			rt->mf6c_origin     = mfccp->mf6cc_origin;			rt->mf6c_mcastgrp   = mfccp->mf6cc_mcastgrp;			rt->mf6c_parent     = mfccp->mf6cc_parent;			rt->mf6c_ifset	    = mfccp->mf6cc_ifset;			/* initialize pkt counters per src-grp */			rt->mf6c_pkt_cnt    = 0;			rt->mf6c_byte_cnt   = 0;			rt->mf6c_wrong_if   = 0;			rt->mf6c_expire = 0;	/* Don't clean this guy up */			n6expire[hash]--;			/* free packets Qed at the end of this entry */			for (rte = rt->mf6c_stall; rte != NULL; ) {				struct rtdetq *n = rte->next;				if (rte->ifp) {					ip6_mdq(rte->m, rte->ifp, rt);				}				m_freem(rte->m);#ifdef UPCALL_TIMING				collate(&(rte->t));#endif /* UPCALL_TIMING */				free(rte, M_MRTABLE);				rte = n;			}			rt->mf6c_stall = NULL;		}	}	/*	 * It is possible that an entry is being inserted without an upcall	 */	if (nstl == 0) {#ifdef MRT6DEBUG		if (mrt6debug & DEBUG_MFC)			log(LOG_DEBUG,			    "add_mfc no upcall h %ld o %s g %s p %x/n",			    hash,//.........这里部分代码省略.........
开发者ID:justincormack,项目名称:rumpkernel-netbsd-src,代码行数:101,


示例27: frag6_input

//.........这里部分代码省略.........     * multiple of 8 octets.     * sizeof(struct ip6_frag) == 8     * sizeof(struct ip6_hdr) = 40     */    if ((ip6f->ip6f_offlg & IP6F_MORE_FRAG) &&            (((ntohs(ip6->ip6_plen) - offset) & 0x7) != 0)) {        icmp6_error(m, ICMP6_PARAM_PROB, ICMP6_PARAMPROB_HEADER,                    offsetof(struct ip6_hdr, ip6_plen));        in6_ifstat_inc(dstifp, ifs6_reass_fail);        return IPPROTO_DONE;    }    V_ip6stat.ip6s_fragments++;    in6_ifstat_inc(dstifp, ifs6_reass_reqd);    /* offset now points to data portion */    offset += sizeof(struct ip6_frag);    /*     * XXX-BZ RFC XXXX (draft-gont-6man-ipv6-atomic-fragments)     * Handle "atomic" fragments (offset and m bit set to 0) upfront,     * unrelated to any reassembly.  Just skip the fragment header.     */    if ((ip6f->ip6f_offlg & ~IP6F_RESERVED_MASK) == 0) {        /* XXX-BZ we want dedicated counters for this. */        V_ip6stat.ip6s_reassembled++;        in6_ifstat_inc(dstifp, ifs6_reass_ok);        *offp = offset;        return (ip6f->ip6f_nxt);    }    IP6Q_LOCK();    /*     * Enforce upper bound on number of fragments.     * If maxfrag is 0, never accept fragments.     * If maxfrag is -1, accept all fragments without limitation.     */    if (V_ip6_maxfrags < 0)        ;    else if (V_frag6_nfrags >= (u_int)V_ip6_maxfrags)        goto dropfrag;    for (q6 = V_ip6q.ip6q_next; q6 != &V_ip6q; q6 = q6->ip6q_next)        if (ip6f->ip6f_ident == q6->ip6q_ident &&                IN6_ARE_ADDR_EQUAL(&ip6->ip6_src, &q6->ip6q_src) &&                IN6_ARE_ADDR_EQUAL(&ip6->ip6_dst, &q6->ip6q_dst)#ifdef MAC                && mac_ip6q_match(m, q6)#endif           )            break;    if (q6 == &V_ip6q) {        /*         * the first fragment to arrive, create a reassembly queue.         */        first_frag = 1;        /*         * Enforce upper bound on number of fragmented packets         * for which we attempt reassembly;         * If maxfragpackets is 0, never accept fragments.         * If maxfragpackets is -1, accept all fragments without         * limitation.         */        if (V_ip6_maxfragpackets < 0)            ;        else if (V_frag6_nfragpackets >= (u_int)V_ip6_maxfragpackets)            goto dropfrag;        V_frag6_nfragpackets++;        q6 = (struct ip6q *)malloc(sizeof(struct ip6q), M_FTABLE,                                   M_NOWAIT);        if (q6 == NULL)            goto dropfrag;        bzero(q6, sizeof(*q6));#ifdef MAC        if (mac_ip6q_init(q6, M_NOWAIT) != 0) {            free(q6, M_FTABLE);            goto dropfrag;        }        mac_ip6q_create(m, q6);#endif        frag6_insque(q6, &V_ip6q);        /* ip6q_nxt will be filled afterwards, from 1st fragment */        q6->ip6q_down	= q6->ip6q_up = (struct ip6asfrag *)q6;#ifdef notyet        q6->ip6q_nxtp	= (u_char *)nxtp;#endif        q6->ip6q_ident	= ip6f->ip6f_ident;        q6->ip6q_ttl	= IPV6_FRAGTTL;        q6->ip6q_src	= ip6->ip6_src;        q6->ip6q_dst	= ip6->ip6_dst;        q6->ip6q_ecn	=            (ntohl(ip6->ip6_flow) >> 20) & IPTOS_ECN_MASK;        q6->ip6q_unfrglen = -1;	/* The 1st fragment has not arrived. */        q6->ip6q_nfrag = 0;    }
开发者ID:yedan2010,项目名称:libuinet,代码行数:101,



注:本文中的IN6_ARE_ADDR_EQUAL函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ IN6_IS_ADDR_LINKLOCAL函数代码示例
C++ IN0函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。