Deleted Added
full compact
sctp_usrreq.c (170056) sctp_usrreq.c (170091)
1/*-
2 * Copyright (c) 2001-2007, 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: sctp_usrreq.c,v 1.48 2005/03/07 23:26:08 itojun Exp $ */
32
33#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2001-2007, 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: sctp_usrreq.c,v 1.48 2005/03/07 23:26:08 itojun Exp $ */
32
33#include <sys/cdefs.h>
34__FBSDID("$FreeBSD: head/sys/netinet/sctp_usrreq.c 170056 2007-05-28 11:17:24Z rrs $");
34__FBSDID("$FreeBSD: head/sys/netinet/sctp_usrreq.c 170091 2007-05-29 09:29:03Z rrs $");
35#include <netinet/sctp_os.h>
36#include <sys/proc.h>
37#include <netinet/sctp_pcb.h>
38#include <netinet/sctp_header.h>
39#include <netinet/sctp_var.h>
40#if defined(INET6)
41#include <netinet6/sctp6_var.h>
42#endif
43#include <netinet/sctp_sysctl.h>
44#include <netinet/sctp_output.h>
45#include <netinet/sctp_uio.h>
46#include <netinet/sctp_asconf.h>
47#include <netinet/sctputil.h>
48#include <netinet/sctp_indata.h>
49#include <netinet/sctp_timer.h>
50#include <netinet/sctp_auth.h>
35#include <netinet/sctp_os.h>
36#include <sys/proc.h>
37#include <netinet/sctp_pcb.h>
38#include <netinet/sctp_header.h>
39#include <netinet/sctp_var.h>
40#if defined(INET6)
41#include <netinet6/sctp6_var.h>
42#endif
43#include <netinet/sctp_sysctl.h>
44#include <netinet/sctp_output.h>
45#include <netinet/sctp_uio.h>
46#include <netinet/sctp_asconf.h>
47#include <netinet/sctputil.h>
48#include <netinet/sctp_indata.h>
49#include <netinet/sctp_timer.h>
50#include <netinet/sctp_auth.h>
51#include <netinet/sctp_bsd_addr.h>
51
52
53
52
53
54
55
54void
55sctp_init(void)
56{
57 /* Init the SCTP pcb in sctp_pcb.c */
58 u_long sb_max_adj;
59
60 sctp_pcb_init();
61

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

1473 }
1474 SCTP_INP_RUNLOCK(inp);
1475 if (error == 0) {
1476 /* return the option value */
1477 *(int *)optval = val;
1478 *optsize = sizeof(val);
1479 }
1480 break;
56void
57sctp_init(void)
58{
59 /* Init the SCTP pcb in sctp_pcb.c */
60 u_long sb_max_adj;
61
62 sctp_pcb_init();
63

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

1475 }
1476 SCTP_INP_RUNLOCK(inp);
1477 if (error == 0) {
1478 /* return the option value */
1479 *(int *)optval = val;
1480 *optsize = sizeof(val);
1481 }
1482 break;
1483 case SCTP_GET_PACKET_LOG:
1484 {
1485#ifdef SCTP_PACKET_LOGGING
1486 uint8_t *target;
1487 int ret;
1481
1488
1489 SCTP_CHECK_AND_CAST(target, optval, uint8_t, *optsize);
1490 ret = sctp_copy_out_packet_log(target, (int)*optsize);
1491 *optsize = ret;
1492#else
1493 error = EOPNOTSUPP;
1494#endif
1495 break;
1496 }
1482 case SCTP_PARTIAL_DELIVERY_POINT:
1483 {
1484 uint32_t *value;
1485
1486 SCTP_CHECK_AND_CAST(value, optval, uint32_t, *optsize);
1487 *value = inp->partial_delivery_point;
1488 *optsize = sizeof(uint32_t);
1489 }

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

