-
- cp();
-
- hdr = (struct ip6_hdr *)(packet->data + 14);
- icmp = (struct icmp6_hdr *)(packet->data + 14 + sizeof(*hdr));
-
- /* Remember original source and destination */
-
- memcpy(&pseudo.ip6_src, &hdr->ip6_dst, 16);
- memcpy(&pseudo.ip6_dst, &hdr->ip6_src, 16);
- pseudo.length = ntohs(hdr->ip6_plen) + sizeof(*hdr);
-
- if(pseudo.length >= IP_MSS - sizeof(*hdr) - sizeof(*icmp))
- pseudo.length = IP_MSS - sizeof(*hdr) - sizeof(*icmp);
-
- /* Copy first part of original contents to ICMP message */
-
- memmove(((char *)icmp) + sizeof(*icmp), hdr, pseudo.length);
-
- /* Fill in IPv6 header */
-
- hdr->ip6_flow = htonl(0x60000000UL);
- hdr->ip6_plen = htons(sizeof(*icmp) + pseudo.length);
- hdr->ip6_nxt = IPPROTO_ICMPV6;
- hdr->ip6_hlim = 255;
- memcpy(&hdr->ip6_dst, &pseudo.ip6_dst, 16);
- memcpy(&hdr->ip6_src, &pseudo.ip6_src, 16);
-
- /* Fill in ICMP header */
-
- icmp->icmp6_type = ICMP6_DST_UNREACH;
- icmp->icmp6_code = code;
- icmp->icmp6_cksum = 0;
-
- /* Create pseudo header */
-
- pseudo.length = htonl(sizeof(*icmp) + pseudo.length);
- pseudo.next = htonl(IPPROTO_ICMPV6);
-
- /* Generate checksum */
-
- checksum = inet_checksum(&pseudo, sizeof(pseudo), ~0);
- checksum = inet_checksum(icmp, ntohl(pseudo.length), checksum);
-
- icmp->icmp6_cksum = checksum;
-
- packet->len = 14 + sizeof(*hdr) + ntohl(pseudo.length);
-
- write_packet(packet);
-}
-
-node_t *route_ipv6(vpn_packet_t *packet)
-{
- subnet_t *subnet;
-
- cp();
-
- subnet = lookup_subnet_ipv6((ipv6_t *) & packet->data[38]);
-
- if(!subnet) {
- if(debug_lvl >= DEBUG_TRAFFIC) {
- syslog(LOG_WARNING, _("Cannot route packet: unknown IPv6 destination address %hx:%hx:%hx:%hx:%hx:%hx:%hx:%hx"),
- ntohs(*(uint16_t *) & packet->data[38]),
- ntohs(*(uint16_t *) & packet->data[40]),
- ntohs(*(uint16_t *) & packet->data[42]),
- ntohs(*(uint16_t *) & packet->data[44]),
- ntohs(*(uint16_t *) & packet->data[46]),
- ntohs(*(uint16_t *) & packet->data[48]),
- ntohs(*(uint16_t *) & packet->data[50]),
- ntohs(*(uint16_t *) & packet->data[52]));
- }
- route_ipv6_unreachable(packet, ICMP6_DST_UNREACH_ADDR);
-
- return NULL;