| 1373 | } |
| 1374 | |
| 1375 | void |
| 1376 | ip6_savecontrol(struct inpcb *inp, struct mbuf *m, struct mbuf **mp) |
| 1377 | { |
| 1378 | struct ip6_hdr *ip6; |
| 1379 | int v4only = 0; |
| 1380 | |
| 1381 | mp = ip6_savecontrol_v4(inp, m, mp, &v4only); |
| 1382 | if (v4only) |
| 1383 | return; |
| 1384 | |
| 1385 | ip6 = mtod(m, struct ip6_hdr *); |
| 1386 | /* |
| 1387 | * IPV6_HOPOPTS socket option. Recall that we required super-user |
| 1388 | * privilege for the option (see ip6_ctloutput), but it might be too |
| 1389 | * strict, since there might be some hop-by-hop options which can be |
| 1390 | * returned to normal user. |
| 1391 | * See also RFC 2292 section 6 (or RFC 3542 section 8). |
| 1392 | */ |
| 1393 | if ((inp->inp_flags & IN6P_HOPOPTS) != 0) { |
| 1394 | /* |
| 1395 | * Check if a hop-by-hop options header is contatined in the |
| 1396 | * received packet, and if so, store the options as ancillary |
| 1397 | * data. Note that a hop-by-hop options header must be |
| 1398 | * just after the IPv6 header, which is assured through the |
| 1399 | * IPv6 input processing. |
| 1400 | */ |
| 1401 | if (ip6->ip6_nxt == IPPROTO_HOPOPTS) { |
| 1402 | struct ip6_hbh *hbh; |
| 1403 | int hbhlen; |
| 1404 | |
| 1405 | hbh = (struct ip6_hbh *)(ip6 + 1); |
| 1406 | hbhlen = (hbh->ip6h_len + 1) << 3; |
| 1407 | |
| 1408 | /* |
| 1409 | * XXX: We copy the whole header even if a |
| 1410 | * jumbo payload option is included, the option which |
| 1411 | * is to be removed before returning according to |
| 1412 | * RFC2292. |
| 1413 | * Note: this constraint is removed in RFC3542 |
| 1414 | */ |
| 1415 | *mp = sbcreatecontrol((caddr_t)hbh, hbhlen, |
| 1416 | IS2292(inp, IPV6_2292HOPOPTS, IPV6_HOPOPTS), |
| 1417 | IPPROTO_IPV6); |
| 1418 | if (*mp) |
| 1419 | mp = &(*mp)->m_next; |
| 1420 | } |
| 1421 | } |
| 1422 | |
| 1423 | if ((inp->inp_flags & (IN6P_RTHDR | IN6P_DSTOPTS)) != 0) { |
| 1424 | int nxt = ip6->ip6_nxt, off = sizeof(struct ip6_hdr); |
| 1425 | |
| 1426 | /* |
| 1427 | * Search for destination options headers or routing |
| 1428 | * header(s) through the header chain, and stores each |
| 1429 | * header as ancillary data. |
| 1430 | * Note that the order of the headers remains in |
| 1431 | * the chain of ancillary data. |
| 1432 | */ |
no test coverage detected