Deleted Added
full compact
sctputil.c (214918) sctputil.c (214939)
1/*-
2 * Copyright (c) 2001-2008, by Cisco Systems, Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 *
7 * a) Redistributions of source code must retain the above copyright notice,
8 * this list of conditions and the following disclaimer.

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

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

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

26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
28 * THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31/* $KAME: sctputil.c,v 1.37 2005/03/07 23:26:09 itojun Exp $ */
32
33#include <sys/cdefs.h>
34__FBSDID("$FreeBSD: head/sys/netinet/sctputil.c 214918 2010-11-07 14:39:40Z tuexen $");
34__FBSDID("$FreeBSD: head/sys/netinet/sctputil.c 214939 2010-11-07 18:50:35Z tuexen $");
35
36#include <netinet/sctp_os.h>
37#include <netinet/sctp_pcb.h>
38#include <netinet/sctputil.h>
39#include <netinet/sctp_var.h>
40#include <netinet/sctp_sysctl.h>
41#ifdef INET6
42#endif
43#include <netinet/sctp_header.h>
44#include <netinet/sctp_output.h>
45#include <netinet/sctp_uio.h>
46#include <netinet/sctp_timer.h>
47#include <netinet/sctp_indata.h>/* for sctp_deliver_data() */
48#include <netinet/sctp_auth.h>
49#include <netinet/sctp_asconf.h>
50#include <netinet/sctp_cc_functions.h>
51#include <netinet/sctp_bsd_addr.h>
52
35
36#include <netinet/sctp_os.h>
37#include <netinet/sctp_pcb.h>
38#include <netinet/sctputil.h>
39#include <netinet/sctp_var.h>
40#include <netinet/sctp_sysctl.h>
41#ifdef INET6
42#endif
43#include <netinet/sctp_header.h>
44#include <netinet/sctp_output.h>
45#include <netinet/sctp_uio.h>
46#include <netinet/sctp_timer.h>
47#include <netinet/sctp_indata.h>/* for sctp_deliver_data() */
48#include <netinet/sctp_auth.h>
49#include <netinet/sctp_asconf.h>
50#include <netinet/sctp_cc_functions.h>
51#include <netinet/sctp_bsd_addr.h>
52
53#define NUMBER_OF_MTU_SIZES 18
54
53
55
56#ifndef KTR_SCTP
57#define KTR_SCTP KTR_SUBSYS
58#endif
59
60void
61sctp_sblog(struct sockbuf *sb,
62 struct sctp_tcb *stcb, int from, int incr)
63{

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

748 (void)SCTP_OS_TIMER_STOP(&net->pmtu_timer.timer);
749 }
750}
751
752/*
753 * a list of sizes based on typical mtu's, used only if next hop size not
754 * returned.
755 */
54#ifndef KTR_SCTP
55#define KTR_SCTP KTR_SUBSYS
56#endif
57
58void
59sctp_sblog(struct sockbuf *sb,
60 struct sctp_tcb *stcb, int from, int incr)
61{

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

746 (void)SCTP_OS_TIMER_STOP(&net->pmtu_timer.timer);
747 }
748}
749
750/*
751 * a list of sizes based on typical mtu's, used only if next hop size not
752 * returned.
753 */
756static int sctp_mtu_sizes[] = {
754static uint32_t sctp_mtu_sizes[] = {
757 68,
758 296,
759 508,
760 512,
761 544,
762 576,
763 1006,
764 1492,

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

769 4352,
770 4464,
771 8166,
772 17914,
773 32000,
774 65535
775};
776
755 68,
756 296,
757 508,
758 512,
759 544,
760 576,
761 1006,
762 1492,

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

767 4352,
768 4464,
769 8166,
770 17914,
771 32000,
772 65535
773};
774
777int
778find_next_best_mtu(int totsz)
775/*
776 * Return the largest MTU smaller than val. If there is no
777 * entry, just return val.
778 */
779uint32_t
780sctp_get_prev_mtu(uint32_t val)
779{
781{
780 int i, perfer;
782 uint32_t i;
781
783
782 /*
783 * if we are in here we must find the next best fit based on the
784 * size of the dg that failed to be sent.
785 */
786 perfer = 0;
787 for (i = 0; i < NUMBER_OF_MTU_SIZES; i++) {
788 if (totsz < sctp_mtu_sizes[i]) {
789 perfer = i - 1;
790 if (perfer < 0)
791 perfer = 0;
784 if (val <= sctp_mtu_sizes[0]) {
785 return (val);
786 }
787 for (i = 1; i < (sizeof(sctp_mtu_sizes) / sizeof(uint32_t)); i++) {
788 if (val <= sctp_mtu_sizes[i]) {
792 break;
793 }
794 }
789 break;
790 }
791 }
795 return (sctp_mtu_sizes[perfer]);
792 return (sctp_mtu_sizes[i - 1]);
796}
797
793}
794
795/*
796 * Return the smallest MTU larger than val. If there is no
797 * entry, just return val.
798 */
799uint32_t
800sctp_get_next_mtu(struct sctp_inpcb *inp, uint32_t val)
801{
802 /* select another MTU that is just bigger than this one */
803 uint32_t i;
804
805 for (i = 0; i < (sizeof(sctp_mtu_sizes) / sizeof(uint32_t)); i++) {
806 if (val < sctp_mtu_sizes[i]) {
807 return (sctp_mtu_sizes[i]);
808 }
809 }
810 return (val);
811}
812
798void
799sctp_fill_random_store(struct sctp_pcb *m)
800{
801 /*
802 * Here we use the MD5/SHA-1 to hash with our good randomNumbers and
803 * our counter. The result becomes our good random numbers and we
804 * then setup to give these out. Note that we do no locking to
805 * protect this. This is ok, since if competing folks call this we

--- 6151 unchanged lines hidden ---
813void
814sctp_fill_random_store(struct sctp_pcb *m)
815{
816 /*
817 * Here we use the MD5/SHA-1 to hash with our good randomNumbers and
818 * our counter. The result becomes our good random numbers and we
819 * then setup to give these out. Note that we do no locking to
820 * protect this. This is ok, since if competing folks call this we

--- 6151 unchanged lines hidden ---