| 92 | #endif |
| 93 | #ifdef INET6 |
| 94 | void |
| 95 | ipsec6_setsockaddrs(const struct mbuf *m, union sockaddr_union *src, |
| 96 | union sockaddr_union *dst) |
| 97 | { |
| 98 | struct ip6_hdr ip6buf; |
| 99 | const struct ip6_hdr *ip6; |
| 100 | |
| 101 | if (m->m_len >= sizeof(*ip6)) |
| 102 | ip6 = mtod(m, const struct ip6_hdr *); |
| 103 | else { |
| 104 | m_copydata(m, 0, sizeof(ip6buf), (caddr_t)&ip6buf); |
| 105 | ip6 = &ip6buf; |
| 106 | } |
| 107 | |
| 108 | bzero(&src->sin6, sizeof(struct sockaddr_in6)); |
| 109 | src->sin6.sin6_family = AF_INET6; |
| 110 | src->sin6.sin6_len = sizeof(struct sockaddr_in6); |
| 111 | bcopy(&ip6->ip6_src, &src->sin6.sin6_addr, sizeof(ip6->ip6_src)); |
| 112 | if (IN6_IS_SCOPE_LINKLOCAL(&ip6->ip6_src)) { |
| 113 | src->sin6.sin6_addr.s6_addr16[1] = 0; |
| 114 | src->sin6.sin6_scope_id = ntohs(ip6->ip6_src.s6_addr16[1]); |
| 115 | } |
| 116 | |
| 117 | bzero(&dst->sin6, sizeof(struct sockaddr_in6)); |
| 118 | dst->sin6.sin6_family = AF_INET6; |
| 119 | dst->sin6.sin6_len = sizeof(struct sockaddr_in6); |
| 120 | bcopy(&ip6->ip6_dst, &dst->sin6.sin6_addr, sizeof(ip6->ip6_dst)); |
| 121 | if (IN6_IS_SCOPE_LINKLOCAL(&ip6->ip6_dst)) { |
| 122 | dst->sin6.sin6_addr.s6_addr16[1] = 0; |
| 123 | dst->sin6.sin6_scope_id = ntohs(ip6->ip6_dst.s6_addr16[1]); |
| 124 | } |
| 125 | } |
| 126 | #endif |
| 127 | |
| 128 | #define IPSEC_MODULE_INCR 2 |
no test coverage detected