• Home
  • Raw
  • Download

Lines Matching refs:ptnl

2323 static int tnl_ioctl(char *dev, int rtype, struct ip_tunnel_parm *ptnl)  in tnl_ioctl()  argument
2328 if ((rtype == SIOCCHGTUNNEL || rtype == SIOCDELTUNNEL) && *ptnl->name) in tnl_ioctl()
2329 xstrncpy(req.ifr_name, ptnl->name, IF_NAMESIZE); in tnl_ioctl()
2332 if (rtype != SIOCGIFHWADDR) req.ifr_ifru.ifru_data = (void*)ptnl; in tnl_ioctl()
2344 static int display_tunnel(struct ip_tunnel_parm *ptnl) in display_tunnel() argument
2348 printf("%s: %s/ip", ptnl->name, ptnl->iph.protocol == IPPROTO_IPIP ? "ip" : in display_tunnel()
2349 (ptnl->iph.protocol == IPPROTO_GRE ? "gre" : in display_tunnel()
2350 (ptnl->iph.protocol == IPPROTO_IPV6 ? "ipv6" : "unknown"))); in display_tunnel()
2351 printf(" remote %s local %s ", ptnl->iph.daddr ? in display_tunnel()
2352 inet_ntop(AF_INET, &ptnl->iph.daddr, rmt_addr, sizeof(rmt_addr)) : "any", in display_tunnel()
2353 ptnl->iph.saddr ? inet_ntop(AF_INET, &ptnl->iph.saddr, lcl_addr, in display_tunnel()
2355 if (ptnl->link) { in display_tunnel()
2359 req.ifr_ifindex = ptnl->link; in display_tunnel()
2365 if (ptnl->iph.ttl) printf(" ttl %d ", ptnl->iph.ttl); in display_tunnel()
2368 if (ptnl->iph.tos) { in display_tunnel()
2370 if (ptnl->iph.tos & 1) printf(" inherit"); in display_tunnel()
2371 if (ptnl->iph.tos & ~1) printf("%c%s ", ptnl->iph.tos & 1 ? '/' : ' ', in display_tunnel()
2372 namefromRPDB((ptnl->iph.tos & ~1), RPDB_rtdsfield)); in display_tunnel()
2374 if (!(ptnl->iph.frag_off & htons(IP_DF))) printf(" nopmtudisc"); in display_tunnel()
2375 inet_ntop(AF_INET, &ptnl->i_key, ikey_str, sizeof(ikey_str)); in display_tunnel()
2376 if ((ptnl->i_flags & GRE_KEY) && (ptnl->o_flags & GRE_KEY) in display_tunnel()
2377 && ptnl->o_key == ptnl->i_key) printf(" key %s", ikey_str); in display_tunnel()
2378 else if ((ptnl->i_flags | ptnl->o_flags) & GRE_KEY) { in display_tunnel()
2379 inet_ntop(AF_INET, &ptnl->o_key, okey_str, sizeof(okey_str)); in display_tunnel()
2380 if (ptnl->i_flags & GRE_KEY) printf(" ikey %s ", ikey_str); in display_tunnel()
2381 if (ptnl->o_flags & GRE_KEY) printf(" okey %s ", okey_str); in display_tunnel()
2383 if (ptnl->i_flags & GRE_SEQ) printf("\n Drop packets out of sequence.\n"); in display_tunnel()
2384 if (ptnl->i_flags & GRE_CSUM) in display_tunnel()
2386 if (ptnl->o_flags & GRE_SEQ) printf("\n Sequence packets on output."); in display_tunnel()
2387 if (ptnl->o_flags & GRE_CSUM) printf("\n Checksum output packets."); in display_tunnel()
2392 static int read_tunnel(struct ip_tunnel_parm *ptnl) in read_tunnel() argument
2408 if (*ptnl->name && strcmp(ptnl->name, iface)) continue; in read_tunnel()
2418 if ((ptnl->link && iptnl.link != ptnl->link) || (*ptnl->name && in read_tunnel()
2419 strcmp(iptnl.name, ptnl->name)) || (ptnl->iph.daddr && in read_tunnel()
2420 iptnl.iph.daddr != ptnl->iph.daddr) || (ptnl->iph.saddr && in read_tunnel()
2421 iptnl.iph.saddr != ptnl->iph.saddr) || (ptnl->i_key && in read_tunnel()
2422 iptnl.i_key != ptnl->i_key)) continue; in read_tunnel()
2429 static void parse_iptunnel_args(struct ip_tunnel_parm *ptnl, char **argv, in parse_iptunnel_args() argument
2442 ptnl->iph.version = 4; // The value indicates the version of IP (4 or 6) in parse_iptunnel_args()
2443 ptnl->iph.ihl = 5; // Minimum Internet Header Length in parse_iptunnel_args()
2445 ptnl->iph.frag_off = htons(IP_DF); in parse_iptunnel_args()
2447 xstrncpy(ptnl->name, *argv, IF_NAMESIZE); in parse_iptunnel_args()
2452 tnl_ioctl(ptnl->name, SIOCGETTUNNEL, &iptnl_old); in parse_iptunnel_args()
2453 *ptnl = iptnl_old; in parse_iptunnel_args()
2462 ptnl->iph.protocol = IPPROTO_IPIP; in parse_iptunnel_args()
2464 ptnl->iph.protocol = IPPROTO_GRE; in parse_iptunnel_args()
2466 ptnl->iph.protocol = IPPROTO_IPV6; in parse_iptunnel_args()
2493 ptnl->i_flags |= GRE_KEY; in parse_iptunnel_args()
2494 ptnl->o_flags |= GRE_KEY; in parse_iptunnel_args()
2495 ptnl->i_key = ptnl->o_key = addr; in parse_iptunnel_args()
2497 ptnl->i_flags |= GRE_KEY; in parse_iptunnel_args()
2498 ptnl->i_key = addr; in parse_iptunnel_args()
2500 ptnl->o_flags |= GRE_KEY; in parse_iptunnel_args()
2501 ptnl->o_key = addr; in parse_iptunnel_args()
2506 ptnl->i_flags |= GRE_SEQ; in parse_iptunnel_args()
2507 ptnl->o_flags |= GRE_SEQ; in parse_iptunnel_args()
2510 ptnl->i_flags |= GRE_SEQ; in parse_iptunnel_args()
2513 ptnl->o_flags |= GRE_SEQ; in parse_iptunnel_args()
2516 ptnl->i_flags |= GRE_CSUM; in parse_iptunnel_args()
2517 ptnl->o_flags |= GRE_CSUM; in parse_iptunnel_args()
2520 ptnl->i_flags |= GRE_CSUM; in parse_iptunnel_args()
2523 ptnl->o_flags |= GRE_CSUM; in parse_iptunnel_args()
2526 ptnl->iph.frag_off = 0; in parse_iptunnel_args()
2529 ptnl->iph.frag_off = htons(IP_DF); in parse_iptunnel_args()
2536 (idx == 12) ? (ptnl->iph.daddr = addr) : (ptnl->iph.saddr = addr); in parse_iptunnel_args()
2548 ptnl->link = req.ifr_ifindex; in parse_iptunnel_args()
2554 ptnl->iph.ttl = atolx_range(*argv, 0, 255); in parse_iptunnel_args()
2569 ptnl->iph.tos = ret; in parse_iptunnel_args()
2570 } else ptnl->iph.tos = tval; in parse_iptunnel_args()
2571 } else ptnl->iph.tos = 1; in parse_iptunnel_args()
2574 if (*ptnl->name) error_exit("invalid tunnel"); in parse_iptunnel_args()
2577 xstrncpy(ptnl->name, *argv, IF_NAMESIZE); in parse_iptunnel_args()
2581 if (*ptnl->name) error_exit("invalid tunnel"); in parse_iptunnel_args()
2582 xstrncpy(ptnl->name, *argv, IF_NAMESIZE); in parse_iptunnel_args()
2586 if (ptnl->iph.protocol == IPPROTO_IPIP || in parse_iptunnel_args()
2587 ptnl->iph.protocol == IPPROTO_IPV6) { in parse_iptunnel_args()
2588 if ((ptnl->i_flags & GRE_KEY) || (ptnl->o_flags & GRE_KEY)) in parse_iptunnel_args()
2590 if ((ptnl->i_flags & GRE_SEQ) || (ptnl->o_flags & GRE_SEQ)) in parse_iptunnel_args()
2592 if ((ptnl->i_flags & GRE_CSUM) || (ptnl->o_flags & GRE_CSUM)) in parse_iptunnel_args()
2595 if (!ptnl->i_key && IN_MULTICAST(ntohl(ptnl->iph.daddr))) { in parse_iptunnel_args()
2596 ptnl->i_key = ptnl->iph.daddr; in parse_iptunnel_args()
2597 ptnl->i_flags |= GRE_KEY; in parse_iptunnel_args()
2599 if (!ptnl->o_key && IN_MULTICAST(ntohl(ptnl->iph.daddr))) { in parse_iptunnel_args()
2600 ptnl->o_key = ptnl->iph.daddr; in parse_iptunnel_args()
2601 ptnl->o_flags |= GRE_KEY; in parse_iptunnel_args()
2603 if (IN_MULTICAST(ntohl(ptnl->iph.daddr)) && !ptnl->iph.saddr) in parse_iptunnel_args()