]>
git.saurik.com Git - apple/xnu.git/blob - bsd/netinet/mp_pcb.h
2 * Copyright (c) 2012-2017 Apple Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
29 #ifndef _NETINET_MP_PCB_H_
30 #define _NETINET_MP_PCB_H_
32 #ifdef BSD_KERNEL_PRIVATE
33 #include <sys/domain.h>
34 #include <sys/protosw.h>
35 #include <sys/socketvar.h>
36 #include <sys/types.h>
37 #include <sys/queue.h>
38 #include <kern/locks.h>
40 /* Keep in sync with bsd/dev/dtrace/scripts/mptcp.d */
41 typedef enum mppcb_state
{
42 MPPCB_STATE_INUSE
= 1,
47 /* net/necp.h already includes mp_pcb.h - so we have to forward-declare */
48 struct necp_client_flow
;
51 * Multipath Protocol Control Block
54 TAILQ_ENTRY(mppcb
) mpp_entry
; /* glue to all PCBs */
55 decl_lck_mtx_data(, mpp_lock
); /* per PCB lock */
56 struct mppcbinfo
*mpp_pcbinfo
; /* PCB info */
57 struct mptses
*mpp_pcbe
; /* ptr to MPTCP-session */
58 struct socket
*mpp_socket
; /* back pointer to socket */
59 uint32_t mpp_flags
; /* PCB flags */
60 mppcb_state_t mpp_state
; /* PCB state */
63 uuid_t necp_client_uuid
;
64 void (*necp_cb
)(void *, int, struct necp_client_flow
*);
68 static inline struct mppcb
*
69 mpsotomppcb(struct socket
*mp_so
)
71 VERIFY(SOCK_DOM(mp_so
) == PF_MULTIPATH
);
72 return ((struct mppcb
*)mp_so
->so_pcb
);
75 /* valid values for mpp_flags */
76 #define MPP_ATTACHED 0x001
77 #define MPP_INSIDE_OUTPUT 0x002 /* MPTCP-stack is inside mptcp_subflow_output */
78 #define MPP_INSIDE_INPUT 0x004 /* MPTCP-stack is inside mptcp_subflow_input */
79 #define MPP_RUPCALL 0x008 /* MPTCP-stack is handling a read upcall */
80 #define MPP_WUPCALL 0x010 /* MPTCP-stack is handling a read upcall */
81 #define MPP_SHOULD_WORKLOOP 0x020 /* MPTCP-stack should call the workloop function */
82 #define MPP_SHOULD_RWAKEUP 0x040 /* MPTCP-stack should call sorwakeup */
83 #define MPP_SHOULD_WWAKEUP 0x080 /* MPTCP-stack should call sowwakeup */
84 #define MPP_CREATE_SUBFLOWS 0x100 /* This connection needs to create subflows */
85 #define MPP_SET_CELLICON 0x200 /* Set the cellicon (deferred) */
86 #define MPP_UNSET_CELLICON 0x400 /* Unset the cellicon (deferred) */
88 static inline boolean_t
89 mptcp_should_defer_upcall(struct mppcb
*mpp
)
91 return !!(mpp
->mpp_flags
& (MPP_INSIDE_OUTPUT
| MPP_INSIDE_INPUT
| MPP_RUPCALL
| MPP_WUPCALL
));
95 * Multipath PCB Information
98 TAILQ_ENTRY(mppcbinfo
) mppi_entry
; /* glue to all PCB info */
99 TAILQ_HEAD(, mppcb
) mppi_pcbs
; /* list of PCBs */
100 uint32_t mppi_count
; /* # of PCBs in list */
101 struct zone
*mppi_zone
; /* zone for this PCB */
102 uint32_t mppi_size
; /* size of PCB structure */
103 lck_grp_t
*mppi_lock_grp
; /* lock grp */
104 lck_attr_t
*mppi_lock_attr
; /* lock attr */
105 lck_grp_attr_t
*mppi_lock_grp_attr
; /* lock grp attr */
106 decl_lck_mtx_data(, mppi_lock
); /* global PCB lock */
107 uint32_t (*mppi_gc
)(struct mppcbinfo
*); /* garbage collector func */
108 uint32_t (*mppi_timer
)(struct mppcbinfo
*); /* timer func */
112 extern void mp_pcbinit(void);
113 extern void mp_pcbinfo_attach(struct mppcbinfo
*);
114 extern int mp_pcbinfo_detach(struct mppcbinfo
*);
115 extern int mp_pcballoc(struct socket
*, struct mppcbinfo
*);
116 extern void mp_pcbdetach(struct socket
*);
117 extern void mp_pcbdispose(struct mppcb
*);
118 extern void mp_gc_sched(void);
119 extern void mptcp_timer_sched(void);
120 extern void mptcp_handle_deferred_upcalls(struct mppcb
*mpp
, uint32_t flag
);
121 extern int mp_getsockaddr(struct socket
*mp_so
, struct sockaddr
**nam
);
122 extern int mp_getpeeraddr(struct socket
*mp_so
, struct sockaddr
**nam
);
125 #endif /* BSD_KERNEL_PRIVATE */
126 #endif /* !_NETINET_MP_PCB_H_ */