3555 if (lep == inp) {
3556 /* already bound to it.. ok */
3557 break;
3558 } else if (lep == NULL) {
3559 ((struct sockaddr_in *)addr_touse)->sin_port = 0;
3560 error = sctp_addr_mgmt_ep_sa(inp, addr_touse,
3561 SCTP_ADD_IP_ADDRESS, vrf_id);
3562 } else {
1497 case SCTP_PARTIAL_DELIVERY_POINT:
1498 {
1499 uint32_t *value;
1500
1501 SCTP_CHECK_AND_CAST(value, optval, uint32_t, *optsize);
1502 *value = inp->partial_delivery_point;
1503 *optsize = sizeof(uint32_t);
1504 }

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

3570 if (lep == inp) {
3571 /* already bound to it.. ok */
3572 break;
3573 } else if (lep == NULL) {
3574 ((struct sockaddr_in *)addr_touse)->sin_port = 0;
3575 error = sctp_addr_mgmt_ep_sa(inp, addr_touse,
3576 SCTP_ADD_IP_ADDRESS, vrf_id);
3577 } else {
3563 error = EADDRNOTAVAIL;
3578 error = EADDRINUSE;
3564 }
3565 if (error)
3566 break;
3567
3568 } else {
3569 /*
3570 * FIX: decide whether we allow assoc based
3571 * bindx

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

3654 error = ip6_ctloutput(so, sopt);
3655 else
3656#endif /* INET6 */
3657 error = ip_ctloutput(so, sopt);
3658 return (error);
3659 }
3660 optsize = sopt->sopt_valsize;
3661 if (optsize) {
3579 }
3580 if (error)
3581 break;
3582
3583 } else {
3584 /*
3585 * FIX: decide whether we allow assoc based
3586 * bindx

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

3669 error = ip6_ctloutput(so, sopt);
3670 else
3671#endif /* INET6 */
3672 error = ip_ctloutput(so, sopt);
3673 return (error);
3674 }
3675 optsize = sopt->sopt_valsize;
3676 if (optsize) {
3662 SCTP_MALLOC(optval, void *, optsize, "SCTPSockOpt");
3677 SCTP_MALLOC(optval, void *, optsize, SCTP_M_SOCKOPT);
3663 if (optval == NULL) {
3664 return (ENOBUFS);
3665 }
3666 error = sooptcopyin(sopt, optval, optsize, optsize);
3667 if (error) {
3678 if (optval == NULL) {
3679 return (ENOBUFS);
3680 }
3681 error = sooptcopyin(sopt, optval, optsize, optsize);
3682 if (error) {
3668 SCTP_FREE(optval);
3683 SCTP_FREE(optval, SCTP_M_SOCKOPT);
3669 goto out;
3670 }
3671 }
3672 p = (void *)sopt->sopt_td;
3673 if (sopt->sopt_dir == SOPT_SET) {
3674 error = sctp_setopt(so, sopt->sopt_name, optval, optsize, p);
3675 } else if (sopt->sopt_dir == SOPT_GET) {
3676 error = sctp_getopt(so, sopt->sopt_name, optval, &optsize, p);
3677 } else {
3678 error = EINVAL;
3679 }
3680 if ((error == 0) && (optval != NULL)) {
3681 error = sooptcopyout(sopt, optval, optsize);
3684 goto out;
3685 }
3686 }
3687 p = (void *)sopt->sopt_td;
3688 if (sopt->sopt_dir == SOPT_SET) {
3689 error = sctp_setopt(so, sopt->sopt_name, optval, optsize, p);
3690 } else if (sopt->sopt_dir == SOPT_GET) {
3691 error = sctp_getopt(so, sopt->sopt_name, optval, &optsize, p);
3692 } else {
3693 error = EINVAL;
3694 }
3695 if ((error == 0) && (optval != NULL)) {
3696 error = sooptcopyout(sopt, optval, optsize);
3682 SCTP_FREE(optval);
3697 SCTP_FREE(optval, SCTP_M_SOCKOPT);
3683 } else if (optval != NULL) {
3698 } else if (optval != NULL) {
3684 SCTP_FREE(optval);
3699 SCTP_FREE(optval, SCTP_M_SOCKOPT);
3685 }
3686out:
3687 return (error);
3688}
3689
3690
3691static int
3692sctp_connect(struct socket *so, struct sockaddr *addr, struct thread *p)

--- 431 unchanged lines hidden ---
3700 }
3701out:
3702 return (error);
3703}
3704
3705
3706static int
3707sctp_connect(struct socket *so, struct sockaddr *addr, struct thread *p)

--- 431 unchanged lines hidden ---