本文整理汇总了C++中IN6_ARE_ADDR_EQUAL函数的典型用法代码示例。如果您正苦于以下问题:C++ IN6_ARE_ADDR_EQUAL函数的具体用法?C++ IN6_ARE_ADDR_EQUAL怎么用?C++ IN6_ARE_ADDR_EQUAL使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了IN6_ARE_ADDR_EQUAL函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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,代码来源:nm-ip6-manager.c
示例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,代码来源:udp6_usrreq.c
示例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,代码来源:ip6_fastfwd.c
示例4: l2tp_ctrl_purge_ipsec_sa
/** Delete the IPsec SA for disconnection */
static void
l2tp_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,代码来源:l2tp_ctrl.c
示例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,代码来源:nd6_nbr.c
示例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,代码来源:listener.c
示例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,代码来源:maptables.c
示例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( ¤t_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( ¤t_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,代码来源:service.c
示例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,代码来源:in6_src.c
示例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,代码来源:conff.c
示例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,代码来源:rttable.c
示例12: process_nduseropt_rdnss
static gboolean
process_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,代码来源:nm-ip6-manager.c
示例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,代码来源:ip6_forward.c
示例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,代码来源:nd6_nbr.c
示例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).
*/
void
sctp_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,代码来源:sctp_hash.c
示例16: v6_v6_equal
static gboolean
v6_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,代码来源:gnome-vfs-address.c
|
请发表评论