| 10989 | } |
| 10990 | |
| 10991 | static void |
| 10992 | sctp_send_resp_msg(struct sockaddr *src, struct sockaddr *dst, |
| 10993 | struct sctphdr *sh, uint32_t vtag, |
| 10994 | uint8_t type, struct mbuf *cause, |
| 10995 | uint8_t mflowtype, uint32_t mflowid, uint16_t fibnum, |
| 10996 | uint32_t vrf_id, uint16_t port) |
| 10997 | { |
| 10998 | struct mbuf *o_pak; |
| 10999 | struct mbuf *mout; |
| 11000 | struct sctphdr *shout; |
| 11001 | struct sctp_chunkhdr *ch; |
| 11002 | #if defined(INET) || defined(INET6) |
| 11003 | struct udphdr *udp; |
| 11004 | #endif |
| 11005 | int ret, len, cause_len, padding_len; |
| 11006 | #ifdef INET |
| 11007 | struct sockaddr_in *src_sin, *dst_sin; |
| 11008 | struct ip *ip; |
| 11009 | #endif |
| 11010 | #ifdef INET6 |
| 11011 | struct sockaddr_in6 *src_sin6, *dst_sin6; |
| 11012 | struct ip6_hdr *ip6; |
| 11013 | #endif |
| 11014 | |
| 11015 | /* Compute the length of the cause and add final padding. */ |
| 11016 | cause_len = 0; |
| 11017 | if (cause != NULL) { |
| 11018 | struct mbuf *m_at, *m_last = NULL; |
| 11019 | |
| 11020 | for (m_at = cause; m_at; m_at = SCTP_BUF_NEXT(m_at)) { |
| 11021 | if (SCTP_BUF_NEXT(m_at) == NULL) |
| 11022 | m_last = m_at; |
| 11023 | cause_len += SCTP_BUF_LEN(m_at); |
| 11024 | } |
| 11025 | padding_len = cause_len % 4; |
| 11026 | if (padding_len != 0) { |
| 11027 | padding_len = 4 - padding_len; |
| 11028 | } |
| 11029 | if (padding_len != 0) { |
| 11030 | if (sctp_add_pad_tombuf(m_last, padding_len) == NULL) { |
| 11031 | sctp_m_freem(cause); |
| 11032 | return; |
| 11033 | } |
| 11034 | } |
| 11035 | } else { |
| 11036 | padding_len = 0; |
| 11037 | } |
| 11038 | /* Get an mbuf for the header. */ |
| 11039 | len = sizeof(struct sctphdr) + sizeof(struct sctp_chunkhdr); |
| 11040 | switch (dst->sa_family) { |
| 11041 | #ifdef INET |
| 11042 | case AF_INET: |
| 11043 | len += sizeof(struct ip); |
| 11044 | break; |
| 11045 | #endif |
| 11046 | #ifdef INET6 |
| 11047 | case AF_INET6: |
| 11048 | len += sizeof(struct ip6_hdr); |
no test coverage detected