Lines Matching defs:ptnl

2429 static int tnl_ioctl(char *dev, int rtype, struct ip_tunnel_parm *ptnl)
2434 if ((rtype == SIOCCHGTUNNEL || rtype == SIOCDELTUNNEL) && *ptnl->name)
2435 xstrncpy(req.ifr_name, ptnl->name, IF_NAMESIZE);
2438 if (rtype != SIOCGIFHWADDR) req.ifr_ifru.ifru_data = (void*)ptnl;
2450 static int display_tunnel(struct ip_tunnel_parm *ptnl)
2454 printf("%s: %s/ip", ptnl->name, ptnl->iph.protocol == IPPROTO_IPIP ? "ip" :
2455 (ptnl->iph.protocol == IPPROTO_GRE ? "gre" :
2456 (ptnl->iph.protocol == IPPROTO_IPV6 ? "ipv6" : "unknown")));
2457 printf(" remote %s local %s ", ptnl->iph.daddr ?
2458 inet_ntop(AF_INET, &ptnl->iph.daddr, rmt_addr, sizeof(rmt_addr)) : "any",
2459 ptnl->iph.saddr ? inet_ntop(AF_INET, &ptnl->iph.saddr, lcl_addr,
2461 if (ptnl->link) {
2465 req.ifr_ifindex = ptnl->link;
2471 if (ptnl->iph.ttl) printf(" ttl %d ", ptnl->iph.ttl);
2474 if (ptnl->iph.tos) {
2476 if (ptnl->iph.tos & 1) printf(" inherit");
2477 if (ptnl->iph.tos & ~1) printf("%c%s ", ptnl->iph.tos & 1 ? '/' : ' ',
2478 namefromRPDB((ptnl->iph.tos & ~1), RPDB_rtdsfield));
2480 if (!(ptnl->iph.frag_off & htons(IP_DF))) printf(" nopmtudisc");
2481 inet_ntop(AF_INET, &ptnl->i_key, ikey_str, sizeof(ikey_str));
2482 if ((ptnl->i_flags & GRE_KEY) && (ptnl->o_flags & GRE_KEY)
2483 && ptnl->o_key == ptnl->i_key) printf(" key %s", ikey_str);
2484 else if ((ptnl->i_flags | ptnl->o_flags) & GRE_KEY) {
2485 inet_ntop(AF_INET, &ptnl->o_key, okey_str, sizeof(okey_str));
2486 if (ptnl->i_flags & GRE_KEY) printf(" ikey %s ", ikey_str);
2487 if (ptnl->o_flags & GRE_KEY) printf(" okey %s ", okey_str);
2489 if (ptnl->i_flags & GRE_SEQ) printf("\n Drop packets out of sequence.\n");
2490 if (ptnl->i_flags & GRE_CSUM)
2492 if (ptnl->o_flags & GRE_SEQ) printf("\n Sequence packets on output.");
2493 if (ptnl->o_flags & GRE_CSUM) printf("\n Checksum output packets.");
2498 static int read_tunnel(struct ip_tunnel_parm *ptnl)
2514 if (*ptnl->name && strcmp(ptnl->name, iface)) continue;
2524 if ((ptnl->link && iptnl.link != ptnl->link) || (*ptnl->name &&
2525 strcmp(iptnl.name, ptnl->name)) || (ptnl->iph.daddr &&
2526 iptnl.iph.daddr != ptnl->iph.daddr) || (ptnl->iph.saddr &&
2527 iptnl.iph.saddr != ptnl->iph.saddr) || (ptnl->i_key &&
2528 iptnl.i_key != ptnl->i_key)) continue;
2535 static void parse_iptunnel_args(struct ip_tunnel_parm *ptnl, char **argv,
2548 ptnl->iph.version = 4; // The value indicates the version of IP (4 or 6)
2549 ptnl->iph.ihl = 5; // Minimum Internet Header Length
2551 ptnl->iph.frag_off = htons(IP_DF);
2553 xstrncpy(ptnl->name, *argv, IF_NAMESIZE);
2558 tnl_ioctl(ptnl->name, SIOCGETTUNNEL, &iptnl_old);
2559 *ptnl = iptnl_old;
2568 ptnl->iph.protocol = IPPROTO_IPIP;
2570 ptnl->iph.protocol = IPPROTO_GRE;
2572 ptnl->iph.protocol = IPPROTO_IPV6;
2599 ptnl->i_flags |= GRE_KEY;
2600 ptnl->o_flags |= GRE_KEY;
2601 ptnl->i_key = ptnl->o_key = addr;
2603 ptnl->i_flags |= GRE_KEY;
2604 ptnl->i_key = addr;
2606 ptnl->o_flags |= GRE_KEY;
2607 ptnl->o_key = addr;
2612 ptnl->i_flags |= GRE_SEQ;
2613 ptnl->o_flags |= GRE_SEQ;
2616 ptnl->i_flags |= GRE_SEQ;
2619 ptnl->o_flags |= GRE_SEQ;
2622 ptnl->i_flags |= GRE_CSUM;
2623 ptnl->o_flags |= GRE_CSUM;
2626 ptnl->i_flags |= GRE_CSUM;
2629 ptnl->o_flags |= GRE_CSUM;
2632 ptnl->iph.frag_off = 0;
2635 ptnl->iph.frag_off = htons(IP_DF);
2642 (idx == 12) ? (ptnl->iph.daddr = addr) : (ptnl->iph.saddr = addr);
2654 ptnl->link = req.ifr_ifindex;
2660 ptnl->iph.ttl = atolx_range(*argv, 0, 255);
2675 ptnl->iph.tos = ret;
2676 } else ptnl->iph.tos = tval;
2677 } else ptnl->iph.tos = 1;
2680 if (*ptnl->name) error_exit("invalid tunnel");
2683 xstrncpy(ptnl->name, *argv, IF_NAMESIZE);
2687 if (*ptnl->name) error_exit("invalid tunnel");
2688 xstrncpy(ptnl->name, *argv, IF_NAMESIZE);
2692 if (ptnl->iph.protocol == IPPROTO_IPIP ||
2693 ptnl->iph.protocol == IPPROTO_IPV6) {
2694 if ((ptnl->i_flags & GRE_KEY) || (ptnl->o_flags & GRE_KEY))
2696 if ((ptnl->i_flags & GRE_SEQ) || (ptnl->o_flags & GRE_SEQ))
2698 if ((ptnl->i_flags & GRE_CSUM) || (ptnl->o_flags & GRE_CSUM))
2701 if (!ptnl->i_key && IN_MULTICAST(ntohl(ptnl->iph.daddr))) {
2702 ptnl->i_key = ptnl->iph.daddr;
2703 ptnl->i_flags |= GRE_KEY;
2705 if (!ptnl->o_key && IN_MULTICAST(ntohl(ptnl->iph.daddr))) {
2706 ptnl->o_key = ptnl->iph.daddr;
2707 ptnl->o_flags |= GRE_KEY;
2709 if (IN_MULTICAST(ntohl(ptnl->iph.daddr)) && !ptnl->iph.saddr)