Deleted Added
full compact
sctp_peeloff.c (170790) sctp_peeloff.c (171477)
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.

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

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
32/* $KAME: sctp_peeloff.c,v 1.13 2005/03/06 16:04:18 itojun Exp $ */
33
34#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.

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

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
32/* $KAME: sctp_peeloff.c,v 1.13 2005/03/06 16:04:18 itojun Exp $ */
33
34#include <sys/cdefs.h>
35__FBSDID("$FreeBSD: head/sys/netinet/sctp_peeloff.c 170790 2007-06-15 20:23:41Z rrs $");
35__FBSDID("$FreeBSD: head/sys/netinet/sctp_peeloff.c 171477 2007-07-17 20:58:26Z rrs $");
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_var.h>
41#include <netinet/sctp_sysctl.h>
42#include <netinet/sctp.h>
43#include <netinet/sctp_uio.h>
44#include <netinet/sctp_peeloff.h>
45#include <netinet/sctputil.h>
46#include <netinet/sctp_auth.h>
47
48
49int
50sctp_can_peel_off(struct socket *head, sctp_assoc_t assoc_id)
51{
52 struct sctp_inpcb *inp;
53 struct sctp_tcb *stcb;
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_var.h>
41#include <netinet/sctp_sysctl.h>
42#include <netinet/sctp.h>
43#include <netinet/sctp_uio.h>
44#include <netinet/sctp_peeloff.h>
45#include <netinet/sctputil.h>
46#include <netinet/sctp_auth.h>
47
48
49int
50sctp_can_peel_off(struct socket *head, sctp_assoc_t assoc_id)
51{
52 struct sctp_inpcb *inp;
53 struct sctp_tcb *stcb;
54 uint32_t state;
54
55 inp = (struct sctp_inpcb *)head->so_pcb;
56 if (inp == NULL) {
57 return (EFAULT);
58 }
59 stcb = sctp_findassociation_ep_asocid(inp, assoc_id, 1);
60 if (stcb == NULL) {
61 return (ENOTCONN);
62 }
55
56 inp = (struct sctp_inpcb *)head->so_pcb;
57 if (inp == NULL) {
58 return (EFAULT);
59 }
60 stcb = sctp_findassociation_ep_asocid(inp, assoc_id, 1);
61 if (stcb == NULL) {
62 return (ENOTCONN);
63 }
64 state = SCTP_GET_STATE((&stcb->asoc));
65 if ((state == SCTP_STATE_EMPTY) ||
66 (state == SCTP_STATE_INUSE) ||
67 (state == SCTP_STATE_COOKIE_WAIT) ||
68 (state == SCTP_STATE_COOKIE_ECHOED)) {
69 SCTP_TCB_UNLOCK(stcb);
70 return (ENOTCONN);
71 }
63 SCTP_TCB_UNLOCK(stcb);
64 /* We are clear to peel this one off */
65 return (0);
66}
67
68int
69sctp_do_peeloff(struct socket *head, struct socket *so, sctp_assoc_t assoc_id)
70{
71 struct sctp_inpcb *inp, *n_inp;
72 struct sctp_tcb *stcb;
72 SCTP_TCB_UNLOCK(stcb);
73 /* We are clear to peel this one off */
74 return (0);
75}
76
77int
78sctp_do_peeloff(struct socket *head, struct socket *so, sctp_assoc_t assoc_id)
79{
80 struct sctp_inpcb *inp, *n_inp;
81 struct sctp_tcb *stcb;
82 uint32_t state;
73
74 inp = (struct sctp_inpcb *)head->so_pcb;
75 if (inp == NULL)
76 return (EFAULT);
77 stcb = sctp_findassociation_ep_asocid(inp, assoc_id, 1);
78 if (stcb == NULL)
79 return (ENOTCONN);
80
83
84 inp = (struct sctp_inpcb *)head->so_pcb;
85 if (inp == NULL)
86 return (EFAULT);
87 stcb = sctp_findassociation_ep_asocid(inp, assoc_id, 1);
88 if (stcb == NULL)
89 return (ENOTCONN);
90
91 state = SCTP_GET_STATE((&stcb->asoc));
92 if ((state == SCTP_STATE_EMPTY) ||
93 (state == SCTP_STATE_INUSE) ||
94 (state == SCTP_STATE_COOKIE_WAIT) ||
95 (state == SCTP_STATE_COOKIE_ECHOED)) {
96 SCTP_TCB_UNLOCK(stcb);
97 return (ENOTCONN);
98 }
81 n_inp = (struct sctp_inpcb *)so->so_pcb;
82 n_inp->sctp_flags = (SCTP_PCB_FLAGS_UDPTYPE |
83 SCTP_PCB_FLAGS_CONNECTED |
84 SCTP_PCB_FLAGS_IN_TCPPOOL | /* Turn on Blocking IO */
85 (SCTP_PCB_COPY_FLAGS & inp->sctp_flags));
86 n_inp->sctp_socket = so;
87 n_inp->sctp_features = inp->sctp_features;
88 n_inp->sctp_frag_point = inp->sctp_frag_point;

--- 110 unchanged lines hidden ---
99 n_inp = (struct sctp_inpcb *)so->so_pcb;
100 n_inp->sctp_flags = (SCTP_PCB_FLAGS_UDPTYPE |
101 SCTP_PCB_FLAGS_CONNECTED |
102 SCTP_PCB_FLAGS_IN_TCPPOOL | /* Turn on Blocking IO */
103 (SCTP_PCB_COPY_FLAGS & inp->sctp_flags));
104 n_inp->sctp_socket = so;
105 n_inp->sctp_features = inp->sctp_features;
106 n_inp->sctp_frag_point = inp->sctp_frag_point;

--- 110 unchanged lines hidden ---