static void print_tunnel(struct ip_tunnel_parm *p) { struct ip_tunnel_6rd ip6rd; char s1[1024]; char s2[1024]; memset(&ip6rd, 0, sizeof(ip6rd)); /* Do not use format_host() for local addr, * symbolic name will not be useful. */ printf("%s: %s/ip remote %s local %s ", p->name, tnl_strproto(p->iph.protocol), p->iph.daddr ? format_host(AF_INET, 4, &p->iph.daddr, s1, sizeof(s1)) : "any", p->iph.saddr ? rt_addr_n2a(AF_INET, &p->iph.saddr, s2, sizeof(s2)) : "any"); if (p->iph.protocol == IPPROTO_IPV6 && (p->i_flags & SIT_ISATAP)) { struct ip_tunnel_prl prl[16]; int i; memset(prl, 0, sizeof(prl)); prl[0].datalen = sizeof(prl) - sizeof(prl[0]); prl[0].addr = htonl(INADDR_ANY); if (!tnl_prl_ioctl(SIOCGETPRL, p->name, prl)) for (i = 1; i < sizeof(prl) / sizeof(prl[0]); i++) { if (prl[i].addr != htonl(INADDR_ANY)) { printf(" %s %s ", (prl[i].flags & PRL_DEFAULT) ? "pdr" : "pr", format_host(AF_INET, 4, &prl[i].addr, s1, sizeof(s1))); } } } if (p->link) { const char *n = ll_index_to_name(p->link); if (n) printf(" dev %s ", n); } if (p->iph.ttl) printf(" ttl %d ", p->iph.ttl); else printf(" ttl inherit "); if (p->iph.tos) { SPRINT_BUF(b1); printf(" tos"); if (p->iph.tos&1) printf(" inherit"); if (p->iph.tos&~1) printf("%c%s ", p->iph.tos&1 ? '/' : ' ', rtnl_dsfield_n2a(p->iph.tos&~1, b1, sizeof(b1))); } if (!(p->iph.frag_off&htons(IP_DF))) printf(" nopmtudisc"); if (p->iph.protocol == IPPROTO_IPV6 && !tnl_ioctl_get_6rd(p->name, &ip6rd) && ip6rd.prefixlen) { printf(" 6rd-prefix %s/%u ", inet_ntop(AF_INET6, &ip6rd.prefix, s1, sizeof(s1)), ip6rd.prefixlen); if (ip6rd.relay_prefix) { printf("6rd-relay_prefix %s/%u ", format_host(AF_INET, 4, &ip6rd.relay_prefix, s1, sizeof(s1)), ip6rd.relay_prefixlen); } } if ((p->i_flags&GRE_KEY) && (p->o_flags&GRE_KEY) && p->o_key == p->i_key) printf(" key %u", ntohl(p->i_key)); else if ((p->i_flags|p->o_flags)&GRE_KEY) { if (p->i_flags&GRE_KEY) printf(" ikey %u ", ntohl(p->i_key)); if (p->o_flags&GRE_KEY) printf(" okey %u ", ntohl(p->o_key)); } if (p->i_flags&GRE_SEQ) printf("%s Drop packets out of sequence.\n", _SL_); if (p->i_flags&GRE_CSUM) printf("%s Checksum in received packet is required.", _SL_); if (p->o_flags&GRE_SEQ) printf("%s Sequence packets on output.", _SL_); if (p->o_flags&GRE_CSUM) printf("%s Checksum output packets.", _SL_); }
static void print_tunnel(struct ip_tunnel_parm *p) { #ifndef NO_IPV6 struct ip_tunnel_6rd ip6rd; #endif char s1[1024]; char s2[1024]; char s3[64]; char s4[64]; #ifndef NO_IPV6 memset(&ip6rd, 0, sizeof(ip6rd)); #endif inet_ntop(AF_INET, &p->i_key, s3, sizeof(s3)); inet_ntop(AF_INET, &p->o_key, s4, sizeof(s4)); /* Do not use format_host() for local addr, * symbolic name will not be useful. */ printf("%s: %s/ip remote %s local %s ", p->name, tnl_strproto(p->iph.protocol), p->iph.daddr ? format_host(AF_INET, 4, &p->iph.daddr, s1, sizeof(s1)) : "any", p->iph.saddr ? rt_addr_n2a(AF_INET, 4, &p->iph.saddr, s2, sizeof(s2)) : "any"); if (p->link) { char *n = tnl_ioctl_get_ifname(p->link); if (n) printf(" dev %s ", n); } if (p->iph.ttl) printf(" ttl %d ", p->iph.ttl); else printf(" ttl inherit "); if (p->iph.tos) { SPRINT_BUF(b1); printf(" tos"); if (p->iph.tos&1) printf(" inherit"); if (p->iph.tos&~1) printf("%c%s ", p->iph.tos&1 ? '/' : ' ', rtnl_dsfield_n2a(p->iph.tos&~1, b1, sizeof(b1))); } if (!(p->iph.frag_off&htons(IP_DF))) printf(" nopmtudisc"); #ifndef NO_IPV6 if (p->iph.protocol == IPPROTO_IPV6 && !tnl_ioctl_get_6rd(p->name, &ip6rd) && ip6rd.prefixlen) { printf(" 6rd-prefix %s/%u ", inet_ntop(AF_INET6, &ip6rd.prefix, s1, sizeof(s1)), ip6rd.prefixlen); if (ip6rd.relay_prefix) { printf("6rd-relay_prefix %s/%u ", format_host(AF_INET, 4, &ip6rd.relay_prefix, s1, sizeof(s1)), ip6rd.relay_prefixlen); } } #endif if ((p->i_flags&GRE_KEY) && (p->o_flags&GRE_KEY) && p->o_key == p->i_key) printf(" key %s", s3); else if ((p->i_flags|p->o_flags)&GRE_KEY) { if (p->i_flags&GRE_KEY) printf(" ikey %s ", s3); if (p->o_flags&GRE_KEY) printf(" okey %s ", s4); } if (p->i_flags&GRE_SEQ) printf("%s Drop packets out of sequence.\n", _SL_); if (p->i_flags&GRE_CSUM) printf("%s Checksum in received packet is required.", _SL_); if (p->o_flags&GRE_SEQ) printf("%s Sequence packets on output.", _SL_); if (p->o_flags&GRE_CSUM) printf("%s Checksum output packets.", _SL_); }