-node_t *route_mac(vpn_packet_t *packet)
-{
- subnet_t *subnet;
-cp
- /* Learn source address */
-
- learn_mac((mac_t *)(&packet->data[6]));
-
- /* Lookup destination address */
-
- subnet = lookup_subnet_mac((mac_t *)(&packet->data[0]));
-
- if(subnet)
- return subnet->owner;
- else
- return NULL;
-}
-
-node_t *route_ipv4(vpn_packet_t *packet)
-{
- subnet_t *subnet;
-cp
- if(priorityinheritance)
- packet->priority = packet->data[15];
-
- subnet = lookup_subnet_ipv4((ipv4_t *)&packet->data[30]);
-cp
- if(!subnet)
- {
- if(debug_lvl >= DEBUG_TRAFFIC)
- {
- syslog(LOG_WARNING, _("Cannot route packet: unknown IPv4 destination address %d.%d.%d.%d"),
- packet->data[30], packet->data[31], packet->data[32], packet->data[33]);
- }
-
- return NULL;
- }
-cp
- return subnet->owner;
-}
-
-node_t *route_ipv6(vpn_packet_t *packet)
-{
- subnet_t *subnet;
-cp
- subnet = lookup_subnet_ipv6((ipv6_t *)&packet->data[38]);
-cp
- 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(*(short unsigned int *)&packet->data[38]),
- ntohs(*(short unsigned int *)&packet->data[40]),
- ntohs(*(short unsigned int *)&packet->data[42]),
- ntohs(*(short unsigned int *)&packet->data[44]),
- ntohs(*(short unsigned int *)&packet->data[46]),
- ntohs(*(short unsigned int *)&packet->data[48]),
- ntohs(*(short unsigned int *)&packet->data[50]),
- ntohs(*(short unsigned int *)&packet->data[52]));
- }
-
- return NULL;
- }
-cp
- return subnet->owner;
-}
-
-void route_neighborsol(vpn_packet_t *packet)
-{
- struct ip6_hdr *hdr;
- struct nd_neighbor_solicit *ns;
- struct nd_opt_hdr *opt;
- subnet_t *subnet;
-cp
- hdr = (struct ip6_hdr *)(packet->data + 14);
- ns = (struct nd_neighbor_solicit *)(packet->data + 14 + sizeof(struct ip6_hdr));
- opt = (struct nd_opt_hdr *)(packet->data + 14 + sizeof(struct ip6_hdr) + sizeof(struct nd_neighbor_solicit));
-
- /* First, snatch the source address from the neighbor solicitation packet */
-
- memcpy(mymac.net.mac.address.x, packet->data + 6, 6);
-
- /* Check if this is a valid neighbor solicitation request */
-
- if(ns->nd_ns_hdr.icmp6_type != ND_NEIGHBOR_SOLICIT ||
- opt->nd_opt_type != ND_OPT_SOURCE_LINKADDR)
- {
- if(debug_lvl > DEBUG_TRAFFIC)
- {
- syslog(LOG_WARNING, _("Cannot route packet: received unknown type neighbor solicitation request"));
- }
- return;
- }
-
- /* Check if the IPv6 address exists on the VPN */
-
- subnet = lookup_subnet_ipv6((ipv6_t *)&ns->nd_ns_target);