ip6_input.c (97676) | ip6_input.c (105194) |
---|---|
1/* $FreeBSD: head/sys/netinet6/ip6_input.c 97676 2002-05-31 17:56:45Z ume $ */ | 1/* $FreeBSD: head/sys/netinet6/ip6_input.c 105194 2002-10-16 01:54:46Z sam $ */ |
2/* $KAME: ip6_input.c,v 1.259 2002/01/21 04:58:09 jinmei Exp $ */ 3 4/* 5 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions --- 131 unchanged lines hidden (view full) --- 141/* firewall hooks */ 142ip6_fw_chk_t *ip6_fw_chk_ptr; 143ip6_fw_ctl_t *ip6_fw_ctl_ptr; 144int ip6_fw_enable = 1; 145 146struct ip6stat ip6stat; 147 148static void ip6_init2 __P((void *)); | 2/* $KAME: ip6_input.c,v 1.259 2002/01/21 04:58:09 jinmei Exp $ */ 3 4/* 5 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions --- 131 unchanged lines hidden (view full) --- 141/* firewall hooks */ 142ip6_fw_chk_t *ip6_fw_chk_ptr; 143ip6_fw_ctl_t *ip6_fw_ctl_ptr; 144int ip6_fw_enable = 1; 145 146struct ip6stat ip6stat; 147 148static void ip6_init2 __P((void *)); |
149static struct mbuf *ip6_setdstifaddr __P((struct mbuf *, struct in6_ifaddr *)); | 149static struct ip6aux *ip6_setdstifaddr __P((struct mbuf *, struct in6_ifaddr *)); |
150static int ip6_hopopts_input __P((u_int32_t *, u_int32_t *, struct mbuf **, int *)); 151#ifdef PULLDOWN_TEST 152static struct mbuf *ip6_pullexthdr __P((struct mbuf *, size_t, int)); 153#endif 154 155 156/* 157 * IP6 initialization: fill in IP6 protocol switch table. --- 695 unchanged lines hidden (view full) --- 853 bad: 854 m_freem(m); 855} 856 857/* 858 * set/grab in6_ifaddr correspond to IPv6 destination address. 859 * XXX backward compatibility wrapper 860 */ | 150static int ip6_hopopts_input __P((u_int32_t *, u_int32_t *, struct mbuf **, int *)); 151#ifdef PULLDOWN_TEST 152static struct mbuf *ip6_pullexthdr __P((struct mbuf *, size_t, int)); 153#endif 154 155 156/* 157 * IP6 initialization: fill in IP6 protocol switch table. --- 695 unchanged lines hidden (view full) --- 853 bad: 854 m_freem(m); 855} 856 857/* 858 * set/grab in6_ifaddr correspond to IPv6 destination address. 859 * XXX backward compatibility wrapper 860 */ |
861static struct mbuf * | 861static struct ip6aux * |
862ip6_setdstifaddr(m, ia6) 863 struct mbuf *m; 864 struct in6_ifaddr *ia6; 865{ | 862ip6_setdstifaddr(m, ia6) 863 struct mbuf *m; 864 struct in6_ifaddr *ia6; 865{ |
866 struct mbuf *n; | 866 struct ip6aux *n; |
867 868 n = ip6_addaux(m); 869 if (n) | 867 868 n = ip6_addaux(m); 869 if (n) |
870 mtod(n, struct ip6aux *)->ip6a_dstia6 = ia6; | 870 n->ip6a_dstia6 = ia6; |
871 return n; /* NULL if failed to set */ 872} 873 874struct in6_ifaddr * 875ip6_getdstifaddr(m) 876 struct mbuf *m; 877{ | 871 return n; /* NULL if failed to set */ 872} 873 874struct in6_ifaddr * 875ip6_getdstifaddr(m) 876 struct mbuf *m; 877{ |
878 struct mbuf *n; | 878 struct ip6aux *n; |
879 880 n = ip6_findaux(m); 881 if (n) | 879 880 n = ip6_findaux(m); 881 if (n) |
882 return mtod(n, struct ip6aux *)->ip6a_dstia6; | 882 return n->ip6a_dstia6; |
883 else 884 return NULL; 885} 886 887/* 888 * Hop-by-Hop options header processing. If a valid jumbo payload option is 889 * included, the real payload length will be stored in plenp. 890 */ --- 713 unchanged lines hidden (view full) --- 1604 else if (newoff == off) 1605 return newoff; 1606 1607 off = newoff; 1608 proto = *nxtp; 1609 } 1610} 1611 | 883 else 884 return NULL; 885} 886 887/* 888 * Hop-by-Hop options header processing. If a valid jumbo payload option is 889 * included, the real payload length will be stored in plenp. 890 */ --- 713 unchanged lines hidden (view full) --- 1604 else if (newoff == off) 1605 return newoff; 1606 1607 off = newoff; 1608 proto = *nxtp; 1609 } 1610} 1611 |
1612struct mbuf * | 1612struct ip6aux * |
1613ip6_addaux(m) 1614 struct mbuf *m; 1615{ | 1613ip6_addaux(m) 1614 struct mbuf *m; 1615{ |
1616 struct mbuf *n; 1617 1618#ifdef DIAGNOSTIC 1619 if (sizeof(struct ip6aux) > MHLEN) 1620 panic("assumption failed on sizeof(ip6aux)"); 1621#endif 1622 n = m_aux_find(m, AF_INET6, -1); 1623 if (n) { 1624 if (n->m_len < sizeof(struct ip6aux)) { 1625 printf("conflicting use of ip6aux"); 1626 return NULL; 1627 } 1628 } else { 1629 n = m_aux_add(m, AF_INET6, -1); 1630 n->m_len = sizeof(struct ip6aux); 1631 bzero(mtod(n, caddr_t), n->m_len); | 1616 struct m_tag *tag = m_tag_find(m, PACKET_TAG_IPV6_INPUT, NULL); 1617 if (!tag) { 1618 tag = m_tag_get(PACKET_TAG_IPV6_INPUT, 1619 sizeof (struct ip6aux), 1620 M_NOWAIT); 1621 if (tag) 1622 m_tag_prepend(m, tag); |
1632 } | 1623 } |
1633 return n; | 1624 if (tag) 1625 bzero(tag+1, sizeof (struct ip6aux)); 1626 return tag ? (struct ip6aux*)(tag+1) : NULL; |
1634} 1635 | 1627} 1628 |
1636struct mbuf * | 1629struct ip6aux * |
1637ip6_findaux(m) 1638 struct mbuf *m; 1639{ | 1630ip6_findaux(m) 1631 struct mbuf *m; 1632{ |
1640 struct mbuf *n; 1641 1642 n = m_aux_find(m, AF_INET6, -1); 1643 if (n && n->m_len < sizeof(struct ip6aux)) { 1644 printf("conflicting use of ip6aux"); 1645 n = NULL; 1646 } 1647 return n; | 1633 struct m_tag *tag = m_tag_find(m, PACKET_TAG_IPV6_INPUT, NULL); 1634 return tag ? (struct ip6aux*)(tag+1) : NULL; |
1648} 1649 1650void 1651ip6_delaux(m) 1652 struct mbuf *m; 1653{ | 1635} 1636 1637void 1638ip6_delaux(m) 1639 struct mbuf *m; 1640{ |
1654 struct mbuf *n; 1655 1656 n = m_aux_find(m, AF_INET6, -1); 1657 if (n) 1658 m_aux_delete(m, n); | 1641 struct m_tag *tag = m_tag_find(m, PACKET_TAG_IPV6_INPUT, NULL); 1642 if (tag) 1643 m_tag_delete(m, tag); |
1659} 1660 1661/* 1662 * System control for IP6 1663 */ 1664 1665u_char inet6ctlerrmap[PRC_NCMDS] = { 1666 0, 0, 0, 0, 1667 0, EMSGSIZE, EHOSTDOWN, EHOSTUNREACH, 1668 EHOSTUNREACH, EHOSTUNREACH, ECONNREFUSED, ECONNREFUSED, 1669 EMSGSIZE, EHOSTUNREACH, 0, 0, 1670 0, 0, 0, 0, 1671 ENOPROTOOPT 1672}; | 1644} 1645 1646/* 1647 * System control for IP6 1648 */ 1649 1650u_char inet6ctlerrmap[PRC_NCMDS] = { 1651 0, 0, 0, 0, 1652 0, EMSGSIZE, EHOSTDOWN, EHOSTUNREACH, 1653 EHOSTUNREACH, EHOSTUNREACH, ECONNREFUSED, ECONNREFUSED, 1654 EMSGSIZE, EHOSTUNREACH, 0, 0, 1655 0, 0, 0, 0, 1656 ENOPROTOOPT 1657}; |