Deleted Added
full compact
sctp_usrreq.c (170587) sctp_usrreq.c (170606)
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 170587 2007-06-12 00:12:01Z rwatson $");
34__FBSDID("$FreeBSD: head/sys/netinet/sctp_usrreq.c 170606 2007-06-12 11:21:00Z 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

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

3493 error = EINVAL;
3494 }
3495
3496 }
3497 break;
3498 case SCTP_BINDX_ADD_ADDR:
3499 {
3500 struct sctp_getaddresses *addrs;
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

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

3493 error = EINVAL;
3494 }
3495
3496 }
3497 break;
3498 case SCTP_BINDX_ADD_ADDR:
3499 {
3500 struct sctp_getaddresses *addrs;
3501 struct sockaddr *addr_touse;
3502 struct sockaddr_in sin;
3503
3501
3504 SCTP_CHECK_AND_CAST(addrs, optval, struct sctp_getaddresses, optsize);
3505
3506 /* see if we're bound all already! */
3507 if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) {
3508 error = EINVAL;
3509 break;
3510 }
3511 /* Is the VRF one we have */
3512 addr_touse = addrs->addr;
3513#if defined(INET6)
3514 if (addrs->addr->sa_family == AF_INET6) {
3515 struct sockaddr_in6 *sin6;
3516
3517 if (addrs->addr->sa_len != sizeof(struct sockaddr_in6)) {
3518 error = EINVAL;
3519 break;
3520 }
3521 sin6 = (struct sockaddr_in6 *)addr_touse;
3522 if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) {
3523 in6_sin6_2_sin(&sin, sin6);
3524 addr_touse = (struct sockaddr *)&sin;
3525 }
3526 }
3527#endif
3528 if (addrs->addr->sa_family == AF_INET) {
3529 if (addrs->addr->sa_len != sizeof(struct sockaddr_in)) {
3530 error = EINVAL;
3531 break;
3532 }
3533 }
3534 if (inp->sctp_flags & SCTP_PCB_FLAGS_UNBOUND) {
3535
3536 if (p == NULL) {
3537 /* Can't get proc for Net/Open BSD */
3538 error = EINVAL;
3539 break;
3540 }
3541 error = sctp_inpcb_bind(so, addr_touse, p);
3542 break;
3543 }
3544 /*
3545 * No locks required here since bind and mgmt_ep_sa
3546 * all do their own locking. If we do something for
3547 * the FIX: below we may need to lock in that case.
3548 */
3549 if (addrs->sget_assoc_id == 0) {
3550 /* add the address */
3551 struct sctp_inpcb *lep;
3552
3553 ((struct sockaddr_in *)addr_touse)->sin_port = inp->sctp_lport;
3554 lep = sctp_pcb_findep(addr_touse, 1, 0, vrf_id);
3555 if (lep != NULL) {
3556 /*
3557 * We must decrement the refcount
3558 * since we have the ep already and
3559 * are binding. No remove going on
3560 * here.
3561 */
3562 SCTP_INP_DECR_REF(inp);
3563 }
3564 if (lep == inp) {
3565 /* already bound to it.. ok */
3566 break;
3567 } else if (lep == NULL) {
3568 ((struct sockaddr_in *)addr_touse)->sin_port = 0;
3569 error = sctp_addr_mgmt_ep_sa(inp, addr_touse,
3570 SCTP_ADD_IP_ADDRESS, vrf_id);
3571 } else {
3572 error = EADDRINUSE;
3573 }
3574 if (error)
3575 break;
3576
3577 } else {
3578 /*
3579 * FIX: decide whether we allow assoc based
3580 * bindx
3581 */
3582 }
3502 SCTP_CHECK_AND_CAST(addrs, optval, struct sctp_getaddresses,
3503 optsize);
3504 sctp_bindx_add_address(so, inp, addrs->addr,
3505 addrs->sget_assoc_id, vrf_id,
3506 &error, p);
3583 }
3584 break;
3585 case SCTP_BINDX_REM_ADDR:
3586 {
3587 struct sctp_getaddresses *addrs;
3507 }
3508 break;
3509 case SCTP_BINDX_REM_ADDR:
3510 {
3511 struct sctp_getaddresses *addrs;
3588 struct sockaddr *addr_touse;
3589 struct sockaddr_in sin;
3590
3591 SCTP_CHECK_AND_CAST(addrs, optval, struct sctp_getaddresses, optsize);
3512
3513 SCTP_CHECK_AND_CAST(addrs, optval, struct sctp_getaddresses, optsize);
3592 /* see if we're bound all already! */
3593 if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) {
3594 error = EINVAL;
3595 break;
3596 }
3597 addr_touse = addrs->addr;
3598#if defined(INET6)
3599 if (addrs->addr->sa_family == AF_INET6) {
3600 struct sockaddr_in6 *sin6;
3601
3602 if (addrs->addr->sa_len != sizeof(struct sockaddr_in6)) {
3603 error = EINVAL;
3604 break;
3605 }
3606 sin6 = (struct sockaddr_in6 *)addr_touse;
3607 if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) {
3608 in6_sin6_2_sin(&sin, sin6);
3609 addr_touse = (struct sockaddr *)&sin;
3610 }
3611 }
3612#endif
3613 if (addrs->addr->sa_family == AF_INET) {
3614 if (addrs->addr->sa_len != sizeof(struct sockaddr_in)) {
3615 error = EINVAL;
3616 break;
3617 }
3618 }
3619 /*
3620 * No lock required mgmt_ep_sa does its own locking.
3621 * If the FIX: below is ever changed we may need to
3622 * lock before calling association level binding.
3623 */
3624 if (addrs->sget_assoc_id == 0) {
3625 /* delete the address */
3626 error = sctp_addr_mgmt_ep_sa(inp, addr_touse,
3627 SCTP_DEL_IP_ADDRESS,
3628 vrf_id);
3629 } else {
3630 /*
3631 * FIX: decide whether we allow assoc based
3632 * bindx
3633 */
3634 }
3514 sctp_bindx_delete_address(so, inp, addrs->addr,
3515 addrs->sget_assoc_id, vrf_id,
3516 &error);
3635 }
3636 break;
3637 default:
3638 error = ENOPROTOOPT;
3639 break;
3640 } /* end switch (opt) */
3641 return (error);
3642}

--- 490 unchanged lines hidden ---
3517 }
3518 break;
3519 default:
3520 error = ENOPROTOOPT;
3521 break;
3522 } /* end switch (opt) */
3523 return (error);
3524}

--- 490 unchanged lines hidden ---