Deleted Added
full compact
sctputil.c (235066) sctputil.c (235075)
1/*-
2 * Copyright (c) 2001-2008, by Cisco Systems, Inc. All rights reserved.
3 * Copyright (c) 2008-2011, by Randall Stewart. All rights reserved.
4 * Copyright (c) 2008-2011, by Michael Tuexen. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *

--- 19 unchanged lines hidden (view full) ---

28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
30 * THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
33/* $KAME: sctputil.c,v 1.37 2005/03/07 23:26:09 itojun Exp $ */
34
35#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2001-2008, by Cisco Systems, Inc. All rights reserved.
3 * Copyright (c) 2008-2011, by Randall Stewart. All rights reserved.
4 * Copyright (c) 2008-2011, by Michael Tuexen. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *

--- 19 unchanged lines hidden (view full) ---

28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
30 * THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
33/* $KAME: sctputil.c,v 1.37 2005/03/07 23:26:09 itojun Exp $ */
34
35#include <sys/cdefs.h>
36__FBSDID("$FreeBSD: head/sys/netinet/sctputil.c 235066 2012-05-05 21:41:16Z tuexen $");
36__FBSDID("$FreeBSD: head/sys/netinet/sctputil.c 235075 2012-05-06 11:02:53Z tuexen $");
37
38#include <netinet/sctp_os.h>
39#include <netinet/sctp_pcb.h>
40#include <netinet/sctputil.h>
41#include <netinet/sctp_var.h>
42#include <netinet/sctp_sysctl.h>
43#ifdef INET6
44#endif

--- 2748 unchanged lines hidden (view full) ---

