* processes the (local) addresses in the INIT-ACK chunk */
| 2749 | * processes the (local) addresses in the INIT-ACK chunk |
| 2750 | */ |
| 2751 | static void |
| 2752 | sctp_process_initack_addresses(struct sctp_tcb *stcb, struct mbuf *m, |
| 2753 | unsigned int offset, unsigned int length) |
| 2754 | { |
| 2755 | struct sctp_paramhdr tmp_param, *ph; |
| 2756 | uint16_t plen, ptype; |
| 2757 | struct sctp_ifa *sctp_ifa; |
| 2758 | union sctp_sockstore store; |
| 2759 | #ifdef INET6 |
| 2760 | struct sctp_ipv6addr_param addr6_store; |
| 2761 | #endif |
| 2762 | #ifdef INET |
| 2763 | struct sctp_ipv4addr_param addr4_store; |
| 2764 | #endif |
| 2765 | |
| 2766 | SCTPDBG(SCTP_DEBUG_ASCONF2, "processing init-ack addresses\n"); |
| 2767 | if (stcb == NULL) /* Un-needed check for SA */ |
| 2768 | return; |
| 2769 | |
| 2770 | /* convert to upper bound */ |
| 2771 | length += offset; |
| 2772 | |
| 2773 | if ((offset + sizeof(struct sctp_paramhdr)) > length) { |
| 2774 | return; |
| 2775 | } |
| 2776 | /* go through the addresses in the init-ack */ |
| 2777 | ph = (struct sctp_paramhdr *) |
| 2778 | sctp_m_getptr(m, offset, sizeof(struct sctp_paramhdr), |
| 2779 | (uint8_t *)&tmp_param); |
| 2780 | while (ph != NULL) { |
| 2781 | ptype = ntohs(ph->param_type); |
| 2782 | plen = ntohs(ph->param_length); |
| 2783 | switch (ptype) { |
| 2784 | #ifdef INET6 |
| 2785 | case SCTP_IPV6_ADDRESS: |
| 2786 | { |
| 2787 | struct sctp_ipv6addr_param *a6p; |
| 2788 | |
| 2789 | /* get the entire IPv6 address param */ |
| 2790 | a6p = (struct sctp_ipv6addr_param *) |
| 2791 | sctp_m_getptr(m, offset, |
| 2792 | sizeof(struct sctp_ipv6addr_param), |
| 2793 | (uint8_t *)&addr6_store); |
| 2794 | if (plen != sizeof(struct sctp_ipv6addr_param) || |
| 2795 | a6p == NULL) { |
| 2796 | return; |
| 2797 | } |
| 2798 | memset(&store, 0, sizeof(union sctp_sockstore)); |
| 2799 | store.sin6.sin6_family = AF_INET6; |
| 2800 | store.sin6.sin6_len = sizeof(struct sockaddr_in6); |
| 2801 | store.sin6.sin6_port = stcb->rport; |
| 2802 | memcpy(&store.sin6.sin6_addr, a6p->addr, sizeof(struct in6_addr)); |
| 2803 | break; |
| 2804 | } |
| 2805 | #endif |
| 2806 | #ifdef INET |
| 2807 | case SCTP_IPV4_ADDRESS: |
| 2808 | { |
no test coverage detected