本文整理汇总了C++中rt_mask函数的典型用法代码示例。如果您正苦于以下问题:C++ rt_mask函数的具体用法?C++ rt_mask怎么用?C++ rt_mask使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rt_mask函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: p_rtentry
static void
p_rtentry(struct rtentry *rt)
{
static struct ifnet ifnet, *lastif;
struct rtentry parent;
static char buffer[128];
static char prettyname[128];
struct sockaddr *sa;
sa_u addr, mask;
/*
* Don't print protocol-cloned routes unless -a.
*/
if (rt->rt_flags & RTF_WASCLONED && !aflag) {
kget(rt->rt_parent, parent);
if (parent.rt_flags & RTF_PRCLONING)
return;
}
bzero(&addr, sizeof(addr));
if ((sa = kgetsa(rt_key(rt))))
bcopy(sa, &addr, sa->sa_len);
bzero(&mask, sizeof(mask));
if (rt_mask(rt) && (sa = kgetsa(rt_mask(rt))))
bcopy(sa, &mask, sa->sa_len);
p_sockaddr(&addr.u_sa, &mask.u_sa, rt->rt_flags, wid_dst);
p_sockaddr(kgetsa(rt->rt_gateway), NULL, RTF_HOST, wid_gw);
snprintf(buffer, sizeof(buffer), "%%-%d.%ds ", wid_flags, wid_flags);
p_flags(rt->rt_flags, buffer);
if (addr.u_sa.sa_family == AF_INET || Wflag) {
printf("%*ld %*lu ", wid_refs, rt->rt_refcnt,
wid_use, rt->rt_use);
if (Wflag) {
if (rt->rt_rmx.rmx_mtu != 0)
printf("%*lu ", wid_mtu, rt->rt_rmx.rmx_mtu);
else
printf("%*s ", wid_mtu, "");
}
}
if (rt->rt_ifp) {
if (rt->rt_ifp != lastif) {
kget(rt->rt_ifp, ifnet);
kread((u_long)ifnet.if_name, buffer, sizeof(buffer));
lastif = rt->rt_ifp;
snprintf(prettyname, sizeof(prettyname),
"%s%d", buffer, ifnet.if_unit);
}
printf("%*.*s", wid_if, wid_if, prettyname);
if (rt->rt_rmx.rmx_expire) {
time_t expire_time;
if ((expire_time =
rt->rt_rmx.rmx_expire - time((time_t *)0)) > 0)
printf(" %*d", wid_expire, (int)expire_time);
}
if (rt->rt_nodes[0].rn_dupedkey)
printf(" =>");
}
putchar('\n');
}
示例2: in_losing
/*
* Check for alternatives when higher level complains
* about service problems. For now, invalidate cached
* routing information. If the route was created dynamically
* (by a redirect), time to try a default gateway again.
*/
void
in_losing(struct inpcb *inp)
{
register struct rtentry *rt;
struct rt_addrinfo info;
if ((rt = inp->inp_route.ro_rt)) {
inp->inp_route.ro_rt = 0;
bzero((caddr_t)&info, sizeof(info));
info.rti_info[RTAX_DST] =
(struct sockaddr *)&inp->inp_route.ro_dst;
info.rti_info[RTAX_GATEWAY] = rt->rt_gateway;
info.rti_info[RTAX_NETMASK] = rt_mask(rt);
rt_missmsg(RTM_LOSING, &info, rt->rt_flags, 0);
if (rt->rt_flags & RTF_DYNAMIC)
(void) rtrequest(RTM_DELETE, rt_key(rt),
rt->rt_gateway, rt_mask(rt), rt->rt_flags,
(struct rtentry **)0);
else
/*
* A new route can be allocated
* the next time output is attempted.
*/
rtfree(rt);
}
}
示例3: size_cols_rtentry
static void
size_cols_rtentry(struct rtentry *rt)
{
static struct ifnet ifnet, *lastif;
static char buffer[100];
const char *bp;
struct sockaddr *sa;
sa_u addr, mask;
int len;
bzero(&addr, sizeof(addr));
if ((sa = kgetsa(rt_key(rt))))
bcopy(sa, &addr, sa->sa_len);
bzero(&mask, sizeof(mask));
if (rt_mask(rt) && (sa = kgetsa(rt_mask(rt))))
bcopy(sa, &mask, sa->sa_len);
bp = fmt_sockaddr(&addr.u_sa, &mask.u_sa, rt->rt_flags);
len = strlen(bp);
wid_dst = MAX(len, wid_dst);
bp = fmt_sockaddr(kgetsa(rt->rt_gateway), NULL, RTF_HOST);
len = strlen(bp);
wid_gw = MAX(len, wid_gw);
bp = fmt_flags(rt->rt_flags);
len = strlen(bp);
wid_flags = MAX(len, wid_flags);
if (addr.u_sa.sa_family == AF_INET || Wflag) {
len = snprintf(buffer, sizeof(buffer), "%d", rt->rt_refcnt);
wid_refs = MAX(len, wid_refs);
len = snprintf(buffer, sizeof(buffer), "%lu", rt->rt_use);
wid_use = MAX(len, wid_use);
if (Wflag && rt->rt_rmx.rmx_mtu != 0) {
len = snprintf(buffer, sizeof(buffer),
"%lu", rt->rt_rmx.rmx_mtu);
wid_mtu = MAX(len, wid_mtu);
}
}
if (rt->rt_ifp) {
if (rt->rt_ifp != lastif) {
if (kget(rt->rt_ifp, ifnet) == 0)
len = strlen(ifnet.if_xname);
else
len = strlen("---");
lastif = rt->rt_ifp;
wid_if = MAX(len, wid_if);
}
if (rt->rt_rmx.rmx_expire) {
time_t expire_time;
if ((expire_time =
rt->rt_rmx.rmx_expire - uptime.tv_sec) > 0) {
len = snprintf(buffer, sizeof(buffer), "%d",
(int)expire_time);
wid_expire = MAX(len, wid_expire);
}
}
}
}
示例4: p_krtentry
static void
p_krtentry(struct rtentry *rt)
{
static struct ifnet ifnet, *lastif;
struct sockaddr_storage sock1, sock2;
struct sockaddr *sa = (struct sockaddr *)&sock1;
struct sockaddr *mask = (struct sockaddr *)&sock2;
bcopy(kgetsa(rt_key(rt)), sa, sizeof(struct sockaddr));
if (sa->sa_len > sizeof(struct sockaddr))
bcopy(kgetsa(rt_key(rt)), sa, sa->sa_len);
if (sa->sa_family == PF_KEY) {
encap_print(rt);
return;
}
if (rt_mask(rt)) {
bcopy(kgetsa(rt_mask(rt)), mask, sizeof(struct sockaddr));
if (sa->sa_len > sizeof(struct sockaddr))
bcopy(kgetsa(rt_mask(rt)), mask, sa->sa_len);
} else
mask = 0;
p_addr(sa, mask, rt->rt_flags);
p_gwaddr(kgetsa(rt->rt_gateway), sa->sa_family);
p_flags(rt->rt_flags, "%-6.6s ");
printf("%5u %8lld ", rt->rt_refcnt, rt->rt_use);
if (rt->rt_rmx.rmx_mtu)
printf("%5u ", rt->rt_rmx.rmx_mtu);
else
printf("%5s ", "-");
putchar((rt->rt_rmx.rmx_locks & RTV_MTU) ? 'L' : ' ');
printf(" %2d", rt->rt_priority);
if (rt->rt_ifp) {
if (rt->rt_ifp != lastif) {
kread((u_long)rt->rt_ifp, &ifnet, sizeof(ifnet));
lastif = rt->rt_ifp;
}
printf(" %.16s%s", ifnet.if_xname,
rt->rt_nodes[0].rn_dupedkey ? " =>" : "");
}
putchar('\n');
if (vflag)
printf("\texpire %10lld%c\n",
(long long)rt->rt_rmx.rmx_expire,
(rt->rt_rmx.rmx_locks & RTV_EXPIRE) ? 'L' : ' ');
}
示例5: arptfree
/*
* Free an arp entry.
*/
static void
arptfree(struct llinfo_arp *la)
{
struct rtentry *rt = la->la_rt;
struct sockaddr_dl *sdl;
lck_mtx_assert(rnh_lock, LCK_MTX_ASSERT_OWNED);
RT_LOCK_ASSERT_HELD(rt);
if (rt->rt_refcnt > 0 && (sdl = SDL(rt->rt_gateway)) &&
sdl->sdl_family == AF_LINK) {
sdl->sdl_alen = 0;
la->la_asked = 0;
rt->rt_flags &= ~RTF_REJECT;
RT_UNLOCK(rt);
} else {
/*
* Safe to drop rt_lock and use rt_key, since holding
* rnh_lock here prevents another thread from calling
* rt_setgate() on this route.
*/
RT_UNLOCK(rt);
rtrequest_locked(RTM_DELETE, rt_key(rt), NULL, rt_mask(rt),
0, NULL);
}
}
示例6: in_ifadownkill
static int
in_ifadownkill(struct radix_node *rn, void *xap)
{
struct in_ifadown_arg *ap = xap;
struct rtentry *rt = (struct rtentry *)rn;
int err;
if (rt->rt_ifa == ap->ifa && !(rt->rt_flags & RTF_STATIC)) {
/*
* We need to disable the automatic prune that happens
* in this case in rtrequest() because it will blow
* away the pointers that rn_walktree() needs in order
* continue our descent. We will end up deleting all
* the routes that rtrequest() would have in any case,
* so that behavior is not needed there.
*/
rt->rt_flags &= ~RTF_PRCLONING;
err = rtrequest(RTM_DELETE, (struct sockaddr *)rt_key(rt),
rt->rt_gateway, rt_mask(rt), rt->rt_flags, 0);
if (err) {
log(LOG_WARNING, "in_ifadownkill: error %d\n", err);
}
}
return 0;
}
示例7: in6_rtqkill
/*
* Get rid of old routes. When draining, this deletes everything, even when
* the timeout is not expired yet. When updating, this makes sure that
* nothing has a timeout longer than the current value of rtq_reallyold.
*/
static int
in6_rtqkill(struct radix_node *rn, void *rock)
{
struct rtqk_arg *ap = rock;
struct rtentry *rt = (struct rtentry *)rn;
int err;
if (rt->rt_flags & RTPRF_OURS) {
ap->found++;
if (ap->draining || rt->rt_rmx.rmx_expire <= time_second) {
if (rt->rt_refcnt > 0)
panic("rtqkill route really not free");
err = rtrequest(RTM_DELETE, rt_key(rt), rt->rt_gateway,
rt_mask(rt), rt->rt_flags, NULL);
if (err)
log(LOG_WARNING, "in6_rtqkill: error %d", err);
else
ap->killed++;
} else {
if (ap->updating &&
(rt->rt_rmx.rmx_expire - time_second >
rtq_reallyold)) {
rt->rt_rmx.rmx_expire =
time_second + rtq_reallyold;
}
ap->nextstop = lmin(ap->nextstop,
rt->rt_rmx.rmx_expire);
}
}
return 0;
}
示例8: rtdeletemsg
/*
* Delete a route and generate a message
*/
int
rtdeletemsg(struct rtentry *rt, u_int tableid)
{
int error;
struct rt_addrinfo info;
struct ifnet *ifp;
/*
* Request the new route so that the entry is not actually
* deleted. That will allow the information being reported to
* be accurate (and consistent with route_output()).
*/
bzero((caddr_t)&info, sizeof(info));
info.rti_info[RTAX_DST] = rt_key(rt);
info.rti_info[RTAX_NETMASK] = rt_mask(rt);
info.rti_info[RTAX_GATEWAY] = rt->rt_gateway;
info.rti_flags = rt->rt_flags;
ifp = rt->rt_ifp;
error = rtrequest1(RTM_DELETE, &info, rt->rt_priority, &rt, tableid);
rt_missmsg(RTM_DELETE, &info, info.rti_flags, ifp, error, tableid);
/* Adjust the refcount */
if (error == 0 && rt->rt_refcnt <= 0) {
rt->rt_refcnt++;
rtfree(rt);
}
return (error);
}
示例9: in_clsroute
/*
* On last reference drop, mark the route as belong to us so that it can be
* timed out.
*/
static void
in_clsroute(struct radix_node *rn, struct radix_node_head *head)
{
struct rtentry *rt = (struct rtentry *)rn;
if(!(rt->rt_flags & RTF_UP))
return; /* prophylactic measures */
if((rt->rt_flags & (RTF_LLINFO | RTF_HOST)) != RTF_HOST)
return;
if((rt->rt_flags & (RTF_WASCLONED | RTPRF_OURS))
!= RTF_WASCLONED)
return;
/*
* As requested by David Greenman:
* If rtq_reallyold is 0, just delete the route without
* waiting for a timeout cycle to kill it.
*/
if(rtq_reallyold != 0) {
rt->rt_flags |= RTPRF_OURS;
rt->rt_rmx.rmx_expire = time_second + rtq_reallyold;
} else {
rtrequest(RTM_DELETE,
(struct sockaddr *)rt_key(rt),
rt->rt_gateway, rt_mask(rt),
rt->rt_flags, 0);
}
}
示例10: rt_plen2mask
struct sockaddr *
rt_plen2mask(struct rtentry *rt, struct sockaddr_in6 *sa_mask)
{
#ifndef ART
return (rt_mask(rt));
#else
return (rt_plentosa(rt_key(rt)->sa_family, rt_plen(rt), sa_mask));
#endif /* ART */
}
示例11: ifart_delete
//------------------------------------------------------------------------------
// FUNCTION
//
//
// DESCRIPTION
//
//
// PARAMETERS
//
//
// RETURN
//
//
//------------------------------------------------------------------------------
static int ifart_delete( struct radix_node *rn, struct in_addr *addr )
{
struct rtentry *rt = (struct rtentry *)rn;
if (((struct sockaddr_in *)rt_key(rt))->sin_addr.s_addr == addr->s_addr)
{
rtrequest(RTM_DELETE, rt_key(rt), rt->rt_gateway, rt_mask(rt),
rt->rt_flags, NULL);
}
return 0;
}
示例12: ifprt_delete
//------------------------------------------------------------------------------
// FUNCTION
//
//
// DESCRIPTION
//
//
// PARAMETERS
//
//
// RETURN
//
//
//------------------------------------------------------------------------------
static int ifprt_delete( struct radix_node *rn, void *ifp )
{
struct rtentry *rt = (struct rtentry *)rn;
if(rt->rt_ifp == ifp)
{
rtrequest(RTM_DELETE, rt_key(rt), rt->rt_gateway, rt_mask(rt),
rt->rt_flags, NULL);
}
return 0;
}
示例13: staticrt_delete
//------------------------------------------------------------------------------
// FUNCTION
//
//
// DESCRIPTION
//
//
// PARAMETERS
//
//
// RETURN
//
//
//------------------------------------------------------------------------------
static int staticrt_delete( struct radix_node *rn, void *vifp )
{
struct rtentry *rt = (struct rtentry *)rn;
if((rt->rt_flags & RTF_STATIC) && !(rt->rt_flags & RTF_LLINFO))
{
rtrequest(RTM_DELETE, rt_key(rt), rt->rt_gateway, rt_mask(rt),
0, NULL);
}
return 0;
}
示例14: bootpboot_p_rtentry
void
bootpboot_p_rtentry(struct rtentry *rt)
{
bootpboot_p_sa(rt_key(rt), rt_mask(rt));
printf(" ");
bootpboot_p_sa(rt->rt_gateway, NULL);
printf(" ");
printf("flags %x", (unsigned short) rt->rt_flags);
printf(" %d", (int) rt->rt_rmx.rmx_expire);
printf(" %s\n", rt->rt_ifp->if_xname);
}
示例15: show_inet_route
/*
* Package everything up before printing it.
* We don't want to block all network operations till
* the printing completes!
*/
static int
show_inet_route (
struct radix_node *rn,
void *vw )
{
struct rtentry *rt = (struct rtentry *)rn;
struct ifnet *ifp;
struct dinfo *dp = (struct dinfo *)vw;
struct rinfo *r;
/*
* Get a pointer to a new route info structure
*/
if (dp->count >= dp->capacity) {
r = realloc (dp->routes, (sizeof *r) * (dp->capacity + 20));
if (r == 0)
return ENOMEM;
dp->capacity += 20;
dp->routes = r;
}
r = dp->routes + dp->count++;
/*
* Fill in the route info structure
*/
copyAddress (&r->dst, rt_key(rt), sizeof r->dst);
if (rt->rt_flags & (RTF_GATEWAY | RTF_HOST)) {
copyAddress (&r->un, rt->rt_gateway, sizeof r->un);
}
else {
/*
* Create a fake address to hold the mask
*/
struct sockaddr_in dummy;
dummy.sin_family = AF_INET;
dummy.sin_len = sizeof dummy;
dummy.sin_addr = ((struct sockaddr_in *)rt_mask(rt))->sin_addr;
copyAddress (&r->un, &dummy, sizeof r->un);
}
r->flags = rt->rt_flags;
r->refcnt = rt->rt_refcnt;
r->pksent = rt->rt_rmx.rmx_pksent;
r->expire = rt->rt_rmx.rmx_expire;
ifp = rt->rt_ifp;
strncpy (r->ifname, (ifp->if_name ? ifp->if_name : ""), sizeof r->ifname);
r->ifunit = ifp->if_unit;
return 0;
}