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 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> |
51#include <netinet/sctp_bsd_addr.h> |
52 53 54 |
55 |
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; |
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 } |
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 { |
3578 error = EADDRINUSE; |
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) { |
3677 SCTP_MALLOC(optval, void *, optsize, SCTP_M_SOCKOPT); |
3678 if (optval == NULL) { 3679 return (ENOBUFS); 3680 } 3681 error = sooptcopyin(sopt, optval, optsize, optsize); 3682 if (error) { |
3683 SCTP_FREE(optval, SCTP_M_SOCKOPT); |
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); |
3697 SCTP_FREE(optval, SCTP_M_SOCKOPT); |
3698 } else if (optval != NULL) { |
3699 SCTP_FREE(optval, SCTP_M_SOCKOPT); |
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 --- |