2793 struct sctp_tmit_chunk *chk, int so_locked
2794#if !defined(__APPLE__) && !defined(SCTP_SO_LOCK_TESTING)
2795 SCTP_UNUSED
2796#endif
2797)
2798{
2799 struct mbuf *m_notify;
2800 struct sctp_send_failed *ssf;
37
38#include <netinet/sctp_os.h>
39#include <netinet/sctp_pcb.h>
40#include <netinet/sctputil.h>
41#include <netinet/sctp_var.h>
42#include <netinet/sctp_sysctl.h>
43#ifdef INET6
44#endif

--- 2748 unchanged lines hidden (view full) ---

2793 struct sctp_tmit_chunk *chk, int so_locked
2794#if !defined(__APPLE__) && !defined(SCTP_SO_LOCK_TESTING)
2795 SCTP_UNUSED
2796#endif
2797)
2798{
2799 struct mbuf *m_notify;
2800 struct sctp_send_failed *ssf;
2801 struct sctp_send_failed_event *ssfe;
2801 struct sctp_queued_to_read *control;
2802 int length;
2803
2804 if ((stcb == NULL) ||
2802 struct sctp_queued_to_read *control;
2803 int length;
2804
2805 if ((stcb == NULL) ||
2805 sctp_stcb_is_feature_off(stcb->sctp_ep, stcb, SCTP_PCB_FLAGS_RECVSENDFAILEVNT)) {
2806 (sctp_stcb_is_feature_off(stcb->sctp_ep, stcb, SCTP_PCB_FLAGS_RECVSENDFAILEVNT) &&
2807 sctp_stcb_is_feature_off(stcb->sctp_ep, stcb, SCTP_PCB_FLAGS_RECVNSENDFAILEVNT))) {
2806 /* event not enabled */
2807 return;
2808 }
2808 /* event not enabled */
2809 return;
2810 }
2809 m_notify = sctp_get_mbuf_for_msg(sizeof(struct sctp_send_failed), 0, M_DONTWAIT, 1, MT_DATA);
2811 if (sctp_stcb_is_feature_on(stcb->sctp_ep, stcb, SCTP_PCB_FLAGS_RECVNSENDFAILEVNT)) {
2812 length = sizeof(struct sctp_send_failed_event);
2813 } else {
2814 length = sizeof(struct sctp_send_failed);
2815 }
2816 m_notify = sctp_get_mbuf_for_msg(length, 0, M_DONTWAIT, 1, MT_DATA);
2810 if (m_notify == NULL)
2811 /* no space left */
2812 return;
2817 if (m_notify == NULL)
2818 /* no space left */
2819 return;
2813 length = sizeof(struct sctp_send_failed) + chk->send_size;
2820 length += chk->send_size;
2814 length -= sizeof(struct sctp_data_chunk);
2815 SCTP_BUF_LEN(m_notify) = 0;
2821 length -= sizeof(struct sctp_data_chunk);
2822 SCTP_BUF_LEN(m_notify) = 0;
2816 ssf = mtod(m_notify, struct sctp_send_failed *);
2817 ssf->ssf_type = SCTP_SEND_FAILED;
2818 if (error == SCTP_NOTIFY_DATAGRAM_UNSENT)
2819 ssf->ssf_flags = SCTP_DATA_UNSENT;
2820 else
2821 ssf->ssf_flags = SCTP_DATA_SENT;
2822 ssf->ssf_length = length;
2823 ssf->ssf_error = error;
2824 /* not exactly what the user sent in, but should be close :) */
2825 bzero(&ssf->ssf_info, sizeof(ssf->ssf_info));
2826 ssf->ssf_info.sinfo_stream = chk->rec.data.stream_number;
2827 ssf->ssf_info.sinfo_ssn = chk->rec.data.stream_seq;
2828 ssf->ssf_info.sinfo_flags = chk->rec.data.rcv_flags;
2829 ssf->ssf_info.sinfo_ppid = chk->rec.data.payloadtype;
2830 ssf->ssf_info.sinfo_context = chk->rec.data.context;
2831 ssf->ssf_info.sinfo_assoc_id = sctp_get_associd(stcb);
2832 ssf->ssf_assoc_id = sctp_get_associd(stcb);
2833
2823 if (sctp_stcb_is_feature_on(stcb->sctp_ep, stcb, SCTP_PCB_FLAGS_RECVNSENDFAILEVNT)) {
2824 ssfe = mtod(m_notify, struct sctp_send_failed_event *);
2825 ssfe->ssfe_type = SCTP_SEND_FAILED_EVENT;
2826 if (error == SCTP_NOTIFY_DATAGRAM_UNSENT)
2827 ssfe->ssfe_flags = SCTP_DATA_UNSENT;
2828 else
2829 ssfe->ssfe_flags = SCTP_DATA_SENT;
2830 ssfe->ssfe_length = length;
2831 ssfe->ssfe_error = error;
2832 /* not exactly what the user sent in, but should be close :) */
2833 bzero(&ssfe->ssfe_info, sizeof(ssfe->ssfe_info));
2834 ssfe->ssfe_info.snd_sid = chk->rec.data.stream_number;
2835 ssfe->ssfe_info.snd_flags = chk->rec.data.rcv_flags;
2836 ssfe->ssfe_info.snd_ppid = chk->rec.data.payloadtype;
2837 ssfe->ssfe_info.snd_context = chk->rec.data.context;
2838 ssfe->ssfe_info.snd_assoc_id = sctp_get_associd(stcb);
2839 ssfe->ssfe_assoc_id = sctp_get_associd(stcb);
2840 SCTP_BUF_LEN(m_notify) = sizeof(struct sctp_send_failed_event);
2841 } else {
2842 ssf = mtod(m_notify, struct sctp_send_failed *);
2843 ssf->ssf_type = SCTP_SEND_FAILED;
2844 if (error == SCTP_NOTIFY_DATAGRAM_UNSENT)
2845 ssf->ssf_flags = SCTP_DATA_UNSENT;
2846 else
2847 ssf->ssf_flags = SCTP_DATA_SENT;
2848 ssf->ssf_length = length;
2849 ssf->ssf_error = error;
2850 /* not exactly what the user sent in, but should be close :) */
2851 bzero(&ssf->ssf_info, sizeof(ssf->ssf_info));
2852 ssf->ssf_info.sinfo_stream = chk->rec.data.stream_number;
2853 ssf->ssf_info.sinfo_ssn = chk->rec.data.stream_seq;
2854 ssf->ssf_info.sinfo_flags = chk->rec.data.rcv_flags;
2855 ssf->ssf_info.sinfo_ppid = chk->rec.data.payloadtype;
2856 ssf->ssf_info.sinfo_context = chk->rec.data.context;
2857 ssf->ssf_info.sinfo_assoc_id = sctp_get_associd(stcb);
2858 ssf->ssf_assoc_id = sctp_get_associd(stcb);
2859 SCTP_BUF_LEN(m_notify) = sizeof(struct sctp_send_failed);
2860 }
2834 if (chk->data) {
2835 /*
2836 * trim off the sctp chunk header(it should be there)
2837 */
2838 if (chk->send_size >= sizeof(struct sctp_data_chunk)) {
2839 m_adj(chk->data, sizeof(struct sctp_data_chunk));
2840 sctp_mbuf_crush(chk->data);
2841 chk->send_size -= sizeof(struct sctp_data_chunk);
2842 }
2843 }
2844 SCTP_BUF_NEXT(m_notify) = chk->data;
2861 if (chk->data) {
2862 /*
2863 * trim off the sctp chunk header(it should be there)
2864 */
2865 if (chk->send_size >= sizeof(struct sctp_data_chunk)) {
2866 m_adj(chk->data, sizeof(struct sctp_data_chunk));
2867 sctp_mbuf_crush(chk->data);
2868 chk->send_size -= sizeof(struct sctp_data_chunk);
2869 }
2870 }
2871 SCTP_BUF_NEXT(m_notify) = chk->data;
2845 SCTP_BUF_LEN(m_notify) = sizeof(struct sctp_send_failed);
2846 /* Steal off the mbuf */
2847 chk->data = NULL;
2848 /*
2849 * For this case, we check the actual socket buffer, since the assoc
2850 * is going away we don't want to overfill the socket buffer for a
2851 * non-reader
2852 */
2853 if (sctp_sbspace_failedmsgs(&stcb->sctp_socket->so_rcv) < SCTP_BUF_LEN(m_notify)) {

--- 23 unchanged lines hidden (view full) ---

2877 struct sctp_stream_queue_pending *sp, int so_locked
2878#if !defined(__APPLE__) && !defined(SCTP_SO_LOCK_TESTING)
2879 SCTP_UNUSED
2880#endif
2881)
2882{
2883 struct mbuf *m_notify;
2884 struct sctp_send_failed *ssf;
2872 /* Steal off the mbuf */
2873 chk->data = NULL;
2874 /*
2875 * For this case, we check the actual socket buffer, since the assoc
2876 * is going away we don't want to overfill the socket buffer for a
2877 * non-reader
2878 */
2879 if (sctp_sbspace_failedmsgs(&stcb->sctp_socket->so_rcv) < SCTP_BUF_LEN(m_notify)) {

--- 23 unchanged lines hidden (view full) ---

2903 struct sctp_stream_queue_pending *sp, int so_locked
2904#if !defined(__APPLE__) && !defined(SCTP_SO_LOCK_TESTING)
2905 SCTP_UNUSED
2906#endif
2907)
2908{
2909 struct mbuf *m_notify;
2910 struct sctp_send_failed *ssf;
2911 struct sctp_send_failed_event *ssfe;
2885 struct sctp_queued_to_read *control;
2886 int length;
2887
2888 if ((stcb == NULL) ||
2912 struct sctp_queued_to_read *control;
2913 int length;
2914
2915 if ((stcb == NULL) ||
2889 sctp_stcb_is_feature_off(stcb->sctp_ep, stcb, SCTP_PCB_FLAGS_RECVSENDFAILEVNT)) {
2916 (sctp_stcb_is_feature_off(stcb->sctp_ep, stcb, SCTP_PCB_FLAGS_RECVSENDFAILEVNT) &&
2917 sctp_stcb_is_feature_off(stcb->sctp_ep, stcb, SCTP_PCB_FLAGS_RECVNSENDFAILEVNT))) {
2890 /* event not enabled */
2891 return;
2892 }
2918 /* event not enabled */
2919 return;
2920 }
2893 length = sizeof(struct sctp_send_failed) + sp->length;
2894 m_notify = sctp_get_mbuf_for_msg(sizeof(struct sctp_send_failed), 0, M_DONTWAIT, 1, MT_DATA);
2895 if (m_notify == NULL)
2921 if (sctp_stcb_is_feature_on(stcb->sctp_ep, stcb, SCTP_PCB_FLAGS_RECVNSENDFAILEVNT)) {
2922 length = sizeof(struct sctp_send_failed_event);
2923 } else {
2924 length = sizeof(struct sctp_send_failed);
2925 }
2926 m_notify = sctp_get_mbuf_for_msg(length, 0, M_DONTWAIT, 1, MT_DATA);
2927 if (m_notify == NULL) {
2896 /* no space left */
2897 return;
2928 /* no space left */
2929 return;
2930 }
2931 length += sp->length;
2898 SCTP_BUF_LEN(m_notify) = 0;
2932 SCTP_BUF_LEN(m_notify) = 0;
2899 ssf = mtod(m_notify, struct sctp_send_failed *);
2900 ssf->ssf_type = SCTP_SEND_FAILED;
2901 if (error == SCTP_NOTIFY_DATAGRAM_UNSENT)
2902 ssf->ssf_flags = SCTP_DATA_UNSENT;
2903 else
2904 ssf->ssf_flags = SCTP_DATA_SENT;
2905 ssf->ssf_length = length;
2906 ssf->ssf_error = error;
2907 /* not exactly what the user sent in, but should be close :) */
2908 bzero(&ssf->ssf_info, sizeof(ssf->ssf_info));
2909 ssf->ssf_info.sinfo_stream = sp->stream;
2910 ssf->ssf_info.sinfo_ssn = sp->strseq;
2911 if (sp->some_taken) {
2912 ssf->ssf_info.sinfo_flags = SCTP_DATA_LAST_FRAG;
2933 if (sctp_stcb_is_feature_on(stcb->sctp_ep, stcb, SCTP_PCB_FLAGS_RECVNSENDFAILEVNT)) {
2934 ssfe = mtod(m_notify, struct sctp_send_failed_event *);
2935 ssfe->ssfe_type = SCTP_SEND_FAILED;
2936 if (error == SCTP_NOTIFY_DATAGRAM_UNSENT)
2937 ssfe->ssfe_flags = SCTP_DATA_UNSENT;
2938 else
2939 ssfe->ssfe_flags = SCTP_DATA_SENT;
2940 ssfe->ssfe_length = length;
2941 ssfe->ssfe_error = error;
2942 /* not exactly what the user sent in, but should be close :) */
2943 bzero(&ssfe->ssfe_info, sizeof(ssfe->ssfe_info));
2944 ssfe->ssfe_info.snd_sid = sp->stream;
2945 if (sp->some_taken) {
2946 ssfe->ssfe_info.snd_flags = SCTP_DATA_LAST_FRAG;
2947 } else {
2948 ssfe->ssfe_info.snd_flags = SCTP_DATA_NOT_FRAG;
2949 }
2950 ssfe->ssfe_info.snd_ppid = sp->ppid;
2951 ssfe->ssfe_info.snd_context = sp->context;
2952 ssfe->ssfe_info.snd_assoc_id = sctp_get_associd(stcb);
2953 ssfe->ssfe_assoc_id = sctp_get_associd(stcb);
2954 SCTP_BUF_LEN(m_notify) = sizeof(struct sctp_send_failed_event);
2913 } else {
2955 } else {
2914 ssf->ssf_info.sinfo_flags = SCTP_DATA_NOT_FRAG;
2956 ssf = mtod(m_notify, struct sctp_send_failed *);
2957 ssf->ssf_type = SCTP_SEND_FAILED;
2958 if (error == SCTP_NOTIFY_DATAGRAM_UNSENT)
2959 ssf->ssf_flags = SCTP_DATA_UNSENT;
2960 else
2961 ssf->ssf_flags = SCTP_DATA_SENT;
2962 ssf->ssf_length = length;
2963 ssf->ssf_error = error;
2964 /* not exactly what the user sent in, but should be close :) */
2965 bzero(&ssf->ssf_info, sizeof(ssf->ssf_info));
2966 ssf->ssf_info.sinfo_stream = sp->stream;
2967 ssf->ssf_info.sinfo_ssn = sp->strseq;
2968 if (sp->some_taken) {
2969 ssf->ssf_info.sinfo_flags = SCTP_DATA_LAST_FRAG;
2970 } else {
2971 ssf->ssf_info.sinfo_flags = SCTP_DATA_NOT_FRAG;
2972 }
2973 ssf->ssf_info.sinfo_ppid = sp->ppid;
2974 ssf->ssf_info.sinfo_context = sp->context;
2975 ssf->ssf_info.sinfo_assoc_id = sctp_get_associd(stcb);
2976 ssf->ssf_assoc_id = sctp_get_associd(stcb);
2977 SCTP_BUF_LEN(m_notify) = sizeof(struct sctp_send_failed);
2915 }
2978 }
2916 ssf->ssf_info.sinfo_ppid = sp->ppid;
2917 ssf->ssf_info.sinfo_context = sp->context;
2918 ssf->ssf_info.sinfo_assoc_id = sctp_get_associd(stcb);
2919 ssf->ssf_assoc_id = sctp_get_associd(stcb);
2920 SCTP_BUF_NEXT(m_notify) = sp->data;
2979 SCTP_BUF_NEXT(m_notify) = sp->data;
2921 SCTP_BUF_LEN(m_notify) = sizeof(struct sctp_send_failed);
2922
2923 /* Steal off the mbuf */
2924 sp->data = NULL;
2925 /*
2926 * For this case, we check the actual socket buffer, since the assoc
2927 * is going away we don't want to overfill the socket buffer for a
2928 * non-reader
2929 */

--- 3912 unchanged lines hidden ---
2980
2981 /* Steal off the mbuf */
2982 sp->data = NULL;
2983 /*
2984 * For this case, we check the actual socket buffer, since the assoc
2985 * is going away we don't want to overfill the socket buffer for a
2986 * non-reader
2987 */

--- 3912 unchanged lines hidden ---