]>
Commit | Line | Data |
---|---|---|
39236c6e | 1 | /* |
5ba3f43e | 2 | * Copyright (c) 2012-2017 Apple Inc. All rights reserved. |
39236c6e A |
3 | * |
4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ | |
5 | * | |
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. | |
14 | * | |
15 | * Please obtain a copy of the License at | |
16 | * http://www.opensource.apple.com/apsl/ and read it before using this file. | |
17 | * | |
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. | |
25 | * | |
26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ | |
27 | */ | |
28 | ||
29 | #ifndef _NETINET_MP_PCB_H_ | |
0a7de745 | 30 | #define _NETINET_MP_PCB_H_ |
39236c6e A |
31 | |
32 | #ifdef BSD_KERNEL_PRIVATE | |
5ba3f43e A |
33 | #include <sys/domain.h> |
34 | #include <sys/protosw.h> | |
35 | #include <sys/socketvar.h> | |
39236c6e A |
36 | #include <sys/types.h> |
37 | #include <sys/queue.h> | |
38 | #include <kern/locks.h> | |
39 | ||
40 | /* Keep in sync with bsd/dev/dtrace/scripts/mptcp.d */ | |
41 | typedef enum mppcb_state { | |
0a7de745 A |
42 | MPPCB_STATE_INUSE = 1, |
43 | MPPCB_STATE_DEAD = 2, | |
39236c6e A |
44 | } mppcb_state_t; |
45 | ||
46 | /* | |
47 | * Multipath Protocol Control Block | |
48 | */ | |
49 | struct mppcb { | |
0a7de745 A |
50 | TAILQ_ENTRY(mppcb) mpp_entry; /* glue to all PCBs */ |
51 | decl_lck_mtx_data(, mpp_lock); /* per PCB lock */ | |
52 | struct mppcbinfo *mpp_pcbinfo; /* PCB info */ | |
53 | struct mptses *mpp_pcbe; /* ptr to MPTCP-session */ | |
54 | struct socket *mpp_socket; /* back pointer to socket */ | |
55 | uint32_t mpp_flags; /* PCB flags */ | |
56 | mppcb_state_t mpp_state; /* PCB state */ | |
cb323159 | 57 | int32_t mpp_inside; /* Indicates whether or not a thread is processing MPTCP */ |
5ba3f43e A |
58 | |
59 | #if NECP | |
60 | uuid_t necp_client_uuid; | |
d9a64523 | 61 | void (*necp_cb)(void *, int, uint32_t, uint32_t, bool *); |
5ba3f43e | 62 | #endif |
39236c6e A |
63 | }; |
64 | ||
5ba3f43e A |
65 | static inline struct mppcb * |
66 | mpsotomppcb(struct socket *mp_so) | |
67 | { | |
68 | VERIFY(SOCK_DOM(mp_so) == PF_MULTIPATH); | |
0a7de745 | 69 | return (struct mppcb *)mp_so->so_pcb; |
5ba3f43e | 70 | } |
39236c6e A |
71 | |
72 | /* valid values for mpp_flags */ | |
0a7de745 A |
73 | #define MPP_ATTACHED 0x001 |
74 | #define MPP_INSIDE_OUTPUT 0x002 /* MPTCP-stack is inside mptcp_subflow_output */ | |
75 | #define MPP_INSIDE_INPUT 0x004 /* MPTCP-stack is inside mptcp_subflow_input */ | |
cb323159 | 76 | #define MPP_INPUT_HANDLE 0x008 /* MPTCP-stack is handling input */ |
0a7de745 A |
77 | #define MPP_WUPCALL 0x010 /* MPTCP-stack is handling a read upcall */ |
78 | #define MPP_SHOULD_WORKLOOP 0x020 /* MPTCP-stack should call the workloop function */ | |
79 | #define MPP_SHOULD_RWAKEUP 0x040 /* MPTCP-stack should call sorwakeup */ | |
80 | #define MPP_SHOULD_WWAKEUP 0x080 /* MPTCP-stack should call sowwakeup */ | |
81 | #define MPP_CREATE_SUBFLOWS 0x100 /* This connection needs to create subflows */ | |
5ba3f43e A |
82 | |
83 | static inline boolean_t | |
84 | mptcp_should_defer_upcall(struct mppcb *mpp) | |
85 | { | |
cb323159 | 86 | return !!(mpp->mpp_flags & (MPP_INSIDE_OUTPUT | MPP_INSIDE_INPUT | MPP_INPUT_HANDLE | MPP_WUPCALL)); |
5ba3f43e | 87 | } |
39236c6e A |
88 | |
89 | /* | |
90 | * Multipath PCB Information | |
91 | */ | |
92 | struct mppcbinfo { | |
0a7de745 A |
93 | TAILQ_ENTRY(mppcbinfo) mppi_entry; /* glue to all PCB info */ |
94 | TAILQ_HEAD(, mppcb) mppi_pcbs; /* list of PCBs */ | |
95 | uint32_t mppi_count; /* # of PCBs in list */ | |
96 | struct zone *mppi_zone; /* zone for this PCB */ | |
97 | uint32_t mppi_size; /* size of PCB structure */ | |
98 | lck_grp_t *mppi_lock_grp; /* lock grp */ | |
99 | lck_attr_t *mppi_lock_attr; /* lock attr */ | |
100 | lck_grp_attr_t *mppi_lock_grp_attr; /* lock grp attr */ | |
101 | decl_lck_mtx_data(, mppi_lock); /* global PCB lock */ | |
39236c6e A |
102 | uint32_t (*mppi_gc)(struct mppcbinfo *); /* garbage collector func */ |
103 | uint32_t (*mppi_timer)(struct mppcbinfo *); /* timer func */ | |
104 | }; | |
105 | ||
106 | __BEGIN_DECLS | |
107 | extern void mp_pcbinit(void); | |
108 | extern void mp_pcbinfo_attach(struct mppcbinfo *); | |
109 | extern int mp_pcbinfo_detach(struct mppcbinfo *); | |
110 | extern int mp_pcballoc(struct socket *, struct mppcbinfo *); | |
5ba3f43e | 111 | extern void mp_pcbdetach(struct socket *); |
39236c6e A |
112 | extern void mp_pcbdispose(struct mppcb *); |
113 | extern void mp_gc_sched(void); | |
114 | extern void mptcp_timer_sched(void); | |
5ba3f43e A |
115 | extern void mptcp_handle_deferred_upcalls(struct mppcb *mpp, uint32_t flag); |
116 | extern int mp_getsockaddr(struct socket *mp_so, struct sockaddr **nam); | |
117 | extern int mp_getpeeraddr(struct socket *mp_so, struct sockaddr **nam); | |
d9a64523 A |
118 | #if NECP |
119 | extern int necp_client_register_multipath_cb(pid_t pid, uuid_t client_id, struct mppcb *mpp); | |
120 | extern void necp_mppcb_dispose(struct mppcb *mpp); | |
121 | #endif | |
39236c6e A |
122 | __END_DECLS |
123 | ||
124 | #endif /* BSD_KERNEL_PRIVATE */ | |
125 | #endif /* !_NETINET_MP_PCB_H_ */